@joy-ride/game 0.25.1 → 0.26.1
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 +1 -5
- package/bookmarklet.d.ts +1 -1
- package/bookmarklet.js +1 -1
- package/embed-chunks/{CodeBlock-DMi-BeLY.js → CodeBlock-Dn8EZ_BP.js} +1 -1
- package/embed-chunks/{Documentation-CI9JoAsv.js → Documentation-FnghYLFE.js} +2 -2
- package/embed-chunks/{EmbedPanel-CgEZTMF7.js → EmbedPanel-DZGEiiy9.js} +1 -1
- package/embed-chunks/{JoyRideView-C3AYwIPH.js → JoyRideView-EDSeeY9m.js} +1 -1
- package/embed-chunks/{configuration~index~embed-CG9auZKS.js → configuration~index~embed-0luxl74s.js} +1 -1
- package/embed-chunks/{configuration~index~embed~bookmarklet-C8RUCiUX.js → configuration~index~embed~bookmarklet-BH7GyoGh.js} +1 -1
- package/embed-chunks/{configuration~index~embed~bookmarklet~vehicle-popover~EmbedPanel~Documentation~JoyRideView~~n76yhyet-zf1LIsS8.js → configuration~index~embed~bookmarklet~vehicle-popover~EmbedPanel~Documentation~JoyRideView~~n76yhyet-mgPW9A8j.js} +1 -1
- package/embed-chunks/{configuration~index~embed~bookmarklet~vehicle-popover~EmbedPanel~JoyRideView~browser-sessio~iaaa3ndj-BBrKrH7m.js → configuration~index~embed~bookmarklet~vehicle-popover~EmbedPanel~JoyRideView~browser-sessio~iaaa3ndj-DLfKTakR.js} +1 -1
- package/embed-chunks/runtime~JoyRideView~browser-session-core-D3nCbCee.js +1 -0
- package/embed-chunks/runtime~browser-session-core-CXDCVDsi.js +1 -0
- package/embed-chunks/runtime~index~embed-BVbNVFHj.js +210 -0
- package/embed-chunks/{runtime~index~embed~vehicle-popover~browser-session-core~renderer-OqE9OpvH.js → runtime~index~embed~vehicle-popover~browser-session-core~renderer-YuWj6rHi.js} +1 -1
- package/embed-chunks/{runtime~vehicle-popover-DI44kx2W.js → runtime~vehicle-popover-vmgt62ll.js} +1 -1
- package/embed-chunks/{runtime~vehicle-popover~browser-session-core-BC-HGK32.js → runtime~vehicle-popover~browser-session-core-CjXpkmYi.js} +1 -1
- package/embed-chunks/{runtime~vehicle-popover~browser-session-core~renderer-CHG4ymHM.js → runtime~vehicle-popover~browser-session-core~renderer-CLLM7CAb.js} +1 -1
- package/embed-chunks/{runtime~vehicle-popover~renderer-DwVymD49.js → runtime~vehicle-popover~renderer-Cx3wjyMH.js} +1 -1
- package/embed-chunks/{src-v4km-Xn-.js → src-BBr94UQ7.js} +2 -2
- package/embed-chunks/{vehicle-catalog~index~embed-DcyLaPhV.js → vehicle-catalog~index~embed-CZzI6C0M.js} +1 -1
- package/embed-chunks/{vehicle-popover-CBTIiR6Q.js → vehicle-popover-DxuDMFyq.js} +1 -1
- package/embed.js +1 -1
- package/{index-BqJy85Tu.d.ts → index-BeKl7UbC.d.ts} +8 -9
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/npm-chunks/{Documentation-D5RIEQza.js → Documentation-_R0nI0HT.js} +2 -2
- package/npm-chunks/{EmbedPanel-COgcEIgT.js → EmbedPanel-lzZkV-zO.js} +1 -1
- package/npm-chunks/{JoyRideView-C2nOVKZu.js → JoyRideView-fHWzVVNB.js} +1 -1
- package/npm-chunks/{configuration~react-CKBQFWEF.js → configuration~react-CgNlw0cC.js} +1 -1
- package/npm-chunks/{configuration~react~vehicle-popover~EmbedPanel~Documentation~JoyRideView~browser-session-co~fvauaeow-zf1LIsS8.js → configuration~react~vehicle-popover~EmbedPanel~Documentation~JoyRideView~browser-session-co~fvauaeow-mgPW9A8j.js} +1 -1
- package/npm-chunks/{configuration~react~vehicle-popover~EmbedPanel~JoyRideView~browser-session-core-BQ8wO_VE.js → configuration~react~vehicle-popover~EmbedPanel~JoyRideView~browser-session-core-rFMaxKZs.js} +1 -1
- package/npm-chunks/{configuration~react~vehicle-popover~EmbedPanel~JoyRideView~browser-session-core~renderer-DJhBwBho.js → configuration~react~vehicle-popover~EmbedPanel~JoyRideView~browser-session-core~renderer-Bo9KSudc.js} +1 -1
- package/npm-chunks/runtime~JoyRideView~browser-session-core-BkwDrc9q.js +1 -0
- package/npm-chunks/runtime~browser-session-core-Y1rfFp6D.js +1 -0
- package/npm-chunks/{runtime~react-BKEnJfDK.js → runtime~react-CoMJOwyg.js} +1 -1
- package/npm-chunks/runtime~react~browser-session-core-35T1PZHO.js +1 -0
- package/npm-chunks/{runtime~vehicle-popover~browser-session-core-Ddxp7Nuh.js → runtime~vehicle-popover~browser-session-core-Ce3U7qky.js} +1 -1
- package/npm-chunks/{runtime~vehicle-popover~renderer-CYXkRwO4.js → runtime~vehicle-popover~renderer-Dmf1M43y.js} +1 -1
- package/npm-chunks/{sync-shadow-theme-Bqi_M9ro.js → sync-shadow-theme-DieEPOi7.js} +1 -1
- package/npm-chunks/{vehicle-catalog~react~vehicle-popover~browser-session-core-B1wVsjdQ.js → vehicle-catalog~react~vehicle-popover~browser-session-core-CX066OIY.js} +1 -1
- package/npm-chunks/{vehicle-popover-CbBEYEjM.js → vehicle-popover-Deuulng7.js} +1 -1
- package/package.json +1 -1
- package/{playground-DrT_x51v.d.ts → playground-e0rOBXY5.d.ts} +1 -0
- package/react.d.ts +2 -2
- package/react.js +2 -2
- package/embed-chunks/runtime~JoyRideView~browser-session-core-Ya-yv4PC.js +0 -1
- package/embed-chunks/runtime~browser-session-core-DUfZaJcj.js +0 -1
- package/embed-chunks/runtime~index~embed-B2Zpd22X.js +0 -210
- package/npm-chunks/runtime~JoyRideView~browser-session-core-CuSPCh9O.js +0 -1
- package/npm-chunks/runtime~browser-session-core-BenGnDZN.js +0 -1
- package/npm-chunks/runtime~react~browser-session-core-Cr50FE3R.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,o as t}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js";import{c as n,n as r,t as i}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js";import{r as a}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{f as o,i as s,s as c,t as l}from"./runtime~react~vehicle-popover~browser-session-core~renderer-Be8cIaU4.js";import{t as u}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-BZJqthWX.js";import{a as d,r as f,t as p}from"./configuration~react~vehicle-popover~EmbedPanel~JoyRideView~browser-session-core-rFMaxKZs.js";import{a as m,g as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./definitions~react~browser-session-core-acRq5AYt.js";import{n as S,r as C}from"./configuration~react~browser-session-core-CyXr42pk.js";import{o as w}from"./vehicle-catalog~react~browser-session-core-BzB5J-Lm.js";var T=class{releases=[];disposed=!1;own(e){if(this.disposed)try{e()}catch(e){console.error(`JoyRide cleanup failed`,e)}else this.releases.push(e)}disown(e){let t=this.releases.lastIndexOf(e);t>=0&&this.releases.splice(t,1)}listen(e,t,n,r){e.addEventListener(t,n,r),this.own(()=>e.removeEventListener(t,n,r))}dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.releases.splice(0).reverse())try{e()}catch(e){console.error(`JoyRide cleanup failed`,e)}}}},E=class extends Error{code=`JR_NON_SERIALIZABLE_DEPENDENCY`;dependencies;constructor(e){super(`Configuration cannot be exported: ${e.map(({path:e,reason:t})=>`${e}: ${t}`).join(`; `)}`),this.name=`NonSerializableDependencyError`,this.dependencies=Object.freeze(e.map(e=>Object.freeze({...e})))}};function D(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`${t} must be an object`);return e}function O(e,t,n){for(let r of Object.keys(e))if(!n.includes(r))throw TypeError(`Unknown ${t} field: ${r}`)}function k(e,t,n,r=()=>!0){if(e[t]!==void 0&&(typeof e[t]!=`number`||!Number.isFinite(e[t])||!r(e[t])))throw TypeError(`${n}.${t} must be a valid number`)}function A(e){let t=D(e,`entry`);O(t,`entry`,[`target`,`delayMs`,`stopAt`,`approach`,`handbrake`]);let n=t.target;if(typeof n==`string`){if(!n.trim())throw TypeError(`entry.target must be a nonempty CSS selector`)}else{let e=D(n,`entry.target`);if(O(e,`entry.target`,[`xPx`,`yPx`]),k(e,`xPx`,`entry.target`),k(e,`yPx`,`entry.target`),e.xPx===void 0||e.yPx===void 0)throw TypeError(`entry.target requires xPx and yPx`)}if(k(t,`delayMs`,`entry`,e=>e>=0),t.stopAt!==void 0){let e=D(t.stopAt,`entry.stopAt`);O(e,`entry.stopAt`,[`x`,`y`,`offsetXPx`,`offsetYPx`]);for(let t of[`x`,`y`,`offsetXPx`,`offsetYPx`])k(e,t,`entry.stopAt`)}if(t.approach!==void 0){let e=D(t.approach,`entry.approach`);O(e,`entry.approach`,[`angleRad`,`distancePx`,`initialSpeedMps`,`fadeFraction`]),k(e,`angleRad`,`entry.approach`),k(e,`distancePx`,`entry.approach`,e=>e>0),k(e,`initialSpeedMps`,`entry.approach`,e=>e>0),k(e,`fadeFraction`,`entry.approach`,e=>e>=0&&e<=1)}if(t.handbrake!==void 0){let e=D(t.handbrake,`entry.handbrake`);O(e,`entry.handbrake`,[`steer`]),k(e,`steer`,`entry.handbrake`,e=>Math.abs(e)<=1)}return e}function j(e,t,n,r=new Set){if(e===null||typeof e==`string`||typeof e==`boolean`||e===void 0||typeof e==`number`&&Number.isFinite(e))return;if(typeof e!=`object`){n.push({path:t,reason:`only finite JSON values can be exported`});return}if(r.has(e)){n.push({path:t,reason:`cyclic references cannot be exported`});return}let i=Object.getPrototypeOf(e);if(!Array.isArray(e)&&i!==null&&Object.getPrototypeOf(i)!==null)n.push({path:t,reason:`DOM references and strategy instances are not serializable`});else{r.add(e);for(let[i,a]of Object.entries(e))j(a,`${t}.${i}`,n,r);r.delete(e)}}function M(e){return e&&typeof e==`object`&&(Object.values(e).forEach(M),Object.freeze(e)),e}function N(e){let t=[];if(j(e,`configuration`,t),t.length)throw new E(t);for(let t of Object.keys(e))if(![`audioSet`,`persist`,`definitions`,`player`,`bindings`,`routes`,`objectives`,`game`,`dialog`,`entry`].includes(t))throw TypeError(`Unknown playground configuration field: ${t}`);if(e.audioSet!==void 0&&!/^[a-z0-9][a-z0-9_-]*$/.test(e.audioSet))throw TypeError(`Audio set must be a folder name`);if(e.persist!==void 0){if(!e.persist||typeof e.persist!=`object`||Array.isArray(e.persist))throw TypeError(`persist must be an object`);for(let[t,n]of Object.entries(e.persist)){if(t!==`vehicle`&&t!==`audio`)throw TypeError(`Unknown persist field: ${t}`);if(typeof n!=`boolean`)throw TypeError(`persist.${t} must be boolean`)}}e.entry!==void 0&&A(e.entry);let n=x(e.definitions??{}),r=e.player===void 0?void 0:v(e.player),i=e.bindings?.map((e,t)=>{if(typeof e.target!=`string`||!e.target.trim())throw new E([{path:`bindings.${t}.target`,reason:`use a selector instead of an element reference`}]);return{target:e.target,spec:g(e.spec)}}),a=e.routes&&Object.fromEntries(Object.entries(e.routes).map(([e,t])=>[e,b(t)])),o=e.objectives&&Object.fromEntries(Object.entries(e.objectives).map(([e,t])=>[e,_(t)])),s=f(d(p,{game:e.game,dialog:e.dialog}));return M(structuredClone({...e,definitions:n,player:r,bindings:i,routes:a,objectives:o,...s,format:`joy-ride-playground`,version:3}))}function P(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`Expected a playground configuration`);let t=e;if(t.format!==`joy-ride-playground`||t.version!==3)throw TypeError(`Unsupported playground configuration format or version`);for(let e of Object.keys(t))if(![`format`,`version`,`audioSet`,`persist`,`definitions`,`player`,`bindings`,`routes`,`objectives`,`game`,`dialog`,`entry`].includes(e))throw TypeError(`Unknown playground configuration field: ${e}`);let{format:n,version:r,...i}=t;return N(i)}function F(e,t){if(!(typeof HTMLElement<`u`&&e instanceof HTMLElement)){for(let e of[`trigger`,`crushable`,`combustible`,`pushable`])if(t[e])throw new h(`object.${e}`,`${e} requires an HTML element`);if(t.liquid&&!(typeof SVGGeometryElement<`u`&&e instanceof SVGGeometryElement))throw new h(`object.liquid`,`liquid requires HTML or an SVG shape`);if(!(typeof SVGSVGElement<`u`&&e instanceof SVGSVGElement)&&(t.breakable||t.burnable))throw new h(`object`,`breakable and burnable artwork require HTML text/artwork or an SVG root`)}}var I=0;function L(e){return e&&typeof e==`object`&&(Object.values(e).forEach(L),Object.freeze(e)),e}var R=class{root;definitions;scope=++I;registrations=new Set;records=new Map;snapshot=Object.freeze([]);identities=new WeakMap;patches=new Map;listeners=new Set;diagnosticListeners=new Set;liquids=new Map;vehicles=new Map;importedVehicles=new Map;importedLiquids=new Map;observer;dirty=!0;disposed=!1;nextId=0;nextRegistration=0;version=0;pageStateChanged=()=>this.invalidate();constructor(e=document,t={}){this.root=e,this.definitions=x(t);try{for(let e of Object.keys(this.definitions.liquids??{}))this.resolveLiquid(e);for(let e of Object.keys(this.definitions.vehicles??{}))this.resolveVehicle(e);for(let e of Object.values(this.definitions.objects??{}))this.resolve(e);this.register(C,{},!0),this.observe()}catch(e){throw this.dispose(),e}}observe(){this.observer?.disconnect(),this.observer??=new MutationObserver(e=>{e.some(e=>{if(e.type!==`attributes`){let t=e.target instanceof Element?e.target:e.target.parentElement;return!(t&&this.records.get(t)?.spec.hud)}if((e.target instanceof Element?e.target:null)?.closest(`[data-jr-embed],[data-jr-overlay],[data-jr-text-run]`))return!1;if([...this.registrations].some(e=>!e.internal&&typeof e.target==`string`))return!0;let t=e.attributeName??``;return t!==`style`&&![`data-jr-trigger-state`,`data-jr-trigger-departed`,`data-jr-crushed`].includes(t)})&&this.invalidate()});for(let e of[`input`,`change`,`focusin`,`focusout`])this.root.addEventListener(e,this.pageStateChanged);this.observer.observe(this.root,{subtree:!0,childList:!0,attributes:!0,characterData:!0})}invalidate(){if(!(this.disposed||this.dirty)){this.dirty=!0,l(`registry invalidations`);for(let e of this.listeners)e()}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}onDiagnostic(e){return this.diagnosticListeners.add(e),()=>this.diagnosticListeners.delete(e)}report(e,t){let n={code:`configuration`,message:e instanceof Error?e.message:String(e),target:t};for(let e of this.diagnosticListeners)e(n);this.root.dispatchEvent(new CustomEvent(`joyride:diagnostic`,{bubbles:!0,detail:n}))}targets(e){if(typeof e==`string`){let t=[...this.root.querySelectorAll(e)];return this.root instanceof Element&&this.root.matches(e)&&t.unshift(this.root),t}if(e instanceof Element)return[e];if(!e||typeof e[Symbol.iterator]!=`function`)throw TypeError(`Expected a selector, element, or iterable of elements`);let t=[...e];if(t.some(e=>!(e instanceof Element)))throw TypeError(`Every binding target must be an Element`);return[...new Set(t)]}accepts(e){return e.isConnected&&!(this.root instanceof Element&&e!==this.root&&!this.root.contains(e))&&!e.closest(`[data-jr-embed],[data-jr-overlay]`)}compose(e,t=[...this.registrations],n=this.patches.get(e)){let r=t.filter(t=>!t.internal&&typeof t.target==`string`&&e.matches(t.target)),i=t.filter(t=>typeof t.target!=`string`&&this.targets(t.target).includes(e)),a=this.resolve(y(...r.map(e=>e.spec),S(e),...i.map(e=>e.spec),n));return F(e,a),a}validateChange(e,t,n,r){this.refresh();let i=new Set(e),a=new Set([...this.records.values()].filter(e=>!i.has(e.target)).map(e=>e.id));for(let i of e){if(!this.accepts(i))continue;let e=this.compose(i,t,i===n?r:this.patches.get(i)).id??this.identities.get(i);if(e&&a.has(e))throw Error(`Duplicate playground object ID: ${e}`);e&&a.add(e)}}bindAll(e){let t=[];try{for(let n of e)t.push(this.bind(n.target,n.spec));return t}catch(e){for(let e of t)e.dispose();throw e}}bind(e,t){return this.register(e,t,!1)}register(e,t,n){if(this.disposed)throw Error(`Playground is disposed`);let r=n?[]:this.targets(e),i={id:++this.nextRegistration,target:typeof e==`string`||e instanceof Element?e:r,spec:g(t),disposed:!1,internal:n};n||this.validateChange(r,[...this.registrations,i]),this.registrations.add(i),this.dirty=!1,this.invalidate();let a=()=>i.disposed||this.disposed?[]:(this.refresh(),this.targets(i.target).flatMap(e=>this.records.get(e)??[]));return{get objects(){return a()},update:e=>{if(i.disposed||this.disposed)throw Error(`Binding is disposed`);let t={...i,spec:g(y(i.spec,e))};this.validateChange(this.targets(i.target),[...this.registrations].map(e=>e===i?t:e)),i.spec=t.spec,this.dirty=!1,this.invalidate()},replace:e=>{if(i.disposed||this.disposed)throw Error(`Binding is disposed`);let t={...i,spec:g(e)};this.validateChange(this.targets(i.target),[...this.registrations].map(e=>e===i?t:e)),i.spec=t.spec,this.dirty=!1,this.invalidate()},refresh:()=>{if(i.disposed||this.disposed)throw Error(`Binding is disposed`);this.dirty=!1,this.invalidate(),this.refresh()},dispose:()=>{i.disposed||(i.disposed=!0,this.registrations.delete(i),this.dirty=!1,this.invalidate())}}}update(e,t){if(this.disposed)throw Error(`Playground is disposed`);if(this.refresh(),!this.records.has(e))throw Error(`Element is not registered`);let n=g(y(this.patches.get(e),t));this.validateChange([e],[...this.registrations],e,n),this.patches.set(e,n),this.dirty=!1,this.invalidate()}get(e){return this.refresh(),this.records.get(e)}get objects(){return this.refresh(),this.snapshot}refresh(){if(!this.dirty||this.disposed)return;this.dirty=!1;let e=new Set;for(let t of this.registrations)for(let n of this.targets(t.target))e.add(n);let t=new Set,n=new Map([...this.records].filter(([t])=>e.has(t)&&this.accepts(t)).map(([e,t])=>[t.id,e])),r=!1;for(let i of e)if(this.accepts(i))try{let e=this.compose(i),a=e.id??this.identities.get(i);a??=`jr-${this.scope}-${++this.nextId}`;let o=n.get(a);if(o&&o!==i||t.has(a))throw Error(`Duplicate playground object ID: ${a}`);t.add(a),this.identities.set(i,a);let s=this.records.get(i);s&&JSON.stringify(s.spec)===JSON.stringify(e)||(this.records.set(i,Object.freeze({id:a,target:i,spec:L(e),revision:++this.version})),r=!0)}catch(e){this.report(e,i)}for(let[t]of this.records)e.has(t)&&this.accepts(t)||(this.records.delete(t),this.patches.delete(t),r=!0);if(r){this.snapshot=Object.freeze([...this.records.values()]);for(let e of this.listeners)e()}}validateObject(e){return this.resolve(e)}exportBindings(){if(this.disposed)throw Error(`Playground is disposed`);let e=[...this.registrations].filter(e=>!e.internal),t=e.flatMap(e=>typeof e.target==`string`?[]:[{path:`bindings.${e.id}.target`,reason:`an exact element binding has no portable selector`}]);if(this.patches.size&&t.push({path:`objectOverrides`,reason:`runtime object overrides are tied to live element identities`}),t.length)throw new E(t);return e.map(e=>({target:e.target,spec:structuredClone(e.spec)}))}exportDefinitions(){if(this.disposed)throw Error(`Playground is disposed`);return x({...this.definitions,liquids:{...this.definitions.liquids,...Object.fromEntries(this.importedLiquids)},vehicles:{...this.definitions.vehicles,...Object.fromEntries(this.importedVehicles)}})}registerVehiclePreset(t,n){if(this.disposed)throw Error(`Playground is disposed`);if(this.definitions.vehicles?.[t]||this.importedVehicles.has(t)||Object.values(e).some(e=>e.id===t))throw Error(`Vehicle recipe already exists: ${t}`);let{id:r,...i}=w(n),a={...i,base:e.porsche911997.id};return x({vehicles:{[t]:a}}),this.importedVehicles.set(t,a),t}vehicleName(t){for(let[e,n]of this.vehicles)if(n.id===t)return e;if(Object.values(e).some(e=>e.id===t))return t;throw new E([{path:`player.vehicle`,reason:`vehicle ${t} has no authored recipe in this catalog`}])}resolve(e,t=new Set){let n=y(e);if(typeof n.object==`string`){let e=n.object;if(t.has(e))throw Error(`Circular object definition: ${e}`);let r=this.definitions.objects?.[e];if(!r)throw Error(`Unknown object definition: ${e}`);t.add(e);let{object:i,...a}=n;n=y(this.resolve(r,t),a)}let r=n.liquid;return r&&typeof r==`object`&&typeof r.kind==`string`&&(r.kind=this.resolveLiquid(r.kind)),m(n)}resolveLiquid(e,t=new Set){let r=this.liquids.get(e);if(r)return r;let a=this.importedLiquids.get(e)??this.definitions.liquids?.[e];if(!a)return n(e);if(t.has(e))throw Error(`Circular liquid definition: ${e}`);t.add(e);let o=this.resolveLiquid(a.base,t),s=`jr-${this.scope}-${this.liquids.size}-`,c=i(`${s}${e.slice(0,64-s.length)}`,{...a,base:o});return this.liquids.set(e,c.kind),c.kind}liquidName(e){for(let[t,n]of this.liquids)if(n===e)return t;return e}resolveVehicle(t,n=new Set){let r=this.vehicles.get(t);if(r)return r;let i=this.importedVehicles.get(t)??this.definitions.vehicles?.[t];if(!i){let n=Object.values(e).find(e=>e.id===t);if(!n)throw Error(`Unknown vehicle definition: ${t}`);return n}if(n.has(t))throw Error(`Circular vehicle definition: ${t}`);n.add(t);let{base:a,appearance:o,slots:s,...c}=i,l=w(y(this.resolveVehicle(a,n),c,{id:`custom-jr-${this.scope}-${t}`}));return this.vehicles.set(t,l),l}vehicleOptions(e){let t=this.importedVehicles.get(e)??this.definitions.vehicles?.[e];return t?y(this.vehicleOptions(t.base),{appearance:t.appearance,slots:t.slots}):{appearance:`auto`,slots:u}}captureState(){return a({patches:this.patches,registrations:new Map([...this.registrations].filter(e=>!e.internal).map(e=>[e.id,e.spec]))})}restoreState(e){let t=a(e);this.patches.clear();for(let[e,n]of t.patches)this.patches.set(e,n);for(let e of this.registrations){let n=t.registrations.get(e.id);n&&(e.spec=n)}this.dirty=!1,this.invalidate(),this.refresh()}reset(){this.patches.clear(),this.dirty=!1,this.invalidate()}dispose(){if(!this.disposed){this.disposed=!0,this.observer?.disconnect();for(let e of[`input`,`change`,`focusin`,`focusout`])this.root.removeEventListener(e,this.pageStateChanged);this.records.clear(),this.snapshot=Object.freeze([]),this.registrations.clear(),this.patches.clear(),this.listeners.clear(),this.diagnosticListeners.clear();for(let e of this.liquids.values())r(e);this.liquids.clear(),this.vehicles.clear(),this.importedVehicles.clear(),this.importedLiquids.clear()}}};function z(e,t){let n=e.getBoundingClientRect(),r=n.left+window.scrollX+n.width/2,i=n.top+window.scrollY+n.height/2,a=r-(t?.xPx??r-185),o=i-(t?.yPx??i);return{target:e,approach:{angleRad:Math.hypot(a,o)>1?Math.atan2(o,a):-(t?.angleRad??0),distancePx:185,fadeFraction:.5},handbrake:{steer:.04}}}function B(e){let t=e.car;return t.rollingResistance*(4+2*t.handbrakeStrength*7)/e.body.mass}function V(e,t){let n=e.car;return n.preset.handbrakeDecelerationMps2+n.preset.coastDecelerationMps2+B(e)*t*.75}function H(e,t,n){return t*t*n/(2*V(e,t))}function U(e,t,n){let r=0,i=60;for(let a=0;a<14;a++){let a=(r+i)/2;H(e,a,n)<t?r=a:i=a}return(r+i)/2}function W(e,n,r){let{handbrake:i,stopAt:a}=e,c={angleRad:e.approach?.angleRad??0,distancePx:e.approach?.distancePx??185,initialSpeedMps:e.approach?.initialSpeedMps,fadeFraction:e.approach?.fadeFraction??.5};if(![c.angleRad,c.distancePx,c.initialSpeedMps??1,c.fadeFraction,i?.steer??0,a?.x??.5,a?.y??.5,a?.offsetXPx??0,a?.offsetYPx??0,r].every(Number.isFinite)||c.distancePx<=0||c.initialSpeedMps!==void 0&&c.initialSpeedMps<=0||c.fadeFraction<0||c.fadeFraction>1||Math.abs(i?.steer??0)>1||r<=0)return null;let l;try{l=typeof e.target==`string`?document.querySelector(e.target):e.target}catch(e){if(e instanceof DOMException&&e.name===`SyntaxError`)return null;throw e}if(!l)return null;let u=`xPx`in l?o(l.xPx,l.yPx):(()=>{if(!l.isConnected)return null;let e=l.getBoundingClientRect();return o(e.left+window.scrollX+e.width*(a?.x??.5),e.top+window.scrollY+e.height*(a?.y??.5))})();if(!u||!Number.isFinite(u.x)||!Number.isFinite(u.y))return null;u.x+=a?.offsetXPx??0,u.y+=a?.offsetYPx??0;let d=o(Math.cos(c.angleRad),Math.sin(c.angleRad)),f=c.initialSpeedMps??U(n,c.distancePx,r),p=f*f*r/(2*c.distancePx),m=s((p-V(n,f))/t(n.car.preset),0,1),h=B(n),g=Math.max(.01,n.car.preset.handbrakeDecelerationMps2+n.car.preset.coastDecelerationMps2+m*t(n.car.preset)),_=h>0?Math.log1p(h*f/g)/h:f/g;return{destination:u,start:o(u.x-d.x*c.distancePx,u.y-d.y*c.distancePx),headingRad:-c.angleRad,velocity:o(d.x*f,-d.y*f),fadeDurationSeconds:_*c.fadeFraction,steer:i?.steer??0,serviceBrake:m}}var G=class{fadeDurationSeconds;steer;serviceBrake;elapsedSeconds=0;done=!1;constructor(e,t,n=0){this.fadeDurationSeconds=e,this.steer=t,this.serviceBrake=n}get opacity(){return this.fadeDurationSeconds===0?1:s(this.elapsedSeconds/this.fadeDurationSeconds,0,1)}get complete(){return this.done}drive(e,t,n,r,i){return this.elapsedSeconds+=r,c(e.body.velocity)<.45||this.elapsedSeconds>3?(this.done=!0,{throttle:0,steer:0,action:!1,boost:!1}):{throttle:0,steer:this.steer,action:!0,brake:this.serviceBrake,boost:!1}}};export{E as a,A as c,R as i,T as l,z as n,N as o,W as r,P as s,G as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t,r as n}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js";import{a as r,r as i}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js";import{r as a}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{S as o,c as s,d as c,f as l,i as u,l as d,o as f,s as p,u as m}from"./runtime~react~vehicle-popover~browser-session-core~renderer-Be8cIaU4.js";import{_ as h,b as g,g as _,h as v,v as y,x as b,y as ee}from"./runtime~vehicle-popover~browser-session-core~renderer-jVG7K050.js";import{n as te,r as x,t as S}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-BZJqthWX.js";import{n as ne,r as re}from"./vehicle-catalog~react~vehicle-popover~browser-session-core-B1wVsjdQ.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),o=s(e,n.center),u=l(f(o,n.forward)/a,f(o,n.side)/a),d=l(f(t,n.forward),f(t,n.side)),m=p(d);if(m<.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:u,inward:c(d,1/m),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=l();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=d(t,c(n.inward,n.depthM*o))}let n=p(t);return n>this.maxDepthM&&(t=c(t,this.maxDepthM/n)),d(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,c=e.widthM/r;for(let t=0;t<r;t++)for(let u=0;u<n;u++){let f=l((u+.5)*o-e.lengthM/2,(t+.5)*c-e.widthM/2),p=f;for(let e=0;e<5;e++)p=d(p,s(f,this.point(p)));let m=Math.floor((p.x/e.lengthM+.5)*n),h=Math.floor((p.y/e.widthM+.5)*r);m>=0&&m<n&&h>=0&&h<r&&(a[t*n+u]=i[h*n+m])}let u={...e,alpha:{columns:n,rows:r,solid:a}};return this.maskCache.set(e,{revision:this.revision,value:u}),u}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=l((e.x/r.width-.5)*t.lengthM,(e.y/r.height-.5)*t.widthM),i=this.point(n);return l((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,u=n*r.height/10,d=(n+1)*r.height/10,f=l(s,u),p=l(c,u),m=l(s,d),h=l(c,d);this.drawTriangle(i,e,t,[f,p,m],[a(f),a(p),a(m)]),this.drawTriangle(i,e,t,[h,m,p],[a(h),a(m),a(p)])}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,ee=(_*m-y*f)/h,te=(v*d-g*p)/h,x=(y*d-_*p)/h,S=c.x-b*a.x-te*a.y,ne=c.y-ee*a.x-x*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,ee,te,x,S,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:t,velocity:n,origin:r}){if(!Number.isFinite(t)||!Number.isFinite(n))throw RangeError(`Pickup angle and velocity must be finite`);if(r&&(!Number.isFinite(r.x)||!Number.isFinite(r.y)||Math.abs(r.x)>.5||Math.abs(r.y)>.5))throw RangeError(`Pickup origin must lie within normalized body coordinates [-0.5, 0.5]`);let a=i(e),o=Math.min(1,Math.abs(n)/32);this.pulses.push({color:[a[0]/255,a[1]/255,a[2]/255],angle:Math.atan2(Math.sin(t),Math.cos(t)),strength:o,velocity:Math.abs(n),origin:r?{...r}: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?[u(+n[1],0,255),u(+n[2],0,255),u(+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,u(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(e,t,n,i,a,o,s){let c=this.coating(e);if(!c||a<=0||s<=0)return;let l=r.paint.thickness,u=(this.sprayRemainder.get(e)??0)+a*(9+(1-l)*7)*(c.material?.spray??.5),d=Math.min(24,Math.floor(u));this.sprayRemainder.set(e,u-Math.floor(u));for(let e of ee(t,n,i,d,o,l)){let t=1+e.angularity*1.7,r={x:e.x,y:e.y};this.marks.push({from:r,point:r,angle:Math.atan2(n.y,n.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,o=!1){let c=this.coating(e);if(!c){this.pauseTrack(e);return}let l=this.previous.get(e),d=this.wetPaths.get(e);if(!d||!l||p(s(t,l))>=1.5*i)d={marks:[],distanceM:0},this.wetPaths.set(e,d),o&&(this.marks.push({...c,from:{...t},point:{...t},angle:n,widthM:r,phaseM:this.travelM.get(e)??0,slip:u(a,0,1),overPuddle:!0}),this.markCount++);else{let f=d.marks.at(-1),m=f&&p(s(f.point,f.from))/i<.02,h=m?f.from:l;m&&(d.distanceM-=p(s(f.point,f.from))/i);let g=p(s(t,h))/i,_={...c,from:{...h},point:{...t},angle:n,widthM:r,phaseM:(this.travelM.get(e)??0)-g,slip:u(a,0,1)};m?d.marks[d.marks.length-1]=_:d.marks.push(_),d.distanceM+=g,o&&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(;d.marks.length>1&&(d.distanceM>v||d.marks.length>128);){let e=d.marks.shift();d.distanceM-=p(s(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,o=0){let c=this.coating(e);if(!c)return;let l=this.previous.get(e),d=l?p(s(t,l)):0,f=this.wetPaths.has(e)||this.exits.has(e)?.01:.05;if(l&&d<f*i)return;let m=l&&d<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+p(s(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+d/i,lengthM:g.lengthM}:void 0;g&&(g.distanceM+=d/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?p(s(t,l))/i:0),wetness:c.wetness,material:c.material,slip:u(o,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*u(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=u(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(t,n,r,i,a,o,s,p){if(n.mode!==`car`){this.reset();return}if(this.presetId&&this.presetId!==n.car.preset.id&&this.reset(),this.previewOpen){this.inspecting=!0,this.presetId=n.car.preset.id,(this.phase===`idle`||this.phase===`closing`)&&this.transition(`opening`),this.elapsed+=t,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 h=!!n.lastInput.rocket;h&&!this.held&&(this.queuedShots++,(this.phase===`idle`||this.phase===`closing`)&&(this.presetId=n.car.preset.id,this.transition(`opening`))),this.held=h;let g=e(n.car.preset);if(this.phase===`idle`&&!this.flights.length)return;this.elapsed+=t,this.launchClock+=t;let _=n.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`),p?.(n.body.world(l(_.xM,_.yM)));else if(this.phase===`igniting`&&this.elapsed>=this.ignitionDuration){let e=m(l(1,0),n.body.angle),t=n.body.world(l(_.xM,_.yM));this.flights.push({position:t,angle:n.body.angle,speedMps:g.launchSpeedMps+Math.max(0,f(n.body.velocity,e)),distanceM:0,age:0}),this.launches++,o?.(t),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 e=u(this.elapsed/Math.min(.27,this.ignitionDuration*.65),0,.9),i=m(l(-1,0),n.body.angle),o=n.body.world(l(_.xM-v*.52,_.yM));r({point:o,flow:c(i,3.5),amount:t*14*e,radiusM:.2}),a?.({from:o,to:o,flow:c(i,12),widthM:.16,intensity:e*.75})}this.phase===`flying`&&(!h&&this.queuedShots===0?this.transition(`closing`):this.launchClock>=Math.max(0,1/g.roundsPerSecond-Math.min(Z.igniting,.7/g.roundsPerSecond))&&(this.ignitionDuration=Math.min(Z.igniting,.7/g.roundsPerSecond),this.transition(`igniting`),p?.(n.body.world(l(_.xM,_.yM)))));for(let e=this.flights.length-1;e>=0;e--){let n=this.flights[e],o=m(l(1,0),n.angle);n.speedMps=Math.min(g.maxSpeedMps,n.speedMps+g.accelerationMps2*t);let u=n.speedMps*t,f=n.position,p=d(f,c(o,u)),h=i?.(f,p,_.sizeM*.18);n.position=h??p,n.distanceM+=u,n.age+=t;let y=d(n.position,c(o,-v*.53)),b=d(f,c(o,-v*.53));if(r({point:y,flow:c(o,-5),amount:t*g.smokePerSecond,radiusM:.2}),a?.({from:b,to:y,flow:c(o,-18),widthM:.13,intensity:.9}),h){s?.(h);for(let e=0;e<7;e++){let t=m(l(1,0),e*Math.PI*2/7);r({point:h,flow:c(t,5.5),amount:.18,radiusM:.22})}this.flights.splice(e,1)}else(n.age>=g.lifetimeSeconds||n.distanceM>100)&&this.flights.splice(e,1)}this.phase===`closing`&&this.elapsed>=Z.closing&&this.transition(`idle`)}get open(){return this.phase===`idle`?0:this.phase===`opening`?u(this.elapsed/Z.opening,0,1):this.phase===`closing`?1-u(this.elapsed/Z.closing,0,1):1}drawMount(e,t,n,r,i,a=1,o){let s=this.open;if(s<=0)return;y();let c=r.roofRocket,l=c.sizeM*i,d=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-d*.78),r=t*(l*.25+d*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:u(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,!h(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,r,i,a){if(t.mode!==`car`){this.reset();return}this.presetId&&this.presetId!==t.car.preset.id&&this.reset();let o=n(t.car.preset),s=!!t.lastInput.machineGun;if(s&&(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(!s&&(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/o.roundsPerSecond),this.phase===`active`){if(s){let n=1/Math.max(1,o.roundsPerSecond);this.shotClock+=e;for(let e=0;this.shotClock>=n&&e<4;e++)this.shotClock-=n,this.fire(t),i?.()}}else this.phase===`closing`&&this.phaseTime>=kn&&(this.phase=`closed`,this.phaseTime=0);for(let t=this.bullets.length-1;t>=0;t--){let n=this.bullets[t],i=n.position,s=d(i,c(n.velocity,e)),l=r?.(i,s,.075);n.age+=e,l||n.age>=o.bulletLifetimeSeconds?(l&&a?.(l,n.velocity),this.bullets.splice(t,1)):n.position=s}}fire(e){let t=n(e.car.preset),r=m(l(1,0),e.body.angle);for(let n of[-1,1]){let i=e.body.world(_(e.car.preset,n)),a=d(c(r,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`?u(this.phaseTime/On,0,1):this.phase===`closing`?1-u(this.phaseTime/kn,0,1):1}drawMount(e,t,n,r,i,a=1,o){v(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(d(i.position,c(i.velocity,-.75/Math.max(1,o)))),l=e.createLinearGradient(s.x,s.y,a.x,a.y);l.addColorStop(0,`rgba(224,153,63,0)`),l.addColorStop(.7,`rgba(224,153,63,.25)`),l.addColorStop(1,`rgba(255,225,157,.7)`),e.globalAlpha=r,e.strokeStyle=l,e.lineWidth=Math.max(.65,n*.025),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(a.x,a.y),e.stroke();let u=t(d(i.position,c(i.velocity,-.09/Math.max(1,o))));e.strokeStyle=`#fff6d7`,e.lineWidth=Math.max(.55,n*.018),e.beginPath(),e.moveTo(u.x,u.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,n,r,i,a){if(n.mode!==`car`){(this.phase!==`closed`||this.jets.length)&&this.reset();return}this.presetId&&this.presetId!==n.car.preset.id&&this.reset();let o=!!n.lastInput.flamethrower,s=t(n.car.preset);if(o&&(this.phase===`closed`||this.phase===`closing`)){this.presetId=n.car.preset.id;let e=this.open;this.phase=`opening`,this.phaseTime=e*jn}else if(!o&&(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`&&o,this.phase===`closing`&&this.phaseTime>=Mn&&(this.phase=`closed`,this.phaseTime=0),this.emitting){let t=m(l(1,0),n.body.angle),i=s.rangeM/.3;for(this.fireClock+=e;this.fireClock>=Q;){this.fireClock-=Q;for(let e of[-1,1]){let r=n.body.world(_(n.car.preset,e));this.jets.push({point:r,velocity:d(c(t,i),c(n.body.velocity,.25)),traveled:0,range:s.rangeM,speed:i,width:s.jetWidthM*s.flowRate})}}for(let i of[-1,1]){let a=n.body.world(_(n.car.preset,i));r({point:d(a,c(t,.06)),flow:c(t,5.5),amount:e*s.smokePerSecond*s.flowRate*.38,radiusM:.12})}}let u=[];for(let t of this.jets){let n=Math.min(t.range-t.traveled,t.speed*e),o=t.point,l=d(o,c(t.velocity,n/t.speed)),f=(t.traveled+n)/t.range,p=t.width*(.65+1.45*f),m=i?.(o,l,Math.max(.3,p*1.25),Q*s.flowRate),h=m??l;t.point=h,t.traveled+=n,a?.(o,h,p,t.velocity,f),(f>.62||m)&&r({point:h,flow:c(t.velocity,.42),amount:e*s.smokePerSecond*s.flowRate*(m?.42:.18),radiusM:Math.max(.11,p*.48)}),m?a?.(h,h,p*1.35,t.velocity,f):t.traveled+1e-6<t.range&&u.push(t)}this.jets=u}get open(){return this.phase===`closed`?0:this.phase===`opening`?u(this.phaseTime/jn,0,1):this.phase===`closing`?1-u(this.phaseTime/Mn,0,1):1}drawMount(e,t,n,r,i,a=1,o){v(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 g;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=S;toolPolicy={};numberedSlots=re(S);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=te(e);this.clearSlotInput(),this.slotConfiguration=t,this.numberedSlots=re(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=x(e);return this.disposed||!this.numberedSlots[t-1]||this.lifecycleState!==`drivable`?!1:(this.slotPulses.add(t),!0)}startSlot(e){let t=x(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(x(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(x)),n=new Set((e.slotPresses??[]).map(x));for(let e of this.blockedSlots)!t.has(e)&&!n.has(e)?this.blockedSlots.delete(e):(t.delete(e),n.delete(e));let r=new Set([...this.slotHeld,...t]),i=new Set([...this.slotPresses,...n]),a=$(e);this.activeEmitters=[];for(let{number:e,slot:t}of this.numberedSlots){let n=r.has(e)&&!this.previousSlotInput.has(e),o=this.slotPulses.has(e)||(t.activation===`tap`?n||i.has(e):i.has(e)&&!r.has(e));(o||t.activation!==`tap`&&r.has(e))&&(t.action===`eject`?(a.eject=!0,this.activeEmitters.push({slot:e,liquid:t.liquid,pulse:o,rate:t.rate??6,amount:t.amount??.65})):a[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=r,a}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,n={}){if(n.toolsEnabled!==this.toolPolicy.toolsEnabled){let t=re(this.slotConfiguration,n);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(x(t))}this.toolPolicy=n,this.numberedSlots=t}this.controls=ne(this.resolveSlots(e),n.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`,b(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>=o.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
|
+
import{a as e,n as t,r as n}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js";import{a as r,r as i}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js";import{r as a}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{S as o,c as s,d as c,f as l,i as u,l as d,o as f,s as p,u as m}from"./runtime~react~vehicle-popover~browser-session-core~renderer-Be8cIaU4.js";import{_ as h,b as g,g as _,h as v,v as y,x as b,y as ee}from"./runtime~vehicle-popover~browser-session-core~renderer-jVG7K050.js";import{n as te,r as x,t as S}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-BZJqthWX.js";import{n as ne,r as re}from"./vehicle-catalog~react~vehicle-popover~browser-session-core-CX066OIY.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),o=s(e,n.center),u=l(f(o,n.forward)/a,f(o,n.side)/a),d=l(f(t,n.forward),f(t,n.side)),m=p(d);if(m<.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:u,inward:c(d,1/m),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=l();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=d(t,c(n.inward,n.depthM*o))}let n=p(t);return n>this.maxDepthM&&(t=c(t,this.maxDepthM/n)),d(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,c=e.widthM/r;for(let t=0;t<r;t++)for(let u=0;u<n;u++){let f=l((u+.5)*o-e.lengthM/2,(t+.5)*c-e.widthM/2),p=f;for(let e=0;e<5;e++)p=d(p,s(f,this.point(p)));let m=Math.floor((p.x/e.lengthM+.5)*n),h=Math.floor((p.y/e.widthM+.5)*r);m>=0&&m<n&&h>=0&&h<r&&(a[t*n+u]=i[h*n+m])}let u={...e,alpha:{columns:n,rows:r,solid:a}};return this.maskCache.set(e,{revision:this.revision,value:u}),u}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=l((e.x/r.width-.5)*t.lengthM,(e.y/r.height-.5)*t.widthM),i=this.point(n);return l((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,u=n*r.height/10,d=(n+1)*r.height/10,f=l(s,u),p=l(c,u),m=l(s,d),h=l(c,d);this.drawTriangle(i,e,t,[f,p,m],[a(f),a(p),a(m)]),this.drawTriangle(i,e,t,[h,m,p],[a(h),a(m),a(p)])}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,ee=(_*m-y*f)/h,te=(v*d-g*p)/h,x=(y*d-_*p)/h,S=c.x-b*a.x-te*a.y,ne=c.y-ee*a.x-x*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,ee,te,x,S,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:t,velocity:n,origin:r}){if(!Number.isFinite(t)||!Number.isFinite(n))throw RangeError(`Pickup angle and velocity must be finite`);if(r&&(!Number.isFinite(r.x)||!Number.isFinite(r.y)||Math.abs(r.x)>.5||Math.abs(r.y)>.5))throw RangeError(`Pickup origin must lie within normalized body coordinates [-0.5, 0.5]`);let a=i(e),o=Math.min(1,Math.abs(n)/32);this.pulses.push({color:[a[0]/255,a[1]/255,a[2]/255],angle:Math.atan2(Math.sin(t),Math.cos(t)),strength:o,velocity:Math.abs(n),origin:r?{...r}: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?[u(+n[1],0,255),u(+n[2],0,255),u(+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,u(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(e,t,n,i,a,o,s){let c=this.coating(e);if(!c||a<=0||s<=0)return;let l=r.paint.thickness,u=(this.sprayRemainder.get(e)??0)+a*(9+(1-l)*7)*(c.material?.spray??.5),d=Math.min(24,Math.floor(u));this.sprayRemainder.set(e,u-Math.floor(u));for(let e of ee(t,n,i,d,o,l)){let t=1+e.angularity*1.7,r={x:e.x,y:e.y};this.marks.push({from:r,point:r,angle:Math.atan2(n.y,n.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,o=!1){let c=this.coating(e);if(!c){this.pauseTrack(e);return}let l=this.previous.get(e),d=this.wetPaths.get(e);if(!d||!l||p(s(t,l))>=1.5*i)d={marks:[],distanceM:0},this.wetPaths.set(e,d),o&&(this.marks.push({...c,from:{...t},point:{...t},angle:n,widthM:r,phaseM:this.travelM.get(e)??0,slip:u(a,0,1),overPuddle:!0}),this.markCount++);else{let f=d.marks.at(-1),m=f&&p(s(f.point,f.from))/i<.02,h=m?f.from:l;m&&(d.distanceM-=p(s(f.point,f.from))/i);let g=p(s(t,h))/i,_={...c,from:{...h},point:{...t},angle:n,widthM:r,phaseM:(this.travelM.get(e)??0)-g,slip:u(a,0,1)};m?d.marks[d.marks.length-1]=_:d.marks.push(_),d.distanceM+=g,o&&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(;d.marks.length>1&&(d.distanceM>v||d.marks.length>128);){let e=d.marks.shift();d.distanceM-=p(s(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,o=0){let c=this.coating(e);if(!c)return;let l=this.previous.get(e),d=l?p(s(t,l)):0,f=this.wetPaths.has(e)||this.exits.has(e)?.01:.05;if(l&&d<f*i)return;let m=l&&d<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+p(s(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+d/i,lengthM:g.lengthM}:void 0;g&&(g.distanceM+=d/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?p(s(t,l))/i:0),wetness:c.wetness,material:c.material,slip:u(o,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*u(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=u(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(t,n,r,i,a,o,s,p){if(n.mode!==`car`){this.reset();return}if(this.presetId&&this.presetId!==n.car.preset.id&&this.reset(),this.previewOpen){this.inspecting=!0,this.presetId=n.car.preset.id,(this.phase===`idle`||this.phase===`closing`)&&this.transition(`opening`),this.elapsed+=t,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 h=!!n.lastInput.rocket;h&&!this.held&&(this.queuedShots++,(this.phase===`idle`||this.phase===`closing`)&&(this.presetId=n.car.preset.id,this.transition(`opening`))),this.held=h;let g=e(n.car.preset);if(this.phase===`idle`&&!this.flights.length)return;this.elapsed+=t,this.launchClock+=t;let _=n.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`),p?.(n.body.world(l(_.xM,_.yM)));else if(this.phase===`igniting`&&this.elapsed>=this.ignitionDuration){let e=m(l(1,0),n.body.angle),t=n.body.world(l(_.xM,_.yM));this.flights.push({position:t,angle:n.body.angle,speedMps:g.launchSpeedMps+Math.max(0,f(n.body.velocity,e)),distanceM:0,age:0}),this.launches++,o?.(t),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 e=u(this.elapsed/Math.min(.27,this.ignitionDuration*.65),0,.9),i=m(l(-1,0),n.body.angle),o=n.body.world(l(_.xM-v*.52,_.yM));r({point:o,flow:c(i,3.5),amount:t*14*e,radiusM:.2}),a?.({from:o,to:o,flow:c(i,12),widthM:.16,intensity:e*.75})}this.phase===`flying`&&(!h&&this.queuedShots===0?this.transition(`closing`):this.launchClock>=Math.max(0,1/g.roundsPerSecond-Math.min(Z.igniting,.7/g.roundsPerSecond))&&(this.ignitionDuration=Math.min(Z.igniting,.7/g.roundsPerSecond),this.transition(`igniting`),p?.(n.body.world(l(_.xM,_.yM)))));for(let e=this.flights.length-1;e>=0;e--){let n=this.flights[e],o=m(l(1,0),n.angle);n.speedMps=Math.min(g.maxSpeedMps,n.speedMps+g.accelerationMps2*t);let u=n.speedMps*t,f=n.position,p=d(f,c(o,u)),h=i?.(f,p,_.sizeM*.18);n.position=h??p,n.distanceM+=u,n.age+=t;let y=d(n.position,c(o,-v*.53)),b=d(f,c(o,-v*.53));if(r({point:y,flow:c(o,-5),amount:t*g.smokePerSecond,radiusM:.2}),a?.({from:b,to:y,flow:c(o,-18),widthM:.13,intensity:.9}),h){s?.(h);for(let e=0;e<7;e++){let t=m(l(1,0),e*Math.PI*2/7);r({point:h,flow:c(t,5.5),amount:.18,radiusM:.22})}this.flights.splice(e,1)}else(n.age>=g.lifetimeSeconds||n.distanceM>100)&&this.flights.splice(e,1)}this.phase===`closing`&&this.elapsed>=Z.closing&&this.transition(`idle`)}get open(){return this.phase===`idle`?0:this.phase===`opening`?u(this.elapsed/Z.opening,0,1):this.phase===`closing`?1-u(this.elapsed/Z.closing,0,1):1}drawMount(e,t,n,r,i,a=1,o){let s=this.open;if(s<=0)return;y();let c=r.roofRocket,l=c.sizeM*i,d=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-d*.78),r=t*(l*.25+d*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:u(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,!h(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,r,i,a){if(t.mode!==`car`){this.reset();return}this.presetId&&this.presetId!==t.car.preset.id&&this.reset();let o=n(t.car.preset),s=!!t.lastInput.machineGun;if(s&&(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(!s&&(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/o.roundsPerSecond),this.phase===`active`){if(s){let n=1/Math.max(1,o.roundsPerSecond);this.shotClock+=e;for(let e=0;this.shotClock>=n&&e<4;e++)this.shotClock-=n,this.fire(t),i?.()}}else this.phase===`closing`&&this.phaseTime>=kn&&(this.phase=`closed`,this.phaseTime=0);for(let t=this.bullets.length-1;t>=0;t--){let n=this.bullets[t],i=n.position,s=d(i,c(n.velocity,e)),l=r?.(i,s,.075);n.age+=e,l||n.age>=o.bulletLifetimeSeconds?(l&&a?.(l,n.velocity),this.bullets.splice(t,1)):n.position=s}}fire(e){let t=n(e.car.preset),r=m(l(1,0),e.body.angle);for(let n of[-1,1]){let i=e.body.world(_(e.car.preset,n)),a=d(c(r,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`?u(this.phaseTime/On,0,1):this.phase===`closing`?1-u(this.phaseTime/kn,0,1):1}drawMount(e,t,n,r,i,a=1,o){v(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(d(i.position,c(i.velocity,-.75/Math.max(1,o)))),l=e.createLinearGradient(s.x,s.y,a.x,a.y);l.addColorStop(0,`rgba(224,153,63,0)`),l.addColorStop(.7,`rgba(224,153,63,.25)`),l.addColorStop(1,`rgba(255,225,157,.7)`),e.globalAlpha=r,e.strokeStyle=l,e.lineWidth=Math.max(.65,n*.025),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(a.x,a.y),e.stroke();let u=t(d(i.position,c(i.velocity,-.09/Math.max(1,o))));e.strokeStyle=`#fff6d7`,e.lineWidth=Math.max(.55,n*.018),e.beginPath(),e.moveTo(u.x,u.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,n,r,i,a){if(n.mode!==`car`){(this.phase!==`closed`||this.jets.length)&&this.reset();return}this.presetId&&this.presetId!==n.car.preset.id&&this.reset();let o=!!n.lastInput.flamethrower,s=t(n.car.preset);if(o&&(this.phase===`closed`||this.phase===`closing`)){this.presetId=n.car.preset.id;let e=this.open;this.phase=`opening`,this.phaseTime=e*jn}else if(!o&&(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`&&o,this.phase===`closing`&&this.phaseTime>=Mn&&(this.phase=`closed`,this.phaseTime=0),this.emitting){let t=m(l(1,0),n.body.angle),i=s.rangeM/.3;for(this.fireClock+=e;this.fireClock>=Q;){this.fireClock-=Q;for(let e of[-1,1]){let r=n.body.world(_(n.car.preset,e));this.jets.push({point:r,velocity:d(c(t,i),c(n.body.velocity,.25)),traveled:0,range:s.rangeM,speed:i,width:s.jetWidthM*s.flowRate})}}for(let i of[-1,1]){let a=n.body.world(_(n.car.preset,i));r({point:d(a,c(t,.06)),flow:c(t,5.5),amount:e*s.smokePerSecond*s.flowRate*.38,radiusM:.12})}}let u=[];for(let t of this.jets){let n=Math.min(t.range-t.traveled,t.speed*e),o=t.point,l=d(o,c(t.velocity,n/t.speed)),f=(t.traveled+n)/t.range,p=t.width*(.65+1.45*f),m=i?.(o,l,Math.max(.3,p*1.25),Q*s.flowRate),h=m??l;t.point=h,t.traveled+=n,a?.(o,h,p,t.velocity,f),(f>.62||m)&&r({point:h,flow:c(t.velocity,.42),amount:e*s.smokePerSecond*s.flowRate*(m?.42:.18),radiusM:Math.max(.11,p*.48)}),m?a?.(h,h,p*1.35,t.velocity,f):t.traveled+1e-6<t.range&&u.push(t)}this.jets=u}get open(){return this.phase===`closed`?0:this.phase===`opening`?u(this.phaseTime/jn,0,1):this.phase===`closing`?1-u(this.phaseTime/Mn,0,1):1}drawMount(e,t,n,r,i,a=1,o){v(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 g;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=S;toolPolicy={};numberedSlots=re(S);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=te(e);this.clearSlotInput(),this.slotConfiguration=t,this.numberedSlots=re(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=x(e);return this.disposed||!this.numberedSlots[t-1]||this.lifecycleState!==`drivable`?!1:(this.slotPulses.add(t),!0)}startSlot(e){let t=x(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(x(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(x)),n=new Set((e.slotPresses??[]).map(x));for(let e of this.blockedSlots)!t.has(e)&&!n.has(e)?this.blockedSlots.delete(e):(t.delete(e),n.delete(e));let r=new Set([...this.slotHeld,...t]),i=new Set([...this.slotPresses,...n]),a=$(e);this.activeEmitters=[];for(let{number:e,slot:t}of this.numberedSlots){let n=r.has(e)&&!this.previousSlotInput.has(e),o=this.slotPulses.has(e)||(t.activation===`tap`?n||i.has(e):i.has(e)&&!r.has(e));(o||t.activation!==`tap`&&r.has(e))&&(t.action===`eject`?(a.eject=!0,this.activeEmitters.push({slot:e,liquid:t.liquid,pulse:o,rate:t.rate??6,amount:t.amount??.65})):a[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=r,a}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,n={}){if(n.toolsEnabled!==this.toolPolicy.toolsEnabled){let t=re(this.slotConfiguration,n);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(x(t))}this.toolPolicy=n,this.numberedSlots=t}this.controls=ne(this.resolveSlots(e),n.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`,b(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>=o.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 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t}from"./configuration~react~vehicle-popover~EmbedPanel~Documentation~JoyRideView~browser-session-co~fvauaeow-zf1LIsS8.js";import{s as n,t as r}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js";import{a as i,c as a,i as o,l as s,o as c,r as l,s as u,u as d}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js";import{r as f,t as p}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{C as m,c as h,d as g,f as _,g as v,i as y,l as b,o as x,s as S,t as C,u as w,v as ee,y as te}from"./runtime~react~vehicle-popover~browser-session-core~renderer-Be8cIaU4.js";import{A as T,B as E,F as ne,S as re,V as D,a as ie,c as O,f as ae,i as oe,j as se,m as ce,o as le,r as ue,s as de,t as fe,y as pe}from"./runtime~vehicle-popover~browser-session-core~renderer-jVG7K050.js";import{n as me,t as he}from"./configuration~react~vehicle-popover~EmbedPanel~JoyRideView~browser-session-core~renderer-DJhBwBho.js";import{r as ge}from"./controls~react~vehicle-popover~JoyRideView~browser-session-core~renderer-Cnf30Q_A.js";var _e=e=>{let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)};function ve(e,t,n,r,i,a,o=1){let s=t.material;e.save();let c=t.exit?.leadInM,l=c?Math.max(.05,c-Math.max(t.widthM*1.5,.25)):0,u=c?Math.max(0,Math.min(1,(c+(t.exit.fromM+t.exit.toM)*.5)/l)):1,d=o*u*u*(3-2*u);if(e.strokeStyle=t.color,e.fillStyle=t.color,e.globalAlpha=t.opacity*d,t.droplet){e.translate(r.x,r.y),e.rotate(t.angle),e.beginPath(),e.ellipse(0,0,i/2,i*t.droplet.aspect/2,0,0,Math.PI*2),e.fill(),e.restore();return}let f=r.x-n.x,p=r.y-n.y,m=Math.hypot(f,p);if(!s){e.lineWidth=i,e.lineCap=`round`,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke(),e.restore();return}e.translate(n.x,n.y),e.rotate(m>.01?Math.atan2(p,f):t.angle);let h=t.wetness??1,g=t.slip??0,_=Math.max(1.5,s.pitchM*a),v=(t.phaseM??0)*a%_,y=t.opacity*d*s.coverage,b=Math.min(1,s.film*(.35+.65*h)+g*.3);if(t.exit){let e=Math.max(0,(t.exit.fromM+t.exit.toM)*.5),n=Math.min(1,e/t.exit.lengthM);b+=(1-b)*(1-n)*(1-n)}b>.005&&m>0&&(e.globalAlpha=y*b,e.lineWidth=i*.88,e.lineCap=t.exit?`round`:`butt`,e.beginPath(),e.moveTo(0,0),e.lineTo(m,0),e.stroke());let x=m<.01?0:_-v;for(let n=x,r=0;n<=m+.001&&r<256;n+=_,r++){let r=Math.round(((t.phaseM??0)*a+n)/_);for(let a=0;a<4;a++){let o=_e(r*17+a*7);if(o<s.breakup*(1-h*.65))continue;let c=(a-1.5)*i*.245,l=i*(.19+o*.025),u=_*(.5+g*.35),d=(a<2?1:-1)*l*.4;e.globalAlpha=y*(.62+o*.38)*(1-b*.65),e.fillStyle=t.color,e.beginPath(),e.moveTo(n-u*.5,c-l*.5),e.lineTo(n+u*.5,c-l*.5+d),e.lineTo(n+u*.5,c+l*.5+d),e.lineTo(n-u*.5,c+l*.5),e.closePath(),e.fill(),(s.gloss>.1||s.emission>0)&&(e.strokeStyle=s.emission>.5?`#ff9b25`:s.iridescence>.15?r%3?`#7faaa3`:`#9d7d99`:`#e2e8db`,e.globalAlpha=y*h*(s.emission>.5?.7:.11+s.gloss*.16),e.lineWidth=Math.max(.2,i*.035),e.beginPath(),e.moveTo(n-u*.4,c-l*.4),e.lineTo(n+u*.4,c-l*.4+d),e.stroke()),s.grain>.1&&o>.45&&(e.globalAlpha=y*s.grain*.35,e.fillStyle=`#372b22`,e.fillRect(n+u*.1,c,Math.max(.25,i*.05),Math.max(.3,i*.1)))}}e.restore()}var ye=[`low`,`medium`,`high`],be=1e3/60,xe=2e3,Se=8,Ce=2e3,we=1e4,Te=12e4,Ee=5e3,De=class{cap=ye.length-1;misses=[];lastTime=null;lastChange=-1/0;lastStepUp=-1/0;stepUpDelay=we;get limit(){return ye[this.cap]}apply(e){return ye[Math.min(ye.indexOf(e),this.cap)]}sample(e,t,n,r){let i=this.lastTime;if(this.lastTime=e,i===null)return!1;let a=e-i;if(!(a>0)||a>250)return!1;for(a>be*1.5&&t<be*.8&&n&&this.misses.push(e);this.misses.length&&e-this.misses[0]>xe;)this.misses.shift();if(e-this.lastChange<Ce)return!1;let o=ye.indexOf(r);return this.misses.length>=Se&&Math.min(this.cap,o)>0?(e-this.lastStepUp<Ee&&(this.stepUpDelay=Math.min(Te,this.stepUpDelay*2)),this.cap=Math.min(this.cap,o)-1,this.changed(e),!0):n&&this.cap<o&&!this.misses.length&&e-this.lastChange>=this.stepUpDelay?(this.cap++,this.lastStepUp=e,this.changed(e),!0):!1}restoreLimit(e){this.cap=e?Math.max(0,ye.indexOf(e)):ye.length-1,this.misses=[],this.lastTime=null}reset(){this.cap=ye.length-1,this.misses=[],this.lastTime=null,this.lastChange=this.lastStepUp=-1/0,this.stepUpDelay=we}changed(e){this.lastChange=e,this.misses=[]}};function Oe(e,t,n){let r=e.size,i=r*.74,a=0,o=0,s=0;for(let c=0;c<6;c++){let l=t*(c+.5)/6*2,u=n*(c+.5)/6*2,d=e.curlX*l*l*l+e.twist*n*2*l*l,f=e.curlY*u*u*u-e.twist*t*1.3*u*u;a+=Math.cos(d)*r*t/6,o+=Math.cos(f)*i*n/6,s+=Math.sin(d)*r*t/6+Math.sin(f)*i*n/6}let c=Math.max(0,t+n-.62);s+=c*c*r*(.35+e.fold);let l=Math.cos(e.tilt),u=Math.sin(e.tilt);return{x:a,y:o*l-s*u,z:o*u+s*l}}var ke=(e,t)=>{let n=Math.imul((e|0)&15^Math.imul(t+17,374761393),668265263);return n=Math.imul(n^n>>>13,1274126177),((n^n>>>16)>>>0)/4294967296},Ae=new Map,je=new Map;function Me(e){let t=Ae.get(e);if(t)return t;let n=e.replace(/^#/,``),r=/^[\da-f]{3}$/i.test(n)?[...n].map(e=>e+e).join(``):n,i=/^[\da-f]{6}$/i.test(r)?[0,2,4].map(e=>parseInt(r.slice(e,e+2),16)):e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/)?.slice(1,4).map(Number)??[195,190,174];return Ae.size>=128&&Ae.delete(Ae.keys().next().value),Ae.set(e,i),i}function Ne(e,t){let n=Math.round(t),r=`${e}:${n}`,i=je.get(r);if(i)return i;let a=`rgb(${Me(e).map(e=>Math.max(0,Math.min(255,e+n))).join(` `)})`;return je.size>=512&&je.delete(je.keys().next().value),je.set(r,a),a}function Pe(e,t){e.beginPath(),t.forEach(([t,n],r)=>{r?e.lineTo(t,n):e.moveTo(t,n)}),e.closePath()}function Fe(e,t,n){let r=Math.max(0,t.z),i=1+Math.min(.65,r/90);e.save(),e.translate(t.x+r*.13,t.y+r*.1),e.rotate(t.angle),e.fillStyle=`#000`,e.globalAlpha=t.opacity*(n?.12:.15)/(1+r/26),e.beginPath(),e.ellipse(0,0,t.size*.46*i,t.size*.27*i,0,0,Math.PI*2),e.fill(),r<5&&(e.globalAlpha*=(1-r/5)*.6,e.beginPath(),e.ellipse(0,0,t.size*.36,t.size*.19,0,0,Math.PI*2),e.fill()),e.restore()}function Ie(e,t){let n=[];for(let e=0;e<=2;e++)n.push(Array.from({length:9},(n,r)=>Oe(t,r/8-.5,e/2-.5)));let r=t.z<.5?Math.max(0,-Math.min(...n.flat().map(e=>e.z))):0,i=e=>[e.x,e.y-(e.z+r)*.48],a=[];for(let e=0;e<2;e++)for(let t=0;t<8;t++){let r=n[e][t],i=n[e][t+1],o=n[e+1][t+1],s=n[e+1][t],c=i.x-r.x,l=i.y-r.y,u=i.z-r.z,d=s.x-r.x,f=s.y-r.y,p=s.z-r.z,m=l*p-u*f,h=u*d-c*p,g=c*f-l*d,_=Math.max(.001,Math.hypot(m,h,g)),v=g+h*.48>0,y=(m*-.35+h*-.45+Math.abs(g)*.7)/_;a.push({a:r,b:i,c:o,d:s,col:t,row:e,front:v,light:y,depth:(r.z+i.z+o.z+s.z)/4})}a.sort((e,t)=>e.depth-t.depth);for(let n of a){let{a:r,b:a,c:o,d:s,front:c,light:l,row:u,col:d}=n;if(Pe(e,[i(r),i(a),i(o),i(s)]),e.fillStyle=Ne(t.color,(c?0:-32)+(l-.7)*45),e.fill(),c&&d>0&&d<(u===0?6:8)&&u<3){e.strokeStyle=Ne(t.color,-100),e.lineWidth=t.size*(u===0?.027:.013);let n=i({x:(r.x+s.x)*.5,y:(r.y+s.y)*.5,z:(r.z+s.z)*.5}),c=i({x:(a.x+o.x)*.5,y:(a.y+o.y)*.5,z:(a.z+o.z)*.5});if(e.beginPath(),e.moveTo(...n),e.lineTo(...c),e.stroke(),u>0){let t=i({x:r.x*.2+s.x*.8,y:r.y*.2+s.y*.8,z:r.z*.2+s.z*.8}),n=i({x:a.x*.2+o.x*.8,y:a.y*.2+o.y*.8,z:a.z*.2+o.z*.8});e.beginPath(),e.moveTo(...t),e.lineTo(...n),e.stroke()}}}}function Le(e,t){let n=t.size,r=t.size*(.35+ke(t.seed,61)*.2),i=Math.cos(t.tilt);if(e.scale(1,Math.abs(i)<.08?.08:i),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.bezierCurveTo(n*.12,r*.65,-n*.25,r*.45,-n*.48,0),e.fillStyle=Ne(t.color,i<0?14:0),e.fill(),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.quadraticCurveTo(0,-r*t.fold*.2,-n*.48,0),e.fillStyle=Ne(t.color,-13-t.fold*9),e.fill(),e.strokeStyle=Ne(t.color,-35),e.lineWidth=.45,e.globalAlpha*=.55,e.beginPath(),e.moveTo(-n*.63,r*.08),e.quadraticCurveTo(-n*.08,-r*t.fold*.2,n*.46,-r*.07),e.stroke(),n>10){e.lineWidth=.3;for(let t of[-.18,.08])e.beginPath(),e.moveTo(n*t,0),e.lineTo(n*(t+.1),-r*.3),e.moveTo(n*t,0),e.lineTo(n*(t-.03),r*.28),e.stroke()}}var k=new Map,Re=0,ze=0,Be=()=>({sprites:k.size,bytes:Re});function Ve(e,t){t.kind===`paper`?Ie(e,t):t.kind===`leaf`&&Le(e,t)}function He(e){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,e);if(typeof document>`u`||typeof HTMLCanvasElement>`u`)return null;let t=document.createElement(`canvas`);return!(t instanceof HTMLCanvasElement)||!t.getContext?null:(t.width=t.height=e,t)}function Ue(e,t,n){if(t.z>.1||Math.abs(t.vz)>.1||Math.hypot(t.vx,t.vy)>.75||t.kind===`paper`&&Math.abs(t.curlVelocityX)+Math.abs(t.curlVelocityY)+Math.abs(t.twistVelocity)>.03)return!1;let r=Math.max(4,Math.round(t.size/4)*4),i=Math.round(t.fold*5)/5,a=Math.cos(t.tilt)<0?4:0,o=a*Math.PI/4;if(Math.abs(Math.sin(t.tilt))>.015)return!1;let s=Math.round(t.curlX*4)/4,c=Math.round(t.curlY*4)/4,l=Math.round(t.twist*4)/4,u=`${s}:${c}:${l}:${t.kind}:${t.seed&15}:${t.color}:${r}:${i}:${a}:${n}`,d=k.get(u),f={...t,size:r,fold:i,tilt:o,curlX:s,curlY:c,twist:l,opacity:1};if(!d){let e=r*1.4+4,t=Math.ceil(e*n),i=t*t*4;if(k.size>=128||Re+i>8388608){for(let[e,t]of k)if(!(ze-t.used<120)&&(k.delete(e),`close`in t.canvas&&t.canvas.close(),Re-=t.bytes,k.size<128&&Re+i<=8388608))break}if(k.size<128&&Re+i<=8388608){let r=He(t),a=r?.getContext(`2d`);r&&a&&(a.scale(n,n),a.translate(e/2,e/2),Ve(a,f),d={canvas:`transferToImageBitmap`in r?r.transferToImageBitmap():r,extent:e,bytes:i,used:ze},k.set(u,d),Re+=i)}}return e.scale(t.size/r,t.size/r),d?(d.used=ze,e.drawImage(d.canvas,-d.extent/2,-d.extent/2,d.extent,d.extent)):(e.save(),Ve(e,f),e.restore()),!0}function We(e,t,n,r,i=`ground`){i===`ground`&&ze++;let a=e.getTransform(),o=Math.min(8,Math.max(1,Math.ceil(Math.hypot(a.a,a.b)))),s=n.x+n.width,c=n.y+n.height;for(let a of t){if(a.opacity<=0)continue;let t=a.size+Math.max(0,a.z)*.35;a.x+t<n.x||a.x-t>s||a.y+t<n.y||a.y-t>c||(i===`ground`&&Fe(e,a,r),i===`ground`==a.z<4&&(e.save(),e.translate(a.x,a.y-Math.max(0,a.z)*.22),e.rotate(a.angle),e.globalAlpha=a.opacity,Ue(e,a,o)||Ve(e,a),e.restore()))}}function Ge(e){let{tireLengthM:t,tireWidthM:n}=e.geometry;return e.image?{length:t*(e.image.wheelVisualScale?.length??.64),width:n*(e.image.wheelVisualScale?.width??.82)}:{length:t,width:n}}function Ke(e,t,n,r,i){let a=D(t,e.naturalWidth,e.naturalHeight),o=Math.min(1,512/Math.max(a.source.width,a.source.height)),s=document.createElement(`canvas`);s.width=Math.max(1,Math.round(a.source.width*o)),s.height=Math.max(1,Math.round(a.source.height*o));let c=s.getContext(`2d`);if(!c)return null;n?c.drawImage(n,0,0,s.width,s.height):c.drawImage(e,a.source.x,a.source.y,a.source.width,a.source.height,0,0,s.width,s.height),c.globalCompositeOperation=`source-in`,c.fillStyle=`#101916`,c.fillRect(0,0,s.width,s.height);let l=`filter`in c,u=e=>{let t=Math.ceil(e*4),n=a.lengthM*r,o=a.widthM*r,c=document.createElement(`canvas`);c.width=Math.max(1,Math.ceil((n+t*2)*i)),c.height=Math.max(1,Math.ceil((o+t*2)*i));let u=c.getContext(`2d`);if(!u)return null;let d=c.width*2;return l?u.filter=`blur(${e*i}px)`:(u.shadowColor=`#101916`,u.shadowBlur=e*i*2,u.shadowOffsetX=d),u.drawImage(s,t*i-(l?0:d),t*i,n*i,o*i),{canvas:c,padding:t}};return{soft:u(6),close:u(1.5),pixelsPerMeter:r,lengthM:a.lengthM,widthM:a.widthM}}var qe={width:56,height:56},Je=8,Ye=10,Xe=6;function Ze(e,t,n=Je){let{width:r,height:i}=qe,a=r/2,o=i/2,s=e.x-t.width/2,c=e.y-t.height/2,l=Math.hypot(s,c)||1,u={x:s/l,y:c/l},d=Math.max(0,t.width/2-a-Ye-Je),f=Math.max(0,t.height/2-o-Ye-(c<0?n:Je)),p=Math.min(Math.abs(s)?d/Math.abs(s):1/0,Math.abs(c)?f/Math.abs(c):1/0),m={x:t.width/2+s*(Number.isFinite(p)?p:0),y:t.height/2+c*(Number.isFinite(p)?p:0)},h={x:u.x*a,y:u.y*o},g={x:h.x+u.x*Ye,y:h.y+u.y*Ye},_=Math.sqrt((r/2)**2-Xe**2),v={x:u.x*_,y:u.y*_};return{center:m,direction:u,edge:h,tip:g,left:{x:v.x-u.y*Xe,y:v.y+u.x*Xe},right:{x:v.x+u.y*Xe,y:v.y-u.x*Xe},width:r,height:i}}var Qe=5120,$e=5121,et=5122,tt=5123,nt=5124,rt=5125,it=5126,at=32819,ot=32820,st=33635,ct=5131,lt=33640,ut=35899,dt=35902,ft=36269,pt=34042,mt={};{let e=mt;e[Qe]=Int8Array,e[$e]=Uint8Array,e[et]=Int16Array,e[tt]=Uint16Array,e[nt]=Int32Array,e[rt]=Uint32Array,e[it]=Float32Array,e[at]=Uint16Array,e[ot]=Uint16Array,e[st]=Uint16Array,e[ct]=Uint16Array,e[lt]=Uint32Array,e[ut]=Uint32Array,e[dt]=Uint32Array,e[ft]=Uint32Array,e[pt]=Uint32Array}function ht(...e){console.error(...e)}var gt=new Map;function _t(e,t){if(!e||typeof e!=`object`)return!1;let n=gt.get(t);n||(n=new WeakMap,gt.set(t,n));let r=n.get(e);if(r===void 0){let i=Object.prototype.toString.call(e);r=i.substring(8,i.length-1)===t,n.set(e,r)}return r}function vt(e,t){return typeof WebGLBuffer<`u`&&_t(t,`WebGLBuffer`)}function yt(e,t){return typeof WebGLTexture<`u`&&_t(t,`WebGLTexture`)}function bt(e,t){return typeof WebGLSampler<`u`&&_t(t,`WebGLSampler`)}var xt=35044,St=34962;function Ct(e,t,n,r,i){e.bindBuffer(t,n),e.bufferData(t,r,i||xt)}function wt(e,t,n,r){if(vt(e,t))return t;n||=St;let i=e.createBuffer();return Ct(e,n,i,t,r),i}function Tt(e){return!!e.texStorage2D}var Et=function(){let e={},t={};function n(n){let r=n.constructor.name;if(!e[r]){for(let e in n)if(typeof n[e]==`number`){let r=t[n[e]];t[n[e]]=r?`${r} | ${e}`:e}e[r]=!0}}return function(e,r){return n(e),t[r]||(typeof r==`number`?`0x${r.toString(16)}`:r)}}();new Uint8Array([128,192,255,255]);var Dt=6406,A=6407,j=6408,Ot=6409,kt=6410,At=6402,jt=34041,Mt=3553,Nt=34067,Pt=32879,Ft=35866,It=34069,Lt=10241,Rt=10240,zt=10242,Bt=10243,Vt=32882,Ht=33082,Ut=33083,Wt=33084,Gt=33085,Kt=34892,qt=34893,Jt=37443,Yt=37441,Xt=37440,Zt=33321,Qt=36756,$t=33325,en=33326,tn=33330,nn=33329,rn=33338,an=33337,on=33340,sn=33339,cn=33323,ln=36757,un=33327,dn=33328,fn=33336,pn=33335,mn=33332,hn=33331,gn=33334,_n=33333,vn=32849,yn=35905,bn=36194,xn=36758,Sn=35898,Cn=35901,wn=34843,Tn=34837,En=36221,Dn=36239,On=36215,kn=36233,An=36209,jn=36227,Mn=32856,Nn=35907,Pn=36759,Fn=32855,In=32854,Ln=32857,Rn=34842,zn=34836,Bn=36220,Vn=36238,Hn=36975,Un=36214,Wn=36232,Gn=36226,Kn=36208,qn=33189,Jn=33190,Yn=36012,Xn=36013,Zn=35056,M=5120,N=5121,Qn=5122,$n=5123,er=5124,tr=5125,P=5126,nr=32819,rr=32820,ir=33635,F=5131,ar=36193,or=33640,sr=35899,cr=35902,lr=36269,ur=34042,dr=33319,fr=33320,pr=6403,mr=36244,hr=36248,gr=36249,_r=33776,vr=33777,yr=33778,br=33779,xr=35916,Sr=35917,Cr=35918,wr=35919,Tr=36196,Er=37488,Dr=37489,Or=37490,kr=37491,Ar=37492,jr=37493,Mr=37494,Nr=37495,Pr=37496,Fr=37497,Ir=35840,Lr=35841,Rr=35842,zr=35843,Br=37808,Vr=37809,Hr=37810,Ur=37811,Wr=37812,Gr=37813,Kr=37814,qr=37815,Jr=37816,Yr=37817,Xr=37818,Zr=37819,Qr=37820,$r=37821,ei=37840,ti=37841,ni=37842,ri=37843,ii=37844,ai=37845,oi=37846,si=37847,ci=37848,li=37849,ui=37850,di=37851,fi=37852,pi=37853,mi=36492,hi=36493,gi=36494,_i=36495,vi=36283,yi=36284,bi=36285,xi=36286,Si={};{let e=Si;e[Dt]={numColorComponents:1},e[Ot]={numColorComponents:1},e[kt]={numColorComponents:2},e[A]={numColorComponents:3},e[j]={numColorComponents:4},e[pr]={numColorComponents:1},e[mr]={numColorComponents:1},e[dr]={numColorComponents:2},e[fr]={numColorComponents:2},e[A]={numColorComponents:3},e[hr]={numColorComponents:3},e[j]={numColorComponents:4},e[gr]={numColorComponents:4},e[At]={numColorComponents:1},e[jt]={numColorComponents:2}}var Ci;function wi(e){if(!Ci){let e={};e[Dt]={textureFormat:Dt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[N,F,ar,P]},e[Ot]={textureFormat:Ot,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[N,F,ar,P]},e[kt]={textureFormat:kt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[N,F,ar,P]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[N,F,ar,P,ir]},e[j]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[N,F,ar,P,nr,rr]},e[At]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[tr,$n]},e[Zt]={textureFormat:pr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[N]},e[Qt]={textureFormat:pr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[M]},e[$t]={textureFormat:pr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[P,F]},e[en]={textureFormat:pr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[P]},e[tn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[N]},e[nn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[M]},e[mn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[$n]},e[hn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Qn]},e[gn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[tr]},e[_n]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[er]},e[cn]={textureFormat:dr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[N]},e[ln]={textureFormat:dr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[M]},e[un]={textureFormat:dr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[P,F]},e[dn]={textureFormat:dr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[P]},e[fn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[N]},e[pn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[M]},e[rn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[$n]},e[an]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Qn]},e[on]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[tr]},e[sn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[er]},e[vn]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[N]},e[yn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[N]},e[bn]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[N,ir]},e[xn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[M]},e[Sn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[P,F,sr]},e[Cn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[P,F,cr]},e[wn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[P,F]},e[Tn]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[P]},e[En]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[N]},e[Dn]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[M]},e[On]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[$n]},e[kn]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Qn]},e[An]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[tr]},e[jn]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[er]},e[Mn]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[N]},e[Nn]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[N]},e[Pn]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[M]},e[Fn]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[N,rr,or]},e[In]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[N,nr]},e[Ln]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[or]},e[Rn]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[P,F]},e[zn]={textureFormat:j,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[P]},e[Bn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[N]},e[Vn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[Hn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[or]},e[Un]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[$n]},e[Wn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Qn]},e[Gn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[er]},e[Kn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[tr]},e[qn]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[$n,tr]},e[Jn]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[tr]},e[Yn]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[P]},e[Zn]={textureFormat:jt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ur]},e[Xn]={textureFormat:jt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[lr]},Object.keys(e).forEach(function(t){let n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(e,t){let r=n.type[t];n.bytesPerElementMap[r]=e})});let t={bytes:8,width:4,height:4},n={bytes:16,width:4,height:4};e[_r]={textureFormat:_r,colorRenderable:!1,textureFilterable:!0,block:t},e[vr]={textureFormat:vr,colorRenderable:!1,textureFilterable:!0,block:t},e[yr]={textureFormat:yr,colorRenderable:!1,textureFilterable:!0,block:n},e[br]={textureFormat:br,colorRenderable:!1,textureFilterable:!0,block:n},e[xr]={textureFormat:xr,colorRenderable:!1,textureFilterable:!0,block:t},e[Sr]={textureFormat:Sr,colorRenderable:!1,textureFilterable:!0,block:t},e[Cr]={textureFormat:Cr,colorRenderable:!1,textureFilterable:!0,block:n},e[wr]={textureFormat:wr,colorRenderable:!1,textureFilterable:!0,block:n},e[Tr]={textureFormat:Tr,colorRenderable:!1,textureFilterable:!0,block:t},e[Er]={textureFormat:Er,colorRenderable:!1,textureFilterable:!0,block:t},e[Dr]={textureFormat:Dr,colorRenderable:!1,textureFilterable:!0,block:t},e[Or]={textureFormat:Or,colorRenderable:!1,textureFilterable:!0,block:n},e[kr]={textureFormat:kr,colorRenderable:!1,textureFilterable:!0,block:n},e[Ar]={textureFormat:Ar,colorRenderable:!1,textureFilterable:!0,block:t},e[jr]={textureFormat:jr,colorRenderable:!1,textureFilterable:!0,block:t},e[Mr]={textureFormat:Mr,colorRenderable:!1,textureFilterable:!0,block:t},e[Nr]={textureFormat:Nr,colorRenderable:!1,textureFilterable:!0,block:t},e[Pr]={textureFormat:Pr,colorRenderable:!1,textureFilterable:!0,block:n},e[Fr]={textureFormat:Fr,colorRenderable:!1,textureFilterable:!0,block:n},e[Ir]={textureFormat:Ir,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:8,height:8}},e[Lr]={textureFormat:Lr,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:16,height:8}},e[Rr]={textureFormat:Rr,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:8,height:8}},e[zr]={textureFormat:zr,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:16,height:8}},e[Br]={textureFormat:Br,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:4,height:4}},e[Vr]={textureFormat:Vr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:4}},e[Hr]={textureFormat:Hr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:5}},e[Ur]={textureFormat:Ur,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:5}},e[Wr]={textureFormat:Wr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:6}},e[Gr]={textureFormat:Gr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:5}},e[Kr]={textureFormat:Kr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:6}},e[qr]={textureFormat:qr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:8}},e[Jr]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:5}},e[Yr]={textureFormat:Yr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:6}},e[Xr]={textureFormat:Xr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:8}},e[Zr]={textureFormat:Zr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:10}},e[Qr]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:10}},e[$r]={textureFormat:$r,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:12}},e[ei]={textureFormat:ei,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:4,height:4}},e[ti]={textureFormat:ti,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:4}},e[ni]={textureFormat:ni,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:5}},e[ri]={textureFormat:ri,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:5}},e[ii]={textureFormat:ii,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:6}},e[ai]={textureFormat:ai,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:5}},e[oi]={textureFormat:oi,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:6}},e[si]={textureFormat:si,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:8}},e[ci]={textureFormat:ci,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:5}},e[li]={textureFormat:li,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:6}},e[ui]={textureFormat:ui,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:8}},e[di]={textureFormat:di,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:10}},e[fi]={textureFormat:fi,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:10}},e[pi]={textureFormat:pi,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:12}},e[mi]={textureFormat:mi,colorRenderable:!1,textureFilterable:!0,block:n},e[hi]={textureFormat:hi,colorRenderable:!1,textureFilterable:!0,block:n},e[gi]={textureFormat:gi,colorRenderable:!1,textureFilterable:!0,block:n},e[_i]={textureFormat:_i,colorRenderable:!1,textureFilterable:!0,block:n},e[vi]={textureFormat:vi,colorRenderable:!1,textureFilterable:!0,block:t},e[yi]={textureFormat:yi,colorRenderable:!1,textureFilterable:!0,block:t},e[bi]={textureFormat:bi,colorRenderable:!1,textureFilterable:!0,block:t},e[xi]={textureFormat:xi,colorRenderable:!1,textureFilterable:!0,block:t},Ci=e}let t=Ci[e];if(!t)throw Error(`unknown internal format`);return t}function Ti(e){let t=wi(e);if(!t)throw Error(`unknown internal format`);return{format:t.textureFormat,type:t.type?.[0]??N}}function Ei(e,t,n){let r,i,a;t.colorspaceConversion!==void 0&&(r=e.getParameter(Jt),e.pixelStorei(Jt,t.colorspaceConversion)),t.premultiplyAlpha!==void 0&&(i=e.getParameter(Yt),e.pixelStorei(Yt,t.premultiplyAlpha)),t.flipY!==void 0&&(a=e.getParameter(Xt),e.pixelStorei(Xt,t.flipY)),n(),r!==void 0&&e.pixelStorei(Jt,r),i!==void 0&&e.pixelStorei(Yt,i),a!==void 0&&e.pixelStorei(Xt,a)}function Di(e,t,n,r){r.minMag&&(n.call(e,t,Lt,r.minMag),n.call(e,t,Rt,r.minMag)),r.min&&n.call(e,t,Lt,r.min),r.mag&&n.call(e,t,Rt,r.mag),r.wrap&&(n.call(e,t,zt,r.wrap),n.call(e,t,Bt,r.wrap),(t===Pt||bt(e,t))&&n.call(e,t,Vt,r.wrap)),r.wrapR&&n.call(e,t,Vt,r.wrapR),r.wrapS&&n.call(e,t,zt,r.wrapS),r.wrapT&&n.call(e,t,Bt,r.wrapT),r.minLod!==void 0&&n.call(e,t,Ht,r.minLod),r.maxLod!==void 0&&n.call(e,t,Ut,r.maxLod),r.baseLevel!==void 0&&n.call(e,t,Wt,r.baseLevel),r.maxLevel!==void 0&&n.call(e,t,Gt,r.maxLevel),r.compareFunc!==void 0&&n.call(e,t,qt,r.compareFunc),r.compareMode!==void 0&&n.call(e,t,Kt,r.compareMode)}function Oi(e,t,n){let r=n.target||Mt;e.bindTexture(r,t),Di(e,r,e.texParameteri,n)}function ki(e,t,n){let r=n.target||Mt;e.bindTexture(r,t);let i=n.level||0,a=n.internalFormat||n.format||j,o=Ti(a),s=n.format||o.format,c=n.type||o.type;Ei(e,n,()=>{if(r===Nt)for(let t=0;t<6;++t)e.texImage2D(It+t,i,a,n.width,n.height,0,s,c,null);else r===Pt||r===Ft?e.texImage3D(r,i,a,n.width,n.height,n.depth,0,s,c,null):e.texImage2D(r,i,a,n.width,n.height,0,s,c,null)})}var Ai=ht;function ji(e){return typeof document<`u`&&document.getElementById?document.getElementById(e):null}var Mi=33984,Ni=34962,Pi=34963,Fi=35713,Ii=35714,Li=35632,Ri=35633,zi=35981,Bi=35718,Vi=35721,Hi=35971,Ui=35382,Wi=35396,Gi=35398,Ki=35392,qi=35395,Ji=5126,Yi=35664,Xi=35665,Zi=35666,Qi=5124,$i=35667,ea=35668,ta=35669,na=35670,ra=35671,ia=35672,aa=35673,oa=35674,sa=35675,ca=35676,la=35678,ua=35680,da=35679,fa=35682,pa=35685,ma=35686,ha=35687,ga=35688,_a=35689,va=35690,ya=36289,ba=36292,xa=36293,Sa=5125,Ca=36294,wa=36295,Ta=36296,Ea=36298,Da=36299,Oa=36300,ka=36303,Aa=36306,ja=36307,Ma=36308,Na=36311,Pa=3553,Fa=34067,Ia=32879,La=35866,I={};function Ra(e,t){return I[t].bindPoint}function za(e,t){return function(n){e.uniform1f(t,n)}}function Ba(e,t){return function(n){e.uniform1fv(t,n)}}function Va(e,t){return function(n){e.uniform2fv(t,n)}}function Ha(e,t){return function(n){e.uniform3fv(t,n)}}function Ua(e,t){return function(n){e.uniform4fv(t,n)}}function Wa(e,t){return function(n){e.uniform1i(t,n)}}function Ga(e,t){return function(n){e.uniform1iv(t,n)}}function Ka(e,t){return function(n){e.uniform2iv(t,n)}}function qa(e,t){return function(n){e.uniform3iv(t,n)}}function Ja(e,t){return function(n){e.uniform4iv(t,n)}}function Ya(e,t){return function(n){e.uniform1ui(t,n)}}function Xa(e,t){return function(n){e.uniform1uiv(t,n)}}function Za(e,t){return function(n){e.uniform2uiv(t,n)}}function Qa(e,t){return function(n){e.uniform3uiv(t,n)}}function $a(e,t){return function(n){e.uniform4uiv(t,n)}}function eo(e,t){return function(n){e.uniformMatrix2fv(t,!1,n)}}function to(e,t){return function(n){e.uniformMatrix3fv(t,!1,n)}}function no(e,t){return function(n){e.uniformMatrix4fv(t,!1,n)}}function ro(e,t){return function(n){e.uniformMatrix2x3fv(t,!1,n)}}function io(e,t){return function(n){e.uniformMatrix3x2fv(t,!1,n)}}function ao(e,t){return function(n){e.uniformMatrix2x4fv(t,!1,n)}}function oo(e,t){return function(n){e.uniformMatrix4x2fv(t,!1,n)}}function so(e,t){return function(n){e.uniformMatrix3x4fv(t,!1,n)}}function co(e,t){return function(n){e.uniformMatrix4x3fv(t,!1,n)}}function L(e,t,n,r){let i=Ra(e,t);return Tt(e)?function(t){let a,o;!t||yt(e,t)?(a=t,o=null):(a=t.texture,o=t.sampler),e.uniform1i(r,n),e.activeTexture(Mi+n),e.bindTexture(i,a),e.bindSampler(n,o)}:function(t){e.uniform1i(r,n),e.activeTexture(Mi+n),e.bindTexture(i,t)}}function R(e,t,n,r,i){let a=Ra(e,t),o=new Int32Array(i);for(let e=0;e<i;++e)o[e]=n+e;return Tt(e)?function(t){e.uniform1iv(r,o),t.forEach(function(t,r){e.activeTexture(Mi+o[r]);let i,s;!t||yt(e,t)?(i=t,s=null):(i=t.texture,s=t.sampler),e.bindSampler(n,s),e.bindTexture(a,i)})}:function(t){e.uniform1iv(r,o),t.forEach(function(t,n){e.activeTexture(Mi+o[n]),e.bindTexture(a,t)})}}I[Ji]={Type:Float32Array,size:4,setter:za,arraySetter:Ba},I[Yi]={Type:Float32Array,size:8,setter:Va,cols:2},I[Xi]={Type:Float32Array,size:12,setter:Ha,cols:3},I[Zi]={Type:Float32Array,size:16,setter:Ua,cols:4},I[Qi]={Type:Int32Array,size:4,setter:Wa,arraySetter:Ga},I[$i]={Type:Int32Array,size:8,setter:Ka,cols:2},I[ea]={Type:Int32Array,size:12,setter:qa,cols:3},I[ta]={Type:Int32Array,size:16,setter:Ja,cols:4},I[Sa]={Type:Uint32Array,size:4,setter:Ya,arraySetter:Xa},I[Ca]={Type:Uint32Array,size:8,setter:Za,cols:2},I[wa]={Type:Uint32Array,size:12,setter:Qa,cols:3},I[Ta]={Type:Uint32Array,size:16,setter:$a,cols:4},I[na]={Type:Uint32Array,size:4,setter:Wa,arraySetter:Ga},I[ra]={Type:Uint32Array,size:8,setter:Ka,cols:2},I[ia]={Type:Uint32Array,size:12,setter:qa,cols:3},I[aa]={Type:Uint32Array,size:16,setter:Ja,cols:4},I[oa]={Type:Float32Array,size:32,setter:eo,rows:2,cols:2},I[sa]={Type:Float32Array,size:48,setter:to,rows:3,cols:3},I[ca]={Type:Float32Array,size:64,setter:no,rows:4,cols:4},I[pa]={Type:Float32Array,size:32,setter:ro,rows:2,cols:3},I[ma]={Type:Float32Array,size:32,setter:ao,rows:2,cols:4},I[ha]={Type:Float32Array,size:48,setter:io,rows:3,cols:2},I[ga]={Type:Float32Array,size:48,setter:so,rows:3,cols:4},I[_a]={Type:Float32Array,size:64,setter:oo,rows:4,cols:2},I[va]={Type:Float32Array,size:64,setter:co,rows:4,cols:3},I[la]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[ua]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[da]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Ia},I[fa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[ya]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La},I[ba]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La},I[xa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[Ea]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[Da]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Ia},I[Oa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[ka]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La},I[Aa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[ja]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Ia},I[Ma]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[Na]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La};function lo(e,t){return function(n){if(n.value)switch(e.disableVertexAttribArray(t),n.value.length){case 4:e.vertexAttrib4fv(t,n.value);break;case 3:e.vertexAttrib3fv(t,n.value);break;case 2:e.vertexAttrib2fv(t,n.value);break;case 1:e.vertexAttrib1fv(t,n.value);break;default:throw Error(`the length of a float constant value must be between 1 and 4!`)}else e.bindBuffer(Ni,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,n.numComponents||n.size,n.type||Ji,n.normalize||!1,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function uo(e,t){return function(n){if(n.value){if(e.disableVertexAttribArray(t),n.value.length===4)e.vertexAttrib4iv(t,n.value);else throw Error(`The length of an integer constant value must be 4!`)}else e.bindBuffer(Ni,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,n.numComponents||n.size,n.type||Qi,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function fo(e,t){return function(n){if(n.value){if(e.disableVertexAttribArray(t),n.value.length===4)e.vertexAttrib4uiv(t,n.value);else throw Error(`The length of an unsigned integer constant value must be 4!`)}else e.bindBuffer(Ni,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,n.numComponents||n.size,n.type||Sa,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function po(e,t,n){let r=n.size,i=n.count;return function(n){e.bindBuffer(Ni,n.buffer);let a=n.size||n.numComponents||r,o=a/i,s=n.type||Ji,c=I[s].size*a,l=n.normalize||!1,u=n.offset||0,d=c/i;for(let r=0;r<i;++r)e.enableVertexAttribArray(t+r),e.vertexAttribPointer(t+r,o,s,l,c,u+d*r),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+r,n.divisor||0)}}var z={};z[Ji]={size:4,setter:lo},z[Yi]={size:8,setter:lo},z[Xi]={size:12,setter:lo},z[Zi]={size:16,setter:lo},z[Qi]={size:4,setter:uo},z[$i]={size:8,setter:uo},z[ea]={size:12,setter:uo},z[ta]={size:16,setter:uo},z[Sa]={size:4,setter:fo},z[Ca]={size:8,setter:fo},z[wa]={size:12,setter:fo},z[Ta]={size:16,setter:fo},z[na]={size:4,setter:uo},z[ra]={size:8,setter:uo},z[ia]={size:12,setter:uo},z[aa]={size:16,setter:uo},z[oa]={size:4,setter:po,count:2},z[sa]={size:9,setter:po,count:3},z[ca]={size:16,setter:po,count:4};var mo=/ERROR:\s*\d+:(\d+)/gi;function ho(e,t=``,n=0){let r=[...t.matchAll(mo)],i=new Map(r.map((e,n)=>{let i=parseInt(e[1]),a=r[n+1],o=a?a.index:t.length,s=t.substring(e.index,o);return[i-1,s]}));return e.split(`
|
|
1
|
+
import{n as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t}from"./configuration~react~vehicle-popover~EmbedPanel~Documentation~JoyRideView~browser-session-co~fvauaeow-mgPW9A8j.js";import{s as n,t as r}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js";import{a as i,c as a,i as o,l as s,o as c,r as l,s as u,u as d}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js";import{r as f,t as p}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{C as m,c as h,d as g,f as _,g as v,i as y,l as b,o as x,s as S,t as C,u as w,v as ee,y as te}from"./runtime~react~vehicle-popover~browser-session-core~renderer-Be8cIaU4.js";import{A as T,B as E,F as ne,S as re,V as D,a as ie,c as O,f as ae,i as oe,j as se,m as ce,o as le,r as ue,s as de,t as fe,y as pe}from"./runtime~vehicle-popover~browser-session-core~renderer-jVG7K050.js";import{n as me,t as he}from"./configuration~react~vehicle-popover~EmbedPanel~JoyRideView~browser-session-core~renderer-Bo9KSudc.js";import{r as ge}from"./controls~react~vehicle-popover~JoyRideView~browser-session-core~renderer-Cnf30Q_A.js";var _e=e=>{let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)};function ve(e,t,n,r,i,a,o=1){let s=t.material;e.save();let c=t.exit?.leadInM,l=c?Math.max(.05,c-Math.max(t.widthM*1.5,.25)):0,u=c?Math.max(0,Math.min(1,(c+(t.exit.fromM+t.exit.toM)*.5)/l)):1,d=o*u*u*(3-2*u);if(e.strokeStyle=t.color,e.fillStyle=t.color,e.globalAlpha=t.opacity*d,t.droplet){e.translate(r.x,r.y),e.rotate(t.angle),e.beginPath(),e.ellipse(0,0,i/2,i*t.droplet.aspect/2,0,0,Math.PI*2),e.fill(),e.restore();return}let f=r.x-n.x,p=r.y-n.y,m=Math.hypot(f,p);if(!s){e.lineWidth=i,e.lineCap=`round`,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke(),e.restore();return}e.translate(n.x,n.y),e.rotate(m>.01?Math.atan2(p,f):t.angle);let h=t.wetness??1,g=t.slip??0,_=Math.max(1.5,s.pitchM*a),v=(t.phaseM??0)*a%_,y=t.opacity*d*s.coverage,b=Math.min(1,s.film*(.35+.65*h)+g*.3);if(t.exit){let e=Math.max(0,(t.exit.fromM+t.exit.toM)*.5),n=Math.min(1,e/t.exit.lengthM);b+=(1-b)*(1-n)*(1-n)}b>.005&&m>0&&(e.globalAlpha=y*b,e.lineWidth=i*.88,e.lineCap=t.exit?`round`:`butt`,e.beginPath(),e.moveTo(0,0),e.lineTo(m,0),e.stroke());let x=m<.01?0:_-v;for(let n=x,r=0;n<=m+.001&&r<256;n+=_,r++){let r=Math.round(((t.phaseM??0)*a+n)/_);for(let a=0;a<4;a++){let o=_e(r*17+a*7);if(o<s.breakup*(1-h*.65))continue;let c=(a-1.5)*i*.245,l=i*(.19+o*.025),u=_*(.5+g*.35),d=(a<2?1:-1)*l*.4;e.globalAlpha=y*(.62+o*.38)*(1-b*.65),e.fillStyle=t.color,e.beginPath(),e.moveTo(n-u*.5,c-l*.5),e.lineTo(n+u*.5,c-l*.5+d),e.lineTo(n+u*.5,c+l*.5+d),e.lineTo(n-u*.5,c+l*.5),e.closePath(),e.fill(),(s.gloss>.1||s.emission>0)&&(e.strokeStyle=s.emission>.5?`#ff9b25`:s.iridescence>.15?r%3?`#7faaa3`:`#9d7d99`:`#e2e8db`,e.globalAlpha=y*h*(s.emission>.5?.7:.11+s.gloss*.16),e.lineWidth=Math.max(.2,i*.035),e.beginPath(),e.moveTo(n-u*.4,c-l*.4),e.lineTo(n+u*.4,c-l*.4+d),e.stroke()),s.grain>.1&&o>.45&&(e.globalAlpha=y*s.grain*.35,e.fillStyle=`#372b22`,e.fillRect(n+u*.1,c,Math.max(.25,i*.05),Math.max(.3,i*.1)))}}e.restore()}var ye=[`low`,`medium`,`high`],be=1e3/60,xe=2e3,Se=8,Ce=2e3,we=1e4,Te=12e4,Ee=5e3,De=class{cap=ye.length-1;misses=[];lastTime=null;lastChange=-1/0;lastStepUp=-1/0;stepUpDelay=we;get limit(){return ye[this.cap]}apply(e){return ye[Math.min(ye.indexOf(e),this.cap)]}sample(e,t,n,r){let i=this.lastTime;if(this.lastTime=e,i===null)return!1;let a=e-i;if(!(a>0)||a>250)return!1;for(a>be*1.5&&t<be*.8&&n&&this.misses.push(e);this.misses.length&&e-this.misses[0]>xe;)this.misses.shift();if(e-this.lastChange<Ce)return!1;let o=ye.indexOf(r);return this.misses.length>=Se&&Math.min(this.cap,o)>0?(e-this.lastStepUp<Ee&&(this.stepUpDelay=Math.min(Te,this.stepUpDelay*2)),this.cap=Math.min(this.cap,o)-1,this.changed(e),!0):n&&this.cap<o&&!this.misses.length&&e-this.lastChange>=this.stepUpDelay?(this.cap++,this.lastStepUp=e,this.changed(e),!0):!1}restoreLimit(e){this.cap=e?Math.max(0,ye.indexOf(e)):ye.length-1,this.misses=[],this.lastTime=null}reset(){this.cap=ye.length-1,this.misses=[],this.lastTime=null,this.lastChange=this.lastStepUp=-1/0,this.stepUpDelay=we}changed(e){this.lastChange=e,this.misses=[]}};function Oe(e,t,n){let r=e.size,i=r*.74,a=0,o=0,s=0;for(let c=0;c<6;c++){let l=t*(c+.5)/6*2,u=n*(c+.5)/6*2,d=e.curlX*l*l*l+e.twist*n*2*l*l,f=e.curlY*u*u*u-e.twist*t*1.3*u*u;a+=Math.cos(d)*r*t/6,o+=Math.cos(f)*i*n/6,s+=Math.sin(d)*r*t/6+Math.sin(f)*i*n/6}let c=Math.max(0,t+n-.62);s+=c*c*r*(.35+e.fold);let l=Math.cos(e.tilt),u=Math.sin(e.tilt);return{x:a,y:o*l-s*u,z:o*u+s*l}}var ke=(e,t)=>{let n=Math.imul((e|0)&15^Math.imul(t+17,374761393),668265263);return n=Math.imul(n^n>>>13,1274126177),((n^n>>>16)>>>0)/4294967296},Ae=new Map,je=new Map;function Me(e){let t=Ae.get(e);if(t)return t;let n=e.replace(/^#/,``),r=/^[\da-f]{3}$/i.test(n)?[...n].map(e=>e+e).join(``):n,i=/^[\da-f]{6}$/i.test(r)?[0,2,4].map(e=>parseInt(r.slice(e,e+2),16)):e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/)?.slice(1,4).map(Number)??[195,190,174];return Ae.size>=128&&Ae.delete(Ae.keys().next().value),Ae.set(e,i),i}function Ne(e,t){let n=Math.round(t),r=`${e}:${n}`,i=je.get(r);if(i)return i;let a=`rgb(${Me(e).map(e=>Math.max(0,Math.min(255,e+n))).join(` `)})`;return je.size>=512&&je.delete(je.keys().next().value),je.set(r,a),a}function Pe(e,t){e.beginPath(),t.forEach(([t,n],r)=>{r?e.lineTo(t,n):e.moveTo(t,n)}),e.closePath()}function Fe(e,t,n){let r=Math.max(0,t.z),i=1+Math.min(.65,r/90);e.save(),e.translate(t.x+r*.13,t.y+r*.1),e.rotate(t.angle),e.fillStyle=`#000`,e.globalAlpha=t.opacity*(n?.12:.15)/(1+r/26),e.beginPath(),e.ellipse(0,0,t.size*.46*i,t.size*.27*i,0,0,Math.PI*2),e.fill(),r<5&&(e.globalAlpha*=(1-r/5)*.6,e.beginPath(),e.ellipse(0,0,t.size*.36,t.size*.19,0,0,Math.PI*2),e.fill()),e.restore()}function Ie(e,t){let n=[];for(let e=0;e<=2;e++)n.push(Array.from({length:9},(n,r)=>Oe(t,r/8-.5,e/2-.5)));let r=t.z<.5?Math.max(0,-Math.min(...n.flat().map(e=>e.z))):0,i=e=>[e.x,e.y-(e.z+r)*.48],a=[];for(let e=0;e<2;e++)for(let t=0;t<8;t++){let r=n[e][t],i=n[e][t+1],o=n[e+1][t+1],s=n[e+1][t],c=i.x-r.x,l=i.y-r.y,u=i.z-r.z,d=s.x-r.x,f=s.y-r.y,p=s.z-r.z,m=l*p-u*f,h=u*d-c*p,g=c*f-l*d,_=Math.max(.001,Math.hypot(m,h,g)),v=g+h*.48>0,y=(m*-.35+h*-.45+Math.abs(g)*.7)/_;a.push({a:r,b:i,c:o,d:s,col:t,row:e,front:v,light:y,depth:(r.z+i.z+o.z+s.z)/4})}a.sort((e,t)=>e.depth-t.depth);for(let n of a){let{a:r,b:a,c:o,d:s,front:c,light:l,row:u,col:d}=n;if(Pe(e,[i(r),i(a),i(o),i(s)]),e.fillStyle=Ne(t.color,(c?0:-32)+(l-.7)*45),e.fill(),c&&d>0&&d<(u===0?6:8)&&u<3){e.strokeStyle=Ne(t.color,-100),e.lineWidth=t.size*(u===0?.027:.013);let n=i({x:(r.x+s.x)*.5,y:(r.y+s.y)*.5,z:(r.z+s.z)*.5}),c=i({x:(a.x+o.x)*.5,y:(a.y+o.y)*.5,z:(a.z+o.z)*.5});if(e.beginPath(),e.moveTo(...n),e.lineTo(...c),e.stroke(),u>0){let t=i({x:r.x*.2+s.x*.8,y:r.y*.2+s.y*.8,z:r.z*.2+s.z*.8}),n=i({x:a.x*.2+o.x*.8,y:a.y*.2+o.y*.8,z:a.z*.2+o.z*.8});e.beginPath(),e.moveTo(...t),e.lineTo(...n),e.stroke()}}}}function Le(e,t){let n=t.size,r=t.size*(.35+ke(t.seed,61)*.2),i=Math.cos(t.tilt);if(e.scale(1,Math.abs(i)<.08?.08:i),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.bezierCurveTo(n*.12,r*.65,-n*.25,r*.45,-n*.48,0),e.fillStyle=Ne(t.color,i<0?14:0),e.fill(),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.quadraticCurveTo(0,-r*t.fold*.2,-n*.48,0),e.fillStyle=Ne(t.color,-13-t.fold*9),e.fill(),e.strokeStyle=Ne(t.color,-35),e.lineWidth=.45,e.globalAlpha*=.55,e.beginPath(),e.moveTo(-n*.63,r*.08),e.quadraticCurveTo(-n*.08,-r*t.fold*.2,n*.46,-r*.07),e.stroke(),n>10){e.lineWidth=.3;for(let t of[-.18,.08])e.beginPath(),e.moveTo(n*t,0),e.lineTo(n*(t+.1),-r*.3),e.moveTo(n*t,0),e.lineTo(n*(t-.03),r*.28),e.stroke()}}var k=new Map,Re=0,ze=0,Be=()=>({sprites:k.size,bytes:Re});function Ve(e,t){t.kind===`paper`?Ie(e,t):t.kind===`leaf`&&Le(e,t)}function He(e){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,e);if(typeof document>`u`||typeof HTMLCanvasElement>`u`)return null;let t=document.createElement(`canvas`);return!(t instanceof HTMLCanvasElement)||!t.getContext?null:(t.width=t.height=e,t)}function Ue(e,t,n){if(t.z>.1||Math.abs(t.vz)>.1||Math.hypot(t.vx,t.vy)>.75||t.kind===`paper`&&Math.abs(t.curlVelocityX)+Math.abs(t.curlVelocityY)+Math.abs(t.twistVelocity)>.03)return!1;let r=Math.max(4,Math.round(t.size/4)*4),i=Math.round(t.fold*5)/5,a=Math.cos(t.tilt)<0?4:0,o=a*Math.PI/4;if(Math.abs(Math.sin(t.tilt))>.015)return!1;let s=Math.round(t.curlX*4)/4,c=Math.round(t.curlY*4)/4,l=Math.round(t.twist*4)/4,u=`${s}:${c}:${l}:${t.kind}:${t.seed&15}:${t.color}:${r}:${i}:${a}:${n}`,d=k.get(u),f={...t,size:r,fold:i,tilt:o,curlX:s,curlY:c,twist:l,opacity:1};if(!d){let e=r*1.4+4,t=Math.ceil(e*n),i=t*t*4;if(k.size>=128||Re+i>8388608){for(let[e,t]of k)if(!(ze-t.used<120)&&(k.delete(e),`close`in t.canvas&&t.canvas.close(),Re-=t.bytes,k.size<128&&Re+i<=8388608))break}if(k.size<128&&Re+i<=8388608){let r=He(t),a=r?.getContext(`2d`);r&&a&&(a.scale(n,n),a.translate(e/2,e/2),Ve(a,f),d={canvas:`transferToImageBitmap`in r?r.transferToImageBitmap():r,extent:e,bytes:i,used:ze},k.set(u,d),Re+=i)}}return e.scale(t.size/r,t.size/r),d?(d.used=ze,e.drawImage(d.canvas,-d.extent/2,-d.extent/2,d.extent,d.extent)):(e.save(),Ve(e,f),e.restore()),!0}function We(e,t,n,r,i=`ground`){i===`ground`&&ze++;let a=e.getTransform(),o=Math.min(8,Math.max(1,Math.ceil(Math.hypot(a.a,a.b)))),s=n.x+n.width,c=n.y+n.height;for(let a of t){if(a.opacity<=0)continue;let t=a.size+Math.max(0,a.z)*.35;a.x+t<n.x||a.x-t>s||a.y+t<n.y||a.y-t>c||(i===`ground`&&Fe(e,a,r),i===`ground`==a.z<4&&(e.save(),e.translate(a.x,a.y-Math.max(0,a.z)*.22),e.rotate(a.angle),e.globalAlpha=a.opacity,Ue(e,a,o)||Ve(e,a),e.restore()))}}function Ge(e){let{tireLengthM:t,tireWidthM:n}=e.geometry;return e.image?{length:t*(e.image.wheelVisualScale?.length??.64),width:n*(e.image.wheelVisualScale?.width??.82)}:{length:t,width:n}}function Ke(e,t,n,r,i){let a=D(t,e.naturalWidth,e.naturalHeight),o=Math.min(1,512/Math.max(a.source.width,a.source.height)),s=document.createElement(`canvas`);s.width=Math.max(1,Math.round(a.source.width*o)),s.height=Math.max(1,Math.round(a.source.height*o));let c=s.getContext(`2d`);if(!c)return null;n?c.drawImage(n,0,0,s.width,s.height):c.drawImage(e,a.source.x,a.source.y,a.source.width,a.source.height,0,0,s.width,s.height),c.globalCompositeOperation=`source-in`,c.fillStyle=`#101916`,c.fillRect(0,0,s.width,s.height);let l=`filter`in c,u=e=>{let t=Math.ceil(e*4),n=a.lengthM*r,o=a.widthM*r,c=document.createElement(`canvas`);c.width=Math.max(1,Math.ceil((n+t*2)*i)),c.height=Math.max(1,Math.ceil((o+t*2)*i));let u=c.getContext(`2d`);if(!u)return null;let d=c.width*2;return l?u.filter=`blur(${e*i}px)`:(u.shadowColor=`#101916`,u.shadowBlur=e*i*2,u.shadowOffsetX=d),u.drawImage(s,t*i-(l?0:d),t*i,n*i,o*i),{canvas:c,padding:t}};return{soft:u(6),close:u(1.5),pixelsPerMeter:r,lengthM:a.lengthM,widthM:a.widthM}}var qe={width:56,height:56},Je=8,Ye=10,Xe=6;function Ze(e,t,n=Je){let{width:r,height:i}=qe,a=r/2,o=i/2,s=e.x-t.width/2,c=e.y-t.height/2,l=Math.hypot(s,c)||1,u={x:s/l,y:c/l},d=Math.max(0,t.width/2-a-Ye-Je),f=Math.max(0,t.height/2-o-Ye-(c<0?n:Je)),p=Math.min(Math.abs(s)?d/Math.abs(s):1/0,Math.abs(c)?f/Math.abs(c):1/0),m={x:t.width/2+s*(Number.isFinite(p)?p:0),y:t.height/2+c*(Number.isFinite(p)?p:0)},h={x:u.x*a,y:u.y*o},g={x:h.x+u.x*Ye,y:h.y+u.y*Ye},_=Math.sqrt((r/2)**2-Xe**2),v={x:u.x*_,y:u.y*_};return{center:m,direction:u,edge:h,tip:g,left:{x:v.x-u.y*Xe,y:v.y+u.x*Xe},right:{x:v.x+u.y*Xe,y:v.y-u.x*Xe},width:r,height:i}}var Qe=5120,$e=5121,et=5122,tt=5123,nt=5124,rt=5125,it=5126,at=32819,ot=32820,st=33635,ct=5131,lt=33640,ut=35899,dt=35902,ft=36269,pt=34042,mt={};{let e=mt;e[Qe]=Int8Array,e[$e]=Uint8Array,e[et]=Int16Array,e[tt]=Uint16Array,e[nt]=Int32Array,e[rt]=Uint32Array,e[it]=Float32Array,e[at]=Uint16Array,e[ot]=Uint16Array,e[st]=Uint16Array,e[ct]=Uint16Array,e[lt]=Uint32Array,e[ut]=Uint32Array,e[dt]=Uint32Array,e[ft]=Uint32Array,e[pt]=Uint32Array}function ht(...e){console.error(...e)}var gt=new Map;function _t(e,t){if(!e||typeof e!=`object`)return!1;let n=gt.get(t);n||(n=new WeakMap,gt.set(t,n));let r=n.get(e);if(r===void 0){let i=Object.prototype.toString.call(e);r=i.substring(8,i.length-1)===t,n.set(e,r)}return r}function vt(e,t){return typeof WebGLBuffer<`u`&&_t(t,`WebGLBuffer`)}function yt(e,t){return typeof WebGLTexture<`u`&&_t(t,`WebGLTexture`)}function bt(e,t){return typeof WebGLSampler<`u`&&_t(t,`WebGLSampler`)}var xt=35044,St=34962;function Ct(e,t,n,r,i){e.bindBuffer(t,n),e.bufferData(t,r,i||xt)}function wt(e,t,n,r){if(vt(e,t))return t;n||=St;let i=e.createBuffer();return Ct(e,n,i,t,r),i}function Tt(e){return!!e.texStorage2D}var Et=function(){let e={},t={};function n(n){let r=n.constructor.name;if(!e[r]){for(let e in n)if(typeof n[e]==`number`){let r=t[n[e]];t[n[e]]=r?`${r} | ${e}`:e}e[r]=!0}}return function(e,r){return n(e),t[r]||(typeof r==`number`?`0x${r.toString(16)}`:r)}}();new Uint8Array([128,192,255,255]);var Dt=6406,A=6407,j=6408,Ot=6409,kt=6410,At=6402,jt=34041,Mt=3553,Nt=34067,Pt=32879,Ft=35866,It=34069,Lt=10241,Rt=10240,zt=10242,Bt=10243,Vt=32882,Ht=33082,Ut=33083,Wt=33084,Gt=33085,Kt=34892,qt=34893,Jt=37443,Yt=37441,Xt=37440,Zt=33321,Qt=36756,$t=33325,en=33326,tn=33330,nn=33329,rn=33338,an=33337,on=33340,sn=33339,cn=33323,ln=36757,un=33327,dn=33328,fn=33336,pn=33335,mn=33332,hn=33331,gn=33334,_n=33333,vn=32849,yn=35905,bn=36194,xn=36758,Sn=35898,Cn=35901,wn=34843,Tn=34837,En=36221,Dn=36239,On=36215,kn=36233,An=36209,jn=36227,Mn=32856,Nn=35907,Pn=36759,Fn=32855,In=32854,Ln=32857,Rn=34842,zn=34836,Bn=36220,Vn=36238,Hn=36975,Un=36214,Wn=36232,Gn=36226,Kn=36208,qn=33189,Jn=33190,Yn=36012,Xn=36013,Zn=35056,M=5120,N=5121,Qn=5122,$n=5123,er=5124,tr=5125,P=5126,nr=32819,rr=32820,ir=33635,F=5131,ar=36193,or=33640,sr=35899,cr=35902,lr=36269,ur=34042,dr=33319,fr=33320,pr=6403,mr=36244,hr=36248,gr=36249,_r=33776,vr=33777,yr=33778,br=33779,xr=35916,Sr=35917,Cr=35918,wr=35919,Tr=36196,Er=37488,Dr=37489,Or=37490,kr=37491,Ar=37492,jr=37493,Mr=37494,Nr=37495,Pr=37496,Fr=37497,Ir=35840,Lr=35841,Rr=35842,zr=35843,Br=37808,Vr=37809,Hr=37810,Ur=37811,Wr=37812,Gr=37813,Kr=37814,qr=37815,Jr=37816,Yr=37817,Xr=37818,Zr=37819,Qr=37820,$r=37821,ei=37840,ti=37841,ni=37842,ri=37843,ii=37844,ai=37845,oi=37846,si=37847,ci=37848,li=37849,ui=37850,di=37851,fi=37852,pi=37853,mi=36492,hi=36493,gi=36494,_i=36495,vi=36283,yi=36284,bi=36285,xi=36286,Si={};{let e=Si;e[Dt]={numColorComponents:1},e[Ot]={numColorComponents:1},e[kt]={numColorComponents:2},e[A]={numColorComponents:3},e[j]={numColorComponents:4},e[pr]={numColorComponents:1},e[mr]={numColorComponents:1},e[dr]={numColorComponents:2},e[fr]={numColorComponents:2},e[A]={numColorComponents:3},e[hr]={numColorComponents:3},e[j]={numColorComponents:4},e[gr]={numColorComponents:4},e[At]={numColorComponents:1},e[jt]={numColorComponents:2}}var Ci;function wi(e){if(!Ci){let e={};e[Dt]={textureFormat:Dt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[N,F,ar,P]},e[Ot]={textureFormat:Ot,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[N,F,ar,P]},e[kt]={textureFormat:kt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[N,F,ar,P]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[N,F,ar,P,ir]},e[j]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[N,F,ar,P,nr,rr]},e[At]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[tr,$n]},e[Zt]={textureFormat:pr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[N]},e[Qt]={textureFormat:pr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[M]},e[$t]={textureFormat:pr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[P,F]},e[en]={textureFormat:pr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[P]},e[tn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[N]},e[nn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[M]},e[mn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[$n]},e[hn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Qn]},e[gn]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[tr]},e[_n]={textureFormat:mr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[er]},e[cn]={textureFormat:dr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[N]},e[ln]={textureFormat:dr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[M]},e[un]={textureFormat:dr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[P,F]},e[dn]={textureFormat:dr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[P]},e[fn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[N]},e[pn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[M]},e[rn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[$n]},e[an]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Qn]},e[on]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[tr]},e[sn]={textureFormat:fr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[er]},e[vn]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[N]},e[yn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[N]},e[bn]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[N,ir]},e[xn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[M]},e[Sn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[P,F,sr]},e[Cn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[P,F,cr]},e[wn]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[P,F]},e[Tn]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[P]},e[En]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[N]},e[Dn]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[M]},e[On]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[$n]},e[kn]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Qn]},e[An]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[tr]},e[jn]={textureFormat:hr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[er]},e[Mn]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[N]},e[Nn]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[N]},e[Pn]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[M]},e[Fn]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[N,rr,or]},e[In]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[N,nr]},e[Ln]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[or]},e[Rn]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[P,F]},e[zn]={textureFormat:j,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[P]},e[Bn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[N]},e[Vn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[Hn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[or]},e[Un]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[$n]},e[Wn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Qn]},e[Gn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[er]},e[Kn]={textureFormat:gr,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[tr]},e[qn]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[$n,tr]},e[Jn]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[tr]},e[Yn]={textureFormat:At,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[P]},e[Zn]={textureFormat:jt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ur]},e[Xn]={textureFormat:jt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[lr]},Object.keys(e).forEach(function(t){let n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(e,t){let r=n.type[t];n.bytesPerElementMap[r]=e})});let t={bytes:8,width:4,height:4},n={bytes:16,width:4,height:4};e[_r]={textureFormat:_r,colorRenderable:!1,textureFilterable:!0,block:t},e[vr]={textureFormat:vr,colorRenderable:!1,textureFilterable:!0,block:t},e[yr]={textureFormat:yr,colorRenderable:!1,textureFilterable:!0,block:n},e[br]={textureFormat:br,colorRenderable:!1,textureFilterable:!0,block:n},e[xr]={textureFormat:xr,colorRenderable:!1,textureFilterable:!0,block:t},e[Sr]={textureFormat:Sr,colorRenderable:!1,textureFilterable:!0,block:t},e[Cr]={textureFormat:Cr,colorRenderable:!1,textureFilterable:!0,block:n},e[wr]={textureFormat:wr,colorRenderable:!1,textureFilterable:!0,block:n},e[Tr]={textureFormat:Tr,colorRenderable:!1,textureFilterable:!0,block:t},e[Er]={textureFormat:Er,colorRenderable:!1,textureFilterable:!0,block:t},e[Dr]={textureFormat:Dr,colorRenderable:!1,textureFilterable:!0,block:t},e[Or]={textureFormat:Or,colorRenderable:!1,textureFilterable:!0,block:n},e[kr]={textureFormat:kr,colorRenderable:!1,textureFilterable:!0,block:n},e[Ar]={textureFormat:Ar,colorRenderable:!1,textureFilterable:!0,block:t},e[jr]={textureFormat:jr,colorRenderable:!1,textureFilterable:!0,block:t},e[Mr]={textureFormat:Mr,colorRenderable:!1,textureFilterable:!0,block:t},e[Nr]={textureFormat:Nr,colorRenderable:!1,textureFilterable:!0,block:t},e[Pr]={textureFormat:Pr,colorRenderable:!1,textureFilterable:!0,block:n},e[Fr]={textureFormat:Fr,colorRenderable:!1,textureFilterable:!0,block:n},e[Ir]={textureFormat:Ir,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:8,height:8}},e[Lr]={textureFormat:Lr,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:16,height:8}},e[Rr]={textureFormat:Rr,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:8,height:8}},e[zr]={textureFormat:zr,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:16,height:8}},e[Br]={textureFormat:Br,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:4,height:4}},e[Vr]={textureFormat:Vr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:4}},e[Hr]={textureFormat:Hr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:5}},e[Ur]={textureFormat:Ur,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:5}},e[Wr]={textureFormat:Wr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:6}},e[Gr]={textureFormat:Gr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:5}},e[Kr]={textureFormat:Kr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:6}},e[qr]={textureFormat:qr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:8}},e[Jr]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:5}},e[Yr]={textureFormat:Yr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:6}},e[Xr]={textureFormat:Xr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:8}},e[Zr]={textureFormat:Zr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:10}},e[Qr]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:10}},e[$r]={textureFormat:$r,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:12}},e[ei]={textureFormat:ei,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:4,height:4}},e[ti]={textureFormat:ti,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:4}},e[ni]={textureFormat:ni,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:5}},e[ri]={textureFormat:ri,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:5}},e[ii]={textureFormat:ii,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:6}},e[ai]={textureFormat:ai,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:5}},e[oi]={textureFormat:oi,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:6}},e[si]={textureFormat:si,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:8}},e[ci]={textureFormat:ci,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:5}},e[li]={textureFormat:li,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:6}},e[ui]={textureFormat:ui,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:8}},e[di]={textureFormat:di,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:10}},e[fi]={textureFormat:fi,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:10}},e[pi]={textureFormat:pi,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:12}},e[mi]={textureFormat:mi,colorRenderable:!1,textureFilterable:!0,block:n},e[hi]={textureFormat:hi,colorRenderable:!1,textureFilterable:!0,block:n},e[gi]={textureFormat:gi,colorRenderable:!1,textureFilterable:!0,block:n},e[_i]={textureFormat:_i,colorRenderable:!1,textureFilterable:!0,block:n},e[vi]={textureFormat:vi,colorRenderable:!1,textureFilterable:!0,block:t},e[yi]={textureFormat:yi,colorRenderable:!1,textureFilterable:!0,block:t},e[bi]={textureFormat:bi,colorRenderable:!1,textureFilterable:!0,block:t},e[xi]={textureFormat:xi,colorRenderable:!1,textureFilterable:!0,block:t},Ci=e}let t=Ci[e];if(!t)throw Error(`unknown internal format`);return t}function Ti(e){let t=wi(e);if(!t)throw Error(`unknown internal format`);return{format:t.textureFormat,type:t.type?.[0]??N}}function Ei(e,t,n){let r,i,a;t.colorspaceConversion!==void 0&&(r=e.getParameter(Jt),e.pixelStorei(Jt,t.colorspaceConversion)),t.premultiplyAlpha!==void 0&&(i=e.getParameter(Yt),e.pixelStorei(Yt,t.premultiplyAlpha)),t.flipY!==void 0&&(a=e.getParameter(Xt),e.pixelStorei(Xt,t.flipY)),n(),r!==void 0&&e.pixelStorei(Jt,r),i!==void 0&&e.pixelStorei(Yt,i),a!==void 0&&e.pixelStorei(Xt,a)}function Di(e,t,n,r){r.minMag&&(n.call(e,t,Lt,r.minMag),n.call(e,t,Rt,r.minMag)),r.min&&n.call(e,t,Lt,r.min),r.mag&&n.call(e,t,Rt,r.mag),r.wrap&&(n.call(e,t,zt,r.wrap),n.call(e,t,Bt,r.wrap),(t===Pt||bt(e,t))&&n.call(e,t,Vt,r.wrap)),r.wrapR&&n.call(e,t,Vt,r.wrapR),r.wrapS&&n.call(e,t,zt,r.wrapS),r.wrapT&&n.call(e,t,Bt,r.wrapT),r.minLod!==void 0&&n.call(e,t,Ht,r.minLod),r.maxLod!==void 0&&n.call(e,t,Ut,r.maxLod),r.baseLevel!==void 0&&n.call(e,t,Wt,r.baseLevel),r.maxLevel!==void 0&&n.call(e,t,Gt,r.maxLevel),r.compareFunc!==void 0&&n.call(e,t,qt,r.compareFunc),r.compareMode!==void 0&&n.call(e,t,Kt,r.compareMode)}function Oi(e,t,n){let r=n.target||Mt;e.bindTexture(r,t),Di(e,r,e.texParameteri,n)}function ki(e,t,n){let r=n.target||Mt;e.bindTexture(r,t);let i=n.level||0,a=n.internalFormat||n.format||j,o=Ti(a),s=n.format||o.format,c=n.type||o.type;Ei(e,n,()=>{if(r===Nt)for(let t=0;t<6;++t)e.texImage2D(It+t,i,a,n.width,n.height,0,s,c,null);else r===Pt||r===Ft?e.texImage3D(r,i,a,n.width,n.height,n.depth,0,s,c,null):e.texImage2D(r,i,a,n.width,n.height,0,s,c,null)})}var Ai=ht;function ji(e){return typeof document<`u`&&document.getElementById?document.getElementById(e):null}var Mi=33984,Ni=34962,Pi=34963,Fi=35713,Ii=35714,Li=35632,Ri=35633,zi=35981,Bi=35718,Vi=35721,Hi=35971,Ui=35382,Wi=35396,Gi=35398,Ki=35392,qi=35395,Ji=5126,Yi=35664,Xi=35665,Zi=35666,Qi=5124,$i=35667,ea=35668,ta=35669,na=35670,ra=35671,ia=35672,aa=35673,oa=35674,sa=35675,ca=35676,la=35678,ua=35680,da=35679,fa=35682,pa=35685,ma=35686,ha=35687,ga=35688,_a=35689,va=35690,ya=36289,ba=36292,xa=36293,Sa=5125,Ca=36294,wa=36295,Ta=36296,Ea=36298,Da=36299,Oa=36300,ka=36303,Aa=36306,ja=36307,Ma=36308,Na=36311,Pa=3553,Fa=34067,Ia=32879,La=35866,I={};function Ra(e,t){return I[t].bindPoint}function za(e,t){return function(n){e.uniform1f(t,n)}}function Ba(e,t){return function(n){e.uniform1fv(t,n)}}function Va(e,t){return function(n){e.uniform2fv(t,n)}}function Ha(e,t){return function(n){e.uniform3fv(t,n)}}function Ua(e,t){return function(n){e.uniform4fv(t,n)}}function Wa(e,t){return function(n){e.uniform1i(t,n)}}function Ga(e,t){return function(n){e.uniform1iv(t,n)}}function Ka(e,t){return function(n){e.uniform2iv(t,n)}}function qa(e,t){return function(n){e.uniform3iv(t,n)}}function Ja(e,t){return function(n){e.uniform4iv(t,n)}}function Ya(e,t){return function(n){e.uniform1ui(t,n)}}function Xa(e,t){return function(n){e.uniform1uiv(t,n)}}function Za(e,t){return function(n){e.uniform2uiv(t,n)}}function Qa(e,t){return function(n){e.uniform3uiv(t,n)}}function $a(e,t){return function(n){e.uniform4uiv(t,n)}}function eo(e,t){return function(n){e.uniformMatrix2fv(t,!1,n)}}function to(e,t){return function(n){e.uniformMatrix3fv(t,!1,n)}}function no(e,t){return function(n){e.uniformMatrix4fv(t,!1,n)}}function ro(e,t){return function(n){e.uniformMatrix2x3fv(t,!1,n)}}function io(e,t){return function(n){e.uniformMatrix3x2fv(t,!1,n)}}function ao(e,t){return function(n){e.uniformMatrix2x4fv(t,!1,n)}}function oo(e,t){return function(n){e.uniformMatrix4x2fv(t,!1,n)}}function so(e,t){return function(n){e.uniformMatrix3x4fv(t,!1,n)}}function co(e,t){return function(n){e.uniformMatrix4x3fv(t,!1,n)}}function L(e,t,n,r){let i=Ra(e,t);return Tt(e)?function(t){let a,o;!t||yt(e,t)?(a=t,o=null):(a=t.texture,o=t.sampler),e.uniform1i(r,n),e.activeTexture(Mi+n),e.bindTexture(i,a),e.bindSampler(n,o)}:function(t){e.uniform1i(r,n),e.activeTexture(Mi+n),e.bindTexture(i,t)}}function R(e,t,n,r,i){let a=Ra(e,t),o=new Int32Array(i);for(let e=0;e<i;++e)o[e]=n+e;return Tt(e)?function(t){e.uniform1iv(r,o),t.forEach(function(t,r){e.activeTexture(Mi+o[r]);let i,s;!t||yt(e,t)?(i=t,s=null):(i=t.texture,s=t.sampler),e.bindSampler(n,s),e.bindTexture(a,i)})}:function(t){e.uniform1iv(r,o),t.forEach(function(t,n){e.activeTexture(Mi+o[n]),e.bindTexture(a,t)})}}I[Ji]={Type:Float32Array,size:4,setter:za,arraySetter:Ba},I[Yi]={Type:Float32Array,size:8,setter:Va,cols:2},I[Xi]={Type:Float32Array,size:12,setter:Ha,cols:3},I[Zi]={Type:Float32Array,size:16,setter:Ua,cols:4},I[Qi]={Type:Int32Array,size:4,setter:Wa,arraySetter:Ga},I[$i]={Type:Int32Array,size:8,setter:Ka,cols:2},I[ea]={Type:Int32Array,size:12,setter:qa,cols:3},I[ta]={Type:Int32Array,size:16,setter:Ja,cols:4},I[Sa]={Type:Uint32Array,size:4,setter:Ya,arraySetter:Xa},I[Ca]={Type:Uint32Array,size:8,setter:Za,cols:2},I[wa]={Type:Uint32Array,size:12,setter:Qa,cols:3},I[Ta]={Type:Uint32Array,size:16,setter:$a,cols:4},I[na]={Type:Uint32Array,size:4,setter:Wa,arraySetter:Ga},I[ra]={Type:Uint32Array,size:8,setter:Ka,cols:2},I[ia]={Type:Uint32Array,size:12,setter:qa,cols:3},I[aa]={Type:Uint32Array,size:16,setter:Ja,cols:4},I[oa]={Type:Float32Array,size:32,setter:eo,rows:2,cols:2},I[sa]={Type:Float32Array,size:48,setter:to,rows:3,cols:3},I[ca]={Type:Float32Array,size:64,setter:no,rows:4,cols:4},I[pa]={Type:Float32Array,size:32,setter:ro,rows:2,cols:3},I[ma]={Type:Float32Array,size:32,setter:ao,rows:2,cols:4},I[ha]={Type:Float32Array,size:48,setter:io,rows:3,cols:2},I[ga]={Type:Float32Array,size:48,setter:so,rows:3,cols:4},I[_a]={Type:Float32Array,size:64,setter:oo,rows:4,cols:2},I[va]={Type:Float32Array,size:64,setter:co,rows:4,cols:3},I[la]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[ua]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[da]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Ia},I[fa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[ya]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La},I[ba]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La},I[xa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[Ea]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[Da]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Ia},I[Oa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[ka]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La},I[Aa]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Pa},I[ja]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Ia},I[Ma]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:Fa},I[Na]={Type:null,size:0,setter:L,arraySetter:R,bindPoint:La};function lo(e,t){return function(n){if(n.value)switch(e.disableVertexAttribArray(t),n.value.length){case 4:e.vertexAttrib4fv(t,n.value);break;case 3:e.vertexAttrib3fv(t,n.value);break;case 2:e.vertexAttrib2fv(t,n.value);break;case 1:e.vertexAttrib1fv(t,n.value);break;default:throw Error(`the length of a float constant value must be between 1 and 4!`)}else e.bindBuffer(Ni,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,n.numComponents||n.size,n.type||Ji,n.normalize||!1,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function uo(e,t){return function(n){if(n.value){if(e.disableVertexAttribArray(t),n.value.length===4)e.vertexAttrib4iv(t,n.value);else throw Error(`The length of an integer constant value must be 4!`)}else e.bindBuffer(Ni,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,n.numComponents||n.size,n.type||Qi,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function fo(e,t){return function(n){if(n.value){if(e.disableVertexAttribArray(t),n.value.length===4)e.vertexAttrib4uiv(t,n.value);else throw Error(`The length of an unsigned integer constant value must be 4!`)}else e.bindBuffer(Ni,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,n.numComponents||n.size,n.type||Sa,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function po(e,t,n){let r=n.size,i=n.count;return function(n){e.bindBuffer(Ni,n.buffer);let a=n.size||n.numComponents||r,o=a/i,s=n.type||Ji,c=I[s].size*a,l=n.normalize||!1,u=n.offset||0,d=c/i;for(let r=0;r<i;++r)e.enableVertexAttribArray(t+r),e.vertexAttribPointer(t+r,o,s,l,c,u+d*r),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+r,n.divisor||0)}}var z={};z[Ji]={size:4,setter:lo},z[Yi]={size:8,setter:lo},z[Xi]={size:12,setter:lo},z[Zi]={size:16,setter:lo},z[Qi]={size:4,setter:uo},z[$i]={size:8,setter:uo},z[ea]={size:12,setter:uo},z[ta]={size:16,setter:uo},z[Sa]={size:4,setter:fo},z[Ca]={size:8,setter:fo},z[wa]={size:12,setter:fo},z[Ta]={size:16,setter:fo},z[na]={size:4,setter:uo},z[ra]={size:8,setter:uo},z[ia]={size:12,setter:uo},z[aa]={size:16,setter:uo},z[oa]={size:4,setter:po,count:2},z[sa]={size:9,setter:po,count:3},z[ca]={size:16,setter:po,count:4};var mo=/ERROR:\s*\d+:(\d+)/gi;function ho(e,t=``,n=0){let r=[...t.matchAll(mo)],i=new Map(r.map((e,n)=>{let i=parseInt(e[1]),a=r[n+1],o=a?a.index:t.length,s=t.substring(e.index,o);return[i-1,s]}));return e.split(`
|
|
2
2
|
`).map((e,t)=>{let r=i.get(t);return`${t+1+n}: ${e}${r?`\n\n^^^ ${r}`:``}`}).join(`
|
|
3
3
|
`)}var go=/^[ \t]*\n/;function _o(e){let t=0;return go.test(e)&&(t=1,e=e.replace(go,``)),{lineOffset:t,shaderSource:e}}function vo(e,t,n,r){if(r||=Ai,!e.getShaderParameter(n,Fi)){let i=e.getShaderInfoLog(n),{lineOffset:a,shaderSource:o}=_o(e.getShaderSource(n)),s=`${ho(o,i,a)}\nError compiling ${Et(e,t)}: ${i}`;return r(s),s}return``}function yo(e,t,n){let r,i,a;if(typeof t==`function`&&(n=t,t=void 0),typeof e==`function`)n=e,e=void 0;else if(e&&!Array.isArray(e)){let t=e;n=t.errorCallback,e=t.attribLocations,r=t.transformFeedbackVaryings,i=t.transformFeedbackMode,a=t.callback}let o=n||Ai,s=[],c={errorCallback(e,...t){s.push(e),o(e,...t)},transformFeedbackVaryings:r,transformFeedbackMode:i,callback:a,errors:s};{let n={};Array.isArray(e)?e.forEach(function(e,r){n[e]=t?t[r]:r}):n=e||{},c.attribLocations=n}return c}var bo=[`VERTEX_SHADER`,`FRAGMENT_SHADER`];function xo(e,t){if(t.indexOf(`frag`)>=0)return Li;if(t.indexOf(`vert`)>=0)return Ri}function So(e,t,n){let r=e.getAttachedShaders(t);for(let t of r)n.has(t)||e.deleteShader(t);e.deleteProgram(t)}var Co=(e=0)=>new Promise(t=>setTimeout(t,e));function wo(e,t,n){let r=e.createProgram(),{attribLocations:i,transformFeedbackVaryings:a,transformFeedbackMode:o}=yo(n);for(let n=0;n<t.length;++n){let i=t[n];if(typeof i==`string`){let t=ji(i),r=t?t.text:i,a=e[bo[n]];t&&t.type&&(a=xo(e,t.type)||a),i=e.createShader(a),e.shaderSource(i,_o(r).shaderSource),e.compileShader(i)}e.attachShader(r,i)}Object.entries(i).forEach(([t,n])=>e.bindAttribLocation(r,n,t));{let t=a;t&&(t.attribs&&(t=t.attribs),Array.isArray(t)||(t=Object.keys(t)),e.transformFeedbackVaryings(r,t,o||zi))}return e.linkProgram(r),r}function To(e,t,n,r,i){let a=yo(n,r,i),o=new Set(t),s=wo(e,t,a);function c(e,t){let n=Do(e,t,a.errorCallback);return n&&So(e,t,o),n}if(a.callback)Eo(e,s).then(()=>{let t=c(e,s);a.callback(t,t?void 0:s)});else return c(e,s)?void 0:s}async function Eo(e,t){let n=e.getExtension(`KHR_parallel_shader_compile`),r=n?(e,t)=>e.getProgramParameter(t,n.COMPLETION_STATUS_KHR):()=>!0,i=0;do await Co(i),i=1e3/60;while(!r(e,t))}function Do(e,t,n){if(n||=Ai,!e.getProgramParameter(t,Ii)){let r=e.getProgramInfoLog(t);return n(`Error in program linking: ${r}`),`${r}\n${e.getAttachedShaders(t).map(t=>vo(e,e.getShaderParameter(t,e.SHADER_TYPE),t,n)).filter(e=>e).join(`
|
|
4
4
|
`)}`}}function Oo(e,t,n,r,i){return To(e,t,n,r,i)}function ko(e){let t=e.name;return t.startsWith(`gl_`)||t.startsWith(`webgl_`)}var Ao=/(\.|\[|]|\w+)/g,jo=e=>e>=`0`&&e<=`9`;function Mo(e,t,n,r){let i=e.split(Ao).filter(e=>e!==``),a=0,o=``;for(;;){let e=i[a++];o+=e;let s=jo(e[0]),c=s?parseInt(e):e;if(s&&(o+=i[a++]),a===i.length){n[c]=t;break}{let e=i[a++],t=e===`[`,s=n[c]||(t?[]:{});n[c]=s,n=s,r[o]=r[o]||function(e){return function(t){Io(e,t)}}(s),o+=e}}}function No(e,t){let n=0;function r(t,r,i){let a=r.name.endsWith(`[0]`),o=r.type,s=I[o];if(!s)throw Error(`unknown type: 0x${o.toString(16)}`);let c;if(s.bindPoint){let t=n;n+=r.size,c=a?s.arraySetter(e,o,t,i,r.size):s.setter(e,o,t,i,r.size)}else c=s.arraySetter&&a?s.arraySetter(e,i):s.setter(e,i);return c.location=i,c}let i={},a={},o=e.getProgramParameter(t,Bi);for(let n=0;n<o;++n){let o=e.getActiveUniform(t,n);if(ko(o))continue;let s=o.name;s.endsWith(`[0]`)&&(s=s.substr(0,s.length-3));let c=e.getUniformLocation(t,o.name);if(c){let e=r(t,o,c);i[s]=e,Mo(s,e,a,i)}}return i}function Po(e,t){let n={},r=e.getProgramParameter(t,Hi);for(let i=0;i<r;++i){let r=e.getTransformFeedbackVarying(t,i);n[r.name]={index:i,type:r.type,size:r.size}}return n}function Fo(e,t){let n=e.getProgramParameter(t,Bi),r=[],i=[];for(let a=0;a<n;++a){i.push(a),r.push({});let n=e.getActiveUniform(t,a);r[a].name=n.name}[[`UNIFORM_TYPE`,`type`],[`UNIFORM_SIZE`,`size`],[`UNIFORM_BLOCK_INDEX`,`blockNdx`],[`UNIFORM_OFFSET`,`offset`]].forEach(function(n){let a=n[0],o=n[1];e.getActiveUniforms(t,i,e[a]).forEach(function(e,t){r[t][o]=e})});let a={},o=e.getProgramParameter(t,Ui);for(let n=0;n<o;++n){let r=e.getActiveUniformBlockName(t,n),i={index:e.getUniformBlockIndex(t,r),usedByVertexShader:e.getActiveUniformBlockParameter(t,n,Wi),usedByFragmentShader:e.getActiveUniformBlockParameter(t,n,Gi),size:e.getActiveUniformBlockParameter(t,n,Ki),uniformIndices:e.getActiveUniformBlockParameter(t,n,qi)};i.used=i.usedByVertexShader||i.usedByFragmentShader,a[r]=i}return{blockSpecs:a,uniformData:r}}function Io(e,t){for(let n in t){let r=e[n];typeof r==`function`?r(t[n]):Io(e[n],t[n])}}function Lo(e,...t){let n=e.uniformSetters||e,r=t.length;for(let e=0;e<r;++e){let r=t[e];if(Array.isArray(r)){let e=r.length;for(let t=0;t<e;++t)Lo(n,r[t])}else for(let e in r){let t=n[e];t&&t(r[e])}}}function Ro(e,t){let n={},r=e.getProgramParameter(t,Vi);for(let i=0;i<r;++i){let r=e.getActiveAttrib(t,i);if(ko(r))continue;let a=e.getAttribLocation(t,r.name),o=z[r.type],s=o.setter(e,a,o);s.location=a,n[r.name]=s}return n}function zo(e,t){for(let n in t){let r=e[n];r&&r(t[n])}}function Bo(e,t,n){n.vertexArrayObject?e.bindVertexArray(n.vertexArrayObject):(zo(t.attribSetters||t,n.attribs),n.indices&&e.bindBuffer(Pi,n.indices))}function Vo(e,t){let n=No(e,t),r=Ro(e,t),i={program:t,uniformSetters:n,attribSetters:r,uniformLocations:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.location])),attribLocations:Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.location]))};return Tt(e)&&(i.uniformBlockSpec=Fo(e,t),i.transformFeedbackInfo=Po(e,t)),i}var Ho=36160,Uo=6402,Wo=33190,Go=36012,Ko=35056,qo=36013,Jo=32854,Yo=32855,Xo=36194,Zo=33189,Qo=6401,$o=36168,es=34041,ts=36096,ns=36128,rs=33306,B={};B[es]=rs,B[Qo]=ns,B[$o]=ns,B[Uo]=ts,B[Zo]=ts,B[Wo]=ts,B[Go]=ts,B[Ko]=rs,B[qo]=rs;var is={};is[Jo]=!0,is[Yo]=!0,is[Xo]=!0,is[es]=!0,is[Zo]=!0,is[Qo]=!0,is[$o]=!0;function as(e,t,n){n||=Ho,t?(e.bindFramebuffer(n,t.framebuffer),e.viewport(0,0,t.width,t.height)):(e.bindFramebuffer(n,null),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight))}var os=new WeakMap;function ss(e,t,n,r){let i=[],a=Oo(e,[t,n],{errorCallback:e=>i.push(e)});if(!a)throw Error(`${r} shader: ${i.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./configuration~react~vehicle-popover~EmbedPanel~Documentation~JoyRideView~browser-session-co~fvauaeow-
|
|
1
|
+
import{i as e}from"./configuration~react~vehicle-popover~EmbedPanel~Documentation~JoyRideView~browser-session-co~fvauaeow-mgPW9A8j.js";function t(){if(typeof document>`u`)return`light`;let e=document.documentElement,t=e.dataset.jrTheme??e.dataset.theme;return t===`light`||t===`dark`?t:e.classList.contains(`dark`)?`dark`:e.classList.contains(`light`)?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function n(n,r=e.dialog.dialogTheme){if(r!==`auto`)return n.classList.toggle(`dark`,r===`dark`),()=>{};let i=()=>n.classList.toggle(`dark`,t()===`dark`),a=window.matchMedia(`(prefers-color-scheme: dark)`);i();let o=new MutationObserver(i);return o.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-jr-theme`,`data-theme`]}),a.addEventListener(`change`,i),()=>{o.disconnect(),a.removeEventListener(`change`,i)}}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-BZJqthWX.js";var n=[{id:`boost`,label:`Boost`,keys:[`Shift`],description:`Burn rear tracks while held`},{id:`eject`,label:`Liquid`,keys:[`1`],description:`Pour while held`},{id:`machineGun`,label:`Machine guns`,keys:[`2`],description:`Fire while held`},{id:`flamethrower`,label:`Flamethrower`,keys:[`3`],description:`Burn objects while held`},{id:`rocket`,label:`Roof rockets`,keys:[`4`],description:`Launch, then repeat while held`},{id:`ghost`,label:`Ghost mode`,keys:[`5`],description:`Phase while held`},{id:`attractor`,label:`Attractor`,keys:[`6`],description:`Pull nearby letters and debris`},{id:`lightning`,label:`Lightning`,keys:[`7`],description:`Hold to charge and repeatedly discharge`}];function r(n=t,r={}){
|
|
1
|
+
import{i as e,t}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-BZJqthWX.js";var n=[{id:`boost`,label:`Boost`,keys:[`Shift`],description:`Burn rear tracks while held`},{id:`eject`,label:`Liquid`,keys:[`1`],description:`Pour while held`},{id:`machineGun`,label:`Machine guns`,keys:[`2`],description:`Fire while held`},{id:`flamethrower`,label:`Flamethrower`,keys:[`3`],description:`Burn objects while held`},{id:`rocket`,label:`Roof rockets`,keys:[`4`],description:`Launch, then repeat while held`},{id:`ghost`,label:`Ghost mode`,keys:[`5`],description:`Phase while held`},{id:`attractor`,label:`Attractor`,keys:[`6`],description:`Pull nearby letters and debris`},{id:`lightning`,label:`Lightning`,keys:[`7`],description:`Hold to charge and repeatedly discharge`}];function r(n=t,r={}){let i=[];for(let t of e){let a=n[t];!a||r.toolsEnabled===!1&&a.action!==`boost`||i.push({number:e[i.length],source:t,slot:a})}return i}function i(e=t,i=!0){let a=r(e,{toolsEnabled:i});return n.filter(e=>i||e.id===`boost`).map(e=>({...e,keys:[...e.id===`boost`?[`Shift`]:[],...a.filter(({slot:t})=>t.action===e.id).map(({number:e})=>String(e))]}))}function a(e,t=!0){let r=e;if(!t){r={...e};for(let e of n)e.id!==`boost`&&(r[e.id]=!1)}return r.ghost&&(r===e&&(r={...e}),r.boost=r.eject=r.machineGun=r.flamethrower=r.rocket=r.attractor=r.lightning=!1),r}export{n as i,a as n,r,i as t};
|