diff --git a/index.html b/index.html index 4ef587e4..7c72197c 100644 --- a/index.html +++ b/index.html @@ -39,6 +39,16 @@

Games

3D Racing · 1 player
+ + + +
+
Map Workbench
+
Yardline editor · keyboard
+
+
diff --git a/yardline-rc/BUILD.md b/yardline-rc/BUILD.md index 49ecee47..cc5436ce 100644 --- a/yardline-rc/BUILD.md +++ b/yardline-rc/BUILD.md @@ -52,8 +52,29 @@ must be ≥1, and `grep -c 'window.__scInput=this' assets/index-*.js` must be 1 (else re-apply, or — the proper fix — restore the embed bridge in `Artan0/razing` and rebuild, then drop the inline shim). +**Map editor nav paths (patched 2026-07-30):** the bundle ships two editors — the +2D "Map Workbench" page (route: `location.pathname === '/map-editor'` **or** +`?tool=map-editor`) and a 3D fly-and-edit overlay (`?fly=1`). Their navigation was +emitted as SITE-absolute literals, the same class of bug as the asset paths above: +`` `/?map=construction-loop&editorDraft=1&seed=…` `` (Test drive, ×3), +`` href:`/map-editor` `` (Open 2D editor), and the workbench brand link `` href:`/` ``. +Under `/games/yardline-rc/` those all bounce to the console root instead of the game. +Patched here to `` `./?map=…` ``, `` `./?tool=map-editor` ``, and `` `./` ``. +After ANY rebuild, verify: ``grep -c 'href=`/?map=' assets/index-*.js`` must be 0. +Reach the editor only via the query form (`?tool=map-editor`) — the pathname branch +can't match under the subpath. The proper source-side fix is `import.meta.env.BASE_URL` +on these, same as the runtime model paths. + +The console links the workbench from the "Map Workbench" tile in `../index.html`. +Note it needs keyboard + mouse (WASD / ⌘S / right-drag look), so it's a laptop tool, +not a TV-pad one. + ## Pruned for the console embed Full build ~138 MB (Downtown MegaKit + editor-only props). The console only plays the fixed `construction-loop` preset, so editor-only assets are pruned to ~64 MB. Kept: everything the preset places + all cars + opponents + particles. If the preset changes to place a different kit asset, re-copy the full `dist/` first. + +This bites the map editor now that it's reachable: its asset palette lists the whole +kit, but only preset-used models are on disk, so placing anything else 404s the model +and drops an invisible object. Re-copy the full `dist/` before authoring maps. diff --git a/yardline-rc/assets/index-CSoa7UUc.js b/yardline-rc/assets/index-CSoa7UUc.js index 9eb7a57a..6756a16c 100644 --- a/yardline-rc/assets/index-CSoa7UUc.js +++ b/yardline-rc/assets/index-CSoa7UUc.js @@ -29134,4 +29134,4 @@ clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousW `),qt.ShadersStore.GLTFDefaultMaterialPixelShader=[`precision highp float;`,``,`uniform vec4 u_emission;`,``,`void main(void)`,`{`,` gl_FragColor = u_emission;`,`}`].join(` `),e._DefaultMaterial=new vp(`GLTFDefaultMaterial`,t,{vertex:`GLTFDefaultMaterial`,fragment:`GLTFDefaultMaterial`},{attributes:[`position`],uniforms:[`worldView`,`projection`,`u_emission`],samplers:[],needAlphaBlending:!1}),e._DefaultMaterial.setColor4(`u_emission`,new fe(.5,.5,.5,1))),e._DefaultMaterial}};h8._DefaultMaterial=null;var g8;(function(e){e[e.IDENTIFIER=1]=`IDENTIFIER`,e[e.UNKNOWN=2]=`UNKNOWN`,e[e.END_OF_INPUT=3]=`END_OF_INPUT`})(g8||={});var _Qe=class{constructor(e){this._pos=0,this.currentToken=g8.UNKNOWN,this.currentIdentifier=``,this.currentString=``,this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}getNextToken(){if(this.isEnd())return g8.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=g8.UNKNOWN,this.currentString===`_`||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=g8.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||this.currentString===`_`);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken}peek(){return this._toParse[this._pos]}read(){return this._toParse[this._pos++]}forward(){this._pos++}isEnd(){return this._pos>=this._maxPos}},vQe=[`MODEL`,`VIEW`,`PROJECTION`,`MODELVIEW`,`MODELVIEWPROJECTION`,`JOINTMATRIX`],yQe=[`world`,`view`,`projection`,`worldView`,`worldViewProjection`,`mBones`],bQe=[`translation`,`rotation`,`scale`],xQe=[`position`,`rotationQuaternion`,`scaling`],SQe=(e,t)=>{for(let n in e){let r=e[n];t.buffers[n]=r,t.buffersCount++}},CQe=(e,t)=>{for(let n in e){let r=e[n];t.shaders[n]=r,t.shaderscount++}},_8=(e,t,n)=>{for(let r in e){let i=e[r];n[t][r]=i}},wQe=e=>{if(e)for(let t=0;t{if(e.semantic===`NORMAL`)return`normal`;if(e.semantic===`POSITION`)return`position`;if(e.semantic===`JOINT`)return`matricesIndices`;if(e.semantic===`WEIGHT`)return`matricesWeights`;if(e.semantic===`COLOR`)return`color`;if(e.semantic&&e.semantic.indexOf(`TEXCOORD_`)!==-1){let t=Number(e.semantic.split(`_`)[1]);return`uv`+(t===0?``:t+1)}return null},EQe=e=>{for(let t in e.animations){let n=e.animations[t];if(!n.channels||!n.samplers)continue;let r=null;for(let i=0;i{let t;if(e.translation||e.rotation||e.scale){let n=j.FromArray(e.scale||[1,1,1]),r=A.FromArray(e.rotation||[0,0,0,1]),i=j.FromArray(e.translation||[0,0,0]);t=M.Compose(n,r,i)}else t=M.FromArray(e.matrix);return t},DQe=(e,t,n,r)=>{for(let e=0;e{for(let n=0;n{let n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(let e in n)if(r=n[e],r.jointName===t)return{node:r,id:e};return null},kQe=(e,t)=>{for(let n=0;n{for(let i in e.nodes){let a=e.nodes[i],o=i;if(!a.jointName||kQe(n,a.jointName))continue;let s=v8(a),c=new zs(a.name||``,t,null,s);c.id=o,r.push({bone:c,node:a,id:o})}for(let e=0;e{if(r||=new vd(t.name||``,``,e.scene),!t.babylonSkeleton)return r;let i=[],a=[];AQe(e,r,t,i),r.bones=[];for(let n=0;n0&&(d=OQe(i,c),d&&a.indexOf(d)===-1&&a.push(d));let p=new zs(s.jointName||``,r,d,f);p.id=c}let o=r.bones;r.bones=[];for(let n=0;n{if(i||(e.scene._blockEntityCollection=!!e.assetContainer,i=new K(t.name||``,e.scene),i._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,i.id=r),!t.babylonNode)return i;let a=[],o=null,s=[],c=[],l=[],u=[];for(let t=0;t1?(d=new al(`multimat`+r,e.scene),d.subMaterials=a):d=new lg(`multimat`+r,e.scene),a.length===1&&(d=a[0]),d._parentContainer=e.assetContainer,i.material||=d,new il(r,e.scene,o,!1,i),i.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,i.subMeshes=[];let f=0;for(let t=0;t{e.position&&=t,(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&=r},NQe=(e,t)=>{if(t.matrix){let n=new j(0,0,0),r=new A,i=new j(0,0,0);M.FromArray(t.matrix).decompose(i,r,n),b8(e,n,r,i)}else t.translation&&t.rotation&&t.scale&&b8(e,j.FromArray(t.translation),A.FromArray(t.rotation),j.FromArray(t.scale));e.computeWorldMatrix(!0)},PQe=(e,t,n)=>{let r=null;if(e.importOnlyMeshes&&(t.skin||t.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&e.importMeshesNames.indexOf(t.name||``)===-1)return null;if(t.skin){if(t.meshes){let i=e.skins[t.skin],a=MQe(e,t,t.meshes,n,t.babylonNode);a.skeleton=e.scene.getLastSkeletonById(t.skin),a.skeleton===null&&(a.skeleton=jQe(e,i,a,i.babylonSkeleton),i.babylonSkeleton||=a.skeleton),r=a}}else if(t.meshes)r=MQe(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode);else if(t.light&&!t.babylonNode&&!e.importOnlyMeshes){let n=e.lights[t.light];if(n){if(n.type===`ambient`){let i=n[n.type],a=new K_(t.light,j.Zero(),e.scene);a.name=t.name||``,i.color&&(a.diffuse=P.FromArray(i.color)),r=a}else if(n.type===`directional`){let i=n[n.type],a=new GC(t.light,j.Zero(),e.scene);a.name=t.name||``,i.color&&(a.diffuse=P.FromArray(i.color)),r=a}else if(n.type===`point`){let i=n[n.type],a=new nj(t.light,j.Zero(),e.scene);a.name=t.name||``,i.color&&(a.diffuse=P.FromArray(i.color)),r=a}else if(n.type===`spot`){let i=n[n.type],a=new WE(t.light,j.Zero(),j.Zero(),0,0,e.scene);a.name=t.name||``,i.color&&(a.diffuse=P.FromArray(i.color)),i.fallOfAngle&&(a.angle=i.fallOfAngle),i.fallOffExponent&&(a.exponent=i.fallOffExponent),r=a}}}else if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){let n=e.cameras[t.camera];if(n){if(e.scene._blockEntityCollection=!!e.assetContainer,n.type===`orthographic`){let n=new mh(t.camera,j.Zero(),e.scene,!1);n.name=t.name||``,n.mode=el.ORTHOGRAPHIC_CAMERA,n.attachControl(),r=n,n._parentContainer=e.assetContainer}else if(n.type===`perspective`){let i=n[n.type],a=new mh(t.camera,j.Zero(),e.scene,!1);a.name=t.name||``,a.attachControl(),i.aspectRatio||=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight(),i.znear&&i.zfar&&(a.maxZ=i.zfar,a.minZ=i.znear),r=a,a._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(r===null){e.scene._blockEntityCollection=!!e.assetContainer;let n=new K(t.name||``,e.scene);n._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,t.babylonNode=n,r=n}}if(r!==null){if(t.matrix&&r instanceof K)NQe(r,t);else{let e=t.translation||[0,0,0],n=t.rotation||[0,0,0,1],i=t.scale||[1,1,1];b8(r,j.FromArray(e),A.FromArray(n),j.FromArray(i))}r.updateCache(!0),t.babylonNode=r}return r},x8=(e,t,n,r=!1)=>{let i=e.nodes[t],a=null;if(r=e.importOnlyMeshes&&!r&&e.importMeshesNames?e.importMeshesNames.indexOf(i.name||``)!==-1||e.importMeshesNames.length===0:!0,!i.jointName&&r&&(a=PQe(e,i,t),a!==null&&(a.id=t,a.parent=n)),i.children)for(let t=0;t{let t=e.currentScene;if(t)for(let n=0;n{let s=a.values||i.parameters;for(let o in n){let c=n[o],l=c.type;if(l===d8.FLOAT_MAT2||l===d8.FLOAT_MAT3||l===d8.FLOAT_MAT4){if(c.semantic&&!c.source&&!c.node)h8.SetMatrix(t.scene,e,c,o,r.getEffect());else if(c.semantic&&(c.source||c.node)){let e=t.scene.getNodeByName(c.source||c.node||``);if(e===null&&(e=t.scene.getNodeById(c.source||c.node||``)),e===null)continue;h8.SetMatrix(t.scene,e,c,o,r.getEffect())}}else{let e=s[i.uniforms[o]];if(!e)continue;if(l===d8.SAMPLER_2D){let n=t.textures[a.values?e:c.value].babylonTexture;if(n==null)continue;r.getEffect().setTexture(o,n)}else h8.SetUniform(r.getEffect(),o,e,l)}}o(r)},LQe=(e,t,n,r,i)=>{let a=r.values||n.parameters,o=n.uniforms;for(let n in i){let s=i[n],c=s.type,l=a[o[n]];if(l===void 0&&(l=s.value),!l)continue;let u=e=>n=>{s.value&&e&&(t.setTexture(e,n),delete i[e])};c===d8.SAMPLER_2D?w8.LoadTextureAsync(e,r.values?l:s.value,u(n),()=>u(null)):s.value&&h8.SetUniform(t,n,r.values?l:s.value,c)&&delete i[n]}},RQe=(e,t,n)=>(r,i)=>{t.dispose(!0),n(`Cannot compile program named `+e.name+`. Error: `+i+`. Default material will be applied`)},zQe=(e,t,n,r,i,a)=>o=>{LQe(e,t,n,r,i),t.onBind=o=>{IQe(o,e,i,t,n,r,a)}},BQe=(e,t,n)=>{for(let r in t.uniforms){let i=t.uniforms[r],a=t.parameters[i];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){let e=vQe.indexOf(a.semantic);if(e!==-1)return delete n[r],yQe[e]}}return e.currentIdentifier},VQe=e=>{for(let t in e.materials)w8.LoadMaterialAsync(e,t,()=>{},()=>{})},S8=class{static CreateRuntime(e,t,n){let r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&_8(e.extensions,`extensions`,r),e.extensionsUsed&&_8(e.extensionsUsed,`extensionsUsed`,r),e.buffers&&SQe(e.buffers,r),e.bufferViews&&_8(e.bufferViews,`bufferViews`,r),e.accessors&&_8(e.accessors,`accessors`,r),e.meshes&&_8(e.meshes,`meshes`,r),e.lights&&_8(e.lights,`lights`,r),e.cameras&&_8(e.cameras,`cameras`,r),e.nodes&&_8(e.nodes,`nodes`,r),e.images&&_8(e.images,`images`,r),e.textures&&_8(e.textures,`textures`,r),e.shaders&&CQe(e.shaders,r),e.programs&&_8(e.programs,`programs`,r),e.samplers&&_8(e.samplers,`samplers`,r),e.techniques&&_8(e.techniques,`techniques`,r),e.materials&&_8(e.materials,`materials`,r),e.animations&&_8(e.animations,`animations`,r),e.skins&&_8(e.skins,`skins`,r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r}static LoadBufferAsync(e,t,n,r,i){let a=e.buffers[t];ge.IsBase64(a.uri)?setTimeout(()=>n(new Uint8Array(ge.DecodeBase64(a.uri)))):ge.LoadFile(e.rootUrl+a.uri,e=>n(new Uint8Array(e)),i,void 0,!0,e=>{e&&r(e.status+` `+e.statusText)})}static LoadTextureBufferAsync(e,t,n,r){let i=e.textures[t];if(!i||!i.source){r(``);return}if(i.babylonTexture){n(null);return}let a=e.images[i.source];ge.IsBase64(a.uri)?setTimeout(()=>n(new Uint8Array(ge.DecodeBase64(a.uri)))):ge.LoadFile(e.rootUrl+a.uri,e=>n(new Uint8Array(e)),void 0,void 0,!0,e=>{e&&r(e.status+` `+e.statusText)})}static CreateTextureAsync(e,t,n,r){let i=e.textures[t];if(i.babylonTexture){r(i.babylonTexture);return}let a=e.samplers[i.sampler],o=a.minFilter===p8.NEAREST_MIPMAP_NEAREST||a.minFilter===p8.NEAREST_MIPMAP_LINEAR||a.minFilter===p8.LINEAR_MIPMAP_NEAREST||a.minFilter===p8.LINEAR_MIPMAP_LINEAR,s=W.BILINEAR_SAMPLINGMODE,c=n==null?new Blob:new Blob([Ot(n)]),l=URL.createObjectURL(c),u=()=>URL.revokeObjectURL(l),d=new W(l,e.scene,!o,!0,s,u,u);a.wrapS!==void 0&&(d.wrapU=h8.GetWrapMode(a.wrapS)),a.wrapT!==void 0&&(d.wrapV=h8.GetWrapMode(a.wrapT)),d.name=t,i.babylonTexture=d,r(d)}static LoadShaderStringAsync(e,t,n,r){let i=e.shaders[t];if(ge.IsBase64(i.uri)){let e=atob(i.uri.split(`,`)[1]);n&&n(e)}else ge.LoadFile(e.rootUrl+i.uri,n,void 0,void 0,!1,e=>{e&&r&&r(e.status+` `+e.statusText)})}static LoadMaterialAsync(e,t,n,r){let i=e.materials[t];if(!i.technique){r&&r(`No technique found.`);return}let a=e.techniques[i.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;let r=new lg(t,e.scene);r._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,r.diffuseColor=new P(.5,.5,.5),r.sideOrientation=Zn.CounterClockWiseSideOrientation,n(r);return}let o=e.programs[a.program],s=a.states,c=qt.ShadersStore[o.vertexShader+`VertexShader`],l=qt.ShadersStore[o.fragmentShader+`PixelShader`],u=``,d=``,f=new _Qe(c),p=new _Qe(l),m={},h=[],g=[],_=[];for(let e in a.uniforms){let t=a.uniforms[e],n=a.parameters[t];if(m[e]=n,n.semantic&&!n.node&&!n.source){let t=vQe.indexOf(n.semantic);t===-1?h.push(e):(h.push(yQe[t]),delete m[e])}else n.type===d8.SAMPLER_2D?_.push(e):h.push(e)}for(let e in a.attributes){let t=a.attributes[e],n=a.parameters[t];if(n.semantic){let e=TQe(n);e&&g.push(e)}}for(;!f.isEnd()&&f.getNextToken();){if(f.currentToken!==g8.IDENTIFIER){u+=f.currentString;continue}let e=!1;for(let t in a.attributes){let n=a.attributes[t],r=a.parameters[n];if(f.currentIdentifier===t&&r.semantic){u+=TQe(r),e=!0;break}}e||(u+=BQe(f,a,m))}for(;!p.isEnd()&&p.getNextToken();){if(p.currentToken!==g8.IDENTIFIER){d+=p.currentString;continue}d+=BQe(p,a,m)}let v={vertex:o.vertexShader+t,fragment:o.fragmentShader+t},y={attributes:g,uniforms:h,samplers:_,needAlphaBlending:s&&s.enable&&s.enable.indexOf(3042)!==-1};qt.ShadersStore[o.vertexShader+t+`VertexShader`]=u,qt.ShadersStore[o.fragmentShader+t+`PixelShader`]=d;let b=new vp(t,e.scene,v,y);if(b.onError=RQe(o,b,r),b.onCompiled=zQe(e,b,a,i,m,n),b.sideOrientation=Zn.CounterClockWiseSideOrientation,s&&s.functions){let e=s.functions;e.cullFace&&e.cullFace[0]!==gQe.BACK&&(b.backFaceCulling=!1);let t=e.blendFuncSeparate;t&&(t[0]===m8.SRC_ALPHA&&t[1]===m8.ONE_MINUS_SRC_ALPHA&&t[2]===m8.ONE&&t[3]===m8.ONE?b.alphaMode=q.ALPHA_COMBINE:t[0]===m8.ONE&&t[1]===m8.ONE&&t[2]===m8.ZERO&&t[3]===m8.ONE?b.alphaMode=q.ALPHA_ONEONE:t[0]===m8.SRC_ALPHA&&t[1]===m8.ONE&&t[2]===m8.ZERO&&t[3]===m8.ONE?b.alphaMode=q.ALPHA_ADD:t[0]===m8.ZERO&&t[1]===m8.ONE_MINUS_SRC_COLOR&&t[2]===m8.ONE&&t[3]===m8.ONE?b.alphaMode=q.ALPHA_SUBTRACT:t[0]===m8.DST_COLOR&&t[1]===m8.ZERO&&t[2]===m8.ONE&&t[3]===m8.ONE?b.alphaMode=q.ALPHA_MULTIPLY:t[0]===m8.SRC_ALPHA&&t[1]===m8.ONE_MINUS_SRC_COLOR&&t[2]===m8.ONE&&t[3]===m8.ONE&&(b.alphaMode=q.ALPHA_MAXIMIZED))}}},C8=class e{static RegisterExtension(t){if(e.Extensions[t.name]){ge.Error(`Tool with the same name "`+t.name+`" already exists`);return}e.Extensions[t.name]=t}dispose(){}_importMeshAsync(e,t,n,r,i,a,o,s){return t.useRightHandedSystem=!0,w8.LoadRuntimeAsync(t,n,r,t=>{t.assetContainer=i,t.importOnlyMeshes=!0,e===``?t.importMeshesNames=[]:typeof e==`string`||e&&!(e instanceof Array)?t.importMeshesNames=[e]:(t.importMeshesNames=[],ge.Warn(`Argument meshesNames must be of type string or string[]`)),this._createNodes(t);let n=[],r=[];for(let e in t.nodes){let r=t.nodes[e];r.babylonNode instanceof Yc&&n.push(r.babylonNode)}for(let e in t.skins){let n=t.skins[e];n.babylonSkeleton instanceof vd&&r.push(n.babylonSkeleton)}this._loadBuffersAsync(t,()=>{this._loadShadersAsync(t,()=>{VQe(t),FQe(t),!l8.IncrementalLoading&&a&&a(n,r)})}),l8.IncrementalLoading&&a&&a(n,r)},s),!0}importMeshAsync(e,t,n,r,i,a){return new Promise((o,s)=>{this._importMeshAsync(e,t,r,i,n,(e,t)=>{o({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})},a,e=>{s(Error(e))})})}_loadAsync(e,t,n,r,i,a){e.useRightHandedSystem=!0,w8.LoadRuntimeAsync(e,t,n,e=>{w8.LoadRuntimeExtensionsAsync(e,()=>{this._createNodes(e),this._loadBuffersAsync(e,()=>{this._loadShadersAsync(e,()=>{VQe(e),FQe(e),l8.IncrementalLoading||r()})}),l8.IncrementalLoading&&r()},a)},a)}async loadAsync(e,t,n,r){return await new Promise((i,a)=>{this._loadAsync(e,t,n,()=>{i()},r,e=>{a(Error(e))})})}_loadShadersAsync(e,t){let n=!1,r=(n,r)=>{w8.LoadShaderStringAsync(e,n,i=>{i instanceof ArrayBuffer||(e.loadedShaderCount++,i&&(qt.ShadersStore[n+(r.type===mQe.VERTEX?`VertexShader`:`PixelShader`)]=i),e.loadedShaderCount===e.shaderscount&&t())},()=>{ge.Error(`Error when loading shader program named `+n+` located at `+r.uri)})};for(let t in e.shaders){n=!0;let i=e.shaders[t];i?r.bind(this,t,i)():ge.Error(`No shader named: `+t)}n||t()}_loadBuffersAsync(e,t){let n=!1,r=(n,r)=>{w8.LoadBufferAsync(e,n,i=>{e.loadedBufferCount++,i&&(i.byteLength!=e.buffers[n].byteLength&&ge.Error(`Buffer named `+n+` is length `+i.byteLength+`. Expected: `+r.byteLength),e.loadedBufferViews[n]=i),e.loadedBufferCount===e.buffersCount&&t()},()=>{ge.Error(`Error when loading buffer named `+n+` located at `+r.uri)})};for(let t in e.buffers){n=!0;let i=e.buffers[t];i?r.bind(this,t,i)():ge.Error(`No buffer named: `+t)}n||t()}_createNodes(e){let t=e.currentScene;if(t)for(let n=0;ne.loadRuntimeAsync(t,n,r,i,a),()=>{setTimeout(()=>{i&&i(S8.CreateRuntime(n.json,t,r))})})}static LoadRuntimeExtensionsAsync(t,n,r){e._ApplyExtensions(e=>e.loadRuntimeExtensionsAsync(t,n,r),()=>{setTimeout(()=>{n()})})}static LoadBufferAsync(t,n,r,i,a){e._ApplyExtensions(e=>e.loadBufferAsync(t,n,r,i,a),()=>{S8.LoadBufferAsync(t,n,r,i,a)})}static LoadTextureAsync(t,n,r,i){e._LoadTextureBufferAsync(t,n,a=>{a&&e._CreateTextureAsync(t,n,a,r,i)},i)}static LoadShaderStringAsync(t,n,r,i){e._ApplyExtensions(e=>e.loadShaderStringAsync(t,n,r,i),()=>{S8.LoadShaderStringAsync(t,n,r,i)})}static LoadMaterialAsync(t,n,r,i){e._ApplyExtensions(e=>e.loadMaterialAsync(t,n,r,i),()=>{S8.LoadMaterialAsync(t,n,r,i)})}static _LoadTextureBufferAsync(t,n,r,i){e._ApplyExtensions(e=>e.loadTextureBufferAsync(t,n,r,i),()=>{S8.LoadTextureBufferAsync(t,n,r,i)})}static _CreateTextureAsync(t,n,r,i,a){e._ApplyExtensions(e=>e.createTextureAsync(t,n,r,i,a),()=>{S8.CreateTextureAsync(t,n,r,i)})}static _ApplyExtensions(e,t){for(let t in C8.Extensions){let n=C8.Extensions[t];if(e(n))return}t()}};l8._CreateGLTF1Loader=()=>new C8;var HQe=`binary_glTF`,UQe=class extends w8{constructor(){super(`KHR_binary_glTF`)}loadRuntimeAsync(e,t,n,r){let i=t.json.extensionsUsed;return!i||i.indexOf(this.name)===-1||!t.bin?!1:(this._bin=t.bin,r(S8.CreateRuntime(t.json,e,n)),!0)}loadBufferAsync(e,t,n,r){return e.extensionsUsed.indexOf(this.name)===-1||t!==HQe?!1:(this._bin.readAsync(0,this._bin.byteLength).then(n,e=>r(e.message)),!0)}loadTextureBufferAsync(e,t,n){let r=e.textures[t],i=e.images[r.source];if(!i.extensions||!(this.name in i.extensions))return!1;let a=i.extensions[this.name],o=e.bufferViews[a.bufferView];return n(h8.GetBufferFromBufferView(e,o,0,o.byteLength,u8.UNSIGNED_BYTE)),!0}loadShaderStringAsync(e,t,n){let r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;let i=r.extensions[this.name],a=e.bufferViews[i.bufferView],o=h8.GetBufferFromBufferView(e,a,0,a.byteLength,u8.UNSIGNED_BYTE);return setTimeout(()=>{n(h8.DecodeBufferToText(o))}),!0}};C8.RegisterExtension(new UQe);var WQe=class extends w8{constructor(){super(`KHR_materials_common`)}loadRuntimeExtensionsAsync(e){if(!e.extensions)return!1;let t=e.extensions[this.name];if(!t)return!1;let n=t.lights;if(n)for(let t in n){let r=n[t];switch(r.type){case`ambient`:{let t=new K_(r.name,new j(0,1,0),e.scene),n=r.ambient;n&&(t.diffuse=P.FromArray(n.color||[1,1,1]));break}case`point`:{let t=new nj(r.name,new j(10,10,10),e.scene),n=r.point;n&&(t.diffuse=P.FromArray(n.color||[1,1,1]));break}case`directional`:{let t=new GC(r.name,new j(0,-1,0),e.scene),n=r.directional;n&&(t.diffuse=P.FromArray(n.color||[1,1,1]));break}case`spot`:{let t=r.spot;if(t){let n=new WE(r.name,new j(0,10,0),new j(0,-1,0),t.fallOffAngle||Math.PI,t.fallOffExponent||0,e.scene);n.diffuse=P.FromArray(t.color||[1,1,1])}break}default:ge.Warn(`GLTF Material Common extension: light type "`+r.type+`” not supported`);break}}return!1}loadMaterialAsync(e,t,n,r){let i=e.materials[t];if(!i||!i.extensions)return!1;let a=i.extensions[this.name];if(!a)return!1;let o=new lg(t,e.scene);return o.sideOrientation=Zn.CounterClockWiseSideOrientation,a.technique===`CONSTANT`&&(o.disableLighting=!0),o.backFaceCulling=a.doubleSided!==void 0&&!a.doubleSided,o.alpha=a.values.transparency===void 0?1:a.values.transparency,o.specularPower=a.values.shininess===void 0?0:a.values.shininess,typeof a.values.ambient==`string`?this._loadTexture(e,a.values.ambient,o,`ambientTexture`,r):o.ambientColor=P.FromArray(a.values.ambient||[0,0,0]),typeof a.values.diffuse==`string`?this._loadTexture(e,a.values.diffuse,o,`diffuseTexture`,r):o.diffuseColor=P.FromArray(a.values.diffuse||[0,0,0]),typeof a.values.emission==`string`?this._loadTexture(e,a.values.emission,o,`emissiveTexture`,r):o.emissiveColor=P.FromArray(a.values.emission||[0,0,0]),typeof a.values.specular==`string`?this._loadTexture(e,a.values.specular,o,`specularTexture`,r):o.specularColor=P.FromArray(a.values.specular||[0,0,0]),!0}_loadTexture(e,t,n,r,i){S8.LoadTextureBufferAsync(e,t,i=>{S8.CreateTextureAsync(e,t,i,e=>n[r]=e)},i)}};C8.RegisterExtension(new WQe);var T8=new Map,GQe=T8;function E8(e,t,n){D8(e)&&F.Warn(`Extension with the name '${e}' already exists`),T8.set(e,{isGLTFExtension:t,factory:n})}function D8(e){return T8.delete(e)}var KQe=[{regex:RegExp(`^/nodes/\\d+/extensions/`)}],qQe=class{constructor(e,t){this._gltf=e,this._infoTree=t}convert(e){let t=this._gltf,n=this._infoTree,r;if(!e.startsWith(`/`))throw Error(`Path must start with a /`);let i=e.split(`/`);if(i.shift(),i[i.length-1].includes(`.length`)){let e=i[i.length-1].split(`.`);i.pop(),i.push(...e)}let a=!1;for(let o of i){let i=o===`length`;if(i&&!n.__array__)throw Error(`Path ${e} is invalid`);if(n.__ignoreObjectTree__&&(a=!0),n.__array__&&!i)n=n.__array__;else if(n=n[o],!n)throw Error(`Path ${e} is invalid`);if(!a)if(t===void 0){if(!KQe.find(t=>t.regex.test(e)))throw Error(`Path ${e} is invalid`)}else i||(t=t?.[o]);(n.__target__||i)&&(r=t)}return{object:r,info:n}}},JQe={length:{type:`number`,get:e=>e.length,getTarget:e=>e.map(e=>e._babylonTransformNode),getPropertyName:[()=>`length`]},__array__:{__target__:!0,translation:{type:`Vector3`,get:e=>e._babylonTransformNode?.position,set:(e,t)=>t._babylonTransformNode?.position.copyFrom(e),getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`position`]},rotation:{type:`Quaternion`,get:e=>e._babylonTransformNode?.rotationQuaternion,set:(e,t)=>t._babylonTransformNode?.rotationQuaternion?.copyFrom(e),getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`rotationQuaternion`]},scale:{type:`Vector3`,get:e=>e._babylonTransformNode?.scaling,set:(e,t)=>t._babylonTransformNode?.scaling.copyFrom(e),getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`scaling`]},weights:{length:{type:`number`,get:e=>e._numMorphTargets,getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`influence`]},__array__:{__target__:!0,type:`number`,get:(e,t)=>t===void 0?void 0:e._primitiveBabylonMeshes?.[0].morphTargetManager?.getTarget(t).influence,getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`influence`]},type:`number[]`,get:(e,t)=>[0],getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`influence`]},matrix:{type:`Matrix`,get:e=>M.Compose(e._babylonTransformNode?.scaling,e._babylonTransformNode?.rotationQuaternion,e._babylonTransformNode?.position),getTarget:e=>e._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:`Matrix`,get:e=>{let t=M.Identity(),n=e.parent;for(;n&&n.parent;)n=n.parent;let r=e._babylonTransformNode?.position._isDirty||e._babylonTransformNode?.rotationQuaternion?._isDirty||e._babylonTransformNode?.scaling._isDirty;if(n){let i=n._babylonTransformNode?.computeWorldMatrix(!0).invert();i&&e._babylonTransformNode?.computeWorldMatrix(r)?.multiplyToRef(i,t)}else e._babylonTransformNode&&t.copyFrom(e._babylonTransformNode.computeWorldMatrix(r));return t},getTarget:e=>e._babylonTransformNode,isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:`number`,get:e=>e._babylonTransformNode?.getChildren(e=>e instanceof WE,!0)[0]?.intensity,getTarget:e=>e._babylonTransformNode?.getChildren(e=>e instanceof WE,!0)[0],set:(e,t)=>{if(t._babylonTransformNode){let n=t._babylonTransformNode.getChildren(e=>e instanceof WE,!0)[0];n&&(n.intensity=e)}}},color:{type:`Color3`,get:e=>e._babylonTransformNode?.getChildren(e=>e instanceof WE,!0)[0]?.diffuse,getTarget:e=>e._babylonTransformNode?.getChildren(e=>e instanceof WE,!0)[0],set:(e,t)=>{if(t._babylonTransformNode){let n=t._babylonTransformNode.getChildren(e=>e instanceof WE,!0)[0];n&&(n.diffuse=e)}}}},KHR_node_visibility:{visible:{type:`boolean`,get:e=>e._primitiveBabylonMeshes?e._primitiveBabylonMeshes[0].isVisible:!1,getTarget:()=>void 0,set:(e,t)=>{t._primitiveBabylonMeshes&&t._primitiveBabylonMeshes.forEach(t=>t.isVisible=e)}}}}}},YQe={length:{type:`number`,get:e=>e.length,getTarget:e=>e.map(e=>e._babylonAnimationGroup),getPropertyName:[()=>`length`]},__array__:{}},XQe={length:{type:`number`,get:e=>e.length,getTarget:e=>e.map(e=>e.primitives[0]._instanceData?.babylonSourceMesh),getPropertyName:[()=>`length`]},__array__:{}},ZQe={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:`Vector2`,get:e=>new O(e._babylonCamera?.orthoLeft??0,e._babylonCamera?.orthoRight??0),set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.orthoLeft=e.x,t._babylonCamera.orthoRight=e.y)},getTarget:e=>e,getPropertyName:[()=>`orthoLeft`,()=>`orthoRight`]},ymag:{componentsCount:2,type:`Vector2`,get:e=>new O(e._babylonCamera?.orthoBottom??0,e._babylonCamera?.orthoTop??0),set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.orthoBottom=e.x,t._babylonCamera.orthoTop=e.y)},getTarget:e=>e,getPropertyName:[()=>`orthoBottom`,()=>`orthoTop`]},zfar:{type:`number`,get:e=>e._babylonCamera?.maxZ,set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:e=>e,getPropertyName:[()=>`maxZ`]},znear:{type:`number`,get:e=>e._babylonCamera?.minZ,set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:e=>e,getPropertyName:[()=>`minZ`]}},perspective:{aspectRatio:{type:`number`,get:e=>e._babylonCamera?.getEngine().getAspectRatio(e._babylonCamera),getTarget:e=>e,getPropertyName:[()=>`aspectRatio`],isReadOnly:!0},yfov:{type:`number`,get:e=>e._babylonCamera?.fov,set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.fov=e)},getTarget:e=>e,getPropertyName:[()=>`fov`]},zfar:{type:`number`,get:e=>e._babylonCamera?.maxZ,set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:e=>e,getPropertyName:[()=>`maxZ`]},znear:{type:`number`,get:e=>e._babylonCamera?.minZ,set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:e=>e,getPropertyName:[()=>`minZ`]}}}},QQe={__array__:{__target__:!0,emissiveFactor:{type:`Color3`,get:(e,t,n)=>k8(e,t,n).emissiveColor,set:(e,t,n,r)=>k8(t,n,r).emissiveColor.copyFrom(e),getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`emissiveColor`]},emissiveTexture:{extensions:{KHR_texture_transform:A8(`emissiveTexture`)}},normalTexture:{scale:{type:`number`,get:(e,t,n)=>O8(e,n,`bumpTexture`)?.level,set:(e,t,n,r)=>{let i=O8(t,r,`bumpTexture`);i&&(i.level=e)},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`level`]},extensions:{KHR_texture_transform:A8(`bumpTexture`)}},occlusionTexture:{strength:{type:`number`,get:(e,t,n)=>k8(e,t,n).ambientTextureStrength,set:(e,t,n,r)=>{let i=k8(t,n,r);i&&(i.ambientTextureStrength=e)},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`ambientTextureStrength`]},extensions:{KHR_texture_transform:A8(`ambientTexture`)}},pbrMetallicRoughness:{baseColorFactor:{type:`Color4`,get:(e,t,n)=>{let r=k8(e,t,n);return fe.FromColor3(r.albedoColor,r.alpha)},set:(e,t,n,r)=>{let i=k8(t,n,r);i.albedoColor.set(e.r,e.g,e.b),i.alpha=e.a},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`albedoColor`,()=>`alpha`]},baseColorTexture:{extensions:{KHR_texture_transform:A8(`albedoTexture`)}},metallicFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).metallic,set:(e,t,n,r)=>{let i=k8(t,n,r);i&&(i.metallic=e)},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`metallic`]},roughnessFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).roughness,set:(e,t,n,r)=>{let i=k8(t,n,r);i&&(i.roughness=e)},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`roughness`]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:A8(`metallicTexture`)}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:`number`,get:(e,t,n)=>k8(e,t,n).anisotropy.intensity,set:(e,t,n,r)=>{k8(t,n,r).anisotropy.intensity=e},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`anisotropy.intensity`]},anisotropyRotation:{type:`number`,get:(e,t,n)=>k8(e,t,n).anisotropy.angle,set:(e,t,n,r)=>{k8(t,n,r).anisotropy.angle=e},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`anisotropy.angle`]},anisotropyTexture:{extensions:{KHR_texture_transform:A8(`anisotropy`,`texture`)}}},KHR_materials_clearcoat:{clearcoatFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).clearCoat.intensity,set:(e,t,n,r)=>{k8(t,n,r).clearCoat.intensity=e},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`clearCoat.intensity`]},clearcoatRoughnessFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).clearCoat.roughness,set:(e,t,n,r)=>{k8(t,n,r).clearCoat.roughness=e},getTarget:(e,t,n)=>k8(e,t,n),getPropertyName:[()=>`clearCoat.roughness`]},clearcoatTexture:{extensions:{KHR_texture_transform:A8(`clearCoat`,`texture`)}},clearcoatNormalTexture:{scale:{type:`number`,get:(e,t,n)=>k8(e,t,n).clearCoat.bumpTexture?.level,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).clearCoat.bumpTexture.level=e},extensions:{KHR_texture_transform:A8(`clearCoat`,`bumpTexture`)}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:A8(`clearCoat`,`textureRoughness`)}}},KHR_materials_dispersion:{dispersion:{type:`number`,get:(e,t,n)=>k8(e,t,n).subSurface.dispersion,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).subSurface.dispersion=e}},KHR_materials_emissive_strength:{emissiveStrength:{type:`number`,get:(e,t,n)=>k8(e,t,n).emissiveIntensity,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).emissiveIntensity=e}},KHR_materials_ior:{ior:{type:`number`,get:(e,t,n)=>k8(e,t,n).indexOfRefraction,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).indexOfRefraction=e}},KHR_materials_iridescence:{iridescenceFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).iridescence.intensity,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).iridescence.intensity=e},iridescenceIor:{type:`number`,get:(e,t,n)=>k8(e,t,n).iridescence.indexOfRefraction,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).iridescence.indexOfRefraction=e},iridescenceTexture:{extensions:{KHR_texture_transform:A8(`iridescence`,`texture`)}},iridescenceThicknessMaximum:{type:`number`,get:(e,t,n)=>k8(e,t,n).iridescence.maximumThickness,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).iridescence.maximumThickness=e},iridescenceThicknessMinimum:{type:`number`,get:(e,t,n)=>k8(e,t,n).iridescence.minimumThickness,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).iridescence.minimumThickness=e},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:A8(`iridescence`,`thicknessTexture`)}}},KHR_materials_sheen:{sheenColorFactor:{type:`Color3`,get:(e,t,n)=>k8(e,t,n).sheen.color,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).sheen.color.copyFrom(e)},sheenColorTexture:{extensions:{KHR_texture_transform:A8(`sheen`,`texture`)}},sheenRoughnessFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).sheen.intensity,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).sheen.intensity=e},sheenRoughnessTexture:{extensions:{KHR_texture_transform:A8(`sheen`,`thicknessTexture`)}}},KHR_materials_specular:{specularFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).metallicF0Factor,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).metallicF0Factor=e,getPropertyName:[()=>`metallicF0Factor`]},specularColorFactor:{type:`Color3`,get:(e,t,n)=>k8(e,t,n).metallicReflectanceColor,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).metallicReflectanceColor.copyFrom(e),getPropertyName:[()=>`metallicReflectanceColor`]},specularTexture:{extensions:{KHR_texture_transform:A8(`metallicReflectanceTexture`)}},specularColorTexture:{extensions:{KHR_texture_transform:A8(`reflectanceTexture`)}}},KHR_materials_transmission:{transmissionFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).subSurface.refractionIntensity,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).subSurface.refractionIntensity=e,getPropertyName:[()=>`subSurface.refractionIntensity`]},transmissionTexture:{extensions:{KHR_texture_transform:A8(`subSurface`,`refractionIntensityTexture`)}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).subSurface.translucencyIntensity,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).subSurface.translucencyIntensity=e},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:A8(`subSurface`,`translucencyIntensityTexture`)}},diffuseTransmissionColorFactor:{type:`Color3`,get:(e,t,n)=>k8(e,t,n).subSurface.translucencyColor,getTarget:k8,set:(e,t,n,r)=>e&&k8(t,n,r).subSurface.translucencyColor?.copyFrom(e)},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:A8(`subSurface`,`translucencyColorTexture`)}}},KHR_materials_volume:{attenuationColor:{type:`Color3`,get:(e,t,n)=>k8(e,t,n).subSurface.tintColor,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).subSurface.tintColor.copyFrom(e)},attenuationDistance:{type:`number`,get:(e,t,n)=>k8(e,t,n).subSurface.tintColorAtDistance,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).subSurface.tintColorAtDistance=e},thicknessFactor:{type:`number`,get:(e,t,n)=>k8(e,t,n).subSurface.maximumThickness,getTarget:k8,set:(e,t,n,r)=>k8(t,n,r).subSurface.maximumThickness=e},thicknessTexture:{extensions:{KHR_texture_transform:A8(`subSurface`,`thicknessTexture`)}}}}}},$Qe={KHR_lights_punctual:{lights:{length:{type:`number`,get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>`length`]},__array__:{__target__:!0,color:{type:`Color3`,get:e=>e._babylonLight?.diffuse,set:(e,t)=>t._babylonLight?.diffuse.copyFrom(e),getTarget:e=>e._babylonLight,getPropertyName:[e=>`diffuse`]},intensity:{type:`number`,get:e=>e._babylonLight?.intensity,set:(e,t)=>t._babylonLight?t._babylonLight.intensity=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>`intensity`]},range:{type:`number`,get:e=>e._babylonLight?.range,set:(e,t)=>t._babylonLight?t._babylonLight.range=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>`range`]},spot:{innerConeAngle:{type:`number`,get:e=>e._babylonLight?.innerAngle,set:(e,t)=>t._babylonLight?t._babylonLight.innerAngle=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>`innerConeAngle`]},outerConeAngle:{type:`number`,get:e=>e._babylonLight?.angle,set:(e,t)=>t._babylonLight?t._babylonLight.angle=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>`outerConeAngle`]}}}}},EXT_lights_area:{lights:{length:{type:`number`,get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>`length`]},__array__:{__target__:!0,color:{type:`Color3`,get:e=>e._babylonLight?.diffuse,set:(e,t)=>t._babylonLight?.diffuse.copyFrom(e),getTarget:e=>e._babylonLight,getPropertyName:[e=>`diffuse`]},intensity:{type:`number`,get:e=>e._babylonLight?.intensity,set:(e,t)=>t._babylonLight?t._babylonLight.intensity=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>`intensity`]},size:{type:`number`,get:e=>e._babylonLight?.height,set:(e,t)=>t._babylonLight?t._babylonLight.height=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>`size`]},rect:{aspect:{type:`number`,get:e=>e._babylonLight?.width/e._babylonLight?.height,set:(e,t)=>t._babylonLight?t._babylonLight.width=e*t._babylonLight.height:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>`aspect`]}}}}},EXT_lights_ies:{lights:{length:{type:`number`,get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>`length`]}}},EXT_lights_image_based:{lights:{length:{type:`number`,get:e=>e.length,getTarget:e=>e.map(e=>e._babylonTexture),getPropertyName:[e=>`length`]},__array__:{__target__:!0,intensity:{type:`number`,get:e=>e._babylonTexture?.level,set:(e,t)=>{t._babylonTexture&&(t._babylonTexture.level=e)},getTarget:e=>e._babylonTexture},rotation:{type:`Quaternion`,get:e=>e._babylonTexture&&A.FromRotationMatrix(e._babylonTexture?.getReflectionTextureMatrix()),set:(e,t)=>{t._babylonTexture&&(t._babylonTexture.getScene()?.useRightHandedSystem||(e=A.Inverse(e)),M.FromQuaternionToRef(e,t._babylonTexture.getReflectionTextureMatrix()))},getTarget:e=>e._babylonTexture}}}}};function O8(e,t,n,r){let i=k8(e,t);return r?i[n][r]:i[n]}function k8(e,t,n){return e._data?.[n?.fillMode??q.MATERIAL_TriangleFillMode]?.babylonMaterial}function A8(e,t){return{offset:{componentsCount:2,type:`Vector2`,get:(n,r,i)=>{let a=O8(n,i,e,t);return new O(a?.uOffset,a?.vOffset)},getTarget:k8,set:(n,r,i,a)=>{let o=O8(r,a,e,t);o.uOffset=n.x,o.vOffset=n.y},getPropertyName:[()=>`${e}${t?`.`+t:``}.uOffset`,()=>`${e}${t?`.`+t:``}.vOffset`]},rotation:{type:`number`,get:(n,r,i)=>O8(n,i,e,t)?.wAng,getTarget:k8,set:(n,r,i,a)=>O8(r,a,e,t).wAng=n,getPropertyName:[()=>`${e}${t?`.`+t:``}.wAng`]},scale:{componentsCount:2,type:`Vector2`,get:(n,r,i)=>{let a=O8(n,i,e,t);return new O(a?.uScale,a?.vScale)},getTarget:k8,set:(n,r,i,a)=>{let o=O8(r,a,e,t);o.uScale=n.x,o.vScale=n.y},getPropertyName:[()=>`${e}${t?`.`+t:``}.uScale`,()=>`${e}${t?`.`+t:``}.vScale`]}}}var j8={cameras:ZQe,nodes:JQe,materials:QQe,extensions:$Qe,animations:YQe,meshes:XQe};function e$e(e){return new qQe(e,j8)}function M8(e){let t=e.split(`/`).map(e=>e.replace(/{}/g,`__array__`)),n=j8;for(let e of t)e&&(n=n[e]);if(n&&n.type&&n.get)return n}function N8(e,t){let n=e.split(`/`).map(e=>e.replace(/{}/g,`__array__`)),r=j8;for(let e of n)e&&(r=r[e]);r&&r.type&&r.get&&(r.interpolation=t)}function P8(e,t){let n=e.split(`/`).map(e=>e.replace(/{}/g,`__array__`)),r=j8;for(let e of n)if(e){if(!r[e]){if(e===`?`){r.__ignoreObjectTree__=!0;continue}r[e]={},e===`__array__`&&(r[e].__target__=!0)}r=r[e]}Object.assign(r,t)}var t$e=new JZ(()=>U(()=>Promise.resolve().then(()=>yc),void 0,import.meta.url)),n$e=new JZ(()=>U(()=>Promise.resolve().then(()=>o$e),void 0,import.meta.url)),F8=class{static Get(e,t,n){if(!t||n==null||!t[n])throw Error(`${e}: Failed to find index (${n})`);return t[n]}static TryGet(e,t){return!e||t==null||!e[t]?null:e[t]}static Assign(e){if(e)for(let t=0;te.dispose&&e.dispose()),this._extensions.length=0,this._materialAdapters.clear(),this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())}async importMeshAsync(e,t,n,r,i,a,o=``){return await Promise.resolve().then(async()=>{this._babylonScene=t,this._assetContainer=n,this._loadData(r);let a=null;if(e){let t={};if(this._gltf.nodes)for(let e of this._gltf.nodes)e.name&&(t[e.name]=e.index);a=(e instanceof Array?e:[e]).map(e=>{let n=t[e];if(n===void 0)throw Error(`Failed to find node '${e}'`);return n})}return await this._loadAsync(i,o,a,()=>({meshes:this._getMeshes(),particleSystems:[],skeletons:this._getSkeletons(),animationGroups:this._getAnimationGroups(),lights:this._babylonLights,transformNodes:this._getTransformNodes(),geometries:this._getGeometries(),spriteManagers:[]}))})}async loadAsync(e,t,n,r,i=``){return this._babylonScene=e,this._loadData(t),await this._loadAsync(n,i,null,()=>void 0)}async _loadAsync(e,t,n,r){return await Promise.resolve().then(async()=>{if(this._rootUrl=e,this._uniqueRootUrl=!e.startsWith(`file:`)&&t?e:`${e}${Date.now()}/`,this._fileName=t,this._allMaterialsDirtyRequired=!1,await this._loadExtensionsAsync(),!this.parent.skipMaterials){let e=this.parent.useOpenPBR||this.isExtensionUsed(`KHR_materials_openpbr`),t=!1;this.parent.useOpenPBR?this._gltf.materials?.length&&this._gltf.materials.some(e=>!e.extensions?.KHR_materials_openpbr)&&(t=!0):t=!0;let n=[];e&&!this._pbrMaterialImpls.has(`openpbr`)&&n.push(Promise.all([U(()=>Promise.resolve().then(()=>Eme),void 0,import.meta.url),U(()=>Promise.resolve().then(()=>u$e),void 0,import.meta.url)]).then(([{OpenPBRMaterial:e,RegisterOpenpbrMaterial:t},{OpenPBRMaterialLoadingAdapter:n}])=>{t(),this._pbrMaterialImpls.set(`openpbr`,{materialClass:e,adapterClass:n})})),t&&!this._pbrMaterialImpls.has(`pbr`)&&n.push(Promise.all([U(()=>Promise.resolve().then(()=>vhe),void 0,import.meta.url),U(()=>Promise.resolve().then(()=>f$e),void 0,import.meta.url)]).then(([{PBRMaterial:e,RegisterPbrMaterial:t},{PBRMaterialLoadingAdapter:n}])=>{t(),this._pbrMaterialImpls.set(`pbr`,{materialClass:e,adapterClass:n})})),await Promise.all(n)}let i=`${c8[c8.LOADING]} => ${c8[c8.READY]}`,a=`${c8[c8.LOADING]} => ${c8[c8.COMPLETE]}`;this._parent._startPerformanceCounter(i),this._parent._startPerformanceCounter(a),this._parent._setState(c8.LOADING),this._extensionsOnLoading();let o=[],s=this._babylonScene.blockMaterialDirtyMechanism;if(this._babylonScene.blockMaterialDirtyMechanism=!0,!this.parent.loadOnlyMaterials){if(n)o.push(this.loadSceneAsync(`/nodes`,{nodes:n,index:-1}));else if(this._gltf.scene!=null||this._gltf.scenes&&this._gltf.scenes[0]){let e=F8.Get(`/scene`,this._gltf.scenes,this._gltf.scene||0);o.push(this.loadSceneAsync(`/scenes/${e.index}`,e))}}if(!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(let e=0;e{}))}return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=s:this._babylonScene._forceBlockMaterialDirtyMechanism(s),this._parent.compileMaterials&&o.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&o.push(this._compileShadowGeneratorsAsync()),await Promise.all(o).then(()=>{this._rootBabylonMesh&&this._rootBabylonMesh!==this._parent.customRootNode&&this._rootBabylonMesh.setEnabled(!0);for(let e of this._babylonScene.materials){let t=e;t.maxSimultaneousLights!==void 0&&(t.maxSimultaneousLights=Math.max(t.maxSimultaneousLights,this._babylonScene.lights.length))}for(let e of Array.from(this._materialAdapters))this._completePromises.push(e.finalizeAsync(this));return this._extensionsOnReady(),this._parent._setState(c8.READY),this._skipStartAnimationStep||this._startAnimations(),r()}).then(e=>(this._parent._endPerformanceCounter(i),ge.SetImmediate(()=>{this._disposed||Promise.all(this._completePromises).then(()=>{this._parent._endPerformanceCounter(a),this._parent._setState(c8.COMPLETE),this._parent.onCompleteObservable.notifyObservers(void 0),this._parent.onCompleteObservable.clear(),this.dispose()},e=>{this._parent.onErrorObservable.notifyObservers(e),this._parent.onErrorObservable.clear(),this.dispose()})}),e))}).catch(e=>{throw this._disposed||(this._parent.onErrorObservable.notifyObservers(e),this._parent.onErrorObservable.clear(),this.dispose()),e})}_loadData(e){if(this._gltf=e.json,this._setupData(),e.bin){let t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){let n=t[0];(n.byteLengthe.bin.byteLength)&&F.Warn(`Binary buffer length (${n.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else F.Warn(`Unexpected BIN chunk`)}}_setupData(){if(F8.Assign(this._gltf.accessors),F8.Assign(this._gltf.animations),F8.Assign(this._gltf.buffers),F8.Assign(this._gltf.bufferViews),F8.Assign(this._gltf.cameras),F8.Assign(this._gltf.images),F8.Assign(this._gltf.materials),F8.Assign(this._gltf.meshes),F8.Assign(this._gltf.nodes),F8.Assign(this._gltf.samplers),F8.Assign(this._gltf.scenes),F8.Assign(this._gltf.skins),F8.Assign(this._gltf.textures),this._gltf.nodes){let e={};for(let t of this._gltf.nodes)if(t.children)for(let n of t.children)e[n]=t.index;let t=this._createRootNode();for(let n of this._gltf.nodes){let r=e[n.index];n.parent=r===void 0?t:this._gltf.nodes[r]}}}async _loadExtensionsAsync(){let e=[];if(GQe.forEach((t,n)=>{this.parent.extensionOptions[n]?.enabled===!1?t.isGLTFExtension&&this.isExtensionUsed(n)&&F.Warn(`Extension ${n} is used but has been explicitly disabled.`):(!t.isGLTFExtension||this.isExtensionUsed(n))&&e.push((async()=>{let e=await t.factory(this);return e.name!==n&&F.Warn(`The name of the glTF loader extension instance does not match the registered name: ${e.name} !== ${n}`),this._parent.onExtensionLoadedObservable.notifyObservers(e),e})())}),this._extensions.push(...await Promise.all(e)),this._extensions.sort((e,t)=>(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired){for(let e of this._gltf.extensionsRequired)if(!this._extensions.some(t=>t.name===e&&t.enabled))throw this.parent.extensionOptions[e]?.enabled===!1?Error(`Required extension ${e} is disabled`):Error(`Required extension ${e} is not available`)}}_createRootNode(){if(this._parent.customRootNode!==void 0)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:this._rootBabylonMesh===null?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;let t=new K(`__root__`,this._babylonScene);this._rootBabylonMesh=t,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);let n={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case o8.AUTO:this._babylonScene.useRightHandedSystem||(n.rotation=[0,1,0,0],n.scale=[1,1,-1],e._LoadTransform(n,this._rootBabylonMesh));break;case o8.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw Error(`Invalid coordinate system mode (${this._parent.coordinateSystemMode})`)}return this._parent.onMeshLoadedObservable.notifyObservers(t),n}loadSceneAsync(e,t){let n=this._extensionsLoadSceneAsync(e,t);if(n)return n;let r=[];if(this.logOpen(`${e} ${t.name||``}`),t.nodes)for(let n of t.nodes){let t=F8.Get(`${e}/nodes/${n}`,this._gltf.nodes,n);r.push(this.loadNodeAsync(`/nodes/${t.index}`,t,e=>{e.parent=this._rootBabylonMesh}))}for(let e of this._postSceneLoadActions)e();return r.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(r).then(()=>{})}_forEachPrimitive(e,t){if(e._primitiveBabylonMeshes)for(let n of e._primitiveBabylonMeshes)t(n)}_getGeometries(){let e=[],t=this._gltf.nodes;if(t)for(let n of t)this._forEachPrimitive(n,t=>{let n=t.geometry;n&&e.indexOf(n)===-1&&e.push(n)});return e}_getMeshes(){let e=[];this._rootBabylonMesh instanceof Yc&&e.push(this._rootBabylonMesh);let t=this._gltf.nodes;if(t)for(let n of t)this._forEachPrimitive(n,t=>{e.push(t)});return e}_getTransformNodes(){let e=[],t=this._gltf.nodes;if(t)for(let n of t)n._babylonTransformNode&&n._babylonTransformNode.getClassName()===`TransformNode`&&e.push(n._babylonTransformNode),n._babylonTransformNodeForSkin&&e.push(n._babylonTransformNodeForSkin);return e}_getSkeletons(){let e=[],t=this._gltf.skins;if(t)for(let n of t)n._data&&e.push(n._data.babylonSkeleton);return e}_getAnimationGroups(){let e=[],t=this._gltf.animations;if(t)for(let n of t)n._babylonAnimationGroup&&e.push(n._babylonAnimationGroup);return e}_startAnimations(){switch(this._parent.animationStartMode){case s8.NONE:break;case s8.FIRST:{let e=this._getAnimationGroups();e.length!==0&&e[0].start(!0);break}case s8.ALL:{let e=this._getAnimationGroups();for(let t of e)t.start(!0);break}default:F.Error(`Invalid animation start mode (${this._parent.animationStartMode})`);return}}loadNodeAsync(t,n,r=()=>{}){let i=this._extensionsLoadNodeAsync(t,n,r);if(i)return i;if(n._babylonTransformNode)throw Error(`${t}: Invalid recursive node hierarchy`);let a=[];this.logOpen(`${t} ${n.name||``}`);let o=i=>{if(e.AddPointerMetadata(i,t),e._LoadTransform(n,i),n.camera!=null){let e=F8.Get(`${t}/camera`,this._gltf.cameras,n.camera);a.push(this.loadCameraAsync(`/cameras/${e.index}`,e,e=>{e.parent=i,this._babylonScene.useRightHandedSystem||(i.scaling.x=-1)}))}if(n.children)for(let e of n.children){let n=F8.Get(`${t}/children/${e}`,this._gltf.nodes,e);a.push(this.loadNodeAsync(`/nodes/${n.index}`,n,e=>{e.parent=i}))}r(i)},s=n.mesh!=null,c=this._parent.loadSkins&&n.skin!=null;if(!s||c){let e=n.name||`node${n.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;let t=new wc(e,this._babylonScene);t._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n.mesh==null?n._babylonTransformNode=t:n._babylonTransformNodeForSkin=t,o(t)}if(s)if(c){let e=F8.Get(`${t}/mesh`,this._gltf.meshes,n.mesh);a.push(this._loadMeshAsync(`/meshes/${e.index}`,n,e,e=>{let r=n._babylonTransformNodeForSkin;e.metadata=Dq(r.metadata,e.metadata||{});let i=F8.Get(`${t}/skin`,this._gltf.skins,n.skin);a.push(this._loadSkinAsync(`/skins/${i.index}`,n,i,t=>{this._forEachPrimitive(n,e=>{e.skeleton=t}),this._postSceneLoadActions.push(()=>{if(i.skeleton!=null){let t=F8.Get(`/skins/${i.index}/skeleton`,this._gltf.nodes,i.skeleton).parent;n.index===t.index?e.parent=r.parent:e.parent=t._babylonTransformNode}else e.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:r,skinnedNode:e})})}))}))}else{let e=F8.Get(`${t}/mesh`,this._gltf.meshes,n.mesh);a.push(this._loadMeshAsync(`/meshes/${e.index}`,n,e,o))}return this.logClose(),Promise.all(a).then(()=>(this._forEachPrimitive(n,e=>{let t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),n._babylonTransformNode))}_loadMeshAsync(e,t,n,r){let i=n.primitives;if(!i||!i.length)throw Error(`${e}: Primitives are missing`);i[0].index??F8.Assign(i);let a=[];this.logOpen(`${e} ${n.name||``}`);let o=t.name||`node${t.index}`;if(i.length===1){let r=n.primitives[0];a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${r.index}`,o,t,n,r,e=>{t._babylonTransformNode=e,t._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,t._babylonTransformNode=new wc(o,this._babylonScene),t._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._primitiveBabylonMeshes=[];for(let r of i)a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${r.index}`,`${o}_primitive${r.index}`,t,n,r,e=>{e.parent=t._babylonTransformNode,t._primitiveBabylonMeshes.push(e)}))}return r(t._babylonTransformNode),this.logClose(),Promise.all(a).then(()=>t._babylonTransformNode)}_loadMeshPrimitiveAsync(t,n,r,i,a,o){let s=this._extensionsLoadMeshPrimitiveAsync(t,n,r,i,a,o);if(s)return s;this.logOpen(`${t}`);let c=this._disableInstancedMesh===0&&this._parent.createInstances&&r.skin==null&&!i.primitives[0].targets,l,u;if(c&&a._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,l=a._instanceData.babylonSourceMesh.createInstance(n),l._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,u=a._instanceData.promise;else{let o=[];this._babylonScene._blockEntityCollection=!!this._assetContainer;let s=new K(n,this._babylonScene);if(s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.sideOrientation=this._babylonScene.useRightHandedSystem?Zn.CounterClockWiseSideOrientation:Zn.ClockWiseSideOrientation,this._createMorphTargets(t,r,i,a,s),o.push(this._loadVertexDataAsync(t,a,s).then(async e=>await this._loadMorphTargetsAsync(t,a,s,e).then(()=>{this._disposed||(this._babylonScene._blockEntityCollection=!!this._assetContainer,e.applyToMesh(s),e._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1)}))),!this.parent.skipMaterials){let n=e._GetDrawMode(t,a.mode);if(a.material==null){let e=this._defaultBabylonMaterialData[n];e||(e=this._createDefaultMaterial(`__GLTFLoader._default`,n,this._getDefaultImpl()),this._parent.onMaterialLoadedObservable.notifyObservers(e),this._defaultBabylonMaterialData[n]=e),s.material=e}else{let e=F8.Get(`${t}/material`,this._gltf.materials,a.material);o.push(this._loadMaterialAsync(`/materials/${e.index}`,e,s,n,e=>{s.material=e}))}}u=Promise.all(o),c&&(a._instanceData={babylonSourceMesh:s,promise:u}),l=s}return e.AddPointerMetadata(l,t),this._parent.onMeshLoadedObservable.notifyObservers(l),o(l),this.logClose(),u.then(()=>l)}_loadVertexDataAsync(e,t,n){let r=this._extensionsLoadVertexDataAsync(e,t,n);if(r)return r;let i=t.attributes;if(!i)throw Error(`${e}: Attributes are missing`);let a=[],o=new il(n.name,this._babylonScene);if(t.indices==null)n.isUnIndexed=!0;else{let n=F8.Get(`${e}/indices`,this._gltf.accessors,t.indices);a.push(this._loadIndicesAccessorAsync(`/accessors/${n.index}`,n).then(e=>{o.setIndices(e)}))}let s=(t,r,s)=>{if(i[t]==null)return;n._delayInfo=n._delayInfo||[],n._delayInfo.indexOf(r)===-1&&n._delayInfo.push(r);let c=F8.Get(`${e}/attributes/${t}`,this._gltf.accessors,i[t]);a.push(this._loadVertexAccessorAsync(`/accessors/${c.index}`,c,r).then(e=>{if(e.getKind()===H.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!n.skeleton){let e=r$e(c);e&&(o._boundingInfo=e,o.useBoundingInfoFromGeometry=!0)}o.setVerticesBuffer(e,c.count)})),r==H.MatricesIndicesExtraKind&&(n.numBoneInfluencers=8),s&&s(c)};return s(`POSITION`,H.PositionKind),s(`NORMAL`,H.NormalKind),s(`TANGENT`,H.TangentKind),s(`TEXCOORD_0`,H.UVKind),s(`TEXCOORD_1`,H.UV2Kind),s(`TEXCOORD_2`,H.UV3Kind),s(`TEXCOORD_3`,H.UV4Kind),s(`TEXCOORD_4`,H.UV5Kind),s(`TEXCOORD_5`,H.UV6Kind),s(`JOINTS_0`,H.MatricesIndicesKind),s(`WEIGHTS_0`,H.MatricesWeightsKind),s(`JOINTS_1`,H.MatricesIndicesExtraKind),s(`WEIGHTS_1`,H.MatricesWeightsExtraKind),s(`COLOR_0`,H.ColorKind,e=>{e.type===`VEC4`&&(n.hasVertexAlpha=!0)}),Promise.all(a).then(()=>o)}_createMorphTargets(e,t,n,r,i){if(!r.targets||!this._parent.loadMorphTargets)return;if(t._numMorphTargets==null)t._numMorphTargets=r.targets.length;else if(r.targets.length!==t._numMorphTargets)throw Error(`${e}: Primitives do not have the same number of targets`);let a=n.extras?n.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,i.morphTargetManager=new hj(this._babylonScene),i.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,i.morphTargetManager.areUpdatesFrozen=!0;for(let e=0;e{a.areUpdatesFrozen=!1,this._parent.useMaxMorphTargetInfluencers&&(a.isUsingTextureForTargets||a.numTargets<=hj.MaxActiveMorphTargetsInVertexAttributeMode)&&(a.optimizeInfluencers=!1,a.numMaxInfluencers=a.numTargets)})}async _loadMorphTargetVertexDataAsync(e,t,n,r){let i=[],a=(r,a,o)=>{if(n[r]==null)return;let s=t.getVertexBuffer(a);if(!s)return;let c=F8.Get(`${e}/${r}`,this._gltf.accessors,n[r]);i.push(this._loadFloatAccessorAsync(`/accessors/${c.index}`,c).then(e=>{o(s,e)}))};return a(`POSITION`,H.PositionKind,(e,t)=>{let n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),r.setPositions(n)}),a(`NORMAL`,H.NormalKind,(e,t)=>{let n=new Float32Array(t.length);e.forEach(n.length,(e,r)=>{n[r]=t[r]+e}),r.setNormals(n)}),a(`TANGENT`,H.TangentKind,(e,t)=>{let n=new Float32Array(t.length/3*4),i=0;e.forEach(t.length/3*4,(e,r)=>{(r+1)%4!=0&&(n[i]=t[i]+e,i++)}),r.setTangents(n)}),a(`TEXCOORD_0`,H.UVKind,(e,t)=>{let n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),r.setUVs(n)}),a(`TEXCOORD_1`,H.UV2Kind,(e,t)=>{let n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),r.setUV2s(n)}),a(`COLOR_0`,H.ColorKind,(t,n)=>{let i=null,a=t.getSize();if(a===3){i=new Float32Array(n.length/3*4),t.forEach(n.length,(e,t)=>{let r=Math.floor(t/3),a=t%3;i[4*r+a]=n[3*r+a]+e});for(let e=0;e{i[t]=n[t]+e});else throw Error(`${e}: Invalid number of components (${a}) for COLOR_0 attribute`);r.setColors(i)}),await Promise.all(i).then(()=>{})}static _LoadTransform(e,t){if(e.skin!=null)return;let n=j.Zero(),r=A.Identity(),i=j.One();e.matrix?M.FromArray(e.matrix).decompose(i,r,n):(e.translation&&(n=j.FromArray(e.translation)),e.rotation&&(r=A.FromArray(e.rotation)),e.scale&&(i=j.FromArray(e.scale))),t.position=n,t.rotationQuaternion=r,t.scaling=i}_loadSkinAsync(e,t,n,r){if(!this._parent.loadSkins)return Promise.resolve();let i=this._extensionsLoadSkinAsync(e,t,n);if(i)return i;if(n._data)return r(n._data.babylonSkeleton),n._data.promise;let a=`skeleton${n.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;let o=new vd(n.name||a,a,this._babylonScene);o._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,n,o);let s=this._loadSkinInverseBindMatricesDataAsync(e,n).then(e=>{this._updateBoneMatrices(o,e)});return n._data={babylonSkeleton:o,promise:s},r(o),s}_loadBones(e,t,n){if(t.skeleton==null||this._parent.alwaysComputeSkeletonRootNode){let n=this._findSkeletonRootNode(`${e}/joints`,t.joints);if(n)if(t.skeleton===void 0)t.skeleton=n.index;else{let r=(e,t)=>{for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1},i=F8.Get(`${e}/skeleton`,this._gltf.nodes,t.skeleton);i!==n&&!r(i,n)&&(F.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),t.skeleton=n.index)}else F.Warn(`${e}: Failed to find common root`)}let r={};for(let i of t.joints){let a=F8.Get(`${e}/joints/${i}`,this._gltf.nodes,i);this._loadBone(a,t,n,r)}}_findSkeletonRootNode(e,t){if(t.length===0)return null;let n={};for(let r of t){let t=[],i=F8.Get(`${e}/${r}`,this._gltf.nodes,r);for(;i.index!==-1;)t.unshift(i),i=i.parent;n[r]=t}let r=null;for(let e=0;;++e){let i=n[t[0]];if(e>=i.length)return r;let a=i[e];for(let o=1;o=i.length||a!==i[e])return r;r=a}}_loadBone(e,t,n,r){e._isJoint=!0;let i=r[e.index];if(i)return i;let a=null;e.index!==t.skeleton&&(e.parent&&e.parent.index!==-1?a=this._loadBone(e.parent,t,n,r):t.skeleton!==void 0&&F.Warn(`/skins/${t.index}/skeleton: Skeleton node is not a common root`));let o=t.joints.indexOf(e.index);return i=new zs(e.name||`joint${e.index}`,n,a,this._getNodeMatrix(e),null,null,o),r[e.index]=i,this._postSceneLoadActions.push(()=>{i.linkTransformNode(e._babylonTransformNode)}),i}_loadSkinInverseBindMatricesDataAsync(e,t){if(t.inverseBindMatrices==null)return Promise.resolve(null);let n=F8.Get(`${e}/inverseBindMatrices`,this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync(`/accessors/${n.index}`,n)}_updateBoneMatrices(e,t){for(let n of e.bones){let e=M.Identity(),r=n._index;t&&r!==-1&&(M.FromArrayToRef(t,r*16,e),e.invertToRef(e));let i=n.getParent();i&&e.multiplyToRef(i.getAbsoluteInverseBindMatrix(),e),n.updateMatrix(e,!1,!1),n._updateAbsoluteBindMatrices(void 0,!1)}}_getNodeMatrix(e){return e.matrix?M.FromArray(e.matrix):M.Compose(e.scale?j.FromArray(e.scale):j.One(),e.rotation?A.FromArray(e.rotation):A.Identity(),e.translation?j.FromArray(e.translation):j.Zero())}loadCameraAsync(t,n,r=()=>{}){let i=this._extensionsLoadCameraAsync(t,n,r);if(i)return i;let a=[];this.logOpen(`${t} ${n.name||``}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;let o=new mh(n.name||`camera${n.index}`,j.Zero(),this._babylonScene,!1);switch(o._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._babylonCamera=o,o.setTarget(new j(0,0,-1)),n.type){case`perspective`:{let e=n.perspective;if(!e)throw Error(`${t}: Camera perspective properties are missing`);o.fov=e.yfov,o.minZ=e.znear,o.maxZ=e.zfar||0;break}case`orthographic`:if(!n.orthographic)throw Error(`${t}: Camera orthographic properties are missing`);o.mode=el.ORTHOGRAPHIC_CAMERA,o.orthoLeft=-n.orthographic.xmag,o.orthoRight=n.orthographic.xmag,o.orthoBottom=-n.orthographic.ymag,o.orthoTop=n.orthographic.ymag,o.minZ=n.orthographic.znear,o.maxZ=n.orthographic.zfar;break;default:throw Error(`${t}: Invalid camera type (${n.type})`)}return e.AddPointerMetadata(o,t),this._parent.onCameraLoadedObservable.notifyObservers(o),r(o),this.logClose(),Promise.all(a).then(()=>o)}_loadAnimationsAsync(){this._parent._startPerformanceCounter(`Load animations`);let e=this._gltf.animations;if(!e)return Promise.resolve();let t=[];for(let n=0;n{e.targetedAnimations.length===0&&e.dispose()}))}return Promise.all(t).then(()=>{this._parent._endPerformanceCounter(`Load animations`)})}loadAnimationAsync(e,t){return this._parent._startPerformanceCounter(`Load animation`),this._extensionsLoadAnimationAsync(e,t)||t$e.value.then(({AnimationGroup:n})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;let r=new n(t.name||`animation${t.index}`,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=r;let i=[];F8.Assign(t.channels),F8.Assign(t.samplers);for(let n of t.channels)i.push(this._loadAnimationChannelAsync(`${e}/channels/${n.index}`,e,t,n,(e,t)=>{e.animations=e.animations||[],e.animations.push(t),r.addTargetedAnimation(t,e)}));return this._parent._endPerformanceCounter(`Load animation`),Promise.all(i).then(()=>(r.normalize(0),r))})}_loadAnimationChannelAsync(e,t,n,r,i){let a=this._extensionsLoadAnimationChannelAsync(e,t,n,r,i);if(a)return a;if(r.target.node==null)return Promise.resolve();let o=F8.Get(`${e}/target/node`,this._gltf.nodes,r.target.node),s=r.target.path,c=s===`weights`;return c&&!o._numMorphTargets||!c&&!o._babylonTransformNode||!this._parent.loadNodeAnimations&&!c&&!o._isJoint?Promise.resolve():n$e.value.then(()=>{let a;switch(s){case`translation`:a=M8(`/nodes/{}/translation`)?.interpolation;break;case`rotation`:a=M8(`/nodes/{}/rotation`)?.interpolation;break;case`scale`:a=M8(`/nodes/{}/scale`)?.interpolation;break;case`weights`:a=M8(`/nodes/{}/weights`)?.interpolation;break;default:throw Error(`${e}/target/path: Invalid value (${r.target.path})`)}if(!a)throw Error(`${e}/target/path: Could not find interpolation properties for target path (${r.target.path})`);let c={object:o,info:a};return this._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,c,i)})}_loadAnimationChannelFromTargetInfoAsync(e,t,n,r,i,a){let o=this.parent.targetFps,s=1/o,c=F8.Get(`${e}/sampler`,n.samplers,r.sampler);return this._loadAnimationSamplerAsync(`${t}/samplers/${r.sampler}`,c).then(e=>{let t=0,c=i.object,l=i.info;for(let i of l){let l=i.getStride(c),u=e.input,d=e.output,f=Array(u.length),p=0;switch(e.interpolation){case`STEP`:for(let e=0;e0){let e=`${n.name||`animation${n.index}`}_channel${r.index}_${t}`,s=i.buildAnimations(c,e,o,f);for(let e of s)t++,a(e.babylonAnimatable,e.babylonAnimation)}}})}_loadAnimationSamplerAsync(e,t){if(t._data)return t._data;let n=t.interpolation||`LINEAR`;switch(n){case`STEP`:case`LINEAR`:case`CUBICSPLINE`:break;default:throw Error(`${e}/interpolation: Invalid value (${t.interpolation})`)}let r=F8.Get(`${e}/input`,this._gltf.accessors,t.input),i=F8.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${r.index}`,r),this._loadFloatAccessorAsync(`/accessors/${i.index}`,i)]).then(([e,t])=>({input:e,interpolation:n,output:t})),t._data}loadBufferAsync(e,t,n,r){let i=this._extensionsLoadBufferAsync(e,t,n,r);if(i)return i;if(!t._data)if(t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{if(!this._bin)throw Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then(t=>{try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw Error(`${e}: ${t.message}`,{cause:t})}})}loadBufferViewAsync(e,t){let n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;let r=F8.Get(`${e}/buffer`,this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync(`/buffers/${r.index}`,r,t.byteOffset||0,t.byteLength),t._data}_loadAccessorAsync(t,n,r){if(n._data)return n._data;let i=e._GetNumComponents(t,n.type),a=i*an(n.componentType),o=i*n.count;if(n.bufferView==null)n._data=Promise.resolve(new r(o));else{let s=F8.Get(`${t}/bufferView`,this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync(`/bufferViews/${s.index}`,s).then(c=>{if(n.componentType===5126&&!n.normalized&&(!s.byteStride||s.byteStride===a))return e._GetTypedArray(t,n.componentType,c,n.byteOffset,o);{let e=new r(o);return tn(c,n.byteOffset||0,s.byteStride||a,i,n.componentType,e.length,n.normalized||!1,(t,n)=>{e[n]=t}),e}})}if(n.sparse){let o=n.sparse;n._data=n._data.then(s=>{let c=s,l=F8.Get(`${t}/sparse/indices/bufferView`,this._gltf.bufferViews,o.indices.bufferView),u=F8.Get(`${t}/sparse/values/bufferView`,this._gltf.bufferViews,o.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${l.index}`,l),this.loadBufferViewAsync(`/bufferViews/${u.index}`,u)]).then(([s,l])=>{let u=e._GetTypedArray(`${t}/sparse/indices`,o.indices.componentType,s,o.indices.byteOffset,o.count),d=i*o.count,f;if(n.componentType===5126&&!n.normalized)f=e._GetTypedArray(`${t}/sparse/values`,n.componentType,l,o.values.byteOffset,d);else{let s=e._GetTypedArray(`${t}/sparse/values`,n.componentType,l,o.values.byteOffset,d);f=new r(d),tn(s,0,a,i,n.componentType,f.length,n.normalized||!1,(e,t)=>{f[t]=e})}let p=0;for(let e=0;ee._GetTypedArray(t,n.componentType,r,n.byteOffset,n.count))}return n._data}_loadVertexBufferViewAsync(e){if(e._babylonBuffer)return e._babylonBuffer;let t=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync(`/bufferViews/${e.index}`,e).then(e=>new sn(t,e,!1)),e._babylonBuffer}_loadVertexAccessorAsync(t,n,r){if(n._babylonVertexBuffer?.[r])return n._babylonVertexBuffer[r];n._babylonVertexBuffer||={};let i=this._babylonScene.getEngine();if(n.sparse||n.bufferView==null)n._babylonVertexBuffer[r]=this._loadFloatAccessorAsync(t,n).then(e=>new H(i,e,r,!1));else{let a=F8.Get(`${t}/bufferView`,this._gltf.bufferViews,n.bufferView);n._babylonVertexBuffer[r]=this._loadVertexBufferViewAsync(a).then(o=>{let s=e._GetNumComponents(t,n.type);return new H(i,o,r,!1,void 0,a.byteStride,void 0,n.byteOffset,s,n.componentType,n.normalized,!0,void 0,!0)})}return n._babylonVertexBuffer[r]}_loadMaterialMetallicRoughnessPropertiesAsync(e,t,n){let r=[],i=this._getOrCreateMaterialAdapter(n);return t&&(t.baseColorFactor?(i.baseColor=P.FromArray(t.baseColorFactor),i.geometryOpacity=t.baseColorFactor[3]):i.baseColor=P.White(),i.baseMetalness=t.metallicFactor==null?1:t.metallicFactor,i.specularRoughness=t.roughnessFactor==null?1:t.roughnessFactor,t.baseColorTexture&&r.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,t.baseColorTexture,e=>{e.name=`${n.name} (Base Color)`,i.baseColorTexture=e})),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,t.metallicRoughnessTexture,e=>{e.name=`${n.name} (Metallic Roughness)`,i.baseMetalnessTexture=e,i.specularRoughnessTexture=e})),i.useRoughnessFromMetallicTextureGreen=!0,i.useMetallicFromMetallicTextureBlue=!0)),Promise.all(r).then(()=>{})}_loadMaterialAsync(t,n,r,i,a=()=>{}){let o=this._extensionsLoadMaterialAsync(t,n,r,i,a);if(o)return o;n._data=n._data||{};let s=n._data[i];if(!s){this.logOpen(`${t} ${n.name||``}`);let r=this.createMaterial(t,n,i);s={babylonMaterial:r,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(t,n,r)},n._data[i]=s,e.AddPointerMetadata(r,t),this._parent.onMaterialLoadedObservable.notifyObservers(r),this.logClose()}return r&&(s.babylonMeshes.push(r),r.onDisposeObservable.addOnce(()=>{let e=s.babylonMeshes.indexOf(r);e!==-1&&s.babylonMeshes.splice(e,1)})),a(s.babylonMaterial),s.promise.then(()=>s.babylonMaterial)}_selectImplForGltfMaterial(e){if(this.parent.useOpenPBR||e.extensions?.KHR_materials_openpbr){let e=this._pbrMaterialImpls.get(`openpbr`);if(e)return e}let t=this._pbrMaterialImpls.get(`pbr`);if(t)return t;throw Error(`No PBR material implementation loaded`)}_getDefaultImpl(){if(this.parent.useOpenPBR){let e=this._pbrMaterialImpls.get(`openpbr`);if(e)return e}let e=this._pbrMaterialImpls.get(`pbr`)??this._pbrMaterialImpls.values().next().value;if(e)return e;throw Error(`No PBR material implementation loaded`)}_createDefaultMaterial(e,t,n){this._babylonScene._blockEntityCollection=!!this._assetContainer;let r=new n.materialClass(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r.fillMode=t,r.transparencyMode=n.materialClass.MATERIAL_OPAQUE;let i=this._getOrCreateMaterialAdapter(r);return i.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,i.baseMetalness=1,i.specularRoughness=1,r}createMaterial(e,t,n){let r=this._extensionsCreateMaterial(e,t,n);if(r)return r;let i=t.name||`material${t.index}`;return this._createDefaultMaterial(i,n,this._selectImplForGltfMaterial(t))}loadMaterialPropertiesAsync(e,t,n){let r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;let i=[];return i.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&i.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(i).then(()=>{})}loadMaterialBasePropertiesAsync(e,t,n){let r=[],i=this._getOrCreateMaterialAdapter(n);i.emissionColor=t.emissiveFactor?P.FromArray(t.emissiveFactor):new P(0,0,0),t.doubleSided&&(i.backFaceCulling=!1,i.twoSidedLighting=!0),t.normalTexture&&(t.normalTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/normalTexture`,t.normalTexture,e=>{e.name=`${n.name} (Normal)`,i.geometryNormalTexture=e,t.normalTexture?.scale!=null&&(e.level=t.normalTexture.scale)})),i.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));let a,o=1,s;return t.occlusionTexture&&(t.occlusionTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/occlusionTexture`,t.occlusionTexture,e=>{e.name=`${n.name} (Occlusion)`,a=e})),t.occlusionTexture.strength!=null&&(o=t.occlusionTexture.strength)),t.emissiveTexture&&r.push(this.loadTextureInfoAsync(`${e}/emissiveTexture`,t.emissiveTexture,e=>{e.name=`${n.name} (Emissive)`,s=e})),Promise.all(r).then(()=>{a&&(i.ambientOcclusionTexture=a,i.ambientOcclusionTextureStrength=o),s&&(i.emissionColorTexture=s)})}loadMaterialAlphaProperties(e,t,n){if(this._pbrMaterialImpls.size===0)throw Error(`${e}: Material type not supported`);let r=this._getOrCreateMaterialAdapter(n),i=r.baseColorTexture;switch(t.alphaMode||`OPAQUE`){case`OPAQUE`:n.transparencyMode=Zn.MATERIAL_OPAQUE,n.alpha=1;break;case`MASK`:n.transparencyMode=Zn.MATERIAL_ALPHATEST,r.alphaCutOff=t.alphaCutoff==null?.5:t.alphaCutoff,i&&(i.hasAlpha=!0,r.useAlphaFromBaseColorTexture=!0);break;case`BLEND`:n.transparencyMode=Zn.MATERIAL_ALPHABLEND,i&&(i.hasAlpha=!0,r.useAlphaFromBaseColorTexture=!0);break;default:throw Error(`${e}/alphaMode: Invalid value (${t.alphaMode})`)}}loadTextureInfoAsync(t,n,r=()=>{}){let i=this._extensionsLoadTextureInfoAsync(t,n,r);if(i)return i;if(this.logOpen(`${t}`),n.texCoord>=6)throw Error(`${t}/texCoord: Invalid value (${n.texCoord})`);let a=F8.Get(`${t}/index`,this._gltf.textures,n.index);a._textureInfo=n;let o=this._loadTextureAsync(`/textures/${n.index}`,a,i=>{i.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(i,t),this._parent.onTextureLoadedObservable.notifyObservers(i),r(i)});return this.logClose(),o}_loadTextureAsync(t,n,r=()=>{}){let i=this._extensionsLoadTextureAsync(t,n,r);if(i)return i;this.logOpen(`${t} ${n.name||``}`);let a=n.sampler==null?e.DefaultSampler:F8.Get(`${t}/sampler`,this._gltf.samplers,n.sampler),o=F8.Get(`${t}/source`,this._gltf.images,n.source),s=this._createTextureAsync(t,a,o,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),s}_createTextureAsync(e,t,n,r=()=>{},i,a){let o=this._loadSampler(`/samplers/${t.index}`,t),s=[],c=new YX;this._babylonScene._blockEntityCollection=!!this._assetContainer;let l={noMipmap:o.noMipMaps,invertY:!1,samplingMode:o.samplingMode,onLoad:()=>{this._disposed||c.resolve()},onError:(t,n)=>{this._disposed||c.reject(Error(`${e}: ${n&&n.message?n.message:t||`Failed to load texture`}`))},mimeType:n.mimeType??ft(n.uri??``),loaderOptions:i,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},u=new W(null,this._babylonScene,l);u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.push(c.promise);let d=n.uri&&!st(n.uri)?n.uri:void 0,f=d??`${this._fileName}#image${n.index}`;return s.push(this.loadImageAsync(`/images/${n.index}`,n).then(e=>{let t=`data:${this._uniqueRootUrl}${f}`;u.updateURL(t,e);let r=u.getInternalTexture();r&&(r.label=n.name)})),u.wrapU=o.wrapU,u.wrapV=o.wrapV,r(u),this._parent.useGltfTextureNames&&(u.name=n.name||d||`image${n.index}`),Promise.all(s).then(()=>u)}_loadSampler(t,n){return n._data||={noMipMaps:n.minFilter===9728||n.minFilter===9729,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode(`${t}/wrapS`,n.wrapS),wrapV:e._GetTextureWrapMode(`${t}/wrapT`,n.wrapT)},n._data}loadImageAsync(e,t){if(!t._data){if(this.logOpen(`${e} ${t.name||``}`),t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{let n=F8.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${n.index}`,n)}this.logClose()}return t._data}loadUriAsync(t,n,r){let i=this._extensionsLoadUriAsync(t,n,r);if(i)return i;if(!e._ValidateUri(r))throw Error(`${t}: '${r}' is invalid`);if(st(r)){let e=new Uint8Array(mt(r));return this.log(`${t}: Decoded ${r.substring(0,64)}... (${e.length} bytes)`),Promise.resolve(e)}return this.log(`${t}: Loading ${r}`),this._parent.preprocessUrlAsync(this._rootUrl+r).then(e=>new Promise((n,i)=>{this._parent._loadFile(this._babylonScene,e,e=>{this._disposed||(this.log(`${t}: Loaded ${r} (${e.byteLength} bytes)`),n(new Uint8Array(e)))},!0,e=>{i(new ut(`${t}: Failed to load '${r}'${e?`: `+e.status+` `+e.statusText:``}`,e))})}))}static AddPointerMetadata(e,t){e.metadata=e.metadata||{};let n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)}static _GetTextureWrapMode(e,t){switch(t??=10497,t){case 33071:return W.CLAMP_ADDRESSMODE;case 33648:return W.MIRROR_ADDRESSMODE;case 10497:return W.WRAP_ADDRESSMODE;default:return F.Warn(`${e}: Invalid value (${t})`),W.WRAP_ADDRESSMODE}}static _GetTextureSamplingMode(e,t){let n=t.magFilter==null?9729:t.magFilter,r=t.minFilter==null?9987:t.minFilter;if(n===9729)switch(r){case 9728:return W.LINEAR_NEAREST;case 9729:return W.LINEAR_LINEAR;case 9984:return W.LINEAR_NEAREST_MIPNEAREST;case 9985:return W.LINEAR_LINEAR_MIPNEAREST;case 9986:return W.LINEAR_NEAREST_MIPLINEAR;case 9987:return W.LINEAR_LINEAR_MIPLINEAR;default:return F.Warn(`${e}/minFilter: Invalid value (${r})`),W.LINEAR_LINEAR_MIPLINEAR}else switch(n!==9728&&F.Warn(`${e}/magFilter: Invalid value (${n})`),r){case 9728:return W.NEAREST_NEAREST;case 9729:return W.NEAREST_LINEAR;case 9984:return W.NEAREST_NEAREST_MIPNEAREST;case 9985:return W.NEAREST_LINEAR_MIPNEAREST;case 9986:return W.NEAREST_NEAREST_MIPLINEAR;case 9987:return W.NEAREST_LINEAR_MIPLINEAR;default:return F.Warn(`${e}/minFilter: Invalid value (${r})`),W.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,t){try{return Dt(t)}catch(t){throw Error(`${e}: ${t.message}`,{cause:t})}}static _GetTypedArray(t,n,r,i,a){let o=r.buffer;i=r.byteOffset+(i||0);let s=e._GetTypedArrayConstructor(`${t}/componentType`,n),c=an(n);return i%c===0?new s(o,i,a):(F.Warn(`${t}: Copying buffer as byte offset (${i}) is not a multiple of component type byte length (${c})`),new s(o.slice(i,i+a*c),0))}static _GetNumComponents(e,t){switch(t){case`SCALAR`:return 1;case`VEC2`:return 2;case`VEC3`:return 3;case`VEC4`:return 4;case`MAT2`:return 4;case`MAT3`:return 9;case`MAT4`:return 16}throw Error(`${e}: Invalid type (${t})`)}static _ValidateUri(e){return ge.IsBase64(e)||e.indexOf(`..`)===-1}static _GetDrawMode(e,t){switch(t??=4,t){case 0:return Zn.PointListDrawMode;case 1:return Zn.LineListDrawMode;case 2:return Zn.LineLoopDrawMode;case 3:return Zn.LineStripDrawMode;case 4:return Zn.TriangleFillMode;case 5:return Zn.TriangleStripDrawMode;case 6:return Zn.TriangleFanDrawMode}throw Error(`${e}: Invalid mesh primitive mode (${t})`)}_compileMaterialsAsync(){this._parent._startPerformanceCounter(`Compile materials`);let e=[];if(this._gltf.materials){for(let t of this._gltf.materials)if(t._data)for(let n in t._data){let r=t._data[n];for(let t of r.babylonMeshes){t.computeWorldMatrix(!0);let n=r.babylonMaterial;e.push(n.forceCompilationAsync(t)),e.push(n.forceCompilationAsync(t,{useInstances:!0})),this._parent.useClipPlane&&(e.push(n.forceCompilationAsync(t,{clipPlane:!0})),e.push(n.forceCompilationAsync(t,{clipPlane:!0,useInstances:!0})))}}}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter(`Compile materials`)})}_compileShadowGeneratorsAsync(){this._parent._startPerformanceCounter(`Compile shadow generators`);let e=[],t=this._babylonScene.lights;for(let n of t){let t=n.getShadowGenerator();t&&e.push(t.forceCompilationAsync())}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter(`Compile shadow generators`)})}_forEachExtensions(e){for(let t of this._extensions)t.enabled&&e(t)}_applyExtensions(e,t,n){for(let r of this._extensions)if(r.enabled){let i=`${r.name}.${t}`,a=e;a._activeLoaderExtensionFunctions=a._activeLoaderExtensionFunctions||{};let o=a._activeLoaderExtensionFunctions;if(!o[i]){o[i]=!0;try{let e=n(r);if(e)return e}finally{delete o[i]}}}return null}_extensionsOnLoading(){this._forEachExtensions(e=>e.onLoading&&e.onLoading())}_extensionsOnReady(){this._forEachExtensions(e=>e.onReady&&e.onReady())}_extensionsLoadSceneAsync(e,t){return this._applyExtensions(t,`loadScene`,n=>n.loadSceneAsync&&n.loadSceneAsync(e,t))}_extensionsLoadNodeAsync(e,t,n){return this._applyExtensions(t,`loadNode`,r=>r.loadNodeAsync&&r.loadNodeAsync(e,t,n))}_extensionsLoadCameraAsync(e,t,n){return this._applyExtensions(t,`loadCamera`,r=>r.loadCameraAsync&&r.loadCameraAsync(e,t,n))}_extensionsLoadVertexDataAsync(e,t,n){return this._applyExtensions(t,`loadVertexData`,r=>r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n))}_extensionsLoadMeshPrimitiveAsync(e,t,n,r,i,a){return this._applyExtensions(i,`loadMeshPrimitive`,o=>o._loadMeshPrimitiveAsync&&o._loadMeshPrimitiveAsync(e,t,n,r,i,a))}_extensionsLoadMaterialAsync(e,t,n,r,i){return this._applyExtensions(t,`loadMaterial`,a=>a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,i))}_extensionsCreateMaterial(e,t,n){return this._applyExtensions(t,`createMaterial`,r=>r.createMaterial&&r.createMaterial(e,t,n))}_extensionsLoadMaterialPropertiesAsync(e,t,n){return this._applyExtensions(t,`loadMaterialProperties`,r=>r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n))}_extensionsLoadTextureInfoAsync(e,t,n){return this._applyExtensions(t,`loadTextureInfo`,r=>r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n))}_extensionsLoadTextureAsync(e,t,n){return this._applyExtensions(t,`loadTexture`,r=>r._loadTextureAsync&&r._loadTextureAsync(e,t,n))}_extensionsLoadAnimationAsync(e,t){return this._applyExtensions(t,`loadAnimation`,n=>n.loadAnimationAsync&&n.loadAnimationAsync(e,t))}_extensionsLoadAnimationChannelAsync(e,t,n,r,i){return this._applyExtensions(n,`loadAnimationChannel`,a=>a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,n,r,i))}_extensionsLoadSkinAsync(e,t,n){return this._applyExtensions(n,`loadSkin`,r=>r._loadSkinAsync&&r._loadSkinAsync(e,t,n))}_extensionsLoadUriAsync(e,t,n){return this._applyExtensions(t,`loadUri`,r=>r._loadUriAsync&&r._loadUriAsync(e,t,n))}_extensionsLoadBufferViewAsync(e,t){return this._applyExtensions(t,`loadBufferView`,n=>n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t))}_extensionsLoadBufferAsync(e,t,n,r){return this._applyExtensions(t,`loadBuffer`,i=>i.loadBufferAsync&&i.loadBufferAsync(e,t,n,r))}static LoadExtensionAsync(e,t,n,r){if(!t.extensions)return null;let i=t.extensions[n];return i?r(`${e}/extensions/${n}`,i):null}static LoadExtraAsync(e,t,n,r){if(!t.extras)return null;let i=t.extras[n];return i?r(`${e}/extras/${n}`,i):null}isExtensionUsed(e){return!!this._gltf.extensionsUsed&&this._gltf.extensionsUsed.indexOf(e)!==-1}logOpen(e){this._parent._logOpen(e)}logClose(){this._parent._logClose()}log(e){this._parent._log(e)}startPerformanceCounter(e){this._parent._startPerformanceCounter(e)}endPerformanceCounter(e){this._parent._endPerformanceCounter(e)}};I8.DefaultSampler={index:-1};var i$e=!1;function a$e(){i$e||(i$e=!0,l8._CreateGLTF2Loader=e=>new I8(e))}a$e(),pQe();var o$e=s({AnimationPropertyInfo:()=>R8,TransformNodeAnimationPropertyInfo:()=>z8,WeightAnimationPropertyInfo:()=>l$e,getQuaternion:()=>s$e,getVector3:()=>L8,getWeights:()=>c$e});function L8(e,t,n,r){return j.FromArray(t,n).scaleInPlace(r)}function s$e(e,t,n,r){return A.FromArray(t,n).scaleInPlace(r)}function c$e(e,t,n,r){let i=Array(e._numMorphTargets);for(let e=0;e({frame:e.frame,inTangent:e.inTangent?e.inTangent[a]:void 0,value:e.value[a],outTangent:e.outTangent?e.outTangent[a]:void 0,interpolation:e.interpolation})),!0),e._primitiveBabylonMeshes){for(let t of e._primitiveBabylonMeshes)if(t.morphTargetManager){let e=t.morphTargetManager.getTarget(a),n=o.clone();e.animations.push(n),i.push({babylonAnimatable:e,babylonAnimation:n})}}}return i}};N8(`/nodes/{}/translation`,[new z8(Ne.ANIMATIONTYPE_VECTOR3,`position`,L8,()=>3)]),N8(`/nodes/{}/rotation`,[new z8(Ne.ANIMATIONTYPE_QUATERNION,`rotationQuaternion`,s$e,()=>4)]),N8(`/nodes/{}/scale`,[new z8(Ne.ANIMATIONTYPE_VECTOR3,`scaling`,L8,()=>3)]),N8(`/nodes/{}/weights`,[new l$e(Ne.ANIMATIONTYPE_FLOAT,`influence`,c$e,e=>e._numMorphTargets)]);var u$e=s({OpenPBRMaterialLoadingAdapter:()=>d$e}),d$e=class{constructor(e){this._specWorkflow=!1,this._diffuseTransmissionTint=P.White(),this._diffuseTransmissionTintTexture=null,this._material=e}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material._useAlphaFromBaseColorTexture=e}get useAlphaFromBaseColorTexture(){return this._material._useAlphaFromBaseColorTexture}get transparencyAsAlphaCoverage(){return!1}set transparencyAsAlphaCoverage(e){}set baseColor(e){this._material.baseColor=e}get baseColor(){return this._material.baseColor}set baseColorTexture(e){this._material.baseColorTexture=e}get baseColorTexture(){return this._material.baseColorTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e}get baseDiffuseRoughness(){return this._material.baseDiffuseRoughness}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.baseMetalness=e}get baseMetalness(){return this._material.baseMetalness}set baseMetalnessTexture(e){this._material.baseMetalnessTexture=e}get baseMetalnessTexture(){return this._material.baseMetalnessTexture}set useRoughnessFromMetallicTextureGreen(e){this._material._useRoughnessFromMetallicTextureGreen=e}set useMetallicFromMetallicTextureBlue(e){this._material._useMetallicFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){}configureSpecularGlossiness(){this._specWorkflow=!0}set specularWeight(e){this._material.specularWeight=e}get specularWeight(){return this._material.specularWeight}set specularWeightTexture(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e}get specularWeightTexture(){return this._material.specularWeightTexture}set specularColor(e){this._material.specularColor=e}get specularColor(){return this._material.specularColor}set specularColorTexture(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)}get specularColorTexture(){return this._material.specularColorTexture}set specularRoughness(e){this._material.specularRoughness=e}get specularRoughness(){return this._material.specularRoughness}set specularRoughnessTexture(e){this._material.specularRoughnessTexture=e}get specularRoughnessTexture(){return this._material.specularRoughnessTexture}set specularIor(e){this._material.specularIor=e}get specularIor(){return this._material.specularIor}set glossiness(e){this._material.specularRoughness=Math.max(1-e,0)}get glossiness(){return 1-this._material.specularRoughness}set emissionColor(e){this._material.emissionColor=e}get emissionColor(){return this._material.emissionColor}set emissionLuminance(e){this._material.emissionLuminance=e}get emissionLuminance(){return this._material.emissionLuminance}set emissionColorTexture(e){this._material.emissionColorTexture=e}get emissionColorTexture(){return this._material.emissionColorTexture}set ambientOcclusionTexture(e){this._material.ambientOcclusionTexture=e}get ambientOcclusionTexture(){return this._material.ambientOcclusionTexture}set ambientOcclusionTextureStrength(e){let t=this._material.ambientOcclusionTexture;t&&(t.level=e)}get ambientOcclusionTextureStrength(){return this._material.ambientOcclusionTexture?.level??1}configureCoat(){}set coatWeight(e){this._material.coatWeight=e}get coatWeight(){return this._material.coatWeight}set coatWeightTexture(e){this._material.coatWeightTexture=e}get coatWeightTexture(){return this._material.coatWeightTexture}set coatColor(e){this._material.coatColor=e}get coatColor(){return this._material.coatColor}set coatColorTexture(e){this._material.coatColorTexture=e}set coatRoughness(e){this._material.coatRoughness=e}get coatRoughness(){return this._material.coatRoughness}set coatRoughnessTexture(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)}get coatRoughnessTexture(){return this._material.coatRoughnessTexture}set coatIor(e){this._material.coatIor=e}get coatIor(){return this._material.coatIor}set coatDarkening(e){this._material.coatDarkening=e}get coatDarkening(){return this._material.coatDarkening}set coatDarkeningTexture(e){this._material.coatDarkeningTexture=e}set coatRoughnessAnisotropy(e){this._material.coatRoughnessAnisotropy=e}get coatRoughnessAnisotropy(){return this._material.coatRoughnessAnisotropy}set geometryCoatTangentAngle(e){this._material.geometryCoatTangentAngle=e}set geometryCoatTangentTexture(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)}get geometryCoatTangentTexture(){return this._material.geometryCoatTangentTexture}configureTransmission(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0}set transmissionWeight(e){this._material.transmissionWeight=e}set transmissionWeightTexture(e){this._material.transmissionWeightTexture=e}get transmissionWeightTexture(){return this._material.transmissionWeightTexture}get transmissionWeight(){return this._material.transmissionWeight}set transmissionScatter(e){this._material.transmissionScatter=e}get transmissionScatter(){return this._material.transmissionScatter}set transmissionScatterTexture(e){this._material.transmissionScatterTexture=e}get transmissionScatterTexture(){return this._material.transmissionScatterTexture}set transmissionScatterAnisotropy(e){this._material.transmissionScatterAnisotropy=e}set transmissionDispersionAbbeNumber(e){this._material.transmissionDispersionAbbeNumber=e}set transmissionDispersionScale(e){this._material.transmissionDispersionScale=e}set transmissionDepth(e){e!==Number.MAX_VALUE||this._material.transmissionDepth!==0?this._material.transmissionDepth=e:this._material.transmissionDepth=0}get transmissionDepth(){return this._material.transmissionDepth}set transmissionColor(e){e.equals(P.White())||(this._material.transmissionColor=e)}get transmissionColor(){return this._material.transmissionColor}get refractionBackgroundTexture(){return this._material.backgroundRefractionTexture}set refractionBackgroundTexture(e){this._material.backgroundRefractionTexture=e}configureVolume(){this._material.geometryThinWalled=0}set geometryThinWalled(e){this._material.geometryThinWalled=+!!e}get geometryThinWalled(){return!!this._material.geometryThinWalled}set volumeThicknessTexture(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0}set volumeThickness(e){this._material.geometryThickness=e}configureSubsurface(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1}set subsurfaceWeight(e){this._material.subsurfaceWeight=e}get subsurfaceWeight(){return this._material.subsurfaceWeight}set subsurfaceWeightTexture(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0}get subsurfaceWeightTexture(){return this._material.subsurfaceWeightTexture}set subsurfaceColor(e){this._material.subsurfaceColor=e}set subsurfaceColorTexture(e){this._material.subsurfaceColorTexture=e}set diffuseTransmissionTint(e){this._diffuseTransmissionTint=e}get diffuseTransmissionTint(){return this._diffuseTransmissionTint}set diffuseTransmissionTintTexture(e){this._diffuseTransmissionTintTexture=e}get subsurfaceRadius(){return this._material.subsurfaceRadius}set subsurfaceRadius(e){this._material.subsurfaceRadius=e}get subsurfaceRadiusScale(){return this._material.subsurfaceRadiusScale}set subsurfaceRadiusScale(e){this._material.subsurfaceRadiusScale=e}set subsurfaceScatterAnisotropy(e){this._material.subsurfaceScatterAnisotropy=e}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){}set fuzzWeight(e){this._material.fuzzWeight=e}set fuzzWeightTexture(e){this._material.fuzzWeightTexture=e}set fuzzColor(e){this._material.fuzzColor=e}set fuzzColorTexture(e){this._material.fuzzColorTexture=e}set fuzzRoughness(e){this._material.fuzzRoughness=e}set fuzzRoughnessTexture(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0}set specularRoughnessAnisotropy(e){this._material.specularRoughnessAnisotropy=e}get specularRoughnessAnisotropy(){return this._material.specularRoughnessAnisotropy}set geometryTangentAngle(e){this._material.geometryTangentAngle=e}set geometryTangentTexture(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0}get geometryTangentTexture(){return this._material.geometryTangentTexture}configureGltfStyleAnisotropy(e=!0){this._material._useGltfStyleAnisotropy=e}set thinFilmWeight(e){this._material.thinFilmWeight=e}set thinFilmIor(e){this._material.thinFilmIor=e}set thinFilmThicknessMinimum(e){this._material.thinFilmThicknessMin=e/1e3}set thinFilmThicknessMaximum(e){this._material.thinFilmThickness=e/1e3}set thinFilmWeightTexture(e){this._material.thinFilmWeightTexture=e}set thinFilmThicknessTexture(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.geometryOpacity=e}get geometryOpacity(){return this._material.geometryOpacity}set geometryNormalTexture(e){this._material.geometryNormalTexture=e}get geometryNormalTexture(){return this._material.geometryNormalTexture}setNormalMapInversions(e,t){}set geometryCoatNormalTexture(e){this._material.geometryCoatNormalTexture=e}get geometryCoatNormalTexture(){return this._material.geometryCoatNormalTexture}set geometryCoatNormalTextureScale(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)}async finalizeAsync(e){if(this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(P.White())||this._diffuseTransmissionTintTexture){if(this._material.geometryThinWalled)this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture;else if(await this.copySurfaceToCoatAsync(e,this.subsurfaceWeight,this.subsurfaceWeightTexture,WH.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0),e._disposed)return}if(this.transmissionWeight>0){if(this._material.geometryThinWalled||this._material.transmissionDepth===0)this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture;else if((!this.baseColor.equals(P.White())||this.baseColorTexture!==null)&&(await this.copySurfaceToCoatAsync(e,this.transmissionWeight,this.transmissionWeightTexture,WH.R,this.baseColor,this.baseColorTexture,!1),e._disposed))return}if(this._specWorkflow){let t=await dEe(`newRoughnessTexture (`+this._material.name+`)`,await pEe(`glossiness (`+this._material.name+`)`,GH(this.specularColorTexture,new fe(this.specularColor.r,this.specularColor.g,this.specularColor.b,this.glossiness),WH.A,HH.Linear),WH.A,this._material.getScene(),HH.Linear,UH.R),this._material.getScene(),UH.R,HH.Linear,UH.R);if(e._disposed){t.texture?.dispose();return}this.specularRoughnessTexture=t.texture,this.specularRoughness=t.factor?t.factor.r:1;let n=await fEe(`metallicTexture (`+this._material.name+`)`,GH(this.specularColorTexture,this.specularColor.toColor4(),WH.RGBA,HH.Linear),this._material.getScene(),!1,HH.SRGB,UH.RGB);if(e._disposed){n.texture?.dispose();return}this.baseMetalnessTexture=n.texture,this.baseMetalness=n.factor?n.factor.r:1;let r=await aU(`newBaseColor (`+this._material.name+`)`,GH(this.baseColorTexture,this.baseColor.toColor4(),WH.RGBA,HH.Linear),GH(this.specularColorTexture,this.specularColor.toColor4(),WH.RGBA,HH.Linear),{...n,dispose:void 0,colorSpace:HH.Linear},this._material.getScene(),HH.SRGB,UH.RGB);if(e._disposed){r.texture?.dispose();return}this.baseColorTexture?.dispose(),this.baseColorTexture=r.texture,this.baseColor=r.factor?new P(r.factor.r,r.factor.g,r.factor.b):P.White(),this.specularColorTexture?.dispose(),this.specularColorTexture=null}}async copySurfaceToCoatAsync(e,t,n,r,i,a,o=!1){let s=this._material.coatWeight,c=this._material.coatWeightTexture,l=this._material.coatColor.clone(),u=this._material.coatColorTexture,d=this._material.geometryCoatNormalTexture,f=new fe(s,s,s,s),p=new fe(t,t,t,t);this.coatWeightTexture=null,this.coatWeight=1;let m=await Promise.allSettled([aU(`lerpExistingCoat`,GH(null,new fe(1,1,1,1)),GH(u,l.toColor4(),WH.RGBA,HH.SRGB),GH(c,f,WH.R),this._material.getScene(),HH.SRGB),aU(`lerpSurfaceColor`,GH(null,new fe(1,1,1,1)),GH(a,i.toColor4(),WH.RGBA,HH.SRGB),GH(n,p,r),this._material.getScene(),HH.SRGB)]),h=m.find(e=>e.status===`rejected`);if(h){for(let e of m)e.status===`fulfilled`&&e.value.texture?.dispose();throw h.reason}let[g,_]=m.map(e=>e.value);if(e._disposed){g.texture?.dispose(),_.texture?.dispose();return}let v=await iU(`newCoatColor (`+this._material.name+`)`,g,_,this._material.getScene(),HH.SRGB);if(e._disposed){v.texture?.dispose();return}v.texture?(this.coatColorTexture=v.texture,this.coatColor=P.White()):v.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([v.factor.r,v.factor.g,v.factor.b]));let y=await aU(`newCoatIor (`+this._material.name+`)`,GH(null,new fe(this._material.specularIor,this._material.specularIor,this._material.specularIor,1),WH.R),GH(null,new fe(this.coatIor,this.coatIor,this.coatIor,1),WH.R),GH(c,f,WH.R),this._material.getScene());if(e._disposed){y.texture?.dispose();return}this.coatIor=y.factor?y.factor.r:this.coatIor;let b=await aU(`newCoatRoughness (`+this._material.name+`)`,GH(this.specularRoughnessTexture,new fe(this.specularRoughness,this.specularRoughness,this.specularRoughness,1),WH.G),GH(this.coatRoughnessTexture,new fe(this.coatRoughness,this.coatRoughness,this.coatRoughness,1),WH.G),GH(c,f,WH.R),this._material.getScene());if(e._disposed){b.texture?.dispose();return}this.coatRoughness=b.factor?b.factor.r:1,this.coatRoughnessTexture=b.texture;let x=await aU(`newCoatDarkening (`+this._material.name+`)`,GH(null,new fe(0,0,0,1),WH.R),GH(null,new fe(this.coatDarkening,this.coatDarkening,this.coatDarkening,1),WH.R),GH(c,f,WH.R),this._material.getScene());if(e._disposed){x.texture?.dispose();return}if(this.coatDarkening=x.factor?x.factor.r:this.coatDarkening,o){let t=await aU(`newSpecularRoughness (`+this._material.name+`)`,GH(this.specularRoughnessTexture,new fe(this._material.specularRoughness,this._material.specularRoughness,this._material.specularRoughness,1),WH.G),GH(null,new fe(1,1,1,1),WH.R),GH(n,p,r),this._material.getScene());if(e._disposed){t.texture?.dispose();return}this.specularRoughness=t.factor?t.factor.r:1,this.specularRoughnessTexture=t.texture}if(d||this.geometryNormalTexture){let t=await aU(`newCoatNormal (`+this._material.name+`)`,GH(this.geometryNormalTexture,this.geometryNormalTexture?new fe(1,1,1,1):new fe(.5,.5,1,1),WH.RGBA),GH(d,d?new fe(1,1,1,1):new fe(.5,.5,1,1),WH.RGBA),GH(c,f,WH.R),this._material.getScene());if(e._disposed){t.texture?.dispose();return}t.texture&&(this.geometryCoatNormalTexture=t.texture)}}},f$e=s({PBRMaterialLoadingAdapter:()=>p$e}),p$e=class{constructor(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}get material(){return this._material}async finalizeAsync(e){}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material.useAlphaFromAlbedoTexture=e}get useAlphaFromBaseColorTexture(){return this._material.useAlphaFromAlbedoTexture}get transparencyAsAlphaCoverage(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha}set transparencyAsAlphaCoverage(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e}set baseColor(e){this._material.albedoColor=e}get baseColor(){return this._material.albedoColor}set baseColorTexture(e){this._material.albedoTexture=e}get baseColorTexture(){return this._material.albedoTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=q.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)}get baseDiffuseRoughness(){return this._material.baseDiffuseRoughness??0}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.metallic=e}get baseMetalness(){return this._material.metallic??1}set baseMetalnessTexture(e){this._material.metallicTexture=e}get baseMetalnessTexture(){return this._material.metallicTexture}set useRoughnessFromMetallicTextureGreen(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e}set useMetallicFromMetallicTextureBlue(e){this._material.useMetallnessFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){e&&(this._material.brdf.dielectricSpecularModel=q.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=q.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR)}configureSpecularGlossiness(){this._specWorkflow=!0,this._material.metallic=null,this._material.roughness=null,this._material.useMicroSurfaceFromReflectivityMapAlpha=!0}set specularWeight(e){this._material.metallicF0Factor=e}get specularWeight(){return this._material.metallicF0Factor??1}set specularWeightTexture(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)}get specularWeightTexture(){return this._material.metallicReflectanceTexture}set specularColor(e){this._specWorkflow?this._material.reflectivityColor=e:this._material.metallicReflectanceColor=e}get specularColor(){return this._specWorkflow?this._material.reflectivityColor:this._material.metallicReflectanceColor}set specularColorTexture(e){this._specWorkflow?(this._material.reflectivityTexture=e,this._material.reflectivityTexture&&(this._material.reflectivityTexture.hasAlpha=!0)):this._material.reflectanceTexture=e}get specularColorTexture(){return this._specWorkflow?this._material.reflectivityTexture:this._material.reflectanceTexture}set specularRoughness(e){this._material.roughness=e}get specularRoughness(){return this._material.roughness??1}set specularRoughnessTexture(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)}get specularRoughnessTexture(){return this._material.metallicTexture}set specularIor(e){this._material.indexOfRefraction=e}get specularIor(){return this._material.indexOfRefraction}get glossiness(){return this._material.microSurface??1}set glossiness(e){this._material.microSurface=e}set emissionColor(e){this._material.emissiveColor=e}get emissionColor(){return this._material.emissiveColor}set emissionLuminance(e){this._material.emissiveIntensity=e}get emissionLuminance(){return this._material.emissiveIntensity}set emissionColorTexture(e){this._material.emissiveTexture=e}get emissionColorTexture(){return this._material.emissiveTexture}set ambientOcclusionTexture(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)}get ambientOcclusionTexture(){return this._material.ambientTexture}set ambientOcclusionTextureStrength(e){this._material.ambientTextureStrength=e}get ambientOcclusionTextureStrength(){return this._material.ambientTextureStrength??1}configureCoat(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1}set coatWeight(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e}get coatWeight(){return this._material.clearCoat.intensity}set coatWeightTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e}get coatWeightTexture(){return this._material.clearCoat.texture}set coatColor(e){this._material.clearCoat.isTintEnabled=e!=P.White(),this._material.clearCoat.tintColor=e}set coatColorTexture(e){this._material.clearCoat.tintTexture=e}set coatRoughness(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e}get coatRoughness(){return this._material.clearCoat.roughness??0}set coatRoughnessTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e}get coatRoughnessTexture(){return this._material.clearCoat.textureRoughness}set coatIor(e){this._material.clearCoat.indexOfRefraction=e}set coatDarkening(e){}set coatDarkeningTexture(e){}set coatRoughnessAnisotropy(e){}get coatRoughnessAnisotropy(){return 0}set geometryCoatTangentAngle(e){}set geometryCoatTangentTexture(e){}get geometryCoatTangentTexture(){return null}set transmissionWeight(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e}get transmissionWeight(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0}set transmissionWeightTexture(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set transmissionDepth(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new P(e,e,e))}get transmissionDepth(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0}set transmissionColor(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)}get transmissionColor(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new P(0,0,0)}set transmissionScatter(e){this._material.subSurface.diffusionDistance=e}get transmissionScatter(){return this._material.subSurface.diffusionDistance}set transmissionScatterTexture(e){}set transmissionScatterAnisotropy(e){}set transmissionDispersionAbbeNumber(e){}set transmissionDispersionScale(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)}get refractionBackgroundTexture(){return this._material.subSurface.refractionTexture}set refractionBackgroundTexture(e){this._material.subSurface.refractionTexture=e}configureTransmission(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0}configureVolume(){}set geometryThinWalled(e){}get geometryThinWalled(){return this._material.subSurface.maximumThickness===0}set volumeThicknessTexture(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set volumeThickness(e){this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=e,this._material.subSurface.useThicknessAsDepth=!0,e>0&&(this._material.subSurface.volumeIndexOfRefraction=this._material.indexOfRefraction)}configureSubsurface(){this._material.subSurface.useGltfStyleTextures=!0,this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0,this._material.subSurface.useAlbedoToTintTranslucency=!1}set subsurfaceWeight(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e}get subsurfaceWeight(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0}set subsurfaceWeightTexture(e){this._material.subSurface.translucencyIntensityTexture=e}set subsurfaceColor(e){let t=new j(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));t.scaleInPlace(1/Math.max(this.transmissionDepth,.001));let n=t,r=Math.max(n.x,Math.max(n.y,n.z)),i=r>0?1/r:1;this._material.subSurface.diffusionDistance=new P(Math.exp(-n.x*i),Math.exp(-n.y*i),Math.exp(-n.z*i))}set subsurfaceColorTexture(e){}set diffuseTransmissionTint(e){this._material.subSurface.tintColor=e}get diffuseTransmissionTint(){return this._material.subSurface.tintColor}set diffuseTransmissionTintTexture(e){this._material.subSurface.translucencyColorTexture=e}get subsurfaceRadius(){return 1}set subsurfaceRadius(e){}get subsurfaceRadiusScale(){return this._material.subSurface.scatteringDiffusionProfile??P.White()}set subsurfaceRadiusScale(e){this._material.subSurface.scatteringDiffusionProfile=e}set subsurfaceScatterAnisotropy(e){}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0}set fuzzWeight(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e}set fuzzWeightTexture(e){this._material.sheen.texture||(this._material.sheen.texture=e)}set fuzzColor(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e}set fuzzColorTexture(e){this._material.sheen.texture=e}set fuzzRoughness(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e}set fuzzRoughnessTexture(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e}set specularRoughnessAnisotropy(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e}get specularRoughnessAnisotropy(){return this._material.anisotropy.intensity}set geometryTangentAngle(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e}set geometryTangentTexture(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e}get geometryTangentTexture(){return this._material.anisotropy.texture}configureGltfStyleAnisotropy(e=!0){}set thinFilmWeight(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e}set thinFilmIor(e){this._material.iridescence.indexOfRefraction=e}set thinFilmThicknessMinimum(e){this._material.iridescence.minimumThickness=e}set thinFilmThicknessMaximum(e){this._material.iridescence.maximumThickness=e}set thinFilmWeightTexture(e){this._material.iridescence.texture=e}set thinFilmThicknessTexture(e){this._material.iridescence.thicknessTexture=e}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.alpha=e}get geometryOpacity(){return this._material.alpha}set geometryNormalTexture(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0}get geometryNormalTexture(){return this._material.bumpTexture}setNormalMapInversions(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t}set geometryCoatNormalTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e}get geometryCoatNormalTexture(){return this._material.clearCoat.bumpTexture}set geometryCoatNormalTextureScale(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)}},B8=`EXT_lights_image_based`,m$e=class{constructor(e){this.name=B8,this._loader=e,this.enabled=this._loader.isExtensionUsed(B8)}dispose(){this._loader=null,delete this._lights}onLoading(){let e=this._loader.gltf.extensions;if(e&&e[this.name]){let t=e[this.name];this._lights=t.lights}}loadSceneAsync(e,t){return I8.LoadExtensionAsync(e,t,this.name,async(n,r)=>{this._loader._allMaterialsDirtyRequired=!0;let i=[];i.push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen(`${n}`);let a=F8.Get(`${n}/light`,this._lights,r.light);return i.push(this._loadLightAsync(`/extensions/${this.name}/lights/${r.light}`,a).then(e=>{this._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),await Promise.all(i).then(()=>{})})}_loadLightAsync(e,t){if(!t._loaded){let n=[];this._loader.logOpen(`${e}`);let r=Array(t.specularImages.length);for(let i=0;i{r[i][t]=e})),this._loader.logClose()}}this._loader.logClose(),t._loaded=Promise.all(n).then(async()=>{let n=new nEe(this._loader.babylonScene,null,t.specularImageSize);if(n.name=t.name||`environment`,t._babylonTexture=n,t.intensity!=null&&(n.level=t.intensity),t.rotation){let e=A.FromArray(t.rotation);this._loader.babylonScene.useRightHandedSystem||(e=A.Inverse(e)),M.FromQuaternionToRef(e,n.getReflectionTextureMatrix())}if(!t.irradianceCoefficients)throw Error(`${e}: Irradiance coefficients are missing`);let i=_v.FromArray(t.irradianceCoefficients);i.scaleInPlace(t.intensity),i.convertIrradianceToLambertianRadiance();let a=vv.FromHarmonics(i),o=(r.length-1)/Math.log2(t.specularImageSize);return await n.updateRGBDAsync(r,a,o)})}return t._loaded.then(()=>t._babylonTexture)}},h$e=!1;function g$e(){h$e||(h$e=!0,D8(B8),E8(B8,!0,e=>new m$e(e)))}g$e();var V8=`EXT_mesh_gpu_instancing`,_$e=class{constructor(e){this.name=V8,this._loader=e,this.enabled=this._loader.isExtensionUsed(V8)}dispose(){this._loader=null}loadNodeAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(e,r)=>{this._loader._disableInstancedMesh++;let i=this._loader.loadNodeAsync(`/nodes/${t.index}`,t,n);if(this._loader._disableInstancedMesh--,!t._primitiveBabylonMeshes)return await i;let a=[],o=0,s=t=>{if(r.attributes[t]==null){a.push(Promise.resolve(null));return}let n=F8.Get(`${e}/attributes/${t}`,this._loader.gltf.accessors,r.attributes[t]);if(a.push(this._loader._loadFloatAccessorAsync(`/accessors/${n.bufferView}`,n)),o===0)o=n.count;else if(o!==n.count)throw Error(`${e}/attributes: Instance buffer accessors do not have the same count.`)};return s(`TRANSLATION`),s(`ROTATION`),s(`SCALE`),s(`_COLOR_0`),await i.then(async e=>{let[n,r,i,s]=await Promise.all(a),c=new Float32Array(o*16);k.Vector3[0].copyFromFloats(0,0,0),k.Quaternion[0].copyFromFloats(0,0,0,1),k.Vector3[1].copyFromFloats(1,1,1);for(let e=0;enew _$e(e)))}y$e();var H8=`EXT_meshopt_compression`,b$e=class{constructor(e){this.name=H8,this.enabled=e.isExtensionUsed(H8),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(e,t){return I8.LoadExtensionAsync(e,t,this.name,async(n,r)=>{let i=t;if(i._meshOptData)return await i._meshOptData;let a=F8.Get(`${e}/buffer`,this._loader.gltf.buffers,r.buffer);return i._meshOptData=this._loader.loadBufferAsync(`/buffers/${a.index}`,a,r.byteOffset||0,r.byteLength).then(async e=>await Eq.Default.decodeGltfBufferAsync(e,r.count,r.byteStride,r.mode,r.filter)),await i._meshOptData})}},x$e=!1;function S$e(){x$e||(x$e=!0,D8(H8),E8(H8,!0,e=>new b$e(e)))}S$e();var U8=`EXT_texture_webp`,C$e=class{constructor(e){this.name=U8,this._loader=e,this.enabled=e.isExtensionUsed(U8)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=t.sampler==null?I8.DefaultSampler:F8.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=F8.Get(`${r}/source`,this._loader.gltf.images,i.source);return await this._loader._createTextureAsync(e,a,o,e=>{n(e)},void 0,!t._textureInfo.nonColorData)})}},w$e=!1;function T$e(){w$e||(w$e=!0,D8(U8),E8(U8,!0,e=>new C$e(e)))}T$e();var W8=`EXT_texture_avif`,E$e=class{constructor(e){this.name=W8,this._loader=e,this.enabled=e.isExtensionUsed(W8)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=t.sampler==null?I8.DefaultSampler:F8.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=F8.Get(`${r}/source`,this._loader.gltf.images,i.source);return await this._loader._createTextureAsync(e,a,o,e=>{n(e)},void 0,!t._textureInfo.nonColorData)})}},D$e=!1;function O$e(){D$e||(D$e=!0,D8(W8),E8(W8,!0,e=>new E$e(e)))}O$e();var G8=`EXT_lights_ies`,k$e=class{constructor(e){this.name=G8,this._loader=e,this.enabled=this._loader.isExtensionUsed(G8)}dispose(){this._loader=null,delete this._lights}onLoading(){let e=this._loader.gltf.extensions;if(e&&e[this.name]){let t=e[this.name];this._lights=t.lights,F8.Assign(this._lights)}}loadNodeAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{this._loader._allMaterialsDirtyRequired=!0;let a,o,s=await this._loader.loadNodeAsync(e,t,e=>{o=F8.Get(r,this._lights,i.light);let t=o.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,a=new WE(t,j.Zero(),j.Backward(),0,1,this._loader.babylonScene),a.angle=Math.PI/2,a.innerAngle=0,a._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,o._babylonLight=a,a.falloffType=Il.FALLOFF_GLTF,a.diffuse=i.color?P.FromArray(i.color):P.White(),a.intensity=i.multiplier||1,a.range=Number.MAX_VALUE,a.parent=e,this._loader._babylonLights.push(a),I8.AddPointerMetadata(a,r),n(e)}),c;if(o.uri)c=await this._loader.loadUriAsync(e,o,o.uri);else{let t=F8.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,o.bufferView);c=await this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return a.iesProfileTexture=new W(name+`_iesProfile`,this._loader.babylonScene,!0,!1,void 0,null,null,c,!0,void 0,void 0,void 0,void 0,`.ies`),s})}},A$e=!1;function j$e(){A$e||(A$e=!0,D8(G8),E8(G8,!0,e=>new k$e(e)))}j$e();var K8=`KHR_draco_mesh_compression`,M$e=class{constructor(e){this.name=K8,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=Cq.DefaultAvailable&&this._loader.isExtensionUsed(K8)}dispose(){delete this.dracoDecoder,this._loader=null}_loadVertexDataAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{if(t.mode!=null&&t.mode!==4&&t.mode!==5)throw Error(`${e}: Unsupported mode ${t.mode}`);let a={},o={},s=(e,r)=>{let s=i.attributes[e];if(s!=null&&(n._delayInfo=n._delayInfo||[],n._delayInfo.indexOf(r)===-1&&n._delayInfo.push(r),a[r]=s,this.useNormalizedFlagFromAccessor)){let n=F8.TryGet(this._loader.gltf.accessors,t.attributes[e]);n&&(o[r]=n.normalized||!1)}};s(`POSITION`,H.PositionKind),s(`NORMAL`,H.NormalKind),s(`TANGENT`,H.TangentKind),s(`TEXCOORD_0`,H.UVKind),s(`TEXCOORD_1`,H.UV2Kind),s(`TEXCOORD_2`,H.UV3Kind),s(`TEXCOORD_3`,H.UV4Kind),s(`TEXCOORD_4`,H.UV5Kind),s(`TEXCOORD_5`,H.UV6Kind),s(`JOINTS_0`,H.MatricesIndicesKind),s(`WEIGHTS_0`,H.MatricesWeightsKind),s(`COLOR_0`,H.ColorKind);let c=F8.Get(r,this._loader.gltf.bufferViews,i.bufferView);return c._dracoBabylonGeometry||=this._loader.loadBufferViewAsync(`/bufferViews/${c.index}`,c).then(async r=>{let i=this.dracoDecoder||Cq.Default,s=F8.TryGet(this._loader.gltf.accessors,t.attributes.POSITION),c=!this._loader.parent.alwaysComputeBoundingBox&&!n.skeleton&&s?r$e(s):null;return await i._decodeMeshToGeometryForGltfAsync(n.name,this._loader.babylonScene,r,a,o,c).catch(t=>{throw Error(`${e}: ${t.message}`)})}),await c._dracoBabylonGeometry})}},N$e=!1;function P$e(){N$e||(N$e=!0,D8(K8),E8(K8,!0,e=>new M$e(e)))}P$e();var q8=`KHR_gaussian_splatting`,J8=.28209479177387814,F$e=`KHR_gaussian_splatting:ROTATION`,I$e=`KHR_gaussian_splatting:SCALE`,L$e=`KHR_gaussian_splatting:OPACITY`,R$e=`KHR_gaussian_splatting:SH_DEGREE_0_COEF_0`,z$e=[0,3,5,7];function Y8(e){return e<=0?0:e>=255?255:e+.5|0}var B$e=class{constructor(e){this.name=q8,this._loader=e,this.enabled=this._loader.isExtensionUsed(q8)}dispose(){this._loader=null}_loadMeshPrimitiveAsync(e,t,n,r,i,a){return I8.LoadExtensionAsync(e,i,this.name,async n=>{if(i.mode!=null&&i.mode!==0)throw Error(`${n}: Gaussian splatting primitives must use POINTS mode`);let r=this._loader,o=t=>{let n=i.attributes[t];if(n==null)return null;let a=F8.Get(`${e}/attributes/${t}`,r.gltf.accessors,n);return r._loadFloatAccessorAsync(`/accessors/${a.index}`,a)},s=o(`POSITION`);if(!s)throw Error(`${n}: Gaussian splatting primitive is missing the POSITION attribute`);let c=0,l=[];for(let e=1;e<=3&&i.attributes[`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_0`]!=null;e++){c=e;for(let t=0;to(e))]),b=p.length/3,x=v?v.length/b:0,S=new ArrayBuffer(32*b),C=new Float32Array(S),w=new Uint8Array(S),T=null;if(c>0){let e=((c+1)*(c+1)-1)*3,t=Math.ceil(e/16),n=f.maxTextureSize;T=TX(t,Math.ceil(b/n)*n*4*4)}for(let e=0;e=4?w[n+27]=Y8(v[e*x+3]*255):w[n+27]=255;let i=e*4,a=m?m[i+0]:0,o=m?m[i+1]:0,s=m?m[i+2]:0,c=m?m[i+3]:1;if(w[n+28]=Y8(c*127.5+127.5),w[n+29]=Y8(a*127.5+127.5),w[n+30]=Y8(o*127.5+127.5),w[n+31]=Y8(s*127.5+127.5),T){let t=e*16;for(let e=0;e>4,s=a&15;T[o][t+s]=Y8(n[r+i]*128+128)}}}}return await d.updateDataAsync(S,T??void 0,void 0,c||void 0),d})}},V$e=!1;function H$e(){V$e||(V$e=!0,D8(q8),E8(q8,!0,e=>new B$e(e)))}H$e();var X8=`KHR_lights_punctual`,U$e=class{constructor(e){this.name=X8,this._loader=e,this.enabled=this._loader.isExtensionUsed(X8)}dispose(){this._loader=null,delete this._lights}onLoading(){let e=this._loader.gltf.extensions;if(e&&e[this.name]){let t=e[this.name];this._lights=t.lights,F8.Assign(this._lights)}}loadNodeAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>(this._loader._allMaterialsDirtyRequired=!0,await this._loader.loadNodeAsync(e,t,e=>{let t,a=F8.Get(r,this._lights,i.light),o=a.name||e.name;switch(this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,a.type){case`directional`:{let e=new GC(o,j.Backward(),this._loader.babylonScene);e.position.setAll(0),t=e;break}case`point`:t=new nj(o,j.Zero(),this._loader.babylonScene);break;case`spot`:{let e=new WE(o,j.Zero(),j.Backward(),0,1,this._loader.babylonScene);e.angle=(a.spot&&a.spot.outerConeAngle||Math.PI/4)*2,e.innerAngle=(a.spot&&a.spot.innerConeAngle||0)*2,t=e;break}default:throw this._loader.babylonScene._blockEntityCollection=!1,Error(`${r}: Invalid light type (${a.type})`)}t._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,a._babylonLight=t,t.falloffType=Il.FALLOFF_GLTF,t.diffuse=a.color?P.FromArray(a.color):P.White(),t.intensity=a.intensity==null?1:a.intensity,t.range=a.range==null?Number.MAX_VALUE:a.range,t.parent=e,this._loader._babylonLights.push(t),I8.AddPointerMetadata(t,r),n(e)})))}},W$e=!1;function G$e(){W$e||(W$e=!0,D8(X8),E8(X8,!0,e=>new U$e(e)))}G$e();var Z8=`EXT_lights_area`,K$e=class{constructor(e){this.name=Z8,this._loader=e,this.enabled=this._loader.isExtensionUsed(Z8)}dispose(){this._loader=null,delete this._lights}onLoading(){let e=this._loader.gltf.extensions;if(e&&e[this.name]){let t=e[this.name];this._lights=t.lights,F8.Assign(this._lights)}}loadNodeAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>(this._loader._allMaterialsDirtyRequired=!0,await this._loader.loadNodeAsync(e,t,e=>{let t,a=F8.Get(r,this._lights,i.light),o=a.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer;let s=a.size===void 0?1:a.size;switch(a.type){case`rect`:{let e=a.rect?.aspect===void 0?s:a.rect.aspect*s,n=s;t=new rj(o,j.Zero(),e,n,this._loader.babylonScene);break}case`disk`:{let e=Math.sqrt(s*s*.25*Math.PI);t=new rj(o,j.Zero(),e,e,this._loader.babylonScene);break}default:throw this._loader.babylonScene._blockEntityCollection=!1,Error(`${r}: Invalid area light type (${a.type})`)}t._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,a._babylonLight=t,t.falloffType=Il.FALLOFF_GLTF,t.diffuse=a.color?P.FromArray(a.color):P.White(),t.intensity=a.intensity==null?1:a.intensity;let c=new wc(`${o}_orientation`,this._loader.babylonScene);c.rotationQuaternion=A.RotationAxis(j.Up(),Math.PI),c.parent=e,t.parent=c,this._loader._babylonLights.push(t),I8.AddPointerMetadata(t,r),n(e)})))}},q$e=!1;function J$e(){q$e||(q$e=!0,D8(Z8),E8(Z8,!0,e=>new K$e(e)))}J$e();var Q8=`KHR_materials_pbrSpecularGlossiness`,Y$e=class{constructor(e){this.name=Q8,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(Q8)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialBasePropertiesAsync(e,t,n)),a.push(this._loadSpecularGlossinessPropertiesAsync(r,i,n)),this._loader.loadMaterialAlphaProperties(e,t,n),await Promise.all(a).then(()=>{})})}_loadSpecularGlossinessPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];return r.configureSpecularGlossiness(),t.diffuseFactor?(r.baseColor=P.FromArray(t.diffuseFactor),n.alpha=t.diffuseFactor[3]):r.baseColor=P.White(),r.specularColor=t.specularFactor?P.FromArray(t.specularFactor):P.White(),r.glossiness=t.glossinessFactor==null?1:t.glossinessFactor,t.diffuseTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTexture`,t.diffuseTexture,e=>{e.name=`${n.name} (Diffuse)`,r.baseColorTexture=e})),t.specularGlossinessTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/specularGlossinessTexture`,t.specularGlossinessTexture,e=>{e.name=`${n.name} (Specular Glossiness)`,r.specularColorTexture=e})),Promise.all(i).then(()=>{})}},X$e=!1;function Z$e(){X$e||(X$e=!0,D8(Q8),E8(Q8,!0,e=>new Y$e(e)))}Z$e();var $8=`KHR_materials_unlit`,Q$e=class{constructor(e){this.name=$8,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed($8)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async()=>await this._loadUnlitPropertiesAsync(e,t,n))}_loadUnlitPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[],a=t.pbrMetallicRoughness;return a&&(a.baseColorFactor&&(r.baseColor=P.FromArray(a.baseColorFactor),r.geometryOpacity=a.baseColorFactor[3]),a.baseColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/baseColorTexture`,a.baseColorTexture,e=>{e.name=`${n.name} (Base Color)`,r.baseColorTexture=e}))),r.isUnlit=!0,t.doubleSided&&(r.backFaceCulling=!1,r.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,t,n),Promise.all(i).then(()=>{})}},$$e=!1;function e1e(){$$e||($$e=!0,D8($8),E8($8,!0,e=>new Q$e(e)))}e1e();var e5=`KHR_materials_clearcoat`,t1e=class{constructor(e){this.name=e5,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(e5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadClearCoatPropertiesAsync(r,i,n)),await Promise.all(a)})}_loadClearCoatPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];return r.configureCoat(),r.coatWeight=t.clearcoatFactor===void 0?0:t.clearcoatFactor,r.coatRoughness=t.clearcoatRoughnessFactor===void 0?0:t.clearcoatRoughnessFactor,t.clearcoatTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatTexture`,t.clearcoatTexture,e=>{e.name=`${n.name} (ClearCoat)`,r.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatRoughnessTexture`,t.clearcoatRoughnessTexture,e=>{e.name=`${n.name} (ClearCoat Roughness)`,r.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatNormalTexture`,t.clearcoatNormalTexture,e=>{e.name=`${n.name} (ClearCoat Normal)`,r.geometryCoatNormalTexture=e,t.clearcoatNormalTexture?.scale!=null&&(r.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),Promise.all(i).then(()=>{})}},n1e=!1;function r1e(){n1e||(n1e=!0,D8(e5),E8(e5,!0,e=>new t1e(e)))}r1e();var t5=`KHR_materials_coat`,i1e=class{constructor(e){this.name=t5,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(t5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),a.push(this._loadCoatPropertiesAsync(r,i,n)),await Promise.all(a)})}_loadCoatPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];r.configureCoat(),r.coatWeight=t.coatFactor===void 0?0:t.coatFactor,r.coatRoughness=t.coatRoughnessFactor===void 0?0:t.coatRoughnessFactor,t.coatTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatTexture`,t.coatTexture,e=>{e.name=`${n.name} (Coat)`,r.coatWeightTexture=e})),t.coatRoughnessTexture&&(t.coatRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatRoughnessTexture`,t.coatRoughnessTexture,e=>{e.name=`${n.name} (Coat Roughness)`,r.coatRoughnessTexture=e}))),t.coatNormalTexture&&(t.coatNormalTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatNormalTexture`,t.coatNormalTexture,e=>{e.name=`${n.name} (Coat Normal)`,r.geometryCoatNormalTexture=e,t.coatNormalTexture?.scale!=null&&(r.geometryCoatNormalTextureScale=t.coatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),r.coatDarkening=t.coatDarkeningFactor===void 0?1:t.coatDarkeningFactor,r.coatIor=t.coatIor===void 0?1.5:t.coatIor;let a=P.White();t.coatColorFactor!==void 0&&a.fromArray(t.coatColorFactor),r.coatColor=a,t.coatColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatColorTexture`,t.coatColorTexture,e=>{e.name=`${n.name} (Coat Color)`,r.coatColorTexture=e}));let o=t.coatAnisotropyStrength??0,s=t.coatAnisotropyRotation??0;return r.coatRoughnessAnisotropy=o,r.geometryCoatTangentAngle=s,this.useOpenPBR||r.configureGltfStyleAnisotropy(!0),t.coatAnisotropyTexture&&(t.coatAnisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatAnisotropyTexture`,t.coatAnisotropyTexture,e=>{e.name=`${n.name} (Coat Anisotropy)`,r.geometryCoatTangentTexture=e}))),Promise.all(i).then(()=>{})}},a1e=!1;function o1e(){a1e||(a1e=!0,D8(t5),E8(t5,!0,e=>new i1e(e)))}o1e();var n5=`KHR_materials_iridescence`,s1e=class{constructor(e){this.name=n5,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(n5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadIridescencePropertiesAsync(r,i,n)),await Promise.all(a).then(()=>{})})}_loadIridescencePropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];return r.thinFilmWeight=t.iridescenceFactor??0,r.thinFilmIor=t.iridescenceIor??t.iridescenceIOR??1.3,r.thinFilmThicknessMinimum=t.iridescenceThicknessMinimum??100,r.thinFilmThicknessMaximum=t.iridescenceThicknessMaximum??400,t.iridescenceTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceTexture`,t.iridescenceTexture,e=>{e.name=`${n.name} (Iridescence)`,r.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceThicknessTexture`,t.iridescenceThicknessTexture,e=>{e.name=`${n.name} (Iridescence Thickness)`,r.thinFilmThicknessTexture=e})),Promise.all(i).then(()=>{})}},c1e=!1;function l1e(){c1e||(c1e=!0,D8(n5),E8(n5,!0,e=>new s1e(e)))}l1e();var r5=`KHR_materials_anisotropy`,u1e=class{constructor(e){this.name=r5,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(r5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadAnisotropyPropertiesAsync(r,i,n)),await Promise.all(a)})}async _loadAnisotropyPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[],a=t.anisotropyStrength??0,o=t.anisotropyRotation??0;r.specularRoughnessAnisotropy=a,r.geometryTangentAngle=o;let s=t.extensions??{};(!s.EXT_materials_anisotropy_openpbr||!s.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled)&&r.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/anisotropyTexture`,t.anisotropyTexture,e=>{e.name=`${n.name} (Anisotropy Intensity)`,r.geometryTangentTexture=e}))),await Promise.all(i)}},d1e=!1;function f1e(){d1e||(d1e=!0,D8(r5),E8(r5,!0,e=>new u1e(e)))}f1e();var i5=`KHR_materials_emissive_strength`,p1e=class{constructor(e){this.name=i5,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(i5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>(await this._loader.loadMaterialPropertiesAsync(e,t,n),this._loadEmissiveProperties(r,i,n),await Promise.resolve()))}_loadEmissiveProperties(e,t,n){if(t.emissiveStrength!==void 0){let e=this._loader._getOrCreateMaterialAdapter(n);e.emissionLuminance=t.emissiveStrength}}},m1e=!1;function h1e(){m1e||(m1e=!0,D8(i5),E8(i5,!0,e=>new p1e(e)))}h1e();var a5=`KHR_materials_sheen`,g1e=class{constructor(e){this.name=a5,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(a5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadSheenPropertiesAsync(r,i,n)),await Promise.all(a).then(()=>{})})}_loadSheenPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];r.configureFuzz();let a=t.sheenColorFactor===void 0?P.Black():P.FromArray(t.sheenColorFactor),o=t.sheenRoughnessFactor===void 0?0:t.sheenRoughnessFactor;return r.fuzzWeight=1,r.fuzzColor=a,r.fuzzRoughness=o,t.sheenColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/sheenColorTexture`,t.sheenColorTexture,e=>{e.name=`${n.name} (Sheen Color)`,r.fuzzColorTexture=e})),t.sheenRoughnessTexture&&(t.sheenRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/sheenRoughnessTexture`,t.sheenRoughnessTexture,e=>{e.name=`${n.name} (Sheen Roughness)`,r.fuzzRoughnessTexture=e}))),Promise.all(i).then(()=>{})}},_1e=!1;function v1e(){_1e||(_1e=!0,D8(a5),E8(a5,!0,e=>new g1e(e)))}v1e();var o5=`KHR_materials_fuzz`,y1e=class{constructor(e){this.name=o5,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(o5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadFuzzPropertiesAsync(r,i,n)),await Promise.all(a).then(()=>{})})}_loadFuzzPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];return r.configureFuzz(),r.fuzzWeight=t.fuzzFactor===void 0?0:t.fuzzFactor,r.fuzzColor=t.fuzzColorFactor===void 0?P.White():P.FromArray(t.fuzzColorFactor),r.fuzzRoughness=t.fuzzRoughnessFactor===void 0?.5:t.fuzzRoughnessFactor,t.fuzzTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/fuzzTexture`,t.fuzzTexture,e=>{e.name=`${n.name} (Fuzz)`,r.fuzzWeightTexture=e})),t.fuzzColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/fuzzColorTexture`,t.fuzzColorTexture,e=>{e.name=`${n.name} (Fuzz Color)`,r.fuzzColorTexture=e})),t.fuzzRoughnessTexture&&(t.fuzzRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/fuzzRoughnessTexture`,t.fuzzRoughnessTexture,e=>{e.name=`${n.name} (Fuzz Roughness)`,r.fuzzRoughnessTexture=e}))),Promise.all(i).then(()=>{})}},b1e=!1;function x1e(){b1e||(b1e=!0,D8(o5),E8(o5,!0,e=>new y1e(e)))}x1e();var s5=`KHR_materials_specular`,S1e=class{constructor(e){this.name=s5,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(s5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadSpecularPropertiesAsync(r,i,n));let o=this._loader._getOrCreateMaterialAdapter(n);return i.extensions&&i.extensions.EXT_materials_specular_edge_color&&i.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&o.enableSpecularEdgeColor(!0),await Promise.all(a).then(()=>{})})}_loadSpecularPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];return r.specularWeight=t.specularFactor??1,r.specularColor=t.specularColorFactor===void 0?new P(1,1,1):P.FromArray(t.specularColorFactor),t.specularTexture&&(t.specularTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/specularTexture`,t.specularTexture,e=>{e.name=`${n.name} (Specular)`,r.specularWeightTexture=e}))),t.specularColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/specularColorTexture`,t.specularColorTexture,e=>{e.name=`${n.name} (Specular Color)`,r.specularColorTexture=e})),Promise.all(i).then(()=>{})}},C1e=!1;function w1e(){C1e||(C1e=!0,D8(s5),E8(s5,!0,e=>new S1e(e)))}w1e();var c5=`KHR_materials_ior`,T1e=class e{constructor(e){this.name=c5,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(c5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadIorPropertiesAsync(r,i,n)),await Promise.all(a).then(()=>{})})}_loadIorPropertiesAsync(t,n,r){let i=this._loader._getOrCreateMaterialAdapter(r);return i.specularIor=n.ior===void 0?e._DEFAULT_IOR:n.ior,Promise.resolve()}};T1e._DEFAULT_IOR=1.5;var E1e=!1;function D1e(){E1e||(E1e=!0,D8(c5),E8(c5,!0,e=>new T1e(e)))}D1e();var l5=`KHR_materials_variants`,O1e=class e{constructor(e){this.name=l5,this._loader=e,this.enabled=this._loader.isExtensionUsed(l5)&&!this._loader.parent.skipMaterials}dispose(){this._loader=null}static GetAvailableVariants(e){let t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]}getAvailableVariants(t){return e.GetAvailableVariants(t)}static SelectVariant(e,t){let n=this._GetExtensionMetadata(e);if(!n)throw Error(`Cannot select variant on a glTF mesh that does not have the ${l5} extension`);let r=e=>{let t=n.variants[e];if(t)for(let e of t)e.mesh.material=e.material};if(t instanceof Array)for(let e of t)r(e);else r(t);n.lastSelected=t}selectVariant(t,n){e.SelectVariant(t,n)}static Reset(e){let t=this._GetExtensionMetadata(e);if(!t)throw Error(`Cannot reset on a glTF mesh that does not have the ${l5} extension`);for(let e of t.original)e.mesh.material=e.material;t.lastSelected=null}reset(t){e.Reset(t)}static GetLastSelectedVariant(e){let t=this._GetExtensionMetadata(e);if(!t)throw Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${l5} extension`);return t.lastSelected}getLastSelectedVariant(t){return e.GetLastSelectedVariant(t)}static _GetExtensionMetadata(e){return e?._internalMetadata?.gltf?.[l5]||null}onLoading(){let e=this._loader.gltf.extensions;if(e&&e[this.name]){let t=e[this.name];this._variants=t.variants}}onReady(){let t=this._loader.rootBabylonMesh;if(t){let n=this._loader.parent.extensionOptions[l5];n?.defaultVariant&&e.SelectVariant(t,n.defaultVariant),n?.onLoaded?.({get variants(){return e.GetAvailableVariants(t)},get selectedVariant(){let n=e.GetLastSelectedVariant(t);return n?Array.isArray(n)?n[0]:n:e.GetAvailableVariants(t)[0]},set selectedVariant(n){e.SelectVariant(t,n)}})}}_loadMeshPrimitiveAsync(t,n,r,i,a,o){return I8.LoadExtensionAsync(t,a,this.name,async(s,c)=>{let l=[];return l.push(this._loader._loadMeshPrimitiveAsync(t,n,r,i,a,n=>{if(o(n),n instanceof K){let r=I8._GetDrawMode(t,a.mode),i=this._loader.rootBabylonMesh,o=i?i._internalMetadata=i._internalMetadata||{}:{},u=o.gltf=o.gltf||{},d=u[l5]=u[l5]||{lastSelected:null,original:[],variants:{}};d.original.push({mesh:n,material:n.material});for(let t=0;t{for(let r=0;r{let r=t,a,o=r;do{if(o=o.parent,!o)return;a=e._GetExtensionMetadata(o)}while(a===null);if(i&&a===e._GetExtensionMetadata(i)){o._internalMetadata={};for(let e in i._internalMetadata)o._internalMetadata[e]=i._internalMetadata[e];o._internalMetadata.gltf=[];for(let e in i._internalMetadata.gltf)o._internalMetadata.gltf[e]=i._internalMetadata.gltf[e];o._internalMetadata.gltf[l5]={lastSelected:null,original:[],variants:{}};for(let e of a.original)o._internalMetadata.gltf[l5].original.push({mesh:e.mesh,material:e.material});for(let e in a.variants)if(Object.prototype.hasOwnProperty.call(a.variants,e)){o._internalMetadata.gltf[l5].variants[e]=[];for(let t of a.variants[e])o._internalMetadata.gltf[l5].variants[e].push({mesh:t.mesh,material:t.material})}a=o._internalMetadata.gltf[l5]}for(let e of a.original)e.mesh===n&&(e.mesh=r);for(let e of a.variants[s.name])e.mesh===n&&(e.mesh=r)})}}))}}})),await Promise.all(l).then(([e])=>e)})}},k1e=!1;function A1e(){k1e||(k1e=!0,D8(l5),E8(l5,!0,e=>new O1e(e)))}A1e();var j1e=class e{static _GetDefaultOptions(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:q.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}}constructor(t,n){this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._newMeshObserver=null,this._removedMeshObserver=null,this._disposed=!1,this._materialImpls=[],this._adapterCache=new WeakMap,this._translucentMaterialIndices=new Map,this._opaqueOnlySubMeshes=new Map,this._savedSubMeshes=new Map,this._options={...e._GetDefaultOptions(),...t},this._scene=n,this._scene._transmissionHelper=this,this.onErrorObservable=new D,this._scene.onDisposeObservable.addOnce(()=>{this.dispose()}),this._parseScene(),this._setupRenderTargets()}addMaterialImpl(e){this._materialImpls.some(t=>t.materialClass===e.materialClass)||this._materialImpls.push(e)}updateOptions(e){if(!Object.keys(e).filter(t=>this._options[t]!==e[t]).length)return;let t={...this._options,...e},n=this._options;this._options=t,t.renderSize!==n.renderSize||t.renderTargetTextureType!==n.renderTargetTextureType||t.generateMipmaps!==n.generateMipmaps||!this._opaqueRenderTarget?this._setupRenderTargets():(this._opaqueRenderTarget.samples=t.samples,this._opaqueRenderTarget.lodGenerationScale=t.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=t.lodGenerationOffset)}getOpaqueTarget(){return this._opaqueRenderTarget}_getOrCreateAdapter(e){let t=this._adapterCache.get(e);if(!t){for(let n of this._materialImpls)if(e instanceof n.materialClass){t=new n.adapterClass(e),this._adapterCache.set(e,t);break}}return t}_classifyMeshMaterials(e){let t=e.material;if(!t)return`opaque`;if(!(t instanceof al)){let e=this._getOrCreateAdapter(t);return e&&e.isTranslucent()?(e.refractionBackgroundTexture=this._opaqueRenderTarget,`transparent`):`opaque`}let n=!1,r=!1,i=new Set;for(let e=0;e!t.has(e.materialIndex)))}_addMesh(e){this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),ge.SetImmediate(()=>{this._disposed||e.material&&(this._classifyMeshMaterials(e)===`transparent`?this._transparentMeshesCache.indexOf(e)===-1&&this._transparentMeshesCache.push(e):this._opaqueMeshesCache.indexOf(e)===-1&&this._opaqueMeshesCache.push(e))})}_removeMesh(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];let t=this._transparentMeshesCache.indexOf(e);t!==-1&&this._transparentMeshesCache.splice(t,1),t=this._opaqueMeshesCache.indexOf(e),t!==-1&&this._opaqueMeshesCache.splice(t,1),this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e)}_parseScene(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._newMeshObserver=this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._removedMeshObserver=this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))}_onMeshMaterialChanged(e){let t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);this._classifyMeshMaterials(e)===`transparent`?n===-1?t===-1&&this._transparentMeshesCache.push(e):(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):t===-1?n===-1&&this._opaqueMeshesCache.push(e):(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e))}_isRenderTargetValid(){return this._opaqueRenderTarget?.getInternalTexture()!==null}_setupRenderTargets(){this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new nr(`opaqueSceneTexture`,this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=this._options.clearColor?.clone()??this._scene.clearColor.clone(),this._opaqueRenderTarget.clearColor.a=0,this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.renderSprites=!0,this._opaqueRenderTarget.renderParticles=!0,this._opaqueRenderTarget.disableImageProcessing=!0;let e;this._opaqueRenderTarget.onBeforeBindObservable.add(t=>{e=this._scene.environmentIntensity,this._scene.environmentIntensity=1,this._options.clearColor?t.clearColor.copyFrom(this._options.clearColor):this._scene.clearColor.toLinearSpaceToRef(t.clearColor,this._scene.getEngine().useExactSrgbConversions),t.clearColor.a=0;let n=this._opaqueOnlySubMeshes.entries();for(let e=n.next();!e.done;e=n.next()){let t=e.value[0],n=e.value[1];t.subMeshes&&=(this._savedSubMeshes.set(t,t.subMeshes),n)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(()=>{this._scene.environmentIntensity=e;let t=this._savedSubMeshes.entries();for(let e=t.next();!e.done;e=t.next())e.value[0].subMeshes=e.value[1];this._savedSubMeshes.clear()});for(let e of this._transparentMeshesCache)e.material&&this._classifyMeshMaterials(e);let t=this._translucentMaterialIndices.entries();for(let e=t.next();!e.done;e=t.next()){let t=e.value[0];t.material&&this._classifyMeshMaterials(t)}}dispose(){this._disposed=!0,this._newMeshObserver?.remove(),this._removedMeshObserver?.remove(),this._newMeshObserver=null,this._removedMeshObserver=null;let e=[...this._transparentMeshesCache,...this._opaqueMeshesCache];for(let t of e){let e=this._materialObservers[t.uniqueId];e&&(e.remove(),delete this._materialObservers[t.uniqueId])}for(let e of this._scene.meshes){let t=this._materialObservers[e.uniqueId];t&&(t.remove(),delete this._materialObservers[e.uniqueId])}this._materialObservers={},this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&=(this._opaqueRenderTarget.dispose(),null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[],this._translucentMaterialIndices.clear(),this._opaqueOnlySubMeshes.clear(),this._savedSubMeshes.clear()}};function M1e(e,t){if(e.parent.dontUseTransmissionHelper)return;let n=t.getScene()._transmissionHelper,r=n??new j1e({},t.getScene());for(let t of Array.from(e._pbrMaterialImpls.values()))r.addMaterialImpl(t);n&&!n._isRenderTargetValid()&&n._setupRenderTargets()}var u5=`KHR_materials_transmission`,N1e=class{constructor(e){this.name=u5,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(u5),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadTransparentPropertiesAsync(r,t,n,i)),await Promise.all(a).then(()=>{})})}_loadTransparentPropertiesAsync(e,t,n,r){let i=this._loader._getOrCreateMaterialAdapter(n),a=r.transmissionFactor===void 0?0:r.transmissionFactor;if(a===0||!i)return Promise.resolve();i.configureTransmission(),i.transmissionWeight=a,a>0&&M1e(this._loader,n);let o=Promise.resolve(null);return r.transmissionTexture&&(r.transmissionTexture.nonColorData=!0,o=this._loader.loadTextureInfoAsync(`${e}/transmissionTexture`,r.transmissionTexture,e=>{e.name=`${n.name} (Transmission)`,i.transmissionWeightTexture=e})),o.then(()=>{})}},P1e=!1;function F1e(){P1e||(P1e=!0,D8(u5),E8(u5,!0,e=>new N1e(e)))}F1e();var d5=`KHR_materials_diffuse_transmission`,I1e=class{constructor(e){this.name=d5,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(d5),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadTranslucentPropertiesAsync(r,t,n,i)),await Promise.all(a).then(()=>{})})}_loadTranslucentPropertiesAsync(e,t,n,r){let i=this._loader._getOrCreateMaterialAdapter(n);i.configureSubsurface(),i.subsurfaceWeight=r.diffuseTransmissionFactor??0,i.subsurfaceWeight>0&&M1e(this._loader,n),i.diffuseTransmissionTint=r.diffuseTransmissionColorFactor===void 0?P.White():P.FromArray(r.diffuseTransmissionColorFactor);let a=[];return r.diffuseTransmissionTexture&&(r.diffuseTransmissionTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionTexture`,r.diffuseTransmissionTexture).then(e=>{e.name=`${n.name} (Diffuse Transmission)`,i.subsurfaceWeightTexture=e}))),r.diffuseTransmissionColorTexture&&a.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionColorTexture`,r.diffuseTransmissionColorTexture).then(e=>{e.name=`${n.name} (Diffuse Transmission Color)`,i.diffuseTransmissionTintTexture=e})),Promise.all(a).then(()=>{})}},L1e=!1;function R1e(){L1e||(L1e=!0,D8(d5),E8(d5,!0,e=>new I1e(e)))}R1e();var f5=`KHR_materials_volume`,z1e=class{constructor(e){this.name=f5,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(f5),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadVolumePropertiesAsync(r,t,n,i)),await Promise.all(a).then(()=>{})})}_loadVolumePropertiesAsync(e,t,n,r){let i=this._loader._getOrCreateMaterialAdapter(n);if(i.transmissionWeight===0&&i.subsurfaceWeight===0||!r.thicknessFactor)return Promise.resolve();i.geometryThinWalled=!1;let a=r.attenuationDistance===void 0?Number.MAX_VALUE:r.attenuationDistance,o=r.attenuationColor!==void 0&&r.attenuationColor.length==3?P.FromArray(r.attenuationColor):P.White();i.configureVolume(),i.transmissionColor=o,i.transmissionDepth=a,i.volumeThickness=r.thicknessFactor??0;let s=[];return r.thicknessTexture&&(r.thicknessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/thicknessTexture`,r.thicknessTexture,e=>{e.name=`${n.name} (Thickness)`,i.volumeThicknessTexture=e}))),Promise.all(s).then(()=>{})}},B1e=!1;function V1e(){B1e||(B1e=!0,D8(f5),E8(f5,!0,e=>new z1e(e)))}V1e();var p5=`KHR_materials_volume_scatter`;function H1e(e){let t=new j(e.r,e.g,e.b),n=new j(4.09712,4.09712,4.09712);n.addInPlace(new j(4.20863,4.20863,4.20863).multiplyInPlace(t));let r=new j(9.59217,9.59217,9.59217);return r.addInPlace(new j(41.6808,41.6808,41.6808).multiplyInPlace(t)),r.addInPlace(new j(17.7126,17.7126,17.7126).multiplyInPlace(t.multiply(t))),n.subtractInPlace(new j(Math.sqrt(r.x),Math.sqrt(r.y),Math.sqrt(r.z))),new j(1,1,1).subtract(n.multiply(n))}var U1e=class{constructor(e){this.name=p5,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed(p5),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadVolumePropertiesAsync(r,t,n,i)),await Promise.all(a).then(()=>{})})}_loadVolumePropertiesAsync(e,t,n,r){let i=this._loader._getOrCreateMaterialAdapter(n);if(i.transmissionWeight===0&&i.subsurfaceWeight===0||i.geometryThinWalled)return Promise.resolve();let a=r.multiscatterColorFactor!==void 0&&r.multiscatterColorFactor.length==3?P.FromArray(r.multiscatterColorFactor):P.Black(),o=r.scatterAnisotropy===void 0?0:r.scatterAnisotropy,s=Promise.resolve(null);r.multiscatterColorTexture&&(r.multiscatterColorTexture.nonColorData=!0,s=this._loader.loadTextureInfoAsync(`${e}/multiscatterColorTexture`,r.multiscatterColorTexture,e=>{e.name=`${n.name} (Scatter Color)`,i.transmissionWeight>0&&(i.transmissionScatterTexture=e),i.subsurfaceWeight>0&&(i.subsurfaceColorTexture=e)}));let c=new j(-Math.log(i.transmissionColor.r),-Math.log(i.transmissionColor.g),-Math.log(i.transmissionColor.b));if(c.scaleInPlace(1/Math.max(i.transmissionDepth,1e-6)),i.transmissionWeight>0){let e=H1e(a),t=c.multiply(e);t.scaleInPlace(i.transmissionDepth),i.transmissionScatter.set(t.x,t.y,t.z),i.transmissionScatterAnisotropy=o}if(i.subsurfaceWeight>0){i.subsurfaceScatterAnisotropy=o,i.subsurfaceColor=a;let e=new j(c.x===0?1:1/c.x,c.y===0?1:1/c.y,c.z===0?1:1/c.z);i.subsurfaceRadius=Math.max(e.x,e.y,e.z),i.subsurfaceRadiusScale=new P(e.x/i.subsurfaceRadius,e.y/i.subsurfaceRadius,e.z/i.subsurfaceRadius)}return s.then(()=>{})}},W1e=!1;function G1e(){W1e||(W1e=!0,D8(p5),E8(p5,!0,e=>new U1e(e)))}G1e();var m5=`KHR_materials_dispersion`,K1e=class{constructor(e){this.name=m5,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(m5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadDispersionPropertiesAsync(r,t,n,i)),await Promise.all(a).then(()=>{})})}_loadDispersionPropertiesAsync(e,t,n,r){let i=this._loader._getOrCreateMaterialAdapter(n);return i.transmissionWeight==0||!r.dispersion?Promise.resolve():(i.transmissionDispersionAbbeNumber=20,i.transmissionDispersionScale=r.dispersion,Promise.resolve())}},q1e=!1;function J1e(){q1e||(q1e=!0,D8(m5),E8(m5,!0,e=>new K1e(e)))}J1e();var h5=`KHR_materials_diffuse_roughness`,Y1e=class{constructor(e){this.name=h5,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(h5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=[];return a.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),a.push(this._loadDiffuseRoughnessPropertiesAsync(r,i,n)),await Promise.all(a).then(()=>{})})}_loadDiffuseRoughnessPropertiesAsync(e,t,n){let r=this._loader._getOrCreateMaterialAdapter(n),i=[];return r.baseDiffuseRoughness=t.diffuseRoughnessFactor??0,t.diffuseRoughnessTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseRoughnessTexture`,t.diffuseRoughnessTexture,e=>{e.name=`${n.name} (Diffuse Roughness)`,r.baseDiffuseRoughnessTexture=e})),Promise.all(i).then(()=>{})}},X1e=!1;function Z1e(){X1e||(X1e=!0,D8(h5),E8(h5,!0,e=>new Y1e(e)))}Z1e();var g5=`KHR_mesh_quantization`,Q1e=class{constructor(e){this.name=g5,this.enabled=e.isExtensionUsed(g5)}dispose(){}},$1e=!1;function e0e(){$1e||($1e=!0,D8(g5),E8(g5,!0,e=>new Q1e(e)))}e0e();var _5=`KHR_texture_basisu`,t0e=class{constructor(e){this.name=_5,this._loader=e,this.enabled=e.isExtensionUsed(_5)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>{let a=t.sampler==null?I8.DefaultSampler:F8.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=F8.Get(`${r}/source`,this._loader.gltf.images,i.source);return await this._loader._createTextureAsync(e,a,o,e=>{n(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)})}},n0e=!1;function r0e(){n0e||(n0e=!0,D8(_5),E8(_5,!0,e=>new t0e(e)))}r0e();var v5=`KHR_texture_transform`,i0e=class{constructor(e){this.name=v5,this._loader=e,this.enabled=this._loader.isExtensionUsed(v5)}dispose(){this._loader=null}loadTextureInfoAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(r,i)=>await this._loader.loadTextureInfoAsync(e,t,e=>{if(!(e instanceof W))throw Error(`${r}: Texture type not supported`);i.offset&&(e.uOffset=i.offset[0],e.vOffset=i.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,i.rotation&&(e.wAng=-i.rotation),i.scale&&(e.uScale=i.scale[0],e.vScale=i.scale[1]),i.texCoord!=null&&(e.coordinatesIndex=i.texCoord),n(e)}))}},a0e=!1;function o0e(){a0e||(a0e=!0,D8(v5),E8(v5,!0,e=>new i0e(e)))}o0e();var y5=`KHR_xmp_json_ld`,s0e=class{constructor(e){this.name=y5,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(y5)}dispose(){this._loader=null}onLoading(){if(this._loader.rootBabylonMesh===null)return;let e=this._loader.gltf.extensions?.KHR_xmp_json_ld,t=this._loader.gltf.asset?.extensions?.KHR_xmp_json_ld;if(e&&t){let n=+t.packet;e.packets&&nnew s0e(e)))}l0e();var b5=`KHR_animation_pointer`,u0e=class{constructor(e){this.name=b5,this._loader=e,this._pathToObjectConverter=e$e(this._loader.gltf)}get enabled(){return this._loader.isExtensionUsed(b5)}dispose(){this._loader=null,delete this._pathToObjectConverter}_loadAnimationChannelAsync(e,t,n,r,i){let a=r.target.extensions?.KHR_animation_pointer;if(!a||!this._pathToObjectConverter)return null;r.target.path!==`pointer`&&F.Warn(`${e}/target/path: Value (${r.target.path}) must be (pointer) when using the ${this.name} extension`),r.target.node!=null&&F.Warn(`${e}/target/node: Value (${r.target.node}) must not be present when using the ${this.name} extension`);let o=`${e}/extensions/${this.name}`,s=a.pointer;if(!s)throw Error(`${o}: Pointer is missing`);try{let a=this._pathToObjectConverter.convert(s);if(!a.info.interpolation)throw Error(`${o}/pointer: Interpolation is missing`);return this._loader._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,{object:a.object,info:a.info.interpolation},i)}catch{return F.Warn(`${o}/pointer: Invalid pointer (${s}) skipped`),null}}},d0e=!1;function f0e(){d0e||(d0e=!0,D8(b5),E8(b5,!0,e=>new u0e(e)))}function x5(e,t,n,r){return P.FromArray(t,n).scale(r)}function p0e(e,t,n,r){return t[n+3]*r}function S5(e,t,n,r){return t[n]*r}function C5(e,t,n,r){return-t[n]*r}function w5(e,t,n,r){return t[n+1]*r}function m0e(e,t,n,r){return t[n]*r*2}function T5(e){return{scale:[new D5(Ne.ANIMATIONTYPE_FLOAT,`${e}.uScale`,S5,()=>2),new D5(Ne.ANIMATIONTYPE_FLOAT,`${e}.vScale`,w5,()=>2)],offset:[new D5(Ne.ANIMATIONTYPE_FLOAT,`${e}.uOffset`,S5,()=>2),new D5(Ne.ANIMATIONTYPE_FLOAT,`${e}.vOffset`,w5,()=>2)],rotation:[new D5(Ne.ANIMATIONTYPE_FLOAT,`${e}.wAng`,C5,()=>1)]}}var E5=class extends R8{buildAnimations(e,t,n,r){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,n,r)}]}},D5=class extends R8{buildAnimations(e,t,n,r){let i=[];for(let a in e._data)i.push({babylonAnimatable:e._data[a].babylonMaterial,babylonAnimation:this._buildAnimation(t,n,r)});return i}},O5=class extends R8{buildAnimations(e,t,n,r){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,n,r)}]}},h0e=class extends R8{buildAnimations(e,t,n,r){return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(e=>({babylonAnimatable:e,babylonAnimation:this._buildAnimation(t,n,r)})):[]}};N8(`/cameras/{}/orthographic/xmag`,[new E5(Ne.ANIMATIONTYPE_FLOAT,`orthoLeft`,C5,()=>1),new E5(Ne.ANIMATIONTYPE_FLOAT,`orthoRight`,w5,()=>1)]),N8(`/cameras/{}/orthographic/ymag`,[new E5(Ne.ANIMATIONTYPE_FLOAT,`orthoBottom`,C5,()=>1),new E5(Ne.ANIMATIONTYPE_FLOAT,`orthoTop`,w5,()=>1)]),N8(`/cameras/{}/orthographic/zfar`,[new E5(Ne.ANIMATIONTYPE_FLOAT,`maxZ`,S5,()=>1)]),N8(`/cameras/{}/orthographic/znear`,[new E5(Ne.ANIMATIONTYPE_FLOAT,`minZ`,S5,()=>1)]),N8(`/cameras/{}/perspective/yfov`,[new E5(Ne.ANIMATIONTYPE_FLOAT,`fov`,S5,()=>1)]),N8(`/cameras/{}/perspective/zfar`,[new E5(Ne.ANIMATIONTYPE_FLOAT,`maxZ`,S5,()=>1)]),N8(`/cameras/{}/perspective/znear`,[new E5(Ne.ANIMATIONTYPE_FLOAT,`minZ`,S5,()=>1)]),N8(`/materials/{}/pbrMetallicRoughness/baseColorFactor`,[new D5(Ne.ANIMATIONTYPE_COLOR3,`albedoColor`,x5,()=>4),new D5(Ne.ANIMATIONTYPE_FLOAT,`alpha`,p0e,()=>4)]),N8(`/materials/{}/pbrMetallicRoughness/metallicFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`metallic`,S5,()=>1)]),N8(`/materials/{}/pbrMetallicRoughness/metallicFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`roughness`,S5,()=>1)]);var k5=T5(`albedoTexture`);N8(`/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale`,k5.scale),N8(`/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset`,k5.offset),N8(`/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation`,k5.rotation);var A5=T5(`metallicTexture`);N8(`//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale`,A5.scale),N8(`//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset`,A5.offset),N8(`//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation`,A5.rotation),N8(`/materials/{}/emissiveFactor`,[new D5(Ne.ANIMATIONTYPE_COLOR3,`emissiveColor`,x5,()=>3)]);var j5=T5(`bumpTexture`);N8(`/materials/{}/normalTexture/scale`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`bumpTexture.level`,S5,()=>1)]),N8(`/materials/{}/normalTexture/extensions/KHR_texture_transform/scale`,j5.scale),N8(`/materials/{}/normalTexture/extensions/KHR_texture_transform/offset`,j5.offset),N8(`/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation`,j5.rotation),N8(`/materials/{}/occlusionTexture/strength`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`ambientTextureStrength`,S5,()=>1)]);var M5=T5(`ambientTexture`);N8(`/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale`,M5.scale),N8(`/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset`,M5.offset),N8(`/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation`,M5.rotation);var N5=T5(`emissiveTexture`);N8(`/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale`,N5.scale),N8(`/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset`,N5.offset),N8(`/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation`,N5.rotation),N8(`/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`anisotropy.intensity`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`anisotropy.angle`,S5,()=>1)]);var P5=T5(`anisotropy.texture`);N8(`/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale`,P5.scale),N8(`/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset`,P5.offset),N8(`/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation`,P5.rotation),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`clearCoat.intensity`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`clearCoat.roughness`,S5,()=>1)]);var F5=T5(`clearCoat.texture`);N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale`,F5.scale),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset`,F5.offset),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation`,F5.rotation);var I5=T5(`clearCoat.bumpTexture`);N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`clearCoat.bumpTexture.level`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale`,I5.scale),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset`,I5.offset),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation`,I5.rotation);var L5=T5(`clearCoat.textureRoughness`);N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale`,L5.scale),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset`,L5.offset),N8(`/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation`,L5.rotation),N8(`/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`subSurface.dispersion`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`emissiveIntensity`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_ior/ior`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`indexOfRefraction`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`iridescence.intensity`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`iridescence.indexOfRefraction`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`iridescence.minimumThickness`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`iridescence.maximumThickness`,S5,()=>1)]);var R5=T5(`iridescence.texture`);N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale`,R5.scale),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset`,R5.offset),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation`,R5.rotation);var z5=T5(`iridescence.thicknessTexture`);N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale`,z5.scale),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset`,z5.offset),N8(`/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation`,z5.rotation),N8(`/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor`,[new D5(Ne.ANIMATIONTYPE_COLOR3,`sheen.color`,x5,()=>3)]),N8(`/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`sheen.roughness`,S5,()=>1)]);var B5=T5(`sheen.texture`);N8(`/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale`,B5.scale),N8(`/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset`,B5.offset),N8(`/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation`,B5.rotation);var V5=T5(`sheen.textureRoughness`);N8(`/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale`,V5.scale),N8(`/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset`,V5.offset),N8(`/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation`,V5.rotation),N8(`/materials/{}/extensions/KHR_materials_specular/specularFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`metallicF0Factor`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_specular/specularColorFactor`,[new D5(Ne.ANIMATIONTYPE_COLOR3,`metallicReflectanceColor`,x5,()=>3)]);var H5=T5(`metallicReflectanceTexture`);N8(`/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale`,H5.scale),N8(`/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset`,H5.offset),N8(`/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation`,H5.rotation);var U5=T5(`reflectanceTexture`);N8(`/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale`,U5.scale),N8(`/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset`,U5.offset),N8(`/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation`,U5.rotation),N8(`/materials/{}/extensions/KHR_materials_transmission/transmissionFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`subSurface.refractionIntensity`,S5,()=>1)]);var W5=T5(`subSurface.refractionIntensityTexture`);N8(`/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale`,W5.scale),N8(`/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset`,W5.offset),N8(`/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation`,W5.rotation),N8(`/materials/{}/extensions/KHR_materials_volume/attenuationColor`,[new D5(Ne.ANIMATIONTYPE_COLOR3,`subSurface.tintColor`,x5,()=>3)]),N8(`/materials/{}/extensions/KHR_materials_volume/attenuationDistance`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`subSurface.tintColorAtDistance`,S5,()=>1)]),N8(`/materials/{}/extensions/KHR_materials_volume/thicknessFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`subSurface.maximumThickness`,S5,()=>1)]);var G5=T5(`subSurface.thicknessTexture`);N8(`/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale`,G5.scale),N8(`/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset`,G5.offset),N8(`/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation`,G5.rotation),N8(`/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor`,[new D5(Ne.ANIMATIONTYPE_FLOAT,`subSurface.translucencyIntensity`,S5,()=>1)]);var K5=T5(`subSurface.translucencyIntensityTexture`);N8(`materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale`,K5.scale),N8(`materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset`,K5.offset),N8(`materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation`,K5.rotation),N8(`/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor`,[new D5(Ne.ANIMATIONTYPE_COLOR3,`subSurface.translucencyColor`,x5,()=>3)]);var q5=T5(`subSurface.translucencyColorTexture`);N8(`materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale`,q5.scale),N8(`materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset`,q5.offset),N8(`materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation`,q5.rotation),N8(`/extensions/KHR_lights_punctual/lights/{}/color`,[new O5(Ne.ANIMATIONTYPE_COLOR3,`diffuse`,x5,()=>3)]),N8(`/extensions/KHR_lights_punctual/lights/{}/intensity`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`intensity`,S5,()=>1)]),N8(`/extensions/KHR_lights_punctual/lights/{}/range`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`range`,S5,()=>1)]),N8(`/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`innerAngle`,m0e,()=>1)]),N8(`/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`angle`,m0e,()=>1)]),N8(`/extensions/EXT_lights_area/lights/{}/color`,[new O5(Ne.ANIMATIONTYPE_COLOR3,`diffuse`,x5,()=>3)]),N8(`/extensions/EXT_lights_area/lights/{}/intensity`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`intensity`,S5,()=>1)]),N8(`/extensions/EXT_lights_area/lights/{}/size`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`radius`,S5,()=>1)]),N8(`/extensions/EXT_lights_area/lights/{}/rect/aspect`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`radius`,S5,()=>1)]),N8(`/nodes/{}/extensions/EXT_lights_ies/color`,[new O5(Ne.ANIMATIONTYPE_COLOR3,`diffuse`,x5,()=>3)]),N8(`/nodes/{}/extensions/EXT_lights_ies/multiplier`,[new O5(Ne.ANIMATIONTYPE_FLOAT,`intensity`,S5,()=>1)]),N8(`/nodes/{}/extensions/KHR_node_visibility/visible`,[new h0e(Ne.ANIMATIONTYPE_FLOAT,`isVisible`,S5,()=>1)]),f0e();var J5=`MSFT_audio_emitter`,g0e=class{constructor(e){this.name=J5,this._loader=e,this.enabled=this._loader.isExtensionUsed(J5)}dispose(){this._loader=null,this._clips=null,this._emitters=null}onLoading(){let e=this._loader.gltf.extensions;if(e&&e[this.name]){let t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,F8.Assign(this._clips),F8.Assign(this._emitters)}}loadSceneAsync(e,t){return I8.LoadExtensionAsync(e,t,this.name,async(n,r)=>{let i=[];i.push(this._loader.loadSceneAsync(e,t));for(let e of r.emitters){let t=F8.Get(`${n}/emitters`,this._emitters,e);if(t.refDistance!=null||t.maxDistance!=null||t.rolloffFactor!=null||t.distanceModel!=null||t.innerAngle!=null||t.outerAngle!=null)throw Error(`${n}: Direction or Distance properties are not allowed on emitters attached to a scene`);i.push(this._loadEmitterAsync(`${n}/emitters/${t.index}`,t))}await Promise.all(i)})}loadNodeAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(e,r)=>{let i=[],a=await this._loader.loadNodeAsync(e,t,t=>{for(let n of r.emitters){let r=F8.Get(`${e}/emitters`,this._emitters,n);i.push(this._loadEmitterAsync(`${e}/emitters/${r.index}`,r).then(()=>{for(let e of r._babylonSounds)e.attachToMesh(t),(r.innerAngle!=null||r.outerAngle!=null)&&(e.setLocalDirectionToMesh(j.Forward()),e.setDirectionalCone(2*ge.ToDegrees(r.innerAngle==null?Math.PI:r.innerAngle),2*ge.ToDegrees(r.outerAngle==null?Math.PI:r.outerAngle),0))}))}n(t)});return await Promise.all(i),a})}loadAnimationAsync(e,t){return I8.LoadExtensionAsync(e,t,this.name,async(n,r)=>{let i=await this._loader.loadAnimationAsync(e,t),a=[];F8.Assign(r.events);for(let o of r.events)a.push(this._loadAnimationEventAsync(`${n}/events/${o.index}`,e,t,o,i));return await Promise.all(a),i})}_loadClipAsync(e,t){if(t._objectURL)return t._objectURL;let n;if(t.uri)n=this._loader.loadUriAsync(e,t,t.uri);else{let r=F8.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,t.bufferView);n=this._loader.loadBufferViewAsync(`/bufferViews/${r.index}`,r)}return t._objectURL=n.then(e=>{let n=Ot(e);return URL.createObjectURL(new Blob([n],{type:t.mimeType}))}),t._objectURL}_loadEmitterAsync(e,t){if(t._babylonSounds=t._babylonSounds||[],!t._babylonData){let e=[],n=t.name||`emitter${t.index}`,r={loop:!1,autoplay:!1,volume:t.volume==null?1:t.volume};for(let i=0;i{let a=t._babylonSounds[i]=new pd(n,e,this._loader.babylonScene,null,r);a.refDistance=t.refDistance||1,a.maxDistance=t.maxDistance||256,a.rolloffFactor=t.rolloffFactor||1,a.distanceModel=t.distanceModel||`exponential`}))}t._babylonData={loaded:Promise.all(e).then(()=>{let e=t.clips.map(e=>e.weight||1),n=new gd(t.loop||!1,t._babylonSounds,e);t.innerAngle&&(n.directionalConeInnerAngle=2*ge.ToDegrees(t.innerAngle)),t.outerAngle&&(n.directionalConeOuterAngle=2*ge.ToDegrees(t.outerAngle)),t.volume&&(n.volume=t.volume),t._babylonData.sound=n})}}return t._babylonData.loaded}_getEventAction(e,t,n,r,i){switch(n){case`play`:return e=>{let n=(i||0)+(e-r);t.play(n)};case`stop`:return()=>{t.stop()};case`pause`:return()=>{t.pause()};default:throw Error(`${e}: Unsupported action ${n}`)}}_loadAnimationEventAsync(e,t,n,r,i){if(i.targetedAnimations.length==0)return Promise.resolve();let a=i.targetedAnimations[0],o=r.emitter,s=F8.Get(`/extensions/${this.name}/emitters`,this._emitters,o);return this._loadEmitterAsync(e,s).then(()=>{let t=s._babylonData.sound;if(t){let n=new oc(r.time,this._getEventAction(e,t,r.action,r.time,r.startOffset));a.animation.addEvent(n),i.onAnimationGroupEndObservable.add(()=>{t.stop()}),i.onAnimationGroupPauseObservable.add(()=>{t.pause()})}})}},_0e=!1;function v0e(){_0e||(_0e=!0,D8(J5),E8(J5,!0,e=>new g0e(e)))}v0e();var Y5=`MSFT_lod`,y0e=class{constructor(e){this.name=Y5,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new D,this.onMaterialLODsLoadedObservable=new D,this._bufferLODs=[],this._nodeIndexLOD=null,this._nodeSignalLODs=[],this._nodePromiseLODs=[],this._nodeBufferLODs=[],this._materialIndexLOD=null,this._materialSignalLODs=[],this._materialPromiseLODs=[],this._materialBufferLODs=[],this._loader=e,this.maxLODsToLoad=this._loader.parent.extensionOptions[Y5]?.maxLODsToLoad??this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(Y5)}dispose(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()}onReady(){for(let e=0;e{e!==0&&(this._loader.endPerformanceCounter(`Node LOD ${e}`),this._loader.log(`Loaded node LOD ${e}`)),this.onNodeLODsLoadedObservable.notifyObservers(e),e!==this._nodePromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Node LOD ${e+1}`),this._loadBufferLOD(this._nodeBufferLODs,e+1),this._nodeSignalLODs[e]&&this._nodeSignalLODs[e].resolve())});this._loader._completePromises.push(t)}for(let e=0;e{e!==0&&(this._loader.endPerformanceCounter(`Material LOD ${e}`),this._loader.log(`Loaded material LOD ${e}`)),this.onMaterialLODsLoadedObservable.notifyObservers(e),e!==this._materialPromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Material LOD ${e+1}`),this._loadBufferLOD(this._materialBufferLODs,e+1),this._materialSignalLODs[e]&&this._materialSignalLODs[e].resolve())});this._loader._completePromises.push(t)}}loadSceneAsync(e,t){let n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n}loadNodeAsync(e,t,n){return I8.LoadExtensionAsync(e,t,this.name,async(e,r)=>{let i,a=this._getLODs(e,t,this._loader.gltf.nodes,r.ids);this._loader.logOpen(`${e}`);for(let e=0;e{n(e),e.setEnabled(!1)}).then(t=>{if(e!==0){let t=a[e-1];t._babylonTransformNode&&(this._disposeTransformNode(t._babylonTransformNode),delete t._babylonTransformNode)}return t.setEnabled(!0),t});this._nodePromiseLODs[e]=this._nodePromiseLODs[e]||[],e===0?i=r:(this._nodeIndexLOD=null,this._nodePromiseLODs[e].push(r))}return this._loader.logClose(),await i})}_loadMaterialAsync(e,t,n,r,i){return this._nodeIndexLOD?null:I8.LoadExtensionAsync(e,t,this.name,async(e,a)=>{let o,s=this._getLODs(e,t,this._loader.gltf.materials,a.ids);this._loader.logOpen(`${e}`);for(let e=0;e{e===0&&i(t)}).then(t=>{if(e!==0){i(t);let n=s[e-1]._data;n[r]&&(this._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t});this._materialPromiseLODs[e]=this._materialPromiseLODs[e]||[],e===0?o=a:(this._materialIndexLOD=null,this._materialPromiseLODs[e].push(a))}return this._loader.logClose(),await o})}_loadUriAsync(e,t,n){if(this._nodeIndexLOD!==null){this._loader.log(`deferred`);let r=this._nodeIndexLOD-1;return this._nodeSignalLODs[r]=this._nodeSignalLODs[r]||new YX,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(async()=>await this._loader.loadUriAsync(e,t,n))}else if(this._materialIndexLOD!==null){this._loader.log(`deferred`);let r=this._materialIndexLOD-1;return this._materialSignalLODs[r]=this._materialSignalLODs[r]||new YX,this._materialSignalLODs[r].promise.then(async()=>await this._loader.loadUriAsync(e,t,n))}return null}loadBufferAsync(e,t,n,r){if(this._loader.parent.useRangeRequests&&!t.uri){if(!this._loader.bin)throw Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);let t=async(e,t)=>{let i=n,a=i+r-1,o=e[t];return o?(o.start=Math.min(o.start,i),o.end=Math.max(o.end,a)):(o={start:i,end:a,loaded:new YX},e[t]=o),await o.loaded.promise.then(e=>new Uint8Array(e.buffer,e.byteOffset+n-o.start,r))};return this._loader.log(`deferred`),this._nodeIndexLOD===null?this._materialIndexLOD===null?t(this._bufferLODs,0):t(this._materialBufferLODs,this._materialIndexLOD):t(this._nodeBufferLODs,this._nodeIndexLOD)}return null}_loadBufferLOD(e,t){let n=e[t];n&&(this._loader.log(`Loading buffer range [${n.start}-${n.end}]`),this._loader.bin.readAsync(n.start,n.end-n.start+1).then(e=>{n.loaded.resolve(e)},e=>{n.loaded.reject(e)}))}_getLODs(e,t,n,r){if(this.maxLODsToLoad<=0)throw Error(`maxLODsToLoad must be greater than zero`);let i=[];for(let t=r.length-1;t>=0;t--)if(i.push(F8.Get(`${e}/ids/${r[t]}`,n,r[t])),i.length===this.maxLODsToLoad)return i;return i.push(t),i}_disposeTransformNode(e){let t=[],n=e.material;n&&t.push(n);for(let n of e.getChildMeshes())n.material&&t.push(n.material);e.dispose();let r=t.filter(e=>this._loader.babylonScene.meshes.every(t=>t.material!=e));this._disposeMaterials(r)}_disposeMaterials(e){let t={};for(let n of e){for(let e of n.getActiveTextures())t[e.uniqueId]=e;n.dispose()}for(let e in t)for(let n of this._loader.babylonScene.materials)n.hasTexture(t[e])&&delete t[e];for(let e in t)t[e].dispose()}},b0e=!1;function x0e(){b0e||(b0e=!0,D8(Y5),E8(Y5,!0,e=>new y0e(e)))}x0e();var X5=`MSFT_minecraftMesh`,S0e=class{constructor(e){this.name=X5,this._loader=e,this.enabled=this._loader.isExtensionUsed(X5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtraAsync(e,t,this.name,async(r,i)=>{if(i){if(!this._loader._pbrMaterialImpls.get(`pbr`))throw Error(`${r}: Material type not supported`);let i=this._loader.loadMaterialPropertiesAsync(e,t,n);return n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,await i}})}},C0e=!1;function w0e(){C0e||(C0e=!0,D8(X5),E8(X5,!0,e=>new S0e(e)))}w0e();var Z5=`MSFT_sRGBFactors`,T0e=class{constructor(e){this.name=Z5,this._loader=e,this.enabled=this._loader.isExtensionUsed(Z5)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return I8.LoadExtraAsync(e,t,this.name,async(r,i)=>{if(i){let r=this._loader._getOrCreateMaterialAdapter(n),i=this._loader.loadMaterialPropertiesAsync(e,t,n),a=n.getScene().getEngine().useExactSrgbConversions;return r.baseColorTexture||r.baseColor.toLinearSpaceToRef(r.baseColor,a),r.specularColorTexture||r.specularColor.toLinearSpaceToRef(r.specularColor,a),await i}})}},E0e=!1;function D0e(){E0e||(E0e=!0,D8(Z5),E8(Z5,!0,e=>new T0e(e)))}D0e();function O0e(e){let[t,n]=e.split(`:`);return k0e({op:t,extension:n})}function k0e(e,t=!0){let n=e.extension?$5[e.extension]?.[e.op]:A0e[e.op];if(!n&&(F.Warn(`No mapping found for operation ${e.op} and extension ${e.extension||`KHR_interactivity`}`),t)){let t={},n={flows:{}};if(e.inputValueSockets){t.values={};for(let n in e.inputValueSockets)t.values[n]={name:n}}return e.outputValueSockets&&(n.values={},Object.keys(e.outputValueSockets).forEach(e=>{n.values[e]={name:e}})),{blocks:[],inputs:t,outputs:n}}return n}function Q5(e,t,n){$5[t]||($5[t]={}),$5[t][e]=n}var $5={BABYLON:{"flow/log":{blocks:[`FlowGraphConsoleLogBlock`],inputs:{values:{message:{name:`message`}}}}}},A0e={"event/onStart":{blocks:[`FlowGraphSceneReadyEventBlock`],outputs:{flows:{out:{name:`done`}}}},"event/onTick":{blocks:[`FlowGraphSceneTickEventBlock`],inputs:{},outputs:{values:{timeSinceLastTick:{name:`deltaTime`,gltfType:`number`}},flows:{out:{name:`done`}}}},"event/send":{blocks:[`FlowGraphSendCustomEventBlock`],extraProcessor(e,t,n,r,i){if(t.op!==`event/send`||!e.configuration||Object.keys(e.configuration).length!==1)throw Error(`Receive event should have a single configuration object, the event itself`);let a=e.configuration.event.value?.[0];if(typeof a!=`number`)throw Error(`Event id should be a number`);let o=r.arrays.events[a],s=i[0];return s.config||={},s.config.eventId=o.eventId,s.config.eventData=o.eventData,i}},"event/receive":{blocks:[`FlowGraphReceiveCustomEventBlock`],outputs:{flows:{out:{name:`done`}}},validation(e,t){if(!e.configuration)return F.Error(`Receive event should have a configuration object`),{valid:!1,error:`Receive event should have a configuration object`};let n=e.configuration.event;if(!n)return F.Error(`Receive event should have a single configuration object, the event itself`),{valid:!1,error:`Receive event should have a single configuration object, the event itself`};let r=n.value?.[0];return typeof r==`number`?t.events?.[r]?{valid:!0}:(F.Error(`Event with id ${r} not found`),{valid:!1,error:`Event with id ${r} not found`}):(F.Error(`Event id should be a number`),{valid:!1,error:`Event id should be a number`})},extraProcessor(e,t,n,r,i){if(t.op!==`event/receive`||!e.configuration||Object.keys(e.configuration).length!==1)throw Error(`Receive event should have a single configuration object, the event itself`);let a=e.configuration.event.value?.[0];if(typeof a!=`number`)throw Error(`Event id should be a number`);let o=r.arrays.events[a],s=i[0];return s.config||={},s.config.eventId=o.eventId,s.config.eventData=o.eventData,i}},"math/E":e7(`FlowGraphEBlock`),"math/Pi":e7(`FlowGraphPIBlock`),"math/Inf":e7(`FlowGraphInfBlock`),"math/NaN":e7(`FlowGraphNaNBlock`),"math/abs":e7(`FlowGraphAbsBlock`),"math/sign":e7(`FlowGraphSignBlock`),"math/trunc":e7(`FlowGraphTruncBlock`),"math/floor":e7(`FlowGraphFloorBlock`),"math/ceil":e7(`FlowGraphCeilBlock`),"math/round":{blocks:[`FlowGraphRoundBlock`],configuration:{},inputs:{values:{a:{name:`a`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i){var a;return(a=i[0]).config||(a.config={}),i[0].config.roundHalfAwayFromZero=!0,i}},"math/fract":e7(`FlowGraphFractBlock`),"math/neg":e7(`FlowGraphNegationBlock`),"math/add":e7(`FlowGraphAddBlock`,[`a`,`b`],!0),"math/sub":e7(`FlowGraphSubtractBlock`,[`a`,`b`],!0),"math/mul":{blocks:[`FlowGraphMultiplyBlock`],extraProcessor(e,t,n,r,i){var a;(a=i[0]).config||(a.config={}),i[0].config.useMatrixPerComponent=!0,i[0].config.preventIntegerFloatArithmetic=!0;let o=-1;return Object.keys(e.values||{}).find(t=>e.values?.[t].type===void 0?!1:(o=e.values[t].type,!0)),o!==-1&&(i[0].config.type=r.arrays.types[o].flowGraphType),i},validation(e){return e.values?j0e(e):{valid:!0}}},"math/div":e7(`FlowGraphDivideBlock`,[`a`,`b`],!0),"math/rem":e7(`FlowGraphModuloBlock`,[`a`,`b`]),"math/min":e7(`FlowGraphMinBlock`,[`a`,`b`]),"math/max":e7(`FlowGraphMaxBlock`,[`a`,`b`]),"math/clamp":e7(`FlowGraphClampBlock`,[`a`,`b`,`c`]),"math/saturate":e7(`FlowGraphSaturateBlock`),"math/mix":e7(`FlowGraphMathInterpolationBlock`,[`a`,`b`,`c`]),"math/eq":e7(`FlowGraphEqualityBlock`,[`a`,`b`]),"math/lt":e7(`FlowGraphLessThanBlock`,[`a`,`b`]),"math/le":e7(`FlowGraphLessThanOrEqualBlock`,[`a`,`b`]),"math/gt":e7(`FlowGraphGreaterThanBlock`,[`a`,`b`]),"math/ge":e7(`FlowGraphGreaterThanOrEqualBlock`,[`a`,`b`]),"math/isNaN":e7(`FlowGraphIsNaNBlock`),"math/isInf":e7(`FlowGraphIsInfBlock`),"math/select":{blocks:[`FlowGraphConditionalBlock`],inputs:{values:{condition:{name:`condition`},a:{name:`onTrue`},b:{name:`onFalse`}}},outputs:{values:{value:{name:`output`}}}},"math/random":{blocks:[`FlowGraphRandomBlock`],outputs:{values:{value:{name:`value`}}}},"math/sin":e7(`FlowGraphSinBlock`),"math/cos":e7(`FlowGraphCosBlock`),"math/tan":e7(`FlowGraphTanBlock`),"math/asin":e7(`FlowGraphASinBlock`),"math/acos":e7(`FlowGraphACosBlock`),"math/atan":e7(`FlowGraphATanBlock`),"math/atan2":e7(`FlowGraphATan2Block`,[`a`,`b`]),"math/sinh":e7(`FlowGraphSinhBlock`),"math/cosh":e7(`FlowGraphCoshBlock`),"math/tanh":e7(`FlowGraphTanhBlock`),"math/asinh":e7(`FlowGraphASinhBlock`),"math/acosh":e7(`FlowGraphACoshBlock`),"math/atanh":e7(`FlowGraphATanhBlock`),"math/exp":e7(`FlowGraphExponentialBlock`),"math/log":e7(`FlowGraphLogBlock`),"math/log2":e7(`FlowGraphLog2Block`),"math/log10":e7(`FlowGraphLog10Block`),"math/sqrt":e7(`FlowGraphSquareRootBlock`),"math/cbrt":e7(`FlowGraphCubeRootBlock`),"math/pow":e7(`FlowGraphPowerBlock`,[`a`,`b`]),"math/length":e7(`FlowGraphLengthBlock`),"math/normalize":e7(`FlowGraphNormalizeBlock`),"math/dot":e7(`FlowGraphDotBlock`,[`a`,`b`]),"math/cross":e7(`FlowGraphCrossBlock`,[`a`,`b`]),"math/rotate2D":{blocks:[`FlowGraphRotate2DBlock`],inputs:{values:{a:{name:`a`},angle:{name:`b`}}},outputs:{values:{value:{name:`value`}}}},"math/rotate3D":{blocks:[`FlowGraphRotate3DBlock`],inputs:{values:{a:{name:`a`},rotation:{name:`b`}}},outputs:{values:{value:{name:`value`}}}},"math/transform":{blocks:[`FlowGraphTransformVectorBlock`],inputs:{values:{a:{name:`a`},b:{name:`b`}}},outputs:{values:{value:{name:`value`}}}},"math/combine2":{blocks:[`FlowGraphCombineVector2Block`],inputs:{values:{a:{name:`input_0`,gltfType:`number`},b:{name:`input_1`,gltfType:`number`}}},outputs:{values:{value:{name:`value`}}}},"math/combine3":{blocks:[`FlowGraphCombineVector3Block`],inputs:{values:{a:{name:`input_0`,gltfType:`number`},b:{name:`input_1`,gltfType:`number`},c:{name:`input_2`,gltfType:`number`}}},outputs:{values:{value:{name:`value`}}}},"math/combine4":{blocks:[`FlowGraphCombineVector4Block`],inputs:{values:{a:{name:`input_0`,gltfType:`number`},b:{name:`input_1`,gltfType:`number`},c:{name:`input_2`,gltfType:`number`},d:{name:`input_3`,gltfType:`number`}}},outputs:{values:{value:{name:`value`}}}},"math/extract2":{blocks:[`FlowGraphExtractVector2Block`],inputs:{values:{a:{name:`input`,gltfType:`number`}}},outputs:{values:{0:{name:`output_0`},1:{name:`output_1`}}}},"math/extract3":{blocks:[`FlowGraphExtractVector3Block`],inputs:{values:{a:{name:`input`,gltfType:`number`}}},outputs:{values:{0:{name:`output_0`},1:{name:`output_1`},2:{name:`output_2`}}}},"math/extract4":{blocks:[`FlowGraphExtractVector4Block`],inputs:{values:{a:{name:`input`,gltfType:`number`}}},outputs:{values:{0:{name:`output_0`},1:{name:`output_1`},2:{name:`output_2`},3:{name:`output_3`}}}},"math/transpose":e7(`FlowGraphTransposeBlock`),"math/determinant":e7(`FlowGraphDeterminantBlock`),"math/inverse":e7(`FlowGraphInvertMatrixBlock`),"math/matMul":e7(`FlowGraphMatrixMultiplicationBlock`,[`a`,`b`]),"math/matCompose":{blocks:[`FlowGraphMatrixCompose`],inputs:{values:{translation:{name:`position`,gltfType:`float3`},rotation:{name:`rotationQuaternion`,gltfType:`float4`},scale:{name:`scaling`,gltfType:`float3`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i,a){let o=i[0].dataInputs.find(e=>e.name===`rotationQuaternion`);if(!o)throw Error(`Rotation quaternion input not found`);return a._connectionValues[o.uniqueId]&&(a._connectionValues[o.uniqueId].type=`Quaternion`),i}},"math/matDecompose":{blocks:[`FlowGraphMatrixDecompose`],inputs:{values:{a:{name:`input`,gltfType:`number`}}},outputs:{values:{translation:{name:`position`},rotation:{name:`rotationQuaternion`},scale:{name:`scaling`}}}},"math/quatConjugate":e7(`FlowGraphConjugateBlock`,[`a`]),"math/quatMul":{blocks:[`FlowGraphMultiplyBlock`],inputs:{values:{a:{name:`a`,gltfType:`vector4`},b:{name:`b`,gltfType:`vector4`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i){var a;return(a=i[0]).config||(a.config={}),i[0].config.type=`Quaternion`,i}},"math/quatAngleBetween":e7(`FlowGraphAngleBetweenBlock`,[`a`,`b`]),"math/quatFromAxisAngle":{blocks:[`FlowGraphQuaternionFromAxisAngleBlock`],inputs:{values:{axis:{name:`a`,gltfType:`float3`},angle:{name:`b`,gltfType:`number`}}},outputs:{values:{value:{name:`value`}}}},"math/quatToAxisAngle":e7(`FlowGraphAxisAngleFromQuaternionBlock`,[`a`]),"math/quatFromDirections":e7(`FlowGraphQuaternionFromDirectionsBlock`,[`a`,`b`]),"math/combine2x2":{blocks:[`FlowGraphCombineMatrix2DBlock`],inputs:{values:{a:{name:`input_0`,gltfType:`number`},b:{name:`input_1`,gltfType:`number`},c:{name:`input_2`,gltfType:`number`},d:{name:`input_3`,gltfType:`number`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i){var a;return(a=i[0]).config||(a.config={}),i[0].config.inputIsColumnMajor=!0,i}},"math/extract2x2":{blocks:[`FlowGraphExtractMatrix2DBlock`],inputs:{values:{a:{name:`input`,gltfType:`float2x2`}}},outputs:{values:{0:{name:`output_0`},1:{name:`output_1`},2:{name:`output_2`},3:{name:`output_3`}}}},"math/combine3x3":{blocks:[`FlowGraphCombineMatrix3DBlock`],inputs:{values:{a:{name:`input_0`,gltfType:`number`},b:{name:`input_1`,gltfType:`number`},c:{name:`input_2`,gltfType:`number`},d:{name:`input_3`,gltfType:`number`},e:{name:`input_4`,gltfType:`number`},f:{name:`input_5`,gltfType:`number`},g:{name:`input_6`,gltfType:`number`},h:{name:`input_7`,gltfType:`number`},i:{name:`input_8`,gltfType:`number`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i){var a;return(a=i[0]).config||(a.config={}),i[0].config.inputIsColumnMajor=!0,i}},"math/extract3x3":{blocks:[`FlowGraphExtractMatrix3DBlock`],inputs:{values:{a:{name:`input`,gltfType:`float3x3`}}},outputs:{values:{0:{name:`output_0`},1:{name:`output_1`},2:{name:`output_2`},3:{name:`output_3`},4:{name:`output_4`},5:{name:`output_5`},6:{name:`output_6`},7:{name:`output_7`},8:{name:`output_8`}}}},"math/combine4x4":{blocks:[`FlowGraphCombineMatrixBlock`],inputs:{values:{a:{name:`input_0`,gltfType:`number`},b:{name:`input_1`,gltfType:`number`},c:{name:`input_2`,gltfType:`number`},d:{name:`input_3`,gltfType:`number`},e:{name:`input_4`,gltfType:`number`},f:{name:`input_5`,gltfType:`number`},g:{name:`input_6`,gltfType:`number`},h:{name:`input_7`,gltfType:`number`},i:{name:`input_8`,gltfType:`number`},j:{name:`input_9`,gltfType:`number`},k:{name:`input_10`,gltfType:`number`},l:{name:`input_11`,gltfType:`number`},m:{name:`input_12`,gltfType:`number`},n:{name:`input_13`,gltfType:`number`},o:{name:`input_14`,gltfType:`number`},p:{name:`input_15`,gltfType:`number`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i){var a;return(a=i[0]).config||(a.config={}),i[0].config.inputIsColumnMajor=!0,i}},"math/extract4x4":{blocks:[`FlowGraphExtractMatrixBlock`],configuration:{},inputs:{values:{a:{name:`input`,gltfType:`number`}}},outputs:{values:{0:{name:`output_0`},1:{name:`output_1`},2:{name:`output_2`},3:{name:`output_3`},4:{name:`output_4`},5:{name:`output_5`},6:{name:`output_6`},7:{name:`output_7`},8:{name:`output_8`},9:{name:`output_9`},10:{name:`output_10`},11:{name:`output_11`},12:{name:`output_12`},13:{name:`output_13`},14:{name:`output_14`},15:{name:`output_15`}}}},"math/not":{blocks:[`FlowGraphBitwiseNotBlock`],inputs:{values:{a:{name:`a`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i,a){var o;(o=i[0]).config||(o.config={});let s=i[0].dataInputs[0];return i[0].config.valueType=a._connectionValues[s.uniqueId]?.type??`FlowGraphInteger`,i}},"math/and":{blocks:[`FlowGraphBitwiseAndBlock`],inputs:{values:{a:{name:`a`},b:{name:`b`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i,a){var o;(o=i[0]).config||(o.config={});let s=i[0].dataInputs[0],c=i[0].dataInputs[1];return i[0].config.valueType=a._connectionValues[s.uniqueId]?.type??a._connectionValues[c.uniqueId]?.type??`FlowGraphInteger`,i}},"math/or":{blocks:[`FlowGraphBitwiseOrBlock`],inputs:{values:{a:{name:`a`},b:{name:`b`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i,a){var o;(o=i[0]).config||(o.config={});let s=i[0].dataInputs[0],c=i[0].dataInputs[1];return i[0].config.valueType=a._connectionValues[s.uniqueId]?.type??a._connectionValues[c.uniqueId]?.type??`FlowGraphInteger`,i}},"math/xor":{blocks:[`FlowGraphBitwiseXorBlock`],inputs:{values:{a:{name:`a`},b:{name:`b`}}},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,n,r,i,a){var o;(o=i[0]).config||(o.config={});let s=i[0].dataInputs[0],c=i[0].dataInputs[1];return i[0].config.valueType=a._connectionValues[s.uniqueId]?.type??a._connectionValues[c.uniqueId]?.type??`FlowGraphInteger`,i}},"math/asr":e7(`FlowGraphBitwiseRightShiftBlock`,[`a`,`b`]),"math/lsl":e7(`FlowGraphBitwiseLeftShiftBlock`,[`a`,`b`]),"math/clz":e7(`FlowGraphLeadingZerosBlock`),"math/ctz":e7(`FlowGraphTrailingZerosBlock`),"math/popcnt":e7(`FlowGraphOneBitsCounterBlock`),"math/rad":e7(`FlowGraphDegToRadBlock`),"math/deg":e7(`FlowGraphRadToDegBlock`),"type/boolToInt":e7(`FlowGraphBooleanToInt`),"type/boolToFloat":e7(`FlowGraphBooleanToFloat`),"type/intToBool":e7(`FlowGraphIntToBoolean`),"type/intToFloat":e7(`FlowGraphIntToFloat`),"type/floatToInt":e7(`FlowGraphFloatToInt`),"type/floatToBool":e7(`FlowGraphFloatToBoolean`),"flow/sequence":{blocks:[`FlowGraphSequenceBlock`],extraProcessor(e,t,n,r,i){let a=i[0];return a.config||={},a.config.outputSignalCount=Object.keys(e.flows||[]).length,a.signalOutputs.forEach((e,t)=>{e.name=`out_`+t}),i}},"flow/branch":{blocks:[`FlowGraphBranchBlock`],outputs:{flows:{true:{name:`onTrue`},false:{name:`onFalse`}}}},"flow/switch":{blocks:[`FlowGraphSwitchBlock`],configuration:{cases:{name:`cases`,isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:`case`},default:{name:`default`}}},validation(e){let t=e.configuration?.cases;if(t&&t.value){if(!t.value.every(e=>typeof e==`number`&&/^-?\d+$/.test(e.toString())))return F.Warn(`Switch cases should be integers. Using empty array instead.`),t.value=[],{valid:!0};let e=new Set(t.value);t.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,n,r,i){if(t.op!==`flow/switch`||!e.flows||Object.keys(e.flows).length===0)throw Error(`Switch should have a single configuration object, the cases array`);return i[0].signalOutputs.forEach(e=>{e.name!=="default"&&(e.name=`out_`+e.name)}),i}},"flow/while":{blocks:[`FlowGraphWhileLoopBlock`],outputs:{flows:{loopBody:{name:`executionFlow`}}}},"flow/for":{blocks:[`FlowGraphForLoopBlock`],configuration:{initialIndex:{name:`initialIndex`,gltfType:`number`,inOptions:!0,defaultValue:0}},inputs:{values:{startIndex:{name:`startIndex`,gltfType:`number`},endIndex:{name:`endIndex`,gltfType:`number`}}},outputs:{values:{index:{name:`index`}},flows:{loopBody:{name:`executionFlow`}}},extraProcessor(e,t,n,r,i){let a=i[0];return a.config||={},a.config.incrementIndexWhenLoopDone=!0,i}},"flow/doN":{blocks:[`FlowGraphDoNBlock`],configuration:{},inputs:{values:{n:{name:`maxExecutions`,gltfType:`number`}}},outputs:{values:{currentCount:{name:`executionCount`}}}},"flow/multiGate":{blocks:[`FlowGraphMultiGateBlock`],configuration:{isRandom:{name:`isRandom`,gltfType:`boolean`,inOptions:!0,defaultValue:!1},isLoop:{name:`isLoop`,gltfType:`boolean`,inOptions:!0,defaultValue:!1}},extraProcessor(e,t,n,r,i){if(t.op!==`flow/multiGate`||!e.flows||Object.keys(e.flows).length===0)throw Error(`MultiGate should have a single configuration object, the number of output flows`);let a=i[0];return a.config||={},a.config.outputSignalCount=Object.keys(e.flows).length,a.signalOutputs.forEach((e,t)=>{e.name=`out_`+t}),i}},"flow/waitAll":{blocks:[`FlowGraphWaitAllBlock`],configuration:{inputFlows:{name:`inputSignalCount`,gltfType:`number`,inOptions:!0,defaultValue:0}},inputs:{flows:{reset:{name:`reset`},"[segment]":{name:`in_$1`}}},validation(e){return typeof e.configuration?.inputFlows?.value?.[0]!=`number`&&(e.configuration=e.configuration||{inputFlows:{value:[0]}},e.configuration.inputFlows.value=[0]),{valid:!0}}},"flow/throttle":{blocks:[`FlowGraphThrottleBlock`],outputs:{flows:{err:{name:`error`}}}},"flow/setDelay":{blocks:[`FlowGraphSetDelayBlock`],outputs:{flows:{err:{name:`error`}}}},"flow/cancelDelay":{blocks:[`FlowGraphCancelDelayBlock`]},"variable/get":{blocks:[`FlowGraphGetVariableBlock`],validation(e){return e.configuration?.variable?.value?{valid:!0}:(F.Error(`Variable get block should have a variable configuration`),{valid:!1,error:`Variable get block should have a variable configuration`})},configuration:{variable:{name:`variable`,gltfType:`number`,flowGraphType:`string`,inOptions:!0,isVariable:!0,dataTransformer(e,t){return t.getVariableName(e)}}}},"variable/set":{blocks:[`FlowGraphSetVariableBlock`],configuration:{variables:{name:`variables`,gltfType:`number`,flowGraphType:`string`,inOptions:!0,isArray:!0,dataTransformer(e,t){return e.map(e=>t.getVariableName(e))}}},extraProcessor(e,t,n,r,i){return i[0].dataInputs.forEach(e=>{e.name=r.getVariableName(+e.name)}),i}},"variable/interpolate":{blocks:[`FlowGraphInterpolationBlock`,`FlowGraphContextBlock`,`FlowGraphPlayAnimationBlock`,`FlowGraphBezierCurveEasing`,`FlowGraphGetVariableBlock`],configuration:{variable:{name:`propertyName`,inOptions:!0,isVariable:!0,dataTransformer(e,t){return t.getVariableName(e)}},useSlerp:{name:`animationType`,inOptions:!0,defaultValue:!1,dataTransformer(e){return e===!0?`Quaternion`:void 0}}},inputs:{values:{value:{name:`value_1`},duration:{name:`duration_1`,gltfType:`number`},p1:{name:`controlPoint1`,toBlock:`FlowGraphBezierCurveEasing`},p2:{name:`controlPoint2`,toBlock:`FlowGraphBezierCurveEasing`}},flows:{in:{name:`in`,toBlock:`FlowGraphPlayAnimationBlock`}}},outputs:{flows:{err:{name:`error`,toBlock:`FlowGraphPlayAnimationBlock`},out:{name:`out`,toBlock:`FlowGraphPlayAnimationBlock`},done:{name:`done`,toBlock:`FlowGraphPlayAnimationBlock`}}},interBlockConnectors:[{input:`object`,output:`userVariables`,inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:`animation`,output:`animation`,inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:`easingFunction`,output:`easingFunction`,inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:`value_0`,output:`value`,inputBlockIndex:0,outputBlockIndex:4,isVariable:!0}],extraProcessor(e,t,n,r,i){var a,o;let s=i[0],c=e.configuration?.variable.value?.[0];if(typeof c!=`number`)throw F.Error(`Variable index is not defined for variable interpolation block`),Error(`Variable index is not defined for variable interpolation block`);let l=r.arrays.staticVariables[c];s.config?.animationType?.value===void 0&&(s.config||={},(a=s.config).animationType||(a.animationType={}),s.config.animationType.value=Gr(l.type));let u=i[4];return u.config||={},(o=u.config).variable||(o.variable={}),u.config.variable.value=r.getVariableName(c),i}},"pointer/get":{blocks:[`FlowGraphGetPropertyBlock`,`FlowGraphJsonPointerParserBlock`],configuration:{pointer:{name:`jsonPointer`,toBlock:`FlowGraphJsonPointerParserBlock`}},inputs:{values:{"[segment]":{name:`$1`,toBlock:`FlowGraphJsonPointerParserBlock`}}},interBlockConnectors:[{input:`object`,output:`object`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`propertyName`,output:`propertyName`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`customGetFunction`,output:`getFunction`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor(e,t,n,r,i){return i.forEach(e=>{e.className===`FlowGraphJsonPointerParserBlock`&&(e.config||={},e.config.outputValue=!0)}),i}},"pointer/set":{blocks:[`FlowGraphSetPropertyBlock`,`FlowGraphJsonPointerParserBlock`],configuration:{pointer:{name:`jsonPointer`,toBlock:`FlowGraphJsonPointerParserBlock`}},inputs:{values:{value:{name:`value`},"[segment]":{name:`$1`,toBlock:`FlowGraphJsonPointerParserBlock`}}},outputs:{flows:{err:{name:`error`}}},interBlockConnectors:[{input:`object`,output:`object`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`propertyName`,output:`propertyName`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`customSetFunction`,output:`setFunction`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor(e,t,n,r,i){return i.forEach(e=>{e.className===`FlowGraphJsonPointerParserBlock`&&(e.config||={},e.config.outputValue=!0)}),i}},"pointer/interpolate":{blocks:[`FlowGraphInterpolationBlock`,`FlowGraphJsonPointerParserBlock`,`FlowGraphPlayAnimationBlock`,`FlowGraphBezierCurveEasing`],configuration:{pointer:{name:`jsonPointer`,toBlock:`FlowGraphJsonPointerParserBlock`}},inputs:{values:{value:{name:`value_1`},"[segment]":{name:`$1`,toBlock:`FlowGraphJsonPointerParserBlock`},duration:{name:`duration_1`,gltfType:`number`},p1:{name:`controlPoint1`,toBlock:`FlowGraphBezierCurveEasing`},p2:{name:`controlPoint2`,toBlock:`FlowGraphBezierCurveEasing`}},flows:{in:{name:`in`,toBlock:`FlowGraphPlayAnimationBlock`}}},outputs:{flows:{err:{name:`error`,toBlock:`FlowGraphPlayAnimationBlock`},out:{name:`out`,toBlock:`FlowGraphPlayAnimationBlock`},done:{name:`done`,toBlock:`FlowGraphPlayAnimationBlock`}}},interBlockConnectors:[{input:`object`,output:`object`,inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:`propertyName`,output:`propertyName`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`customBuildAnimation`,output:`generateAnimationsFunction`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`animation`,output:`animation`,inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:`easingFunction`,output:`easingFunction`,inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:`value_0`,output:`value`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor(e,t,n,r,i){return i.forEach(t=>{t.className===`FlowGraphJsonPointerParserBlock`?(t.config||={},t.config.outputValue=!0):t.className===`FlowGraphInterpolationBlock`&&(t.config||={},Object.keys(e.values||[]).forEach(n=>{let i=e.values?.[n];if(n===`value`&&i){let e=i.type;e!==void 0&&(t.config.animationType=r.arrays.types[e].flowGraphType)}}))}),i}},"animation/start":{blocks:[`FlowGraphPlayAnimationBlock`,`FlowGraphArrayIndexBlock`,`KHR_interactivity/FlowGraphGLTFDataProvider`],inputs:{values:{animation:{name:`index`,gltfType:`number`,toBlock:`FlowGraphArrayIndexBlock`},speed:{name:`speed`,gltfType:`number`},startTime:{name:`from`,gltfType:`number`,dataTransformer:(e,t)=>[e[0]*t._animationTargetFps]},endTime:{name:`to`,gltfType:`number`,dataTransformer:(e,t)=>[e[0]*t._animationTargetFps]}}},outputs:{flows:{err:{name:`error`}}},interBlockConnectors:[{input:`animationGroup`,output:`value`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`array`,output:`animationGroups`,inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor(e,t,n,r,i,a,o){let s=i[i.length-1];return s.config||={},s.config.glTF=o,i}},"animation/stop":{blocks:[`FlowGraphStopAnimationBlock`,`FlowGraphArrayIndexBlock`,`KHR_interactivity/FlowGraphGLTFDataProvider`],inputs:{values:{animation:{name:`index`,gltfType:`number`,toBlock:`FlowGraphArrayIndexBlock`}}},outputs:{flows:{err:{name:`error`}}},interBlockConnectors:[{input:`animationGroup`,output:`value`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`array`,output:`animationGroups`,inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor(e,t,n,r,i,a,o){let s=i[i.length-1];return s.config||={},s.config.glTF=o,i}},"animation/stopAt":{blocks:[`FlowGraphStopAnimationBlock`,`FlowGraphArrayIndexBlock`,`KHR_interactivity/FlowGraphGLTFDataProvider`],configuration:{},inputs:{values:{animation:{name:`index`,gltfType:`number`,toBlock:`FlowGraphArrayIndexBlock`},stopTime:{name:`stopAtFrame`,gltfType:`number`,dataTransformer:(e,t)=>[e[0]*t._animationTargetFps]}}},outputs:{flows:{err:{name:`error`}}},interBlockConnectors:[{input:`animationGroup`,output:`value`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`array`,output:`animationGroups`,inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor(e,t,n,r,i,a,o){let s=i[i.length-1];return s.config||={},s.config.glTF=o,i}},"math/switch":{blocks:[`FlowGraphDataSwitchBlock`],configuration:{cases:{name:`cases`,isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:`case`}}},validation(e){let t=e.configuration?.cases;if(t&&t.value){if(!t.value.every(e=>typeof e==`number`&&/^-?\d+$/.test(e.toString())))return F.Warn(`Switch cases should be integers. Using empty array instead.`),t.value=[],{valid:!0};let e=new Set(t.value);t.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,n,r,i){let a=i[0];return a.dataInputs.forEach(e=>{e.name!=="default"&&e.name!==`case`&&(e.name=`in_`+e.name)}),a.config||={},a.config.treatCasesAsIntegers=!0,i}},"debug/log":{blocks:[`FlowGraphConsoleLogBlock`],configuration:{message:{name:`messageTemplate`,inOptions:!0}}}};function e7(e,t=[`a`],n){return{blocks:[e],inputs:{values:t.reduce((e,t)=>(e[t]={name:t},e),{})},outputs:{values:{value:{name:`value`}}},extraProcessor(e,t,r,i,a){var o;if(n){(o=a[0]).config||(o.config={}),a[0].config.preventIntegerFloatArithmetic=!0;let t=-1;Object.keys(e.values||{}).find(n=>e.values?.[n].type===void 0?!1:(t=e.values[n].type,!0)),t!==-1&&(a[0].config.type=i.arrays.types[t].flowGraphType)}return a},validation(e){return n?j0e(e):{valid:!0}}}}function j0e(e){if(e.values){let t=Object.keys(e.values).map(t=>e.values[t].type).filter(e=>e!==void 0);if(!t.every(e=>e===t[0]))return{valid:!1,error:`All inputs must be of the same type`}}return{valid:!0}}var M0e={float:{length:1,flowGraphType:`number`,elementType:`number`},bool:{length:1,flowGraphType:`boolean`,elementType:`boolean`},float2:{length:2,flowGraphType:`Vector2`,elementType:`number`},float3:{length:3,flowGraphType:`Vector3`,elementType:`number`},float4:{length:4,flowGraphType:`Vector4`,elementType:`number`},float4x4:{length:16,flowGraphType:`Matrix`,elementType:`number`},float2x2:{length:4,flowGraphType:`Matrix2D`,elementType:`number`},float3x3:{length:9,flowGraphType:`Matrix3D`,elementType:`number`},int:{length:1,flowGraphType:`FlowGraphInteger`,elementType:`number`}},N0e=class{constructor(e,t,n=60){this._interactivityGraph=e,this._gltf=t,this._animationTargetFps=n,this._types=[],this._mappings=[],this._staticVariables=[],this._events=[],this._internalEventsCounter=0,this._nodes=[],this._parseTypes(),this._parseDeclarations(),this._parseVariables(),this._parseEvents(),this._parseNodes()}get arrays(){return{types:this._types,mappings:this._mappings,staticVariables:this._staticVariables,events:this._events,nodes:this._nodes}}_parseTypes(){if(this._interactivityGraph.types)for(let e of this._interactivityGraph.types)this._types.push(M0e[e.signature])}_parseDeclarations(){if(this._interactivityGraph.declarations)for(let e of this._interactivityGraph.declarations){let t=k0e(e);if(!t)throw F.Error([`No mapping found for declaration`,e]),Error(`Error parsing declarations`);this._mappings.push({flowGraphMapping:t,fullOperationName:e.extension?e.op+`:`+e.extension:e.op})}}_parseVariables(){if(this._interactivityGraph.variables)for(let e of this._interactivityGraph.variables){let t=this._parseVariable(e);this._staticVariables.push(t)}}_parseVariable(e,t){let n=this._types[e.type];if(!n)throw F.Error([`No type found for variable`,e]),Error(`Error parsing variables`);if(e.value&&e.value.length!==n.length)throw F.Error([`Invalid value length for variable`,e,n]),Error(`Error parsing variables`);let r=e.value||[];if(!r.length)switch(n.flowGraphType){case`boolean`:r.push(!1);break;case`FlowGraphInteger`:r.push(0);break;case`number`:r.push(NaN);break;case`Vector2`:r.push(NaN,NaN);break;case`Vector3`:r.push(NaN,NaN,NaN);break;case`Vector4`:case`Matrix2D`:case`Quaternion`:r.fill(NaN,0,4);break;case`Matrix`:r.fill(NaN,0,16);break;case`Matrix3D`:r.fill(NaN,0,9);break;default:break}return n.elementType===`number`&&typeof r[0]==`string`&&(r[0]=parseFloat(r[0])),{type:n.flowGraphType,value:t?t(r,this):r}}_parseEvents(){if(this._interactivityGraph.events)for(let e of this._interactivityGraph.events){let t={eventId:e.id||`internalEvent_`+this._internalEventsCounter++};e.values&&(t.eventData=Object.keys(e.values).map(t=>{let n=e.values?.[t];if(!n)throw F.Error([`No value found for event key`,t]),Error(`Error parsing events`);let r=this._types[n.type];if(!r)throw F.Error([`No type found for event value`,n]),Error(`Error parsing events`);let i=n.value===void 0?void 0:this._parseVariable(n);return{id:t,type:r.flowGraphType,eventData:!0,value:i}})),this._events.push(t)}}_parseNodes(){if(this._interactivityGraph.nodes)for(let e of this._interactivityGraph.nodes){if(typeof e.declaration!=`number`)throw F.Error([`No declaration found for node`,e]),Error(`Error parsing nodes`);let t=this._mappings[e.declaration];if(!t)throw F.Error([`No mapping found for node`,e]),Error(`Error parsing nodes`);if(t.flowGraphMapping.validation){let n=t.flowGraphMapping.validation(e,this._interactivityGraph,this._gltf);if(!n.valid)throw Error(`Error validating interactivity node ${this._interactivityGraph.declarations?.[e.declaration].op} - ${n.error}`)}let n=[];for(let r of t.flowGraphMapping.blocks){let i=this._getEmptyBlock(r,t.fullOperationName);this._parseNodeConfiguration(e,i,t.flowGraphMapping,r),n.push(i)}this._nodes.push({blocks:n,fullOperationName:t.fullOperationName})}}_getEmptyBlock(e,t){return{uniqueId:jt(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:t,metadata:{}}}_parseNodeConfiguration(e,t,n,r){let i=e.configuration;if(i)for(let e in i){let a=i[e];if(!a)throw Error(`Error parsing node configuration`);let o=n.configuration?.[e];if(o&&o.toBlock?o.toBlock===r:n.blocks.indexOf(r)===0){let n=o?.defaultValue;a?.value&&(n=a.value),o?.isArray||(n.length!==1&&F.Warn(`Invalid non-array value length: ${n.length}`),n=n[0]),o?.dataTransformer&&(n=o.dataTransformer(n,this)),n!==void 0&&(t.config[o?.name||e]={value:n})}}}_parseNodeConnections(e){for(let t=0;te.className===n.toBlock)||r.blocks[0]).signalOutputs.push(s);let c=t.node,l=this._nodes[c];if(!l)throw F.Error([`No node found for input node id`,c]),Error(`Error parsing node connections`);let u=O0e(l.fullOperationName);if(!u)throw F.Error([`No mapping found for input node`,l]),Error(`Error parsing node connections`);let d=u.inputs?.flows?.[t.socket||`in`],f=!1;if(!d)for(let e in u.inputs?.flows)e.startsWith(`[`)&&e.endsWith(`]`)&&(f=!0,d=u.inputs?.flows?.[e]);let p=d?f?d.name.replace(`$1`,t.socket||``):d.name:t.socket||`in`,m=d&&d.toBlock&&l.blocks.find(e=>e.className===d.toBlock)||l.blocks[0],h=m.signalInputs.find(e=>e.name===p);h||(h=this._createNewSocketConnection(p),m.signalInputs.push(h)),h.connectedPointIds.push(s.uniqueId),s.connectedPointIds.push(h.uniqueId)}let s=n.values||{},c=Object.keys(s);for(let t of c){let n=s[t],a=i.flowGraphMapping.inputs?.values?.[t],o=!1;if(!a)for(let e in i.flowGraphMapping.inputs?.values)e.startsWith(`[`)&&e.endsWith(`]`)&&(o=!0,a=i.flowGraphMapping.inputs?.values?.[e]);let c=a?o?a.name.replace(`$1`,t):a.name:t,l=this._createNewSocketConnection(c);if((a&&a.toBlock&&r.blocks.find(e=>e.className===a.toBlock)||r.blocks[0]).dataInputs.push(l),n.value!==void 0){let t=this._parseVariable(n,a&&a.dataTransformer);e._connectionValues[l.uniqueId]=t}else if(n.node!==void 0){let e=n.node,t=n.socket||`value`,r=this._nodes[e];if(!r)throw F.Error([`No node found for output socket reference`,n]),Error(`Error parsing node connections`);let i=O0e(r.fullOperationName);if(!i)throw F.Error([`No mapping found for output socket reference`,n]),Error(`Error parsing node connections`);let a=i.outputs?.values?.[t],o=!1;if(!a)for(let e in i.outputs?.values)e.startsWith(`[`)&&e.endsWith(`]`)&&(o=!0,a=i.outputs?.values?.[e]);let s=a?o?a.name.replace(`$1`,t):a?.name:t,c=a&&a.toBlock&&r.blocks.find(e=>e.className===a.toBlock)||r.blocks[0],u=c.dataOutputs.find(e=>e.name===s);u||(u=this._createNewSocketConnection(s,!0),c.dataOutputs.push(u)),l.connectedPointIds.push(u.uniqueId),u.connectedPointIds.push(l.uniqueId)}else throw F.Error([`Invalid value for value connection`,n]),Error(`Error parsing node connections`)}if(i.flowGraphMapping.interBlockConnectors)for(let e of i.flowGraphMapping.interBlockConnectors){let t=e.input,n=e.output,i=e.isVariable;this._connectFlowGraphNodes(t,n,r.blocks[e.inputBlockIndex],r.blocks[e.outputBlockIndex],i)}if(i.flowGraphMapping.extraProcessor){let t=this._interactivityGraph.declarations?.[n.declaration];if(!t)throw F.Error([`No declaration found for extra processor`,n]),Error(`Error parsing node connections`);r.blocks=i.flowGraphMapping.extraProcessor(n,t,i.flowGraphMapping,this,r.blocks,e,this._gltf)}}}_createNewSocketConnection(e,t){return{uniqueId:jt(),name:e,_connectionType:+!!t,connectedPointIds:[]}}_connectFlowGraphNodes(e,t,n,r,i){let a=i?n.dataInputs:n.signalInputs,o=i?r.dataOutputs:r.signalOutputs,s=a.find(t=>t.name===e)||this._createNewSocketConnection(e),c=o.find(e=>e.name===t)||this._createNewSocketConnection(t,!0);a.find(t=>t.name===e)||a.push(s),o.find(e=>e.name===t)||o.push(c),s.connectedPointIds.push(c.uniqueId),c.connectedPointIds.push(s.uniqueId)}getVariableName(e){return`staticVariable_`+e}serializeToFlowGraph(){let e={uniqueId:jt(),_userVariables:{},_connectionValues:{}};this._parseNodeConnections(e);for(let t=0;te.concat(t.blocks),[]),executionContexts:[e]}}},t7=`KHR_interactivity`,P0e=class{constructor(e){this._loader=e,this.name=t7,this.enabled=this._loader.isExtensionUsed(t7),this._pathConverter=e$e(this._loader.gltf),e._skipStartAnimationStep=!0;let t=e.babylonScene;t&&F0e(t)}dispose(){this._loader=null,delete this._pathConverter}async onReady(){if(!this._loader.babylonScene||!this._pathConverter)return;let e=this._loader.babylonScene,t=this._loader.gltf.extensions?.KHR_interactivity;if(!t)return;let n=new jy({scene:e});n.dispatchEventsSynchronously=!1;let r=t.graphs.map(e=>new N0e(e,this._loader.gltf,this._loader.parent.targetFps).serializeToFlowGraph());await Promise.all(r.map(async e=>await hce(e,{coordinator:n,pathConverter:this._pathConverter}))),n.start()}};function F0e(e){P8(`/extensions/KHR_interactivity/?/activeCamera/rotation`,{get:()=>{if(!e.activeCamera)return new A(NaN,NaN,NaN,NaN);let t=A.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(t.w*=-1,t.x*=-1),t},type:`Quaternion`,getTarget:()=>e.activeCamera}),P8(`/extensions/KHR_interactivity/?/activeCamera/position`,{get:()=>{if(!e.activeCamera)return new j(NaN,NaN,NaN);let t=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(t.x*=-1),t},type:`Vector3`,getTarget:()=>e.activeCamera}),P8(`/animations/{}/extensions/KHR_interactivity/isPlaying`,{get:e=>e._babylonAnimationGroup?.isPlaying??!1,type:`boolean`,getTarget:e=>e._babylonAnimationGroup}),P8(`/animations/{}/extensions/KHR_interactivity/minTime`,{get:e=>(e._babylonAnimationGroup?.from??0)/60,type:`number`,getTarget:e=>e._babylonAnimationGroup}),P8(`/animations/{}/extensions/KHR_interactivity/maxTime`,{get:e=>(e._babylonAnimationGroup?.to??0)/60,type:`number`,getTarget:e=>e._babylonAnimationGroup}),P8(`/animations/{}/extensions/KHR_interactivity/playhead`,{get:e=>(e._babylonAnimationGroup?.getCurrentFrame()??0)/60,type:`number`,getTarget:e=>e._babylonAnimationGroup}),P8(`/animations/{}/extensions/KHR_interactivity/virtualPlayhead`,{get:e=>(e._babylonAnimationGroup?.getCurrentFrame()??0)/60,type:`number`,getTarget:e=>e._babylonAnimationGroup})}var I0e=!1;function L0e(){I0e||(I0e=!0,pce(t7,`FlowGraphGLTFDataProvider`,async()=>(await U(async()=>{let{FlowGraphGLTFDataProvider:e}=await import(`./flowGraphGLTFDataProvider-CZYGVPvX.js`);return{FlowGraphGLTFDataProvider:e}},__vite__mapDeps([75,40,3,41,23,42,26,27,43,4,35]),import.meta.url)).FlowGraphGLTFDataProvider),D8(t7),E8(t7,!0,e=>new P0e(e)))}L0e();var n7=`KHR_node_visibility`,R0e=class{constructor(e){this.name=n7,this._loader=e,this.enabled=e.isExtensionUsed(n7)}onReady(){if(!this._loader)return;let e=this._loader.gltf.nodes;if(e)for(let t of e){let e=t._babylonTransformNode;e&&(e.inheritVisibility=!0,t.extensions&&t.extensions.KHR_node_visibility&&t.extensions.KHR_node_visibility.visible===!1&&(e.isVisible=!1))}}dispose(){delete this._loader}},z0e=!1;function B0e(){z0e||(z0e=!0,P8(`/nodes/{}/extensions/KHR_node_visibility/visible`,{get:e=>{let t=e._babylonTransformNode;return t&&t.isVisible!==void 0?t.isVisible:!0},set:(e,t)=>{t._primitiveBabylonMeshes?.forEach(e=>{e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),t._primitiveBabylonMeshes?.forEach(t=>{t.isVisible=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`isVisible`],type:`boolean`}),D8(n7),E8(n7,!0,e=>new R0e(e)))}B0e();var r7=`KHR_node_selectability`,V0e=class{constructor(e){this.name=r7,this._loader=e,this.enabled=e.isExtensionUsed(r7)}async onReady(){this._loader.gltf.nodes?.forEach(e=>{e.extensions?.KHR_node_selectability&&e.extensions?.KHR_node_selectability.selectable===!1&&e._babylonTransformNode?.getChildMeshes().forEach(e=>{e.isPickable=!1})})}dispose(){this._loader=null}},H0e=!1;function U0e(){H0e||(H0e=!0,Q5(`event/onSelect`,r7,{blocks:[`FlowGraphMeshPickEventBlock`,`FlowGraphGetVariableBlock`,`FlowGraphIndexOfBlock`,`KHR_interactivity/FlowGraphGLTFDataProvider`],configuration:{stopPropagation:{name:`stopPropagation`},nodeIndex:{name:`variable`,toBlock:`FlowGraphGetVariableBlock`,dataTransformer(e){return`pickedMesh_`+e}}},outputs:{values:{selectedNodeIndex:{name:`index`,toBlock:`FlowGraphIndexOfBlock`},controllerIndex:{name:`pointerId`},selectionPoint:{name:`pickedPoint`},selectionRayOrigin:{name:`pickOrigin`}},flows:{out:{name:`done`}}},interBlockConnectors:[{input:`asset`,output:`value`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`array`,output:`nodes`,inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:`object`,output:`pickedMesh`,inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor(e,t,n,r,i,a,o){let s=i[i.length-1];s.config=s.config||{},s.config.glTF=o;let c=e.configuration?.nodeIndex?.value?.[0];if(c===void 0||typeof c!=`number`)throw Error(`nodeIndex not found in configuration`);let l=`pickedMesh_`+c;return i[1].config.variable=l,a._userVariables[l]={className:`Mesh`,id:o?.nodes?.[c]._babylonTransformNode?.id,uniqueId:o?.nodes?.[c]._babylonTransformNode?.uniqueId},i}}),P8(`/nodes/{}/extensions/KHR_node_selectability/selectable`,{get:e=>{let t=e._babylonTransformNode;return t&&t.isPickable!==void 0?t.isPickable:!0},set:(e,t)=>{t._primitiveBabylonMeshes?.forEach(t=>{t.isPickable=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`isPickable`],type:`boolean`}),D8(r7),E8(r7,!0,e=>new V0e(e)))}U0e();var i7=`KHR_node_hoverability`,W0e=`targetMeshPointerOver_`,G0e=`targetMeshPointerOut_`,K0e=class{constructor(e){this.name=i7,this._loader=e,this.enabled=e.isExtensionUsed(i7)}async onReady(){this._loader.gltf.nodes?.forEach(e=>{e.extensions?.KHR_node_hoverability&&e.extensions?.KHR_node_hoverability.hoverable===!1&&e._babylonTransformNode?.getChildMeshes().forEach(e=>{e.pointerOverDisableMeshTesting=!0})})}dispose(){this._loader=null}},q0e=!1;function J0e(){q0e||(q0e=!0,Q5(`event/onHoverIn`,i7,{blocks:[`FlowGraphPointerOverEventBlock`,`FlowGraphGetVariableBlock`,`FlowGraphIndexOfBlock`,`KHR_interactivity/FlowGraphGLTFDataProvider`],configuration:{stopPropagation:{name:`stopPropagation`},nodeIndex:{name:`variable`,toBlock:`FlowGraphGetVariableBlock`,dataTransformer(e){return W0e+e}}},outputs:{values:{hoverNodeIndex:{name:`index`,toBlock:`FlowGraphIndexOfBlock`},controllerIndex:{name:`pointerId`}},flows:{out:{name:`done`}}},interBlockConnectors:[{input:`targetMesh`,output:`value`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`array`,output:`nodes`,inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:`object`,output:`meshUnderPointer`,inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor(e,t,n,r,i,a,o){let s=i[i.length-1];s.config=s.config||{},s.config.glTF=o;let c=e.configuration?.nodeIndex?.value?.[0];if(c===void 0||typeof c!=`number`)throw Error(`nodeIndex not found in configuration`);let l=W0e+c;return i[1].config.variable=l,a._userVariables[l]={className:`Mesh`,id:o?.nodes?.[c]._babylonTransformNode?.id,uniqueId:o?.nodes?.[c]._babylonTransformNode?.uniqueId},i}}),Q5(`event/onHoverOut`,i7,{blocks:[`FlowGraphPointerOutEventBlock`,`FlowGraphGetVariableBlock`,`FlowGraphIndexOfBlock`,`KHR_interactivity/FlowGraphGLTFDataProvider`],configuration:{stopPropagation:{name:`stopPropagation`},nodeIndex:{name:`variable`,toBlock:`FlowGraphGetVariableBlock`,dataTransformer(e){return G0e+e}}},outputs:{values:{hoverNodeIndex:{name:`index`,toBlock:`FlowGraphIndexOfBlock`},controllerIndex:{name:`pointerId`}},flows:{out:{name:`done`}}},interBlockConnectors:[{input:`targetMesh`,output:`value`,inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:`array`,output:`nodes`,inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:`object`,output:`meshOutOfPointer`,inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor(e,t,n,r,i,a,o){let s=i[i.length-1];s.config=s.config||{},s.config.glTF=o;let c=e.configuration?.nodeIndex?.value?.[0];if(c===void 0||typeof c!=`number`)throw Error(`nodeIndex not found in configuration`);let l=G0e+c;return i[1].config.variable=l,a._userVariables[l]={className:`Mesh`,id:o?.nodes?.[c]._babylonTransformNode?.id,uniqueId:o?.nodes?.[c]._babylonTransformNode?.uniqueId},i}}),P8(`/nodes/{}/extensions/KHR_node_hoverability/hoverable`,{get:e=>{let t=e._babylonTransformNode;return t&&t.pointerOverDisableMeshTesting!==void 0?t.pointerOverDisableMeshTesting:!0},set:(e,t)=>{t._primitiveBabylonMeshes?.forEach(t=>{t.pointerOverDisableMeshTesting=!e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>`pointerOverDisableMeshTesting`],type:`boolean`}),D8(i7),E8(i7,!0,e=>new K0e(e)))}J0e();var a7=`ExtrasAsMetadata`,Y0e=class{_assignExtras(e,t){if(t.extras&&Object.keys(t.extras).length>0){let n=e.metadata=e.metadata||{},r=n.gltf=n.gltf||{};r.extras=t.extras}}constructor(e){this.name=a7,this.enabled=!0,this._loader=e}dispose(){this._loader=null}loadNodeAsync(e,t,n){return this._loader.loadNodeAsync(e,t,e=>{this._assignExtras(e,t),n(e)})}loadCameraAsync(e,t,n){return this._loader.loadCameraAsync(e,t,e=>{this._assignExtras(e,t),n(e)})}createMaterial(e,t,n){let r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r}loadAnimationAsync(e,t){return this._loader.loadAnimationAsync(e,t).then(e=>(this._assignExtras(e,t),e))}},X0e=!1;function Z0e(){X0e||(X0e=!0,D8(a7),E8(a7,!1,e=>new Y0e(e)))}Z0e();var o7=class e{constructor(){this.materials=[]}parseMTL(t,n,r,i){if(n instanceof ArrayBuffer)return;let a=n.split(` `),o=/\s+/,s,c=null;for(let n=0;n=0?l.substring(0,u):l;d=d.toLowerCase();let f=u>=0?l.substring(u+1).trim():``;if(d===`newmtl`)c&&this.materials.push(c),t._blockEntityCollection=!!i,c=new lg(f,t),c._parentContainer=i,t._blockEntityCollection=!1;else if(d===`kd`&&c)s=f.split(o,3).map(parseFloat),c.diffuseColor=P.FromArray(s);else if(d===`ka`&&c)s=f.split(o,3).map(parseFloat),c.ambientColor=P.FromArray(s);else if(d===`ks`&&c)s=f.split(o,3).map(parseFloat),c.specularColor=P.FromArray(s);else if(d===`ke`&&c)s=f.split(o,3).map(parseFloat),c.emissiveColor=P.FromArray(s);else if(d===`ns`&&c)c.specularPower=parseFloat(f);else if(d===`d`&&c)c.alpha=parseFloat(f);else if(d===`map_ka`&&c)c.ambientTexture=e._GetTexture(r,f,t);else if(d===`map_kd`&&c)c.diffuseTexture=e._GetTexture(r,f,t);else if(d===`map_ks`&&c)c.specularTexture=e._GetTexture(r,f,t);else if(d!==`map_ns`)if(d===`map_bump`&&c){let n=f.split(o),i=n.indexOf(`-bm`),a=null;i>=0&&(a=n[i+1],n.splice(i,2)),c.bumpTexture=e._GetTexture(r,n.join(` `),t),c.bumpTexture&&a!==null&&(c.bumpTexture.level=parseFloat(a))}else d===`map_d`&&c&&(c.opacityTexture=e._GetTexture(r,f,t))}c&&this.materials.push(c)}static _GetTexture(t,n,r){if(!n)return null;let i=t;if(t===`file:`){let e=n.lastIndexOf(`\\`);e===-1&&(e=n.lastIndexOf(`/`)),e>-1?i+=n.substring(e+1):i+=n}else i+=n;return new W(i,r,!1,e.INVERT_TEXTURE_Y)}};o7.INVERT_TEXTURE_Y=!0;var s7=class e{constructor(e,t,n){this._positions=[],this._normals=[],this._uvs=[],this._colors=[],this._extColors=[],this._meshesFromObj=[],this._indicesForBabylon=[],this._wrappedPositionForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._wrappedNormalsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0,this._hasMeshes=!1,this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[],this._triangles=[],this._materialNameFromObj=``,this._objMeshName=``,this._increment=1,this._isFirstMaterial=!0,this._grayColor=new fe(.5,.5,.5,1),this._hasLineData=!1,this._materialToUse=e,this._babylonMeshesArray=t,this._loadingOptions=n}_isInArray(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});let n=e[t[0]].normals.indexOf(t[1]);return n===-1?-1:e[t[0]].idx[n]}_isInArrayUV(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});let n=e[t[0]].normals.indexOf(t[1]);return n!=1&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1}_setData(e){e.indiceUvsFromObj??=-1,e.indiceNormalFromObj??=-1;let t;t=this._loadingOptions.optimizeWithUV?this._isInArrayUV(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj,e.indiceUvsFromObj]):this._isInArray(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj]),t===-1?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(e.positionVectorFromOBJ),e.textureVectorFromOBJ!==void 0&&this._wrappedUvsForBabylon.push(e.textureVectorFromOBJ),e.normalsVectorFromOBJ!==void 0&&this._wrappedNormalsForBabylon.push(e.normalsVectorFromOBJ),e.positionColorsFromOBJ!==void 0&&this._wrappedColorsForBabylon.push(e.positionColorsFromOBJ),this._tuplePosNorm[e.indicePositionFromObj].normals.push(e.indiceNormalFromObj),this._tuplePosNorm[e.indicePositionFromObj].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e.indicePositionFromObj].uv.push(e.indiceUvsFromObj)):this._indicesForBabylon.push(t)}_unwrapData(){try{for(let e=0;e0&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._unwrapData(),this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._handledMesh.indices=this._indicesForBabylon.slice(),this._handledMesh.positions=this._unwrappedPositionsForBabylon.slice(),this._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice()),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon.slice()),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._handledMesh.hasLines=this._hasLineData,this._indicesForBabylon.length=0,this._unwrappedPositionsForBabylon.length=0,this._unwrappedColorsForBabylon.length=0,this._unwrappedNormalsForBabylon.length=0,this._unwrappedUVForBabylon.length=0,this._hasLineData=!1)}_optimizeNormals(e){let t=e.getVerticesData(H.PositionKind),n=e.getVerticesData(H.NormalKind),r={};if(!t||!n)return;for(let e=0;ethis._triangles.push(e[0],e[t],e[t+1]),this._handednessSign=1):r.useRightHandedSystem?(this._pushTriangle=(e,t)=>this._triangles.push(e[0],e[t+1],e[t]),this._handednessSign=1):(this._pushTriangle=(e,t)=>this._triangles.push(e[0],e[t],e[t+1]),this._handednessSign=-1);let o=n.split(` -`),s=[],c=[];s.push(c);for(let t=0;t=7){let e=parseFloat(r[4]),t=parseFloat(r[5]),n=parseFloat(r[6]);this._colors.push(new fe(e>1?e/255:e,t>1?t/255:t,n>1?n/255:n,r.length===7||r[7]===void 0?1:parseFloat(r[7])))}else this._colors.push(this._grayColor)}else if((r=e.NormalPattern.exec(n))!==null)this._normals.push(new j(parseFloat(r[1]),parseFloat(r[2]),parseFloat(r[3])));else if((r=e.UVPattern.exec(n))!==null)this._uvs.push(new O(parseFloat(r[1])*this._loadingOptions.UVScaling.x,parseFloat(r[2])*this._loadingOptions.UVScaling.y));else if((r=e.FacePattern3.exec(n))!==null)this._setDataForCurrentFaceWithPattern3(r[1].trim().split(` `),1);else if((r=e.FacePattern4.exec(n))!==null)this._setDataForCurrentFaceWithPattern4(r[1].trim().split(` `),1);else if((r=e.FacePattern5.exec(n))!==null)this._setDataForCurrentFaceWithPattern5(r[1].trim().split(` `),1);else if((r=e.FacePattern2.exec(n))!==null)this._setDataForCurrentFaceWithPattern2(r[1].trim().split(` `),1);else if((r=e.FacePattern1.exec(n))!==null)this._setDataForCurrentFaceWithPattern1(r[1].trim().split(` `),1);else if((r=e.LinePattern1.exec(n))!==null)this._setDataForCurrentFaceWithPattern1(r[1].trim().split(` `),0),this._hasLineData=!0;else if((r=e.LinePattern2.exec(n))!==null)this._setDataForCurrentFaceWithPattern2(r[1].trim().split(` `),0),this._hasLineData=!0;else if(r=e._GetZbrushMRGB(n,!this._loadingOptions.importVertexColors))for(let e of r)this._extColors.push(e);else if((r=e.LinePattern3.exec(n))!==null)this._setDataForCurrentFaceWithPattern3(r[1].trim().split(` `),0),this._hasLineData=!0;else if(e.GroupDescriptor.test(n)||e.ObjectDescriptor.test(n)){let t={name:n.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:e.ObjectDescriptor.test(n)};this._addPreviousObjMesh(),this._meshesFromObj.push(t),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else if(e.UseMtlDescriptor.test(n)){if(this._materialNameFromObj=n.substring(7).trim(),!this._isFirstMaterial||!this._hasMeshes){this._addPreviousObjMesh();let e={name:(this._objMeshName||`mesh`)+`_mm`+this._increment.toString(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:!1};this._increment++,this._meshesFromObj.push(e),this._hasMeshes=!0}this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)}else e.MtlLibGroupDescriptor.test(n)?a(n.substring(7).trim()):e.SmoothDescriptor.test(n)||F.Log(`Unhandled expression at line : `+n)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon),this._handledMesh.hasLines=this._hasLineData),!this._hasMeshes){let e=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(let e of this._positions)this._unwrappedPositionsForBabylon.push(e.x,e.y,e.z);if(this._normals.length)for(let e of this._normals)this._unwrappedNormalsForBabylon.push(e.x,e.y,e.z);if(this._uvs.length)for(let e of this._uvs)this._unwrappedUVForBabylon.push(e.x,e.y);if(this._extColors.length)for(let e of this._extColors)this._unwrappedColorsForBabylon.push(e.r,e.g,e.b,e.a);else if(this._colors.length)for(let e of this._colors)this._unwrappedColorsForBabylon.push(e.r,e.g,e.b,e.a);this._materialNameFromObj||(e=new lg(il.RandomId(),r),e.pointsCloud=!0,this._materialNameFromObj=e.name,this._normals.length||(e.disableLighting=!0,e.emissiveColor=P.White()))}this._meshesFromObj.push({name:il.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:e,isObject:!0,hasLines:this._hasLineData})}for(let e=0;e=0;--t)if(this._meshesFromObj[t].isObject&&this._meshesFromObj[t]._babylonMesh){n.parent=this._meshesFromObj[t]._babylonMesh;break}}if(this._materialToUse.push(this._meshesFromObj[e].materialName),this._handledMesh.hasLines&&(n._internalMetadata??={},n._internalMetadata._isLine=!0),this._handledMesh.positions?.length===0){this._babylonMeshesArray.push(n);continue}let a=new Fc;if(a.indices=this._handledMesh.indices,a.positions=this._handledMesh.positions,this._loadingOptions.computeNormals||!this._handledMesh.normals?.length){let e=[];Fc.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,e),a.normals=e}else a.normals=this._handledMesh.normals;this._handledMesh.uvs?.length&&(a.uvs=this._handledMesh.uvs),this._handledMesh.colors?.length&&(a.colors=this._handledMesh.colors),a.applyToMesh(n),this._loadingOptions.invertY&&(n.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(n),this._babylonMeshesArray.push(n),this._handledMesh.directMaterial&&(n.material=this._handledMesh.directMaterial)}}};s7.ObjectDescriptor=/^o/,s7.GroupDescriptor=/^g/,s7.MtlLibGroupDescriptor=/^mtllib /,s7.UseMtlDescriptor=/^usemtl /,s7.SmoothDescriptor=/^s /,s7.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/,s7.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,s7.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,s7.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/,s7.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,s7.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,s7.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,s7.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,s7.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/,s7.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,s7.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/;var c7={name:`obj`,extensions:`.obj`},l7=class e{static get INVERT_TEXTURE_Y(){return o7.INVERT_TEXTURE_Y}static set INVERT_TEXTURE_Y(e){o7.INVERT_TEXTURE_Y=e}constructor(t){this.name=c7.name,this.extensions=c7.extensions,this._assetContainer=null,this._loadingOptions={...e._DefaultLoadingOptions,...t??{}}}static get _DefaultLoadingOptions(){return{computeNormals:e.COMPUTE_NORMALS,optimizeNormals:e.OPTIMIZE_NORMALS,importVertexColors:e.IMPORT_VERTEX_COLORS,invertY:e.INVERT_Y,invertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,materialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:e.OPTIMIZE_WITH_UV,skipMaterials:e.SKIP_MATERIALS,useLegacyBehavior:e.USE_LEGACY_BEHAVIOR}}_loadMTL(e,t,n,r){let i=t+e;ge.LoadFile(i,n,void 0,void 0,!1,(e,t)=>{r(i,t)})}createPlugin(t){return new e(t[c7.name])}canDirectLoad(){return!1}importMeshAsync(e,t,n,r){return this._parseSolidAsync(e,t,n,r).then(e=>({meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))}loadAsync(e,t,n){return this.importMeshAsync(null,e,t,n).then(()=>{})}loadAssetContainerAsync(e,t,n){let r=new Bl(e);return this._assetContainer=r,this.importMeshAsync(null,e,t,n).then(e=>(e.meshes.forEach(e=>r.meshes.push(e)),e.meshes.forEach(e=>{let t=e.material;t&&r.materials.indexOf(t)==-1&&(r.materials.push(t),t.getActiveTextures().forEach(e=>{r.textures.indexOf(e)==-1&&r.textures.push(e)}))}),this._assetContainer=null,r)).catch(e=>{throw this._assetContainer=null,e})}_parseSolidAsync(e,t,n,r){let i=``,a=new o7,o=[],s=[];n=n.replace(/#.*$/gm,``).trim(),new s7(o,s,this._loadingOptions).parse(e,n,t,this._assetContainer,e=>{i=e});let c=[];return i!==``&&!this._loadingOptions.skipMaterials&&c.push(new Promise((e,n)=>{this._loadMTL(i,r,c=>{try{a.parseMTL(t,c,r,this._assetContainer);for(let e=0;e-1;)n.push(r),t=r+1;if(r===-1&&n.length===0)a.materials[e].dispose();else for(let t=0;t{ge.Warn(`Error downloading MTL file: '${i}'`),this._loadingOptions.materialLoadingFailsSilently?e():n(r)})})),Promise.all(c).then(()=>{let e=e=>!!(e._internalMetadata?._isLine??!1);return s.forEach(n=>{if(e(n)){let r=n.material??new lg(n.name+`_line`,t);r.getBindedMeshes().filter(t=>!e(t)).length>0&&(r=r.clone(r.name+`_line`)??r),r.wireframe=!0,n.material=r,n._internalMetadata&&(n._internalMetadata._isLine=void 0)}}),s})}};l7.OPTIMIZE_WITH_UV=!0,l7.INVERT_Y=!1,l7.IMPORT_VERTEX_COLORS=!1,l7.COMPUTE_NORMALS=!1,l7.OPTIMIZE_NORMALS=!1,l7.UV_SCALING=new O(1,1),l7.SKIP_MATERIALS=!1,l7.MATERIAL_LOADING_FAILS_SILENTLY=!0,l7.USE_LEGACY_BEHAVIOR=!1;var Q0e=!1;function $0e(){Q0e||(Q0e=!0,hD(new l7))}$0e();function e2e(e={}){let t=e.wheelbase??1.7,n=(e.trackWidth??1.25)*.5,r=e.suspensionOriginY??-.22,i=e.wheelRadius??.28,a=e.suspensionRestLength??.24,o=e.suspensionTravel??.14,s=t*.5,c=-s,l=e.allWheelDrive===!1?0:1,u=(e,t,n,s,c,l)=>({id:e,originLocal:new j(t,r,n),radius:i,restLength:a,travel:o,steerFactor:s,driveFactor:c,brakeFactor:1,handbrakeFactor:l});return[u(`frontLeft`,-n,s,1,l,0),u(`frontRight`,n,s,1,l,0),u(`rearLeft`,-n,c,0,1,1),u(`rearRight`,n,c,0,1,1)]}var t2e={wheels:e2e(),suspensionStrength:145,suspensionDamping:11,maxSuspensionAcceleration:38,gripCoefficient:1.7,lateralGrip:10,frontGripMultiplier:1,rearGripMultiplier:1.05,handbrakeGripMultiplier:.28,centerOfMassOffset:new j(0,-.28,-.05),tireForceApplicationHeight:.72,antiRollStrength:46,antiFlipMultiplier:3.2,rollingResistance:.32,engineAcceleration:24,reverseAccelerationMultiplier:.55,brakeDeceleration:34,handbrakeDeceleration:22,maxForwardSpeed:27,maxReverseSpeed:10,maxSteerAngle:Math.PI*.19,highSpeedSteerMultiplier:.42,steerResponse:7.5,yawResponse:1,maxYawRate:2.9,handbrakeYawResponseMultiplier:.18,throttleResponse:7,brakeResponse:10,directionChangeBrakeSpeed:1.2,downforceCoefficient:.018,maxDownforceAcceleration:14,groundUprightStrength:12,groundUprightDamping:2.8,airYawControl:2.6,airPitchControl:2.2,linearDamping:.08,angularDamping:.16};function n2e(e={}){return{...t2e,...e,wheels:e.wheels??t2e.wheels}}var u7=`assets/kenney/car-kit/models/`,r2e=`assets/custom/rc-sport-car/`,d7=`assets/custom/player-cars/`,i2e=1.28,a2e=1.16;function f7(e,t){let n=e2e({wheelbase:t.wheelbase,trackWidth:t.trackWidth,wheelRadius:t.radius,suspensionOriginY:t.originY,suspensionRestLength:t.restLength,suspensionTravel:t.travel}),r=t=>{let n=t.steerFactor>0;return e===`FWD`?+!!n:e===`RWD`?+!n:n?.46:.54};return n.map(e=>({...e,driveFactor:r(e)}))}var o2e={mass:2.25,friction:.78,restitution:.025,chassisSize:[2.05,.7,3.5],controller:{wheels:f7(`4WD`,{wheelbase:2.25,trackWidth:1.78,radius:.43,originY:-.14,restLength:.3,travel:.18}),suspensionStrength:150,suspensionDamping:11.2,maxSuspensionAcceleration:39,gripCoefficient:1.92,lateralGrip:9.8,frontGripMultiplier:1,rearGripMultiplier:1.07,centerOfMassOffset:new j(0,-.29,-.04),tireForceApplicationHeight:.74,antiRollStrength:48,antiFlipMultiplier:3.4,engineAcceleration:23.5,brakeDeceleration:35,handbrakeDeceleration:22,maxForwardSpeed:25.5,maxSteerAngle:Math.PI*.2,highSpeedSteerMultiplier:.44,steerResponse:7.7,yawResponse:.95,maxYawRate:2.75,throttleResponse:7.2,airYawControl:2.8,airPitchControl:2.55,groundUprightStrength:22,groundUprightDamping:4.8,angularDamping:.18}},s2e={mass:2.5,friction:.75,restitution:.02,chassisSize:[2.08,.68,3.62],controller:{wheels:f7(`FWD`,{wheelbase:2.34,trackWidth:1.76,radius:.42,originY:-.15,restLength:.28,travel:.16}),suspensionStrength:154,suspensionDamping:11.4,maxSuspensionAcceleration:40,gripCoefficient:1.78,lateralGrip:9.5,frontGripMultiplier:.94,rearGripMultiplier:1.08,centerOfMassOffset:new j(0,-.32,.02),tireForceApplicationHeight:.77,antiRollStrength:54,antiFlipMultiplier:3.7,engineAcceleration:26,brakeDeceleration:37,handbrakeDeceleration:23,maxForwardSpeed:28,maxSteerAngle:Math.PI*.185,highSpeedSteerMultiplier:.4,steerResponse:8,yawResponse:.8,maxYawRate:2.55,throttleResponse:7.8,airYawControl:2.45,airPitchControl:2.25,groundUprightStrength:24,groundUprightDamping:5.1,downforceCoefficient:.021}},c2e={mass:1.82,friction:.68,restitution:.035,chassisSize:[1.9,.66,3.2],controller:{wheels:f7(`RWD`,{wheelbase:2.02,trackWidth:1.65,radius:.4,originY:-.13,restLength:.29,travel:.19}),suspensionStrength:164,suspensionDamping:11.4,maxSuspensionAcceleration:43,gripCoefficient:1.55,lateralGrip:8.25,frontGripMultiplier:1,rearGripMultiplier:1.12,centerOfMassOffset:new j(0,-.23,-.09),tireForceApplicationHeight:.64,antiRollStrength:34,antiFlipMultiplier:2.6,handbrakeGripMultiplier:.22,engineAcceleration:30.5,brakeDeceleration:33,handbrakeDeceleration:24,maxForwardSpeed:30.5,maxSteerAngle:Math.PI*.22,highSpeedSteerMultiplier:.46,steerResponse:9,yawResponse:1.2,maxYawRate:3.4,handbrakeYawResponseMultiplier:.12,throttleResponse:9,airYawControl:3.65,airPitchControl:3.35,groundUprightStrength:18,groundUprightDamping:4.1,angularDamping:.14}},p7={mass:3.25,friction:.84,restitution:.018,chassisSize:[2.2,.84,3.72],controller:{wheels:f7(`4WD`,{wheelbase:2.38,trackWidth:1.9,radius:.48,originY:-.18,restLength:.34,travel:.23}),suspensionStrength:182,suspensionDamping:14.2,maxSuspensionAcceleration:46,gripCoefficient:2.08,lateralGrip:10.4,frontGripMultiplier:.98,rearGripMultiplier:1.08,centerOfMassOffset:new j(0,-.39,-.05),tireForceApplicationHeight:.83,antiRollStrength:68,antiFlipMultiplier:4.3,rollingResistance:.36,engineAcceleration:22.5,brakeDeceleration:40,handbrakeDeceleration:27,maxForwardSpeed:27.5,maxSteerAngle:Math.PI*.12,highSpeedSteerMultiplier:.28,steerResponse:5.8,yawResponse:.4,maxYawRate:1.65,throttleResponse:6.4,airYawControl:1.95,airPitchControl:1.75,groundUprightStrength:31,groundUprightDamping:6.2,maxDownforceAcceleration:16,angularDamping:.22}},l2e={mass:2.14,friction:.73,restitution:.015,chassisSize:[2.04,.62,3.7],controller:{wheels:f7(`RWD`,{wheelbase:2.42,trackWidth:1.78,radius:.41,originY:-.17,restLength:.25,travel:.14}),suspensionStrength:172,suspensionDamping:13.5,maxSuspensionAcceleration:44,gripCoefficient:1.72,lateralGrip:8.7,frontGripMultiplier:1,rearGripMultiplier:1.1,centerOfMassOffset:new j(0,-.35,-.1),tireForceApplicationHeight:.81,antiRollStrength:60,antiFlipMultiplier:3.9,handbrakeGripMultiplier:.2,rollingResistance:.28,engineAcceleration:29.5,brakeDeceleration:39,handbrakeDeceleration:26,maxForwardSpeed:34,maxSteerAngle:Math.PI*.182,highSpeedSteerMultiplier:.38,steerResponse:8.5,yawResponse:1,maxYawRate:3,handbrakeYawResponseMultiplier:.13,throttleResponse:8.1,airYawControl:3.05,airPitchControl:2.75,groundUprightStrength:28,groundUprightDamping:5.6,downforceCoefficient:.026,maxDownforceAcceleration:18,linearDamping:.065,angularDamping:.145}},m7=[{id:`sports-car`,name:`Sports Car`,tagline:`Low, clean, and built for speed.`,description:`A planted rear-drive sports car with high-speed grip and a sharp racing line.`,class:`Advanced`,engine:`Electric`,drivetrain:`RWD`,model:{assetRootUrl:d7,fileName:`sports-car.glb`,scale:[3.78,3.78,3.78],offset:[0,-.46,0],rotation:[0,Math.PI/2,0],wheelNodeNames:{frontLeft:`tripo_part_3`,frontRight:`tripo_part_7`,rearLeft:`tripo_part_1`,rearRight:`tripo_part_15`},wheelCenters:{frontLeft:[-.2982,.069,-.1611],frontRight:[-.3011,.0693,.1608],rearLeft:[.2551,.0813,-.1758],rearRight:[.2557,.0809,.1759]},wheelSpinAxis:[0,0,1],wheelSteerAxis:[0,1,0],replacementWheelScale:.0182,hasEmbeddedWheels:!0},physics:l2e,displayStats:{speed:94,acceleration:88,handling:84,weight:48,toughness:51}},{id:`orange-off-road`,name:`Orange Off-Road`,tagline:`Take the line nobody else can.`,description:`A high-clearance 4WD bruiser tuned for grass, curbs, and hard landings.`,class:`Semi-Pro`,engine:`Glow`,drivetrain:`4WD`,model:{assetRootUrl:d7,fileName:`orange-off-road.glb`,scale:[3.79,3.79,3.79],offset:[0,-.48,0],rotation:[0,Math.PI/2,0],wheelNodeNames:{frontLeft:`tripo_part_2`,frontRight:`tripo_part_7`,rearLeft:`tripo_part_4`,rearRight:`tripo_part_3`},wheelCenters:{frontLeft:[-.2912,.0894,-.188],frontRight:[-.2934,.0927,.1941],rearLeft:[.276,.0945,-.1909],rearRight:[.2689,.0939,.1934]},wheelSpinAxis:[0,0,1],wheelSteerAxis:[0,1,0],replacementWheelScale:.0242,hasEmbeddedWheels:!0},physics:p7,displayStats:{speed:72,acceleration:64,handling:55,weight:83,toughness:95}},{id:`pickup-truck`,name:`Pickup Truck`,tagline:`Torque first. Questions later.`,description:`A stable all-wheel-drive pickup that trades rotation for durability and traction.`,class:`Amateur`,engine:`Electric`,drivetrain:`4WD`,model:{assetRootUrl:d7,fileName:`pickup-truck.glb`,scale:[3.83,3.83,3.83],offset:[0,-.48,0],rotation:[0,Math.PI/2+1.029+Math.PI,0],wheelNodeNames:{frontLeft:`tripo_part_1`,frontRight:`tripo_part_4`,rearLeft:`tripo_part_5`,rearRight:`tripo_part_6`},wheelCenters:{frontLeft:[.0162,.0892,-.271],frontRight:[-.247,.0896,-.1131],rearLeft:[.2983,.0891,.1984],rearRight:[.035,.089,.3563]},wheelSpinAxis:[-.8569,0,.5155],wheelSteerAxis:[0,1,0],hasEmbeddedWheels:!0},physics:p7,displayStats:{speed:68,acceleration:61,handling:50,weight:90,toughness:92}},{id:`modified-sports-car`,name:`Modified Sports`,tagline:`Street tuned. Track proven.`,description:`A light modified coupe with fast turn-in, strong acceleration, and a lively rear end.`,class:`Pro`,engine:`Glow`,drivetrain:`RWD`,model:{assetRootUrl:d7,fileName:`modified-sports-car.glb`,scale:[3.65,3.65,3.65],offset:[0,-.46,0],rotation:[0,Math.PI/2,0],hasEmbeddedWheels:!0},physics:c2e,displayStats:{speed:91,acceleration:94,handling:90,weight:35,toughness:43}},{id:`voltage-bandit`,name:`Voltage Bandit`,tagline:`Light feet. Loud attitude.`,description:`A forgiving all-wheel-drive buggy with predictable grip and soft landings.`,class:`Rookie`,engine:`Electric`,drivetrain:`4WD`,model:{assetRootUrl:r2e,fileName:`10600_RC_Car_animated.obj`,scale:[.075,.1,.075],offset:[-.01,-.36,-.18],rotation:[-Math.PI/2,0,0],wheelSuspensionAxis:[0,0,1],wheelCenters:{frontLeft:[-11.5765,-14.126,3.996],frontRight:[11.9005,-14.126,3.996],rearLeft:[-11.5355,8.2535,4.0095],rearRight:[11.929,8.2535,4.0095]}},physics:o2e,displayStats:{speed:70,acceleration:76,handling:78,weight:43,toughness:55}},{id:`kestrel-gt`,name:`Kestrel GT`,tagline:`Corners are invitations.`,description:`A precise electric tourer. Front drive rewards clean entries but pushes wide under power.`,class:`Amateur`,engine:`Electric`,drivetrain:`FWD`,model:{assetRootUrl:u7,fileName:`sedan-sports.glb`,scale:[1.39,1.39,1.39],offset:[0,-.46,0],rotation:[0,0,0]},physics:s2e,displayStats:{speed:76,acceleration:84,handling:68,weight:54,toughness:58}},{id:`pocket-rocket`,name:`Pocket Rocket`,tagline:`Small target. Serious trouble.`,description:`An explosive rear-drive glow car with quick rotation, long jumps, and little patience.`,class:`Advanced`,engine:`Glow`,drivetrain:`RWD`,model:{assetRootUrl:u7,fileName:`hatchback-sports.glb`,scale:[1.34,1.34,1.34],offset:[0,-.43,0],rotation:[0,0,0]},physics:c2e,displayStats:{speed:86,acceleration:91,handling:92,weight:29,toughness:38}},{id:`iron-howl`,name:`Iron Howl`,tagline:`The shortcut is straight through.`,description:`A heavy 4WD glow bruiser built to absorb landings and win contact at the apex.`,class:`Semi-Pro`,engine:`Glow`,drivetrain:`4WD`,model:{assetRootUrl:u7,fileName:`suv-luxury.glb`,scale:[1.5,1.5,1.5],offset:[0,-.54,0],rotation:[0,0,0]},physics:p7,displayStats:{speed:70,acceleration:58,handling:48,weight:91,toughness:96}},{id:`circuit-wasp`,name:`Circuit Wasp`,tagline:`Blink and you missed the apex.`,description:`A low-slung pro prototype: fastest on clean lines, lively on throttle, ruthless at speed.`,class:`Pro`,engine:`Electric`,drivetrain:`RWD`,model:{assetRootUrl:u7,fileName:`race-future.glb`,scale:[1.4,1.4,1.4],offset:[0,-.45,0],rotation:[0,0,0]},physics:l2e,displayStats:{speed:98,acceleration:88,handling:86,weight:47,toughness:51}}],u2e=new Map(m7.map(e=>[e.id,e]));function h7(e){return u2e.has(e)}function d2e(e){return h7(e)?u2e.get(e):void 0}function g7(e){let t=d2e(e);if(!t)throw Error(`Unknown car profile: ${e}`);return t}function f2e(e){let t=typeof e==`string`?g7(e).physics.controller:e.physics.controller;return{...t,engineAcceleration:(t.engineAcceleration??24)*a2e,maxForwardSpeed:(t.maxForwardSpeed??27)*i2e,maxReverseSpeed:(t.maxReverseSpeed??10)*1.12}}var p2e=[[`frontLeft`,`wheel-front-left`],[`frontRight`,`wheel-front-right`],[`rearLeft`,`wheel-back-left`],[`rearRight`,`wheel-back-right`]],m2e=`assets/custom/rc-sport-car/`,h2e=`RC_Wheel_Kit.obj`;async function _7(e,t,n,r=`voltage-bandit`){y7(e,`full`);try{let i=g7(r),a=await xD.ImportMeshAsync(``,i.model.assetRootUrl,i.model.fileName,t),o=a.meshes.find(e=>e.name===`__root__`),s=o??new wc(`${r}-imported-root`,t);o||a.meshes.forEach(e=>{e.parent||=s}),s.parent=e.driftRoot,s.position.set(...i.model.offset),s.rotationQuaternion=null,s.rotation.set(...i.model.rotation),s.scaling.set(...i.model.scale),a.meshes.forEach(e=>{e.isPickable=!1,e.receiveShadows=!0,n.addShadowCaster(e)});let c=[...a.meshes,...a.transformNodes],l=i.model.wheelSuspensionAxis?new j(...i.model.wheelSuspensionAxis).normalize():j.Up(),u=Math.max(1e-4,Math.hypot(l.x*i.model.scale[0],l.y*i.model.scale[1],l.z*i.model.scale[2])),d=p2e.flatMap(([e,n],r)=>{let a=i.model.wheelNodeNames?.[e]??n,o=c.find(e=>e.name.toLowerCase()===a),s=i.model.wheelCenters?.[e];if(!o)return[];let d=i.model.wheelNodeNames&&s?_2e(t,o,s,e):o;!i.model.wheelNodeNames&&s&&o.position.set(...s);let f=i.model.wheelSteerAxis?new j(...i.model.wheelSteerAxis):j.Forward(),p=i.model.wheelSpinAxis?new j(...i.model.wheelSpinAxis):j.Right();return o?[{wheelId:e,node:d,followSuspension:!1,suspensionScale:1/u,suspensionAxis:l,steerAxis:f,spinAxis:p,spinDirection:r%2==0?-1:1}]:[]});if(i.model.replacementWheelScale&&d.length===4){let e=await g2e(t,n,s,i.model.wheelCenters??{},i.model.replacementWheelScale,1/u,l);e.length===4&&(d.forEach(e=>e.node.getChildMeshes().forEach(e=>e.setEnabled(!1))),d=e)}return e.wheelPivots.forEach(e=>e.scaling.setAll(1)),d.length===4?(e.wheelVisuals=d,y7(e,`hidden`)):i.model.hasEmbeddedWheels?(e.wheelVisuals=[],y7(e,`hidden`)):(e.wheelVisuals=v7(e),y7(e,`wheels`)),()=>{s.dispose(!1,!0),e.wheelVisuals=v7(e),y7(e,`full`)}}catch(t){return console.warn(`The detailed car model could not be loaded; using the built-in fallback.`,t),e.wheelVisuals=v7(e),y7(e,`full`),()=>void 0}}async function g2e(e,t,n,r,i,a,o){let s=await xD.ImportMeshAsync(``,m2e,h2e,e),c=[...s.meshes,...s.transformNodes],l=A.RotationAxis(new j(1,1,1).normalize(),-2*Math.PI/3);return p2e.flatMap(([s,u],d)=>{let f=c.find(e=>e.name.toLowerCase()===u),p=r[s];if(!f||!p)return[];let m=new wc(`${s}-replacement-wheel-pivot`,e);m.parent=n,m.position.set(...p);let h=new wc(`${s}-replacement-wheel-geometry`,e);return h.parent=m,h.rotationQuaternion=l.clone(),h.scaling.setAll(i),f.parent=h,f.position.setAll(0),f.rotation.setAll(0),f.rotationQuaternion=A.Identity(),f.getChildMeshes(!1).forEach(e=>{e.isPickable=!1,e.receiveShadows=!0,t.addShadowCaster(e)}),f instanceof K&&(f.isPickable=!1,f.receiveShadows=!0,t.addShadowCaster(f)),[{wheelId:s,node:m,followSuspension:!1,suspensionScale:a,suspensionAxis:o,steerAxis:j.Up(),spinAxis:j.Forward(),spinDirection:d%2==0?-1:1}]})}function _2e(e,t,n,r){let i=new wc(`${r}-imported-wheel-pivot`,e);return i.parent=t.parent,i.position.set(...n),t.parent=i,t.position.subtractInPlace(i.position),i}function v7(e,t=.19){let n=[`frontLeft`,`frontRight`,`rearLeft`,`rearRight`];return e.wheelPivots.map((e,r)=>({wheelId:n[r],node:e,positionOffset:new j(r%2==0?-t:t,.02,r<2?.025:-.025),spinDirection:r%2==0?-1:1}))}function y7(e,t){e.visualRoot.setEnabled(t!==`hidden`);let n=new Set(e.wheelMeshes);e.visualRoot.getChildMeshes().forEach(e=>{e.setEnabled(t===`full`||t===`wheels`&&n.has(e))})}function b7(e,t,n,r=.25){let i=new lg(t,e);return i.diffuseColor=P.FromHexString(n),i.specularColor=new P(r,r,r),i}function v2e(e,t,n){let r=b7(e,`car-shell`,`#c45f31`,.48),i=b7(e,`car-shell-dark`,`#71361f`,.32),a=b7(e,`tire-rubber`,`#17191c`,.08),o=b7(e,`wheel-rim`,`#b5b0a5`,.62),s=b7(e,`car-glass`,`#263f49`,.72),c=b7(e,`car-light`,`#f0d49a`,.8),l=vm.CreateBox(`car-physics-chassis`,{width:2.15,height:.72,depth:3.65},e);l.position.copyFrom(n),l.isVisible=!1;let u=new wc(`car-presentation-root`,e);u.position.copyFrom(n),u.rotationQuaternion=A.Identity();let d=new wc(`car-drift-root`,e);d.parent=u,d.rotationQuaternion=A.Identity();let f=new wc(`car-visual-root`,e);f.parent=d;let p=vm.CreateBox(`car-lower-shell`,{width:2.2,height:.58,depth:3.7},e);p.position.y=.03,p.material=r,p.parent=f,p.edgesWidth=.6;let m=vm.CreateBox(`car-nose`,{width:2.05,height:.35,depth:1.05},e);m.position.set(0,.34,1.3),m.rotation.x=-.08,m.material=r,m.parent=f;let h=vm.CreateBox(`car-cabin`,{width:1.56,height:.72,depth:1.45},e);h.position.set(0,.64,-.25),h.scaling.z=.92,h.material=s,h.parent=f;let g=vm.CreateBox(`car-roof`,{width:1.48,height:.16,depth:1.1},e);g.position.set(0,1.05,-.28),g.material=i,g.parent=f;let _=vm.CreateBox(`car-spoiler`,{width:2.15,height:.12,depth:.42},e);_.position.set(0,.83,-1.68),_.material=i,_.parent=f;for(let t of[-.65,.65]){let n=vm.CreateBox(`spoiler-mount-${t}`,{width:.12,height:.48,depth:.13},e);n.position.set(t,.58,-1.58),n.material=i,n.parent=f}for(let t of[-.72,.72]){let n=vm.CreateBox(`headlight-${t}`,{width:.42,height:.18,depth:.08},e);n.position.set(t,.28,1.87),n.material=c,n.parent=f}let v=[],y=[],b=[[-1.08,-.05,1.15,!0],[1.08,-.05,1.15,!0],[-1.08,-.05,-1.15,!1],[1.08,-.05,-1.15,!1]];b.forEach(([t,n,r,i],s)=>{let c=new wc(`wheel-pivot-${s}`,e);c.position.set(t,n,r),c.parent=f;let l=vm.CreateCylinder(`wheel-${s}`,{diameter:.88,height:.5,tessellation:24},e);l.rotation.z=Math.PI/2,l.material=a,l.parent=c;let u=vm.CreateCylinder(`wheel-hub-${s}`,{diameter:.36,height:.52,tessellation:16},e);u.rotation.z=Math.PI/2,u.material=o,u.parent=c,y.push(l,u),i&&v.push(c)});let x=vm.CreateCylinder(`antenna`,{diameter:.055,height:2.1,tessellation:10},e);x.position.set(.58,1.47,-.8),x.rotation.z=-.14,x.material=i,x.parent=f;let S=vm.CreateSphere(`antenna-tip`,{diameter:.18,segments:12},e);S.position.set(.73,2.49,-.8),S.material=r,S.parent=f,f.getChildMeshes().forEach(e=>t.addShadowCaster(e));let C=new ZO(l,YO.BOX,{mass:2.4,friction:.72,restitution:.02},e);C.body.setLinearDamping(.18),C.body.setAngularDamping(.72);let w={chassis:l,aggregate:C,presentationRoot:u,driftRoot:d,visualRoot:f,frontWheelPivots:v,wheelPivots:b.map((t,n)=>e.getTransformNodeByName(`wheel-pivot-${n}`)),wheelMeshes:y,wheelVisuals:[],dispose:()=>{C.dispose(),l.dispose(!1,!0),u.dispose(!1,!0)}};return w.wheelVisuals=v7(w),w}var y2e=class{constructor(e,t,n,r,i){this.previousPosition=new j,this.currentPosition=new j,this.previousRotation=new A,this.currentRotation=new A,this.accumulator=0,this.scene=e,this.physicsNode=t,this.presentationNode=n,this.fixedStep=r,this.maximumAccumulator=r*i,this.resetToPhysicsPose(),this.observer=e.onBeforeRenderObservable.add(()=>this.present())}beginFrame(e){this.scene.physicsEnabled&&(this.accumulator=Math.min(this.maximumAccumulator,this.accumulator+Math.max(0,e)))}capturePhysicsPose(){let e=this.physicsNode.position,t=this.physicsNode.rotationQuaternion??A.Identity();if(j.DistanceSquared(e,this.currentPosition)>16){this.previousPosition.copyFrom(e),this.currentPosition.copyFrom(e),this.previousRotation.copyFrom(t),this.currentRotation.copyFrom(t),this.accumulator=0;return}this.previousPosition.copyFrom(this.currentPosition),this.previousRotation.copyFrom(this.currentRotation),this.currentPosition.copyFrom(e),this.currentRotation.copyFrom(t),this.accumulator=Math.max(0,this.accumulator-this.fixedStep)}resetToPhysicsPose(){let e=this.physicsNode.rotationQuaternion??A.Identity();this.previousPosition.copyFrom(this.physicsNode.position),this.currentPosition.copyFrom(this.physicsNode.position),this.previousRotation.copyFrom(e),this.currentRotation.copyFrom(e),this.presentationNode.position.copyFrom(this.physicsNode.position),this.presentationNode.rotationQuaternion??=A.Identity(),this.presentationNode.rotationQuaternion.copyFrom(e),this.accumulator=0}dispose(){this.scene.onBeforeRenderObservable.remove(this.observer)}present(){let e=Math.max(0,Math.min(1,this.accumulator/this.fixedStep));j.LerpToRef(this.previousPosition,this.currentPosition,e,this.presentationNode.position),this.presentationNode.rotationQuaternion??=A.Identity(),A.SlerpToRef(this.previousRotation,this.currentRotation,e,this.presentationNode.rotationQuaternion)}},b2e=7*Math.PI/180,x2e=3.5*Math.PI/180,S2e=class{constructor(e,t,n){this.targetYaw=0,this.targetRoll=0,this.targetAmount=0,this.yaw=0,this.roll=0,this.amount=0,this.scene=e,this.visualRoot=n,this.visualRoot.rotationQuaternion??=A.Identity(),this.smoke=[-.78,.78].map((n,r)=>{let i=new K(`drift-smoke-emitter-${r}`,e);i.isVisible=!1,i.parent=t,i.position.set(n,-.28,-1.32);let a=new RZ(`drift-smoke-${r}`,120,e);return a.particleTexture=new W(`assets/kenney/particle-pack/sprites/smoke_04.png`,e),a.emitter=i,a.minEmitBox.set(-.08,-.02,-.08),a.maxEmitBox.set(.08,.04,.08),a.color1=new fe(.74,.77,.78,.3),a.color2=new fe(.5,.53,.54,.18),a.colorDead=new fe(.42,.44,.45,0),a.minSize=.12,a.maxSize=.32,a.minLifeTime=.24,a.maxLifeTime=.58,a.emitRate=0,a.direction1=new j(-.25,.45,-.35),a.direction2=new j(.25,.85,.15),a.minEmitPower=.4,a.maxEmitPower=1.05,a.updateSpeed=.012,a.start(),a}),this.observer=e.onBeforeRenderObservable.add(()=>this.update())}setVehicleState(e){let t=Math.abs(e.forwardSpeed),n=x7((t-2.5)/8,0,1),r=Math.atan2(e.lateralSpeed,Math.max(t,2)),i=x7((Math.abs(r)-.04)/.25,0,1),a=+(e.groundedWheelCount>=2);this.targetAmount=n*i*a,this.targetYaw=x7(-r*.55,-b2e,b2e)*n*a,this.targetRoll=x7(-e.lateralSpeed*.018,-x2e,x2e)*n*a}reset(){this.targetYaw=0,this.targetRoll=0,this.targetAmount=0,this.yaw=0,this.roll=0,this.amount=0,this.visualRoot.rotationQuaternion??=A.Identity(),this.visualRoot.rotationQuaternion.copyFrom(A.Identity()),this.smoke.forEach(e=>{e.emitRate=0})}dispose(){this.scene.onBeforeRenderObservable.remove(this.observer),this.smoke.forEach(e=>{let t=e.emitter;e.dispose(),t instanceof wc&&t.dispose()})}update(){let e=Math.min(.05,this.scene.getEngine().getDeltaTime()/1e3),t=1-Math.exp(-10*e),n=1-Math.exp(-7*e);this.yaw+=(this.targetYaw-this.yaw)*t,this.roll+=(this.targetRoll-this.roll)*t,this.amount+=(this.targetAmount-this.amount)*n,this.visualRoot.rotationQuaternion??=A.Identity(),A.FromEulerAnglesToRef(0,this.yaw,this.roll,this.visualRoot.rotationQuaternion),this.smoke.forEach(e=>{e.emitRate=this.amount*34})}};function x7(e,t,n){return Math.max(t,Math.min(n,e))}var C2e=4.6,w2e=1.85,T2e=5.4,S7=Math.PI*.82,E2e=class{constructor(e,t,n,r={}){this.smoothedLookAt=new j,this.previousForward=j.Forward(),this.orbitYaw=0,this.heightAdjustment=0,this.distance=C2e,this.dragging=!1,this.pointerId=null,this.lastPointerX=0,this.lastPointerY=0,this.lastInteractionAt=0,this.filteredYawRate=0,this.motionBlurPending=!1,this.onPointerDown=e=>{this.scene.activeCamera===this.camera&&(e.isPrimary===!1||e.pointerType===`mouse`&&e.button!==0||this.dragging||(this.dragging=!0,this.pointerId=e.pointerId,this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.lastInteractionAt=performance.now(),this.canvas.focus({preventScroll:!0}),this.canvas.setPointerCapture?.(e.pointerId),e.preventDefault()))},this.onPointerMove=e=>{if(!this.dragging||e.pointerId!==this.pointerId)return;let t=e.clientX-this.lastPointerX,n=e.clientY-this.lastPointerY;this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.applyDrag(t,n),e.preventDefault()},this.onPointerUp=e=>{e.pointerId===this.pointerId&&(this.dragging=!1,this.pointerId=null,this.lastInteractionAt=performance.now(),this.canvas.hasPointerCapture?.(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId))},this.onMouseDown=e=>{this.scene.activeCamera!==this.camera||e.button!==0||this.dragging||(this.dragging=!0,this.pointerId=null,this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.lastInteractionAt=performance.now(),this.canvas.focus({preventScroll:!0}),e.preventDefault())},this.onMouseMove=e=>{if(!this.dragging||this.pointerId!==null)return;let t=e.clientX-this.lastPointerX,n=e.clientY-this.lastPointerY;this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.applyDrag(t,n),e.preventDefault()},this.onMouseUp=e=>{!this.dragging||this.pointerId!==null||e.button!==0||(this.dragging=!1,this.lastInteractionAt=performance.now())},this.onWindowBlur=()=>{this.dragging=!1,this.pointerId=null,this.lastInteractionAt=performance.now()},this.onWheel=e=>{this.scene.activeCamera===this.camera&&(this.distance=xq.Clamp(this.distance+e.deltaY*.004,3.35,6.8),this.lastInteractionAt=performance.now(),e.preventDefault())},this.scene=e,this.canvas=t,this.target=n,this.enableMotionBlur=r.enableMotionBlur??!1,this.camera=new mh(`race-camera`,j.Zero(),e),this.camera.minZ=.06,this.camera.maxZ=500,this.camera.fov=65*Math.PI/180,this.camera.inertia=0,t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),window.addEventListener(`pointerup`,this.onPointerUp),window.addEventListener(`pointercancel`,this.onPointerUp),t.addEventListener(`mousedown`,this.onMouseDown),window.addEventListener(`mousemove`,this.onMouseMove),window.addEventListener(`mouseup`,this.onMouseUp),window.addEventListener(`blur`,this.onWindowBlur),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.beforeRenderObserver=e.onBeforeRenderObservable.add(()=>this.update()),this.snapToTarget()}activate(){this.snapToTarget(),this.scene.activeCamera=this.camera,!(!this.enableMotionBlur||this.motionBlur||this.motionBlurPending)&&(this.motionBlurPending=!0,this.scene.onAfterRenderObservable.addOnce(()=>{this.motionBlurPending=!1,!(this.scene.isDisposed||this.scene.activeCamera!==this.camera)&&(this.motionBlur=new T1(`race-camera-motion-blur`,this.scene,1,this.camera),this.motionBlur.isObjectBased=!1,this.motionBlur.motionStrength=.16,this.motionBlur.motionBlurSamples=8)}))}snapToTarget(){this.orbitYaw=0,this.heightAdjustment=0,this.filteredYawRate=0;let e=this.calculatePose();this.camera.position.copyFrom(e.position),this.smoothedLookAt.copyFrom(e.lookAt),this.camera.setTarget(this.smoothedLookAt),this.previousForward.copyFrom(e.forward)}dispose(){this.canvas.removeEventListener(`pointerdown`,this.onPointerDown),this.canvas.removeEventListener(`pointermove`,this.onPointerMove),window.removeEventListener(`pointerup`,this.onPointerUp),window.removeEventListener(`pointercancel`,this.onPointerUp),this.canvas.removeEventListener(`mousedown`,this.onMouseDown),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`mouseup`,this.onMouseUp),window.removeEventListener(`blur`,this.onWindowBlur),this.canvas.removeEventListener(`wheel`,this.onWheel),this.scene.onBeforeRenderObservable.remove(this.beforeRenderObserver),this.motionBlur?.dispose(this.camera),this.camera.dispose()}applyDrag(e,t){this.orbitYaw=xq.Clamp(this.orbitYaw+e*.005,-S7,S7),this.heightAdjustment=xq.Clamp(this.heightAdjustment-t*.006,-.65,1.05),this.lastInteractionAt=performance.now()}update(){if(this.scene.activeCamera!==this.camera)return;let e=xq.Clamp(this.scene.getEngine().getDeltaTime()/1e3,1/240,1/20);if(!this.dragging&&performance.now()-this.lastInteractionAt>500){let t=1-Math.exp(-2.35*e);this.orbitYaw=xq.Lerp(this.orbitYaw,0,t),this.heightAdjustment=xq.Lerp(this.heightAdjustment,0,t)}let t=this.calculatePose();j.LerpToRef(this.camera.position,t.position,1-Math.exp(-7.5*e),this.camera.position),j.LerpToRef(this.smoothedLookAt,t.lookAt,1-Math.exp(-10.5*e),this.smoothedLookAt),this.camera.setTarget(this.smoothedLookAt);let n=Math.atan2(this.previousForward.x,this.previousForward.z),r=Math.atan2(t.forward.x,t.forward.z),i=Math.atan2(Math.sin(r-n),Math.cos(r-n));this.filteredYawRate=xq.Lerp(this.filteredYawRate,i/e,1-Math.exp(-5*e));let a=xq.Clamp(-this.filteredYawRate*.012,-.035,.035);this.camera.rotation.z=xq.Lerp(this.camera.rotation.z,a,1-Math.exp(-4.5*e)),this.previousForward.copyFrom(t.forward)}calculatePose(){this.target.computeWorldMatrix(!0);let e=this.target.getAbsolutePosition(),t=this.target.getDirection(j.Forward());t.y=0,t.lengthSquared()<1e-4&&t.copyFrom(j.Forward()),t.normalize();let n=j.TransformNormal(t,M.RotationY(this.orbitYaw)).normalize(),r=e.subtract(n.scale(this.distance)).addInPlaceFromFloats(0,w2e+this.heightAdjustment,0),i=T2e*(1-Math.min(1,Math.abs(this.orbitYaw)/S7)*.82);return{position:r,lookAt:e.add(t.scale(i)).addInPlaceFromFloats(0,.42,0),forward:t}}},D2e=87,O2e=65,k2e=83,A2e=68,j2e=81,M2e=69,N2e=class{constructor(e,t,n){this.boostActive=!1,this.keyboardSuspended=!1,this.disposed=!1,this.focusCanvas=()=>this.canvas.focus({preventScroll:!0}),this.preventContextMenu=e=>e.preventDefault(),this.onKeyDown=e=>{this.scene.activeCamera===this.camera&&(C7(e.target)||((e.code===`ShiftLeft`||e.code===`ShiftRight`)&&(this.boostActive=!0),(e.code===`KeyR`||e.code===`Digit1`)&&!e.repeat&&this.resetView(),e.code===`Digit2`&&!e.repeat&&this.focusPoint(new j(-102,0,157),78),e.code===`Digit3`&&!e.repeat&&this.focusPoint(new j(-16,0,56),92),e.code===`Digit4`&&!e.repeat&&this.focusPoint(new j(70,0,-116),118),e.code===`Digit5`&&!e.repeat&&this.focusPointFrom(new j(158,0,-55),new j(-92,68,-38)),e.code===`Digit6`&&!e.repeat&&this.focusPointFrom(new j(20,0,-207),new j(58,66,92)),e.code===`Digit7`&&!e.repeat&&this.focusPointFrom(new j(-184,0,70),new j(92,74,-76)),e.code===`Digit8`&&!e.repeat&&this.focusPointFrom(new j(0,13,112),new j(0,14,-58)),e.code===`Digit9`&&!e.repeat&&this.focusPointFrom(new j(70,15,-132),new j(0,15,-58)),e.code===`Digit0`&&!e.repeat&&this.focusPointFrom(new j(-98,13,84),new j(0,14,58)),e.code===`KeyH`&&!e.repeat&&this.focusPointFrom(new j(-35,13,8),new j(58,14,0))))},this.onKeyUp=e=>{(e.code===`ShiftLeft`||e.code===`ShiftRight`)&&(this.boostActive=!1)},this.onFocusIn=e=>{!C7(e.target)||this.keyboardSuspended||(this.keyboardInput?.detachControl(),this.keyboardSuspended=!0,this.boostActive=!1)},this.onFocusOut=()=>{queueMicrotask(()=>{this.disposed||!this.keyboardSuspended||C7(document.activeElement)||(this.keyboardInput?.attachControl(!1),this.keyboardSuspended=!1)})},this.scene=e,this.canvas=t;let r=P2e(n);this.initialPosition=r.position,this.initialTarget=r.target,this.normalSpeed=r.speed;let i=new vh(`map-fly-review-camera`,r.position.clone(),e);this.camera=i,i.minZ=.08,i.maxZ=Math.max(2e3,r.span*8),i.fov=67*Math.PI/180,i.inertia=.38,i.angularSensibility=1600,i.speed=this.normalSpeed,i.keysUp.push(D2e),i.keysDown.push(k2e),i.keysLeft.push(O2e),i.keysRight.push(A2e),i.keysUpward.push(M2e),i.keysDownward.push(j2e),i.setTarget(this.initialTarget),i.attachControl(t,!1),this.keyboardInput=i.inputs.attached.keyboard;let a=i.inputs.attached.mouse;a&&(a.buttons=[1,2]),e.activeCamera=i,t.addEventListener(`pointerdown`,this.focusCanvas),t.addEventListener(`contextmenu`,this.preventContextMenu),window.addEventListener(`keydown`,this.onKeyDown),window.addEventListener(`keyup`,this.onKeyUp),document.addEventListener(`focusin`,this.onFocusIn),document.addEventListener(`focusout`,this.onFocusOut),this.beforeRenderObserver=e.onBeforeRenderObservable.add(()=>this.updateSpeed())}dispose(){this.disposed=!0,this.canvas.removeEventListener(`pointerdown`,this.focusCanvas),this.canvas.removeEventListener(`contextmenu`,this.preventContextMenu),window.removeEventListener(`keydown`,this.onKeyDown),window.removeEventListener(`keyup`,this.onKeyUp),document.removeEventListener(`focusin`,this.onFocusIn),document.removeEventListener(`focusout`,this.onFocusOut),this.scene.onBeforeRenderObservable.remove(this.beforeRenderObserver),this.camera.detachControl(),this.camera.dispose()}updateSpeed(){let e=this.normalSpeed*(this.boostActive?5.5:1);this.camera.speed=xq.Lerp(this.camera.speed,e,.24)}resetView(){this.camera.position.copyFrom(this.initialPosition),this.camera.cameraDirection.setAll(0),this.camera.cameraRotation.setAll(0),this.camera.setTarget(this.initialTarget)}focusPoint(e,t){this.focusPointFrom(e,new j(t*.62,t*.72,-t*.62))}focusPointFrom(e,t){this.camera.position.copyFrom(e.add(t)),this.camera.cameraDirection.setAll(0),this.camera.cameraRotation.setAll(0),this.camera.setTarget(e)}};function C7(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable||!!e.closest(`[contenteditable="true"]`)}function P2e(e){if(e.length===0)return{position:new j(80,100,-80),target:j.Zero(),speed:3.2,span:180};let t=1/0,n=-1/0,r=1/0,i=-1/0,a=0;e.forEach(e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.z),i=Math.max(i,e.z),a=Math.max(a,e.y)});let o=new j((t+n)/2,a+1,(r+i)/2),s=Math.max(80,n-t,i-r)*1.28;return{position:o.add(new j(s*.34,s*.68,-s*.56)),target:o,speed:xq.Clamp(s/92,2.4,7.4),span:s}}var w7=(e,t=-1,n=1)=>Math.min(n,Math.max(t,e)),F2e=class{constructor(){window.__scInput=this,this.keys=new Set,this.touchThrottle=0,this.touchSteering=0,this.touchBrake=0,this.touchHandbrake=!1,this.resetRequested=!1,this.powerupRequested=!1,this.gamepadPowerupWasDown=!1,this.disposed=!1,this.onKeyDown=e=>{[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`].includes(e.code)&&e.preventDefault(),this.keys.add(e.code),e.code===`KeyR`&&(this.resetRequested=!0),e.code===`KeyE`&&!e.repeat&&(this.powerupRequested=!0)},this.onKeyUp=e=>{this.keys.delete(e.code)},window.addEventListener(`keydown`,this.onKeyDown,{passive:!1}),window.addEventListener(`keyup`,this.onKeyUp)}setTouchDrive(e,t){this.touchThrottle=w7(e),this.touchSteering=w7(t)}setTouchBrake(e){this.touchBrake=w7(e,0,1)}setTouchHandbrake(e){this.touchHandbrake=e}requestReset(){this.resetRequested=!0}requestUsePowerup(){this.powerupRequested=!0}sample(){let e=Number(this.keys.has(`KeyW`)||this.keys.has(`ArrowUp`))-Number(this.keys.has(`KeyS`)||this.keys.has(`ArrowDown`)),t=Number(this.keys.has(`KeyD`)||this.keys.has(`ArrowRight`))-Number(this.keys.has(`KeyA`)||this.keys.has(`ArrowLeft`)),n=Number(this.keys.has(`ShiftLeft`)||this.keys.has(`ShiftRight`)),r=this.keys.has(`Space`),i=navigator.getGamepads?.()[0];if(i){let a=.12,o=Math.abs(i.axes[0]??0)>a?i.axes[0]:0,s=Math.abs(i.axes[1]??0)>a?-(i.axes[1]??0):0;t=Math.abs(o)>Math.abs(t)?o:t,e=Math.abs(s)>Math.abs(e)?s:e,n=Math.max(n,i.buttons[6]?.value??0),r||=i.buttons[0]?.pressed??!1;let c=i.buttons[1]?.pressed??!1;c&&!this.gamepadPowerupWasDown&&(this.powerupRequested=!0),this.gamepadPowerupWasDown=c,i.buttons[9]?.pressed&&(this.resetRequested=!0)}else this.gamepadPowerupWasDown=!1;Math.abs(this.touchThrottle)>Math.abs(e)&&(e=this.touchThrottle),Math.abs(this.touchSteering)>Math.abs(t)&&(t=this.touchSteering),n=Math.max(n,this.touchBrake),r||=this.touchHandbrake;let a=this.resetRequested;this.resetRequested=!1;let o=this.powerupRequested;return this.powerupRequested=!1,{throttle:w7(e),steering:w7(t),brake:w7(n,0,1),handbrake:r,reset:a,usePowerup:o}}dispose(){this.disposed||(this.disposed=!0,window.removeEventListener(`keydown`,this.onKeyDown),window.removeEventListener(`keyup`,this.onKeyUp))}},I2e=class{constructor(e){window.__scRace=this,this.phase=`menu`,this.raceStartedAt=0,this.countdownStartedAt=0,this.lapStartedAt=0,this.pausedAt=0,this.penaltyMs=0,this.currentCheckpoint=1,this.currentLap=1,this.lapTimes=[],this.checkpoints=e.checkpoints,this.totalLaps=e.totalLaps??3;let t=e.checkpointRadius??5.25;this.checkpointRadiusSquared=t*t,this.onPhaseChange=e.onPhaseChange,this.onResult=e.onResult}getPhase(){return this.phase}setTotalLaps(e){this.phase!==`menu`&&this.phase!==`finished`||(this.totalLaps=Math.max(1,Math.min(9,Math.round(e))))}start(e=performance.now()){this.lapTimes.length=0,this.currentCheckpoint=1,this.currentLap=1,this.countdownStartedAt=e,this.raceStartedAt=0,this.lapStartedAt=0,this.penaltyMs=0,this.setPhase(`countdown`)}addPenalty(e){this.penaltyMs+=Math.max(0,e)}returnToMenu(){this.setPhase(`menu`)}togglePause(e=performance.now()){if(this.phase===`racing`)this.pausedAt=e,this.setPhase(`paused`);else if(this.phase===`paused`){let t=e-this.pausedAt;this.raceStartedAt+=t,this.lapStartedAt+=t,this.pausedAt=0,this.setPhase(`racing`)}}update(e,t=performance.now()){if(this.phase===`countdown`){t-this.countdownStartedAt>=3200&&(this.raceStartedAt=t,this.lapStartedAt=t,this.setPhase(`racing`));return}if(this.phase!==`racing`)return;let n=this.checkpoints[this.currentCheckpoint],r=e.x-n.x,i=e.z-n.z;if(r*r+i*i>this.checkpointRadiusSquared)return;if(this.currentCheckpoint!==0){this.currentCheckpoint+=1,this.currentCheckpoint>=this.checkpoints.length&&(this.currentCheckpoint=0);return}let a=t-this.lapStartedAt;if(this.lapTimes.push(a),this.currentLap>=this.totalLaps){this.setPhase(`finished`),this.onResult?.({totalTimeMs:t-this.raceStartedAt+this.penaltyMs,bestLapMs:Math.min(...this.lapTimes),lapTimes:[...this.lapTimes]});return}this.currentLap+=1,this.currentCheckpoint=1,this.lapStartedAt=t}telemetry(e,t,n=performance.now()){let r=n-this.countdownStartedAt,i=this.phase===`countdown`?Math.max(0,Math.ceil((3e3-r)/1e3)):null,a=this.raceStartedAt>0?n-this.raceStartedAt+this.penaltyMs:0;return{phase:this.phase,speedKph:e,lap:this.currentLap,totalLaps:this.totalLaps,position:1,racers:1,elapsedMs:a,bestLapMs:this.lapTimes.length?Math.min(...this.lapTimes):null,currentLapMs:this.lapStartedAt>0?n-this.lapStartedAt:0,countdown:i,checkpoint:this.currentCheckpoint,checkpointCount:this.checkpoints.length,airborne:t,wrongWay:!1,surface:`asphalt`,boost:0,direction:`straight`}}setPhase(e){e!==this.phase&&(this.phase=e,this.onPhaseChange?.(e))}},L2e={killHeight:-20,upsideDownUpDot:-.2,upsideDownDelay:3,cooldown:.6,lift:.18},R2e=class{constructor(e,t,n,r={}){this._upsideDownTime=0,this._cooldownRemaining=0,this._teleportGeneration=0,this._preTeleportType=null,this._scene=e,this._body=t,this.options={...L2e,...r},this._checkpoint=T7(n)}setCheckpoint(e){this._checkpoint=T7(e)}getCheckpoint(){return T7(this._checkpoint)}update(e,t,n=!1){let r=Math.max(0,Math.min(e,.1));this._cooldownRemaining=Math.max(0,this._cooldownRemaining-r),t=this.options.upsideDownDelay;return(n||i||a)&&this._cooldownRemaining<=0?(this.respawn(),!0):!1}respawn(e=this._checkpoint){let t=this._body.transformNode,n=e.position.add(new j(0,this.options.lift,0)),r=this._preTeleportType??this._body.getPrestepType();this._preTeleportType=r;let i=++this._teleportGeneration;t.position.copyFrom(n),t.rotationQuaternion??=A.Identity(),t.rotationQuaternion.copyFrom(e.rotation),t.computeWorldMatrix(!0),this._body.setLinearVelocity(j.Zero()),this._body.setAngularVelocity(j.Zero()),this._body.setPrestepType(XO.TELEPORT),this._scene.onAfterPhysicsObservable.addOnce(()=>{i===this._teleportGeneration&&(this._body.setLinearVelocity(j.Zero()),this._body.setAngularVelocity(j.Zero()),this._body.setPrestepType(r),this._preTeleportType=null)}),this._upsideDownTime=0,this._cooldownRemaining=this.options.cooldown}};function z2e(e){let t=e.transformNode;return{position:t.position.clone(),rotation:(t.rotationQuaternion??A.Identity()).clone()}}function T7(e){return{position:e.position.clone(),rotation:e.rotation.clone()}}var B2e=[`hatchback-sports.glb`,`race-future.glb`,`sedan-sports.glb`,`suv-luxury.glb`,`race.glb`],V2e=1.9,H2e=.72,U2e=3.35,W2e=class{constructor(e,t,n,r,i){this.opponents=[],this.segmentLengths=[],this.totalLength=0,this.racing=!1,this.raceTime=0,this.scene=e,this.shadow=t,this.path=n,this.grid=r,this.startHeading=i;for(let e=0;ethis.loadOpponent(t));(await Promise.allSettled(t)).forEach(e=>{e.status===`fulfilled`?this.opponents.push(e.value):console.warn(`An opponent model could not be loaded.`,e.reason)})}setRacing(e){this.racing=e}reset(){this.raceTime=0,this.opponents.forEach(e=>{e.distance=this.distanceAlongPath(e.spawnPosition),e.disabledUntil=0,e.slowedUntil=0,e.slowMultiplier=1,e.laneOffset=e.preferredLane,e.targetLaneOffset=e.preferredLane,e.respawn.respawn({position:e.spawnPosition,rotation:A.RotationAxis(j.Up(),this.startHeading)})}),this.racing=!1}update(e,t){let n=E7(e,0,.05),r=performance.now();this.racing&&(this.raceTime+=n);for(let e of this.opponents){let i=e.aggregate.body,a=i.getLinearVelocity(),o=e.root.rotationQuaternion??A.Identity(),s=G2e(j.Up(),o);if(e.respawn.update(n,s.y,!1)){e.distance=this.distanceAlongPath(e.spawnPosition);continue}if(!this.racing){i.setLinearVelocity(new j(0,Math.min(0,a.y),0)),i.setAngularVelocity(j.Zero());continue}let c=this.samplePath(e.distance),l=j.Dot(a,c.forward);e.distance+=E7(l,2.5,e.baseSpeed*1.18)*n;let u=7.5+Math.max(0,l)*.24,d=this.samplePath(e.distance+u),f=this.samplePath(e.distance+19),p=E7(j.Dot(d.forward,f.forward),-1,1),m=.68+.32*Math.sqrt(Math.max(0,(p+1)*.5)),h=this.findBlockingRacer(e,c,t),g=e.preferredLane+Math.sin(this.raceTime*.55+e.rhythm)*.22;e.targetLaneOffset=h?E7(g+(h.side<=0?2.15:-2.15),-2.45,2.45):g,e.laneOffset=K2e(e.laneOffset,e.targetLaneOffset,n*(1.7+e.aggression));let _=d.position.add(d.right.scale(e.laneOffset)).subtract(e.root.absolutePosition);_.y=0,_.lengthSquared()<.001?_.copyFrom(d.forward):_.normalize();let v=rw*w&&C.normalize().scaleInPlace(w),i.applyForce(C.scale(e.mass),i.getObjectCenterWorld()),i.applyForce(new j(0,-e.mass*3.2,0),i.getObjectCenterWorld());let T=G2e(j.Forward(),o),E=Math.atan2(T.x,T.z),ee=q2e(Math.atan2(_.x,_.z)-E),D=i.getAngularVelocity();i.setAngularVelocity(new j(D.x*.12,E7(ee*(3.8+e.aggression*.4),-2.8,2.8),D.z*.12))}}get positions(){return this.opponents.map(e=>e.root.position)}get abilityTargets(){return this.opponents.map(e=>({id:e.id,body:e.aggregate.body,radius:.96}))}disable(e,t){let n=this.opponents.find(t=>t.id===e);n&&(n.disabledUntil=Math.max(n.disabledUntil,performance.now()+t*1e3))}slow(e,t,n){let r=this.opponents.find(t=>t.id===e);if(!r)return;let i=performance.now();r.slowMultiplier=i{e.aggregate.dispose(),e.root.dispose(!1,!0)}),this.opponents.length=0}async loadOpponent(e){let t=B2e[e%B2e.length],n=await xD.ImportMeshAsync(``,`assets/kenney/car-kit/models/`,t,this.scene),r=(this.grid[e]??this.samplePath(8-e*5).position).clone(),i=vm.CreateBox(`opponent-${e}-body`,{width:V2e,height:H2e,depth:U2e},this.scene);i.position.copyFrom(r),i.rotationQuaternion=A.RotationAxis(j.Up(),this.startHeading),i.isVisible=!1,i.isPickable=!1;let a=new wc(`opponent-${e}-visual`,this.scene);a.parent=i;let o=n.meshes.find(e=>e.name===`__root__`)??n.meshes[0];o&&(o.parent=a,o.position.set(0,-.48,0),o.rotationQuaternion=null,o.rotation.set(0,0,0),o.scaling.setAll(1.42)),n.meshes.forEach(e=>{e.isPickable=!1,e.receiveShadows=!0,this.shadow.addShadowCaster(e)});let s=2.15+e%3*.16,c=new ZO(i,YO.BOX,{mass:s,friction:.72,restitution:.04},this.scene);c.body.setLinearDamping(.12),c.body.setAngularDamping(.82);let l=new R2e(this.scene,c.body,{position:r,rotation:A.RotationAxis(j.Up(),this.startHeading)},{killHeight:-3.5,upsideDownDelay:1.8,lift:.3}),u=(e%2==0?-1:1)*(1.15+e%3*.12);return{id:`opponent-${e}`,root:i,aggregate:c,respawn:l,spawnPosition:r,distance:this.distanceAlongPath(r),baseSpeed:21.5+e%4*1.25+Math.floor(e/4)*.7,mass:s,disabledUntil:0,slowedUntil:0,slowMultiplier:1,preferredLane:u,laneOffset:u,targetLaneOffset:u,aggression:.55+e%5*.11,rhythm:e*1.73}}findBlockingRacer(e,t,n){let r,i=n=>{let i=n.subtract(e.root.absolutePosition),a=j.Dot(i,t.forward),o=j.Dot(i,t.right);a<=.5||a>11||Math.abs(o)>2.35||(!r||a{t!==e&&i(t.root.absolutePosition)}),n&&i(n),r}distanceAlongPath(e){let t=0,n=1/0,r=0;for(let i=0;i0?E7(j.Dot(c,o)/s,0,1):0,u=a.add(o.scale(l)),d=j.DistanceSquared(e,u);dthis.segmentLengths[n];)t-=this.segmentLengths[n],n+=1;let r=this.path[n],i=this.path[(n+1)%this.path.length],a=this.segmentLengths[n],o=a>0?t/a:0,s=j.Lerp(r,i,o),c=i.subtract(r).normalize();return{position:s,heading:Math.atan2(c.x,c.z),forward:c,right:new j(c.z,0,-c.x)}}};function G2e(e,t){let n=j.Zero();return e.rotateByQuaternionToRef(t,n),n}function E7(e,t,n){return Math.max(t,Math.min(n,e))}function K2e(e,t,n){return Math.abs(t-e)<=n?t:e+Math.sign(t-e)*n}function q2e(e){return Math.atan2(Math.sin(e),Math.cos(e))}var J2e=class{constructor(e,t,n){this.pickups=[],this.elapsed=0,this.onCollect=n;let r=new lg(`pickup-shell`,e);r.diffuseColor=P.FromHexString(`#e3b51e`),r.emissiveColor=P.FromHexString(`#8d4f06`),r.specularColor=P.FromHexString(`#fff3a8`);let i=new lg(`pickup-core`,e);i.diffuseColor=P.FromHexString(`#de352a`),i.emissiveColor=P.FromHexString(`#7d100e`),t.forEach((t,n)=>{let a=vm.CreatePolyhedron(`powerup-${n}`,{type:1,size:.82},e);a.position.copyFrom(t),a.material=n%2==0?r:i,a.isPickable=!1;let o=vm.CreateTorus(`powerup-ring-${n}`,{diameter:1.75,thickness:.09,tessellation:24},e);o.position.copyFrom(t),o.rotation.x=Math.PI/2,o.material=r,o.isPickable=!1,this.pickups.push({mesh:a,ring:o,home:t.clone(),active:!0,respawnAt:0,phase:n*.71})}),this.burst=new RZ(`powerup-burst`,72,e),this.burst.particleTexture=new W(`assets/kenney/particle-pack/sprites/star_06.png`,e),this.burst.color1=fe.FromHexString(`#ffdf42ff`),this.burst.color2=fe.FromHexString(`#ef382bff`),this.burst.colorDead=fe.FromHexString(`#1a56b000`),this.burst.minSize=.12,this.burst.maxSize=.38,this.burst.minLifeTime=.18,this.burst.maxLifeTime=.55,this.burst.emitRate=0,this.burst.manualEmitCount=0,this.burst.minEmitPower=2.5,this.burst.maxEmitPower=5.5,this.burst.gravity=new j(0,-5,0),this.burst.direction1=new j(-1,.8,-1),this.burst.direction2=new j(1,2.8,1),this.burst.disposeOnStop=!1,this.burst.start()}update(e,t,n){this.elapsed+=e;let r=performance.now();for(let i of this.pickups){if(!i.active){r>=i.respawnAt&&(i.active=!0,i.mesh.setEnabled(!0),i.ring.setEnabled(!0));continue}let a=Math.sin(this.elapsed*2.7+i.phase)*.16;i.mesh.position.y=i.home.y+a,i.ring.position.y=i.home.y+a,i.mesh.rotation.y+=e*1.8,i.mesh.rotation.x+=e*.55,i.ring.rotation.z-=e*1.25,!(!n||j.DistanceSquared(t,i.mesh.position)>2.7)&&(this.onCollect&&!this.onCollect()||(i.active=!1,i.respawnAt=r+7500,i.mesh.setEnabled(!1),i.ring.setEnabled(!1),this.burst.emitter=i.mesh.position.clone(),this.burst.manualEmitCount=54))}}reset(){this.pickups.forEach(e=>{e.active=!0,e.respawnAt=0,e.mesh.setEnabled(!0),e.ring.setEnabled(!0)})}dispose(){this.burst.dispose(),this.pickups.forEach(e=>{e.mesh.dispose(),e.ring.dispose()}),this.pickups.length=0}},Y2e={"sports-car":`#d9252a`,"orange-off-road":`#ef7f25`,"pickup-truck":`#c8a56a`,"modified-sports-car":`#7d62c7`,"voltage-bandit":`#e7af32`,"kestrel-gt":`#4a90c7`,"pocket-rocket":`#e5532f`,"iron-howl":`#718c63`,"circuit-wasp":`#d9ded8`},D7=m7.map(e=>({id:e.id,name:e.name,subtitle:e.tagline,assetRootUrl:e.model.assetRootUrl,assetFile:e.model.fileName,modelRotation:e.model.rotation,wheelCenters:e.model.wheelCenters,accent:Y2e[e.id],className:e.class,drivetrain:e.drivetrain,engine:e.engine,stats:{speed:e.displayStats.speed,acceleration:e.displayStats.acceleration,handling:e.displayStats.handling,weight:e.displayStats.weight}})),X2e=[[`frontLeft`,`wheel-front-left`],[`frontRight`,`wheel-front-right`],[`rearLeft`,`wheel-back-left`],[`rearRight`,`wheel-back-right`]],O7=new j(620,34,620),k7=new j(0,.72,0),A7=new j(17,.58,0),j7={attract:{alpha:Math.PI*1.16,beta:Math.PI*.34,radius:14.8,target:O7.add(new j(-.4,1.6,0))},garage:{alpha:Math.PI*1.25,beta:Math.PI*.38,radius:11.6,target:O7.add(new j(0,1.55,0))},"track-preview":{alpha:Math.PI*1.17,beta:Math.PI*.3,radius:16.8,target:O7.add(A7).add(new j(0,.85,0))}};function Z2e(e){return P.FromHexString(e)}function M7(e,t,n,r=.8){let i=new lg(t,e);return i.diffuseColor=Z2e(n),i.specularColor=new P(1-r,1-r,1-r),i}function N7(e,t,n,r,i,a){let o=vm.CreateBox(n,r,e);return o.parent=t,o.position.copyFrom(i),o.material=a,o.isPickable=!1,o}function Q2e(e,t,n,r){let i=new wc(`${r}-placeholder`,e);i.parent=t;let a=M7(e,`${r}-placeholder-paint`,n,.36),o=M7(e,`${r}-placeholder-trim`,`#191b1d`,.58),s=M7(e,`${r}-placeholder-glass`,`#35474c`,.22);N7(e,i,`${r}-placeholder-body`,{width:2.1,height:.55,depth:4.2},new j(0,.65,0),a),N7(e,i,`${r}-placeholder-cabin`,{width:1.72,height:.68,depth:1.82},new j(0,1.19,-.22),s),N7(e,i,`${r}-placeholder-bumper`,{width:2.22,height:.18,depth:.2},new j(0,.45,-2.06),o);for(let t of[-1.05,1.05])for(let n of[-1.35,1.35]){let a=vm.CreateCylinder(`${r}-placeholder-wheel`,{diameter:.8,height:.34,tessellation:18},e);a.parent=i,a.position.set(t,.43,n),a.rotation.z=Math.PI*.5,a.material=o,a.isPickable=!1}return i}var $2e=class{constructor(e,t={}){this.cars=D7,this.loadedCars=[],this.previousCamera=null,this.observer=null,this.mode=`hidden`,this.selectedIndex=0,this.desiredPose=j7.attract,this.elapsed=0,this.disposed=!1,this.initializePromise=null,this.scene=e,this.options=t,this.assetRootUrl=t.assetRootUrl,this.quality=t.quality??this.detectQuality(),this.selectedIndex=Math.max(0,D7.findIndex(e=>e.id===t.initialCarId)),this.root=new wc(`yardline-frontend-root`,e),this.root.position.copyFrom(O7),this.garage=new wc(`yardline-garage`,e),this.garage.parent=this.root,this.diorama=new wc(`yardline-track-diorama`,e),this.diorama.parent=this.root,this.diorama.position.copyFrom(A7),this.carPivot=new wc(`yardline-selected-car-pivot`,e),this.carPivot.parent=this.root,this.carPivot.position.copyFrom(k7),this.camera=new gh(`yardline-frontend-camera`,j7.attract.alpha,j7.attract.beta,j7.attract.radius,j7.attract.target,e),this.camera.minZ=.05,this.camera.maxZ=180,this.camera.fov=.7,this.camera.lowerRadiusLimit=6.8,this.camera.upperRadiusLimit=24,this.camera.lowerBetaLimit=.35,this.camera.upperBetaLimit=1.34,this.camera.inputs.clear(),this.buildGarage(),this.buildDiorama(),this.createLights(),this.createCarSlots(),this.root.setEnabled(!1),t.autoUpdate!==!1&&(this.observer=e.onBeforeRenderObservable.add(()=>this.update()))}initialize(){return this.initializePromise||=this.loadCars(),this.initializePromise}getMode(){return this.mode}getQuality(){return this.quality}getSelectedCar(){return D7[this.selectedIndex]}getSelectedIndex(){return this.selectedIndex}setMode(e,t=!1){if(this.disposed||e===this.mode)return;if(e===`hidden`){this.mode=e,this.root.setEnabled(!1),this.scene.activeCamera===this.camera&&this.previousCamera&&(this.scene.activeCamera=this.previousCamera);return}this.mode===`hidden`&&(this.previousCamera=this.scene.activeCamera),this.mode=e,this.root.setEnabled(!0),this.scene.activeCamera=this.camera;let n=e===`track`?`track-preview`:e;this.desiredPose=j7[n],this.garage.setEnabled(n!==`track-preview`),this.diorama.setEnabled(n===`track-preview`),n===`track-preview`?(this.carPivot.position.copyFrom(A7.add(new j(-3.2,.58,1.1))),this.carPivot.scaling.setAll(.42),this.carPivot.rotation.y=Math.PI*.44):(this.carPivot.position.copyFrom(k7),this.carPivot.scaling.setAll(1)),this.applyCarLayout(n),t&&this.applyPose(this.desiredPose)}setVisible(e){e?this.setMode(this.mode===`hidden`?`attract`:this.mode):this.setMode(`hidden`)}selectCar(e){let t=typeof e==`number`?(e%D7.length+D7.length)%D7.length:D7.findIndex(t=>t.id===e);if(t<0||t===this.selectedIndex)return this.getSelectedCar();this.selectedIndex=t;let n=this.mode===`track`?`track-preview`:this.mode===`hidden`?`attract`:this.mode;this.applyCarLayout(n);let r=this.getSelectedCar();return this.options.onSelectionChange?.(r,t),r}stepCar(e){return this.selectCar(this.selectedIndex+e)}setQuality(e){this.quality=e;let t=e!==`low`;for(let e of this.diorama.getChildMeshes())e.metadata?.frontendDetail===`secondary`&&e.setEnabled(t)}dispose(){this.disposed||(this.disposed=!0,this.observer&&this.scene.onBeforeRenderObservable.remove(this.observer),this.observer=null,this.scene.activeCamera===this.camera&&this.previousCamera&&(this.scene.activeCamera=this.previousCamera),this.camera.dispose(),this.root.dispose(!1,!0),this.loadedCars.length=0)}detectQuality(){let e=typeof matchMedia<`u`&&matchMedia(`(pointer: coarse)`).matches,t=typeof navigator<`u`?navigator.hardwareConcurrency??4:4;return e||t<=4?`low`:t>=10?`high`:`balanced`}createCarSlots(){for(let e=0;e{if(!this.disposed){try{let t=this.assetRootUrl??n.definition.assetRootUrl,r=await xD.ImportMeshAsync(``,t,n.definition.assetFile,this.scene);if(this.disposed){r.meshes.forEach(e=>e.dispose(!1,!0));return}let i=[...r.meshes,...r.transformNodes],a=new Set(i);for(let e of i)(!e.parent||!a.has(e.parent))&&(e.parent=n.modelRoot);n.importedNodes=i,this.normalizeImportedCar(n,r.meshes),n.placeholder.dispose(!1,!0),n.loaded=!0,e+=1}catch(e){n.failed=!0,t+=1,console.warn(`[Yardline frontend] Failed to load ${n.definition.assetFile}; using fallback.`,e)}this.emitLoading(e,t,e+t===D7.length)}});await Promise.allSettled(n);let r=this.mode===`track`?`track-preview`:this.mode===`hidden`?`attract`:this.mode;this.applyCarLayout(r)}normalizeImportedCar(e,t){let n=t.filter(e=>e.getTotalVertices()>0);if(n.length===0)return;for(let[t,r]of X2e){let i=n.find(e=>e.name.toLowerCase()===r),a=e.definition.wheelCenters?.[t];i&&a&&i.position.set(...a)}e.modelRoot.rotation.set(...e.definition.modelRotation),e.modelRoot.computeWorldMatrix(!0);let r=new j(1/0,1/0,1/0),i=new j(-1/0,-1/0,-1/0);for(let e of n){e.computeWorldMatrix(!0);let t=e.getBoundingInfo().boundingBox;r=j.Minimize(r,t.minimumWorld),i=j.Maximize(i,t.maximumWorld),e.isPickable=!1}let a=i.subtract(r),o=4.55/Math.max(a.x,a.z,.01),s=r.add(i).scale(.5),c=e.root.getAbsolutePosition(),l=s.subtract(c),u=r.y-c.y;e.modelRoot.scaling.setAll(o),e.modelRoot.position.set(-l.x*o,-u*o,-l.z*o)}emitLoading(e,t,n){this.options.onLoadingState?.({loaded:e,failed:t,total:D7.length,complete:n})}update(e){if(this.mode===`hidden`||this.disposed)return;let t=Math.min(e??this.scene.getEngine().getDeltaTime()/1e3,.05);this.elapsed+=t;let n=1-Math.exp(-t*6.5);this.camera.alpha+=(this.desiredPose.alpha-this.camera.alpha)*n,this.camera.beta+=(this.desiredPose.beta-this.camera.beta)*n,this.camera.radius+=(this.desiredPose.radius-this.camera.radius)*n;let r=this.camera.getTarget();this.camera.setTarget(j.Lerp(r,this.desiredPose.target,n));let i=this.loadedCars[this.selectedIndex]?.root;this.mode===`attract`?(this.camera.alpha+=t*.055,i&&(i.rotation.y+=t*.19)):this.mode===`garage`?(i&&(i.rotation.y+=t*.34),this.carPivot.position.y=k7.y+Math.sin(this.elapsed*1.15)*.018):this.camera.alpha+=Math.sin(this.elapsed*.23)*t*.012}applyPose(e){this.camera.alpha=e.alpha,this.camera.beta=e.beta,this.camera.radius=e.radius,this.camera.setTarget(e.target)}applyCarLayout(e){let t=this.loadedCars.length;if(t!==0)for(let n=0;nMath.floor(t/2)?i-t:i;if(r.root.rotation.set(0,0,0),e!==`garage`){let e=n===this.selectedIndex;r.root.setEnabled(e),r.root.position.set(0,0,0),r.root.scaling.setAll(1);continue}r.root.setEnabled(!0),a===0?(r.root.position.set(0,0,0),r.root.scaling.setAll(1)):Math.abs(a)===1?(r.root.position.set(a*5.25,.92,1.5),r.root.scaling.setAll(.43),r.root.rotation.y=a*-.38):(r.root.position.set(a*3.9,3.32,4.65),r.root.scaling.setAll(.29),r.root.rotation.y=a*-.2)}}buildGarage(){let e=M7(this.scene,`frontend-floor-dark`,`#6c4b2d`,.62),t=M7(this.scene,`frontend-floor-light`,`#8f6841`,.58),n=M7(this.scene,`frontend-wall`,`#111c2b`,.9),r=M7(this.scene,`frontend-beam`,`#090e16`,.62),i=M7(this.scene,`frontend-yardline-orange`,`#d86131`,.55),a=M7(this.scene,`frontend-shelf-brass`,`#9b7136`,.38),o=[M7(this.scene,`frontend-box-red`,`#b64d38`,.82),M7(this.scene,`frontend-box-cream`,`#c5ad7b`,.86),M7(this.scene,`frontend-box-blue`,`#3f6072`,.84),M7(this.scene,`frontend-box-yellow`,`#c5912e`,.82)],s=new ZE(`frontend-turntable-metal`,this.scene);s.albedoColor=Z2e(`#60686a`),s.metallic=.64,s.roughness=.34,N7(this.scene,this.garage,`frontend-garage-floor`,{width:25,height:.3,depth:18},new j(0,-.22,0),e);for(let n=0;n<22;n+=1)N7(this.scene,this.garage,`frontend-floor-plank-${n}`,{width:1.08,height:.025,depth:17.4},new j(-11.35+n*1.08,-.055,0),n%2?e:t);N7(this.scene,this.garage,`frontend-garage-back-wall`,{width:25,height:9,depth:.35},new j(0,4.25,5.8),n),N7(this.scene,this.garage,`frontend-garage-left-wall`,{width:.35,height:9,depth:18},new j(-12.3,4.25,0),n),N7(this.scene,this.garage,`frontend-garage-beam-top`,{width:25,height:.45,depth:.55},new j(0,7.8,5.35),r);for(let e of[-11,-7.2,-3.6,0,3.6,7.2,11])N7(this.scene,this.garage,`frontend-garage-beam`,{width:.24,height:8.2,depth:.44},new j(e,3.75,5.3),r);for(let e of[2.35,4.55,6.75])N7(this.scene,this.garage,`frontend-toy-shelf`,{width:23.5,height:.18,depth:1.45},new j(0,e,4.75),a);for(let e=0;e<2;e+=1)for(let t=0;t<11;t+=1){if(e===0&&t>3&&t<7)continue;let n=t%3==0?1.42:1.62,r=e===0?1.32:1.45;N7(this.scene,this.garage,`frontend-product-box-${e}-${t}`,{width:n,height:r,depth:1.05},new j(-10.2+t*2.02,3.12+e*2.2,4.58),o[(e+t)%o.length])}let c=vm.CreateCylinder(`frontend-turntable`,{diameter:6.5,height:.5,tessellation:64},this.scene);c.parent=this.garage,c.position.y=.12,c.material=s,c.isPickable=!1;let l=vm.CreateTorus(`frontend-turntable-ring`,{diameter:6.58,thickness:.12,tessellation:64},this.scene);l.parent=this.garage,l.position.y=.42,l.material=i,l.isPickable=!1;let u=vm.CreatePlane(`frontend-yardline-sign`,{width:7.8,height:1.75},this.scene);u.parent=this.garage,u.position.set(0,7.15,5.58),u.rotation.y=Math.PI,u.material=this.createSignMaterial(),u.isPickable=!1}createSignMaterial(){let e=new pg(`frontend-yardline-sign-texture`,{width:1024,height:256},this.scene,!1);e.hasAlpha=!1;let t=e.getContext();t.fillStyle=`#171b1c`,t.fillRect(0,0,1024,256),t.fillStyle=`#d86131`,t.fillRect(0,0,28,256),t.font=`800 104px Arial`,t.fillStyle=`#f0efe8`,t.fillText(`YARDLINE RC`,72,139),t.font=`600 27px Arial`,t.fillStyle=`#8d9797`,t.fillText(`WORKSHOP / CLUB RACING DIVISION`,78,194),e.update();let n=new lg(`frontend-yardline-sign-material`,this.scene);return n.diffuseTexture=e,n.emissiveColor=new P(.24,.24,.22),n.specularColor=P.Black(),n}buildDiorama(){let e=M7(this.scene,`frontend-diorama-lawn`,`#668352`,.96),t=M7(this.scene,`frontend-diorama-asphalt`,`#3f4547`,.94),n=M7(this.scene,`frontend-diorama-curb-light`,`#d9d9cf`,.84),r=M7(this.scene,`frontend-diorama-curb-accent`,`#c95632`,.7),i=[M7(this.scene,`frontend-house-cream`,`#c7b990`,.9),M7(this.scene,`frontend-house-clay`,`#a65f48`,.88),M7(this.scene,`frontend-house-blue`,`#64808a`,.9)];N7(this.scene,this.diorama,`frontend-diorama-base`,{width:22,height:.55,depth:16},new j(0,-.42,0),e);let a=[new j(-6.6,0,2.6),new j(-4.2,0,-4.6),new j(2.7,0,-5),new j(6.8,0,-1.8),new j(5.2,0,4.3),new j(-1.6,0,5.2)];for(let e=0;e0&&(e.node.position.copyFrom(e.basePosition),t.grounded&&e.suspensionReference===void 0&&(e.suspensionReference=t.suspensionLength),e.suspensionReference!==void 0&&e.node.position.addInPlace(e.suspensionAxis.scale((e.suspensionReference-t.suspensionLength)*e.suspensionScale)));let r=A.RotationAxis(e.steerAxis,t.steerAngle),i=A.RotationAxis(e.spinAxis,t.rotationAngle*e.spinDirection);r.multiply(i).multiplyToRef(e.baseRotation,e.node.rotationQuaternion)}}},r4e=class{constructor(e,t,n={}){this._input=e4e(),this._smoothedThrottle=0,this._smoothedSteer=0,this._smoothedBrake=0,this._resetWasPressed=!1,this._respawnRequested=!1,this._engineMultiplier=1,this._gripMultiplier=1,this._state={speed:0,speedKph:0,forwardSpeed:0,lateralSpeed:0,groundedWheelCount:0,airborne:!0,upDot:1},this._body=t;let r=e.getPhysicsEngine();if(!r||r.getPluginVersion()!==2)throw Error(`ArcadeVehicleController requires an enabled Babylon Physics V2 engine.`);if(this._physicsEngine=r,this.config=n2e(n.config),this.config.wheels.length===0)throw Error(`ArcadeVehicleController requires at least one wheel.`);let i=new Set;for(let e of this.config.wheels){if(i.has(e.id))throw Error(`Duplicate wheel id: ${e.id}`);i.add(e.id)}this._inputSource=n.inputSource,this._mass=Math.max(.001,t.getMassProperties().mass??1);let a=t.getMassProperties();t.setMassProperties({...a,mass:this._mass,centerOfMass:this.config.centerOfMassOffset.clone()}),this._wheelbase=a4e(this.config.wheels),this._antiRollPairs=o4e(this.config.wheels),this._driveFactorTotal=F7(this.config.wheels,`driveFactor`),this._brakeFactorTotal=F7(this.config.wheels,`brakeFactor`),this._handbrakeFactorTotal=F7(this.config.wheels,`handbrakeFactor`),this._wheelStates=this.config.wheels.map(i4e),this._wheelVisualController=n.wheelVisuals?new n4e(this.config.wheels,n.wheelVisuals):void 0,t.setLinearDamping(this.config.linearDamping),t.setAngularDamping(this.config.angularDamping);let o=n.spawnPose??z2e(t);this.respawnController=new R2e(e,t,o,n.respawn)}update(e,t){let n=Math.max(1/240,Math.min(e,.05));t?t4e(t,this._input):this._inputSource?(this._inputSource.readInput(this._input),t4e(this._input,this._input)):Object.assign(this._input,e4e()),this._smoothedThrottle=L7(this._smoothedThrottle,this._input.throttle,this.config.throttleResponse*n),this._smoothedSteer=L7(this._smoothedSteer,this._input.steer,this.config.steerResponse*n),this._smoothedBrake=L7(this._smoothedBrake,this._input.brake,this.config.brakeResponse*n);let r=this._input.reset&&!this._resetWasPressed;this._resetWasPressed=this._input.reset,this._simulateWheels(n);let i=r||this._respawnRequested;this._respawnRequested=!1,this.respawnController.update(n,this._state.upDot,i)&&this._clearControlSmoothing(),this._wheelVisualController?.update(this._wheelStates)}requestRespawn(){this._respawnRequested=!0}setDriveMultipliers(e=1,t=1){this._engineMultiplier=R7(e,.1,2.5),this._gripMultiplier=R7(t,.05,2)}respawn(e){this.respawnController.respawn(e),this._clearControlSmoothing()}setCheckpoint(e){this.respawnController.setCheckpoint(e)}get state(){return this._state}get speed(){return this._state.speed}get speedKph(){return this._state.speedKph}get airborne(){return this._state.airborne}get wheelStates(){return this._wheelStates}_simulateWheels(e){let t=this._body.transformNode;t.computeWorldMatrix(!0);let n=t.absolutePosition,r=t.absoluteRotationQuaternion??t.rotationQuaternion??A.Identity(),i=I7(j.Up(),r).normalize(),a=I7(j.Forward(),r).normalize(),o=I7(j.Right(),r).normalize(),s=i.scale(-1),c=this._body.getLinearVelocity(),l=this._body.getAngularVelocity(),u=this._body.getObjectCenterWorld(),d=c.length(),f=j.Dot(c,a),p=j.Dot(c,o),m=R7(Math.abs(f)/this.config.maxForwardSpeed,0,1),h=d4e(1,this.config.highSpeedSteerMultiplier,m*m),g=this._smoothedSteer*this.config.maxSteerAngle*h,_=0,v=j.Zero();for(let t=0;t.001?this.config.frontGripMultiplier:this.config.rearGripMultiplier,D=this._input.handbrake&&o.handbrakeFactor>0?this.config.handbrakeGripMultiplier:1,te=-d.lateralSpeed*this._mass*this.config.lateralGrip*ee*D*this._gripMultiplier/this.config.wheels.length,O=w.scale(E).addInPlace(T.scale(te)),ne=C*this.config.gripCoefficient*ee*this._gripMultiplier;O.lengthSquared()>ne*ne&&O.normalize().scaleInPlace(ne);let re=s4e(d.contactPoint,u,i,this.config.tireForceApplicationHeight);this._body.applyForce(O,re)}_>0?(v.scaleInPlace(1/_).normalize(),this._applyAntiRoll(i),this._applyGroundStability(i,v,l),this._applyGroundYawControl(v,l,f,g)):this._applyAirControl(a,o,i),this._applyDownforce(i,d,u),this._state={speed:d,speedKph:d*3.6,forwardSpeed:f,lateralSpeed:p,groundedWheelCount:_,airborne:_===0,upDot:j.Dot(i,j.Up())}}_longitudinalForce(e,t,n,r){let i=this._smoothedThrottle,a=this._smoothedBrake;Math.abs(n)>this.config.directionChangeBrakeSpeed&&Math.sign(i)!==Math.sign(n)&&(a=Math.max(a,Math.abs(i)),i=0);let o=0;if(e.driveFactor>0&&this._driveFactorTotal>0&&i!==0){let t=i>0?this.config.maxForwardSpeed:this.config.maxReverseSpeed,r=i>0?1:this.config.reverseAccelerationMultiplier,a=R7(1-Math.max(0,n*Math.sign(i))/t,0,1)**.72;o+=this._mass*this.config.engineAcceleration*this._engineMultiplier*r*i*a*(e.driveFactor/this._driveFactorTotal)}let s=e.brakeFactor>0&&this._brakeFactorTotal>0?e.brakeFactor/this._brakeFactorTotal:0,c=e.handbrakeFactor>0&&this._handbrakeFactorTotal>0?e.handbrakeFactor/this._handbrakeFactorTotal:0,l=this._mass*(this.config.brakeDeceleration*a*s+(this._input.handbrake?this.config.handbrakeDeceleration*c:0));if(l>0&&Math.abs(t)>.01){let e=this._mass*Math.abs(t)/r/this.config.wheels.length;o-=Math.sign(t)*Math.min(l,e)}return o-=t*this._mass*this.config.rollingResistance/this.config.wheels.length,o}_applyGroundStability(e,t,n){let r=j.Cross(e,t),i=1+R7((.94-R7(j.Dot(e,t),-1,1))/.7,0,1)*this.config.antiFlipMultiplier,a=n.subtract(t.scale(j.Dot(n,t))),o=r.scale(this._mass*this.config.groundUprightStrength*i).subtractInPlace(a.scale(this._mass*this.config.groundUprightDamping*Math.sqrt(i)));this._body.applyTorque(o)}_applyAntiRoll(e){let t=this._mass*22;for(let[n,r]of this._antiRollPairs){let i=this._wheelStates[n],a=this._wheelStates[r];if(!i.grounded||!a.grounded)continue;let o=R7((i.compression-a.compression)*this.config.antiRollStrength*this._mass,-t,t);this._body.applyForce(e.scale(o),i.contactPoint),this._body.applyForce(e.scale(-o),a.contactPoint)}}_applyGroundYawControl(e,t,n,r){let i=R7(Math.abs(n)/2.4,0,1);if(i<=0)return;let a=R7(n/this._wheelbase*Math.tan(r),-this.config.maxYawRate,this.config.maxYawRate),o=j.Dot(t,e),s=this._input.handbrake?this.config.handbrakeYawResponseMultiplier:1,c=(a-o)*this.config.yawResponse*i*s;this._body.applyTorque(e.scale(this._mass*c))}_applyAirControl(e,t,n){let r=n.scale(this._smoothedSteer*this._mass*this.config.airYawControl),i=t.scale(-this._smoothedThrottle*this._mass*this.config.airPitchControl),a=e.scale(-this._smoothedSteer*this._mass*this.config.airPitchControl*.35);this._body.applyTorque(r.addInPlace(i).addInPlace(a))}_applyDownforce(e,t,n){let r=Math.min(this.config.maxDownforceAcceleration,t*t*this.config.downforceCoefficient);r>0&&this._body.applyForce(e.scale(-this._mass*r),n)}_clearControlSmoothing(){this._smoothedThrottle=0,this._smoothedSteer=0,this._smoothedBrake=0}};function i4e(e){return{id:e.id,grounded:!1,suspensionLength:e.restLength+e.travel,compression:0,steerAngle:0,rotationAngle:0,contactPoint:j.Zero(),contactNormal:j.Up(),longitudinalSpeed:0,lateralSpeed:0}}function F7(e,t){return e.reduce((e,n)=>e+Math.max(0,n[t]),0)}function a4e(e){let t=-1/0,n=1/0;for(let r of e)t=Math.max(t,r.originLocal.z),n=Math.min(n,r.originLocal.z);return Math.max(.5,t-n)}function o4e(e){let t=[],n=e.map((e,t)=>({wheel:e,index:t})).filter(({wheel:e})=>e.originLocal.x>0);return e.forEach((e,r)=>{if(e.originLocal.x>=0)return;let i;for(let t of n){let n=Math.abs(t.wheel.originLocal.z-e.originLocal.z);(!i||n[]),this.callbacks=n.callbacks??{},this.random=n.random??Math.random,this.maxProjectiles=n.maxProjectiles??6,this.maxHazards=n.maxHazards??10,this.materials={rocketBody:z7(e,`rocket-body`,`#d92d20`,`#6f0805`),rocketNose:z7(e,`rocket-nose`,`#f1eee0`,`#4a4538`),rocketFin:z7(e,`rocket-fin`,`#242c35`,`#111820`),rocketGlow:z7(e,`rocket-glow`,`#ffae27`,`#ff6a0a`,.9,!0),oil:z7(e,`oil-puddle`,`#090c12`,`#060912`,.9),oilSheen:z7(e,`oil-sheen`,`#26374c`,`#264f65`,.42,!0),mine:z7(e,`mine-shell`,`#d9aa17`,`#704507`),mineDark:z7(e,`mine-dark`,`#242a31`,`#10151b`),warning:z7(e,`mine-warning`,`#ff3528`,`#ff1208`,.98,!0),emp:z7(e,`emp-energy`,`#54eaff`,`#188cff`,.62,!0),turbo:z7(e,`turbo-flame`,`#fff1a0`,`#ff7919`,.92,!0),smoke:z7(e,`effect-smoke`,`#4d5966`,`#131820`,.5)},this.materials.oil.backFaceCulling=!1,this.materials.oilSheen.backFaceCulling=!1}get state(){return{item:this.item,charges:this.charges,activeTurboSeconds:this.turboSeconds,rolling:this.rouletteSeconds>0||this.pendingItem!==null}}collect(e,t=1){return this.disposed||this.item||this.pendingItem||this.collectionCooldownSeconds>0?!1:(this.pendingItem=e??f4e[Math.floor(this.random()*f4e.length)],this.pendingCharges=Math.max(1,Math.min(3,Math.floor(t))),this.rouletteSeconds=1.15,this.notifyInventory(),!0)}clearInventory(){this.item=null,this.charges=0,this.pendingItem=null,this.pendingCharges=0,this.rouletteSeconds=0,this.collectionCooldownSeconds=0,this.notifyInventory()}use(){if(!this.item||this.charges<=0||this.disposed)return!1;let e=this.item,t=this.playerBody.transformNode.absolutePosition.clone(),n=_4e(this.playerBody),r=t;switch(e){case`turbo-battery`:this.turboSeconds=Math.max(this.turboSeconds,2.65),this.callbacks.onTurboChanged?.(!0,1.42),this.startTurboVisual(t);break;case`pulse-rocket`:this.spawnRocket(t.add(n.scale(1.8)).addInPlaceFromFloats(0,.3,0),n);break;case`oil-slick`:r=this.spawnHazard(`oil-slick`,t.subtract(n.scale(2.2)));break;case`proximity-mine`:r=this.spawnHazard(`proximity-mine`,t.subtract(n.scale(2)));break;case`arc-emp`:this.fireEmp(t);break}return this.emit({type:e,sourceId:this.playerId,position:r.clone()}),--this.charges,this.charges<=0&&(this.item=null,this.collectionCooldownSeconds=Math.max(this.collectionCooldownSeconds,.7)),this.notifyInventory(),!0}update(e){if(this.disposed)return;let t=Math.max(0,Math.min(e,.05));this.collectionCooldownSeconds=Math.max(0,this.collectionCooldownSeconds-t),this.rouletteSeconds>0&&(this.rouletteSeconds=Math.max(0,this.rouletteSeconds-t),this.rouletteSeconds===0&&this.pendingItem&&(this.item=this.pendingItem,this.charges=this.pendingCharges,this.pendingItem=null,this.pendingCharges=0,this.notifyInventory())),this.turboSeconds>0&&(this.turboSeconds=Math.max(0,this.turboSeconds-t),this.updateTurboVisual(),this.turboSeconds===0&&(this.callbacks.onTurboChanged?.(!1,1),this.stopTurboVisual())),this.updateProjectiles(t),this.updateHazards(t),this.updateEffects(t)}reset(){this.clearInventory(),this.turboSeconds>0&&this.callbacks.onTurboChanged?.(!1,1),this.turboSeconds=0,this.stopTurboVisual();for(let e of this.projectiles)this.disposeProjectile(e);for(let e of this.hazards)e.root.dispose(!1,!0);for(let e of this.effects)this.disposeEffect(e);this.projectiles.length=0,this.hazards.length=0,this.effects.length=0}dispose(){this.disposed||=(this.reset(),Object.values(this.materials).forEach(e=>e.dispose()),!0)}spawnRocket(e,t){if(this.projectiles.length>=this.maxProjectiles){let e=this.projectiles.shift();e&&this.disposeProjectile(e)}let n=new wc(`pulse-rocket`,this.scene);n.position.copyFrom(e),n.rotationQuaternion=A.FromLookDirectionLH(t,j.Up());let r=vm.CreateCylinder(`rocket-fuselage`,{height:.86,diameter:.25,tessellation:16},this.scene);r.parent=n,r.rotation.x=Math.PI/2,r.material=this.materials.rocketBody;let i=vm.CreateCylinder(`rocket-nose`,{height:.34,diameterTop:0,diameterBottom:.25,tessellation:16},this.scene);i.parent=n,i.position.z=.6,i.rotation.x=Math.PI/2,i.material=this.materials.rocketNose;let a=vm.CreateTorus(`rocket-band`,{diameter:.27,thickness:.035,tessellation:16},this.scene);a.parent=n,a.position.z=.25,a.rotation.x=Math.PI/2,a.material=this.materials.rocketNose;for(let[e,t]of[[.2,0],[-.2,0],[0,.2],[0,-.2]]){let r=vm.CreateBox(`rocket-fin`,{width:.08,height:.25,depth:.34},this.scene);r.parent=n,r.position.set(e,t,-.3),e===0&&(r.rotation.z=Math.PI/2),r.material=this.materials.rocketFin}let o=vm.CreateSphere(`rocket-engine-glow`,{diameter:.25,segments:10},this.scene);o.parent=n,o.position.z=-.52,o.scaling.z=1.7,o.material=this.materials.rocketGlow;let s=[this.createTrail(o,`flame_05.png`,fe.FromHexString(`#fff3adff`),fe.FromHexString(`#ff3d08ff`),62,.06,.22),this.createTrail(o,`smoke_07.png`,fe.FromHexString(`#87909a99`),fe.FromHexString(`#252c3500`),24,.13,.36)],c=this.acquireTarget(e,t),l={root:n,engineGlow:o,trails:s,velocity:t.scale(m4e*.72),sourceId:this.playerId,targetId:c?.id,age:0,life:4.4};c&&(l.lockMarker=this.createLockMarker(B7(c))),this.projectiles.push(l),this.spawnDeployBurst(e,fe.FromHexString(`#ff9a28ff`))}spawnHazard(e,t){this.hazards.length>=this.maxHazards&&this.hazards.shift()?.root.dispose(!1,!0);let n=new wc(e,this.scene);n.position.copyFrom(t),n.position.y-=e===`oil-slick`?.48:.36;let r,i;if(e===`oil-slick`){for(let[e,t,r,i]of[[0,0,1.38,1.08],[.72,.2,.88,.68],[-.66,.18,.92,.72],[.28,-.48,.78,.62],[-.36,-.47,.72,.6]]){let a=vm.CreateDisc(`oil-lobe`,{radius:1.05,tessellation:28,sideOrientation:K.DOUBLESIDE},this.scene);a.parent=n,a.position.set(e,0,t),a.rotation.x=Math.PI/2,a.rotation.z=this.random()*Math.PI,a.scaling.set(r,i,1),a.material=this.materials.oil}for(let e=0;e<3;e+=1){let t=vm.CreateTorus(`oil-rainbow-sheen`,{diameter:.48+e*.26,thickness:.025,tessellation:24},this.scene);t.parent=n,t.position.set(-.25+e*.21,.025,.12-e*.15),t.scaling.z=.55,t.material=this.materials.oilSheen}}else{let e=vm.CreateSphere(`mine-core`,{diameter:.7,segments:12},this.scene);e.parent=n,e.material=this.materials.mineDark;for(let e=0;e<8;e+=1){let t=e*Math.PI/4,r=vm.CreateCylinder(`mine-spike`,{height:.45,diameterTop:.03,diameterBottom:.14,tessellation:8},this.scene);r.parent=n,r.position.set(Math.sin(t)*.42,.02,Math.cos(t)*.42),r.rotation.z=Math.PI/2,r.rotation.y=t,r.material=this.materials.mine}r=vm.CreateSphere(`mine-warning-light`,{diameter:.22,segments:10},this.scene),r.parent=n,r.position.y=.42,r.material=this.materials.warning,i=vm.CreateTorus(`mine-arming-ring`,{diameter:1.25,thickness:.045,tessellation:28},this.scene),i.parent=n,i.position.y=-.25,i.material=this.materials.warning}return n.scaling.setAll(.12),this.hazards.push({root:n,kind:e,sourceId:this.playerId,baseY:n.position.y,life:e===`oil-slick`?11:13,armedIn:e===`oil-slick`?.12:.72,age:0,touched:new Set,signal:r,ring:i}),this.spawnDeployBurst(n.position,e===`oil-slick`?fe.FromHexString(`#27394aaa`):fe.FromHexString(`#ffad20ff`)),n.position.clone()}fireEmp(e){this.spawnEmpWave(e);for(let t of this.activeTargets()){if(t.id===this.playerId||V7(e,t)>8.4**2)continue;let n={type:`arc-emp`,sourceId:this.playerId,targetId:t.id,position:e.clone()};this.callbacks.onTargetDisabled?.(t.id,1.7,n),this.emit(n)}}startTurboVisual(e){if(this.turboVisual)return;let t=this.playerBody.transformNode,n=[],r=[];for(let e of[-.43,.43]){let i=vm.CreateCylinder(`turbo-exhaust`,{height:.82,diameterTop:.08,diameterBottom:.3,tessellation:12},this.scene);i.parent=t,i.position.set(e,.04,-1.08),i.rotation.x=Math.PI/2,i.material=this.materials.turbo,r.push(i),n.push(this.createTrail(i,`flame_06.png`,fe.FromHexString(`#d9fbffff`),fe.FromHexString(`#ff6411ff`),88,.08,.25))}this.turboVisual={particles:n,flames:r},this.spawnShockwave(e)}updateTurboVisual(){if(!this.turboVisual)return;let e=.82+Math.sin(performance.now()*.032)*.18;for(let t=0;te.dispose()),this.turboVisual.flames.forEach(e=>e.dispose()),void 0)}updateProjectiles(e){let t=this.activeTargets();for(let n=this.projectiles.length-1;n>=0;--n){let r=this.projectiles[n];r.life-=e,r.age+=e;let i=r.root.position,a=r.targetId?t.find(e=>e.id===r.targetId):void 0;!a&&r.age<.85&&(a=this.acquireTarget(i,r.velocity.normalize(),t),r.targetId=a?.id,a&&!r.lockMarker&&(r.lockMarker=this.createLockMarker(B7(a))));let o=Math.min(m4e,r.velocity.length()+e*16);if(a){let t=B7(a);if(t){let n=t.subtract(i).normalize(),a=r.velocity.normalize(),s=Math.min(1,e*(r.age<.2?2.2:5.4));j.LerpToRef(a,n,s,r.velocity),r.velocity.normalize().scaleInPlace(o),r.lockMarker?.position.copyFrom(t),r.lockMarker&&(r.lockMarker.rotation.y+=e*3.8,r.lockMarker.scaling.setAll(.9+Math.sin(r.age*15)*.08))}}else r.velocity.normalize().scaleInPlace(o);i.addInPlace(r.velocity.scale(e));let s=r.velocity.normalize();r.root.rotationQuaternion=A.FromLookDirectionLH(s,j.Up()),r.root.rotate(j.Forward(),e*8,0);let c=.85+Math.sin(r.age*38)*.18;r.engineGlow.scaling.set(1,1,1.5+c);let l=v4e(i,t,r.sourceId,1.2);if(l){let e=B7(l)??i;l.body&&l.body.applyImpulse(s.scale(4.2),l.body.getObjectCenterWorld());let t={type:`pulse-rocket`,sourceId:r.sourceId,targetId:l.id,position:e.clone()};this.callbacks.onTargetDisabled?.(l.id,.85,t),this.emit(t),this.spawnExplosion(i,1),r.life=0}r.life<=0&&(l||this.spawnExplosion(i,.55),this.disposeProjectile(r),this.projectiles.splice(n,1))}}updateHazards(e){let t=this.activeTargets();for(let n=this.hazards.length-1;n>=0;--n){let r=this.hazards[n];r.life-=e,r.age+=e,r.armedIn=Math.max(0,r.armedIn-e);let i=Math.min(1,r.age/.28),a=1+Math.sin(i*Math.PI)*.28;if(r.root.scaling.setAll(i*a),r.kind===`oil-slick`)r.root.rotation.y+=e*.07,r.root.position.y=r.baseY+Math.sin(r.age*2.3)*.008,r.life<1&&H7(r.root,Math.max(0,r.life));else{r.root.rotation.y+=e*(r.armedIn>0?2.5:.65),r.root.position.y=r.baseY+Math.sin(r.age*4.2)*.035;let t=r.armedIn>0?.25+Math.sin(r.age*18)*.2:.65+Math.sin(r.age*8)*.35;if(r.signal&&r.signal.scaling.setAll(Math.max(.18,t)),r.ring){let e=r.age*1.8%1;r.ring.scaling.setAll(.65+e*.72),r.ring.visibility=r.armedIn>0?.2:.72*(1-e)}}for(let e of t){if(e.id===r.sourceId&&r.life>10.5)continue;let t=r.kind===`oil-slick`?1.85:1.72;if(!(!(V7(r.root.position,e)<=(t+(e.radius??.55))**2)||r.armedIn>0))if(r.kind===`oil-slick`)r.touched.has(e.id)||(r.touched.add(e.id),this.callbacks.onOilContact?.(e.id,.24,1.55),this.emit({type:`oil-slick`,sourceId:r.sourceId,targetId:e.id,position:r.root.position.clone()}));else{let t=B7(e);if(e.body&&t){let n=y4e(t.subtract(r.root.position),j.Up());e.body.applyImpulse(n.scale(5.3).addInPlaceFromFloats(0,2.4,0),e.body.getObjectCenterWorld())}let n={type:`proximity-mine`,sourceId:r.sourceId,targetId:e.id,position:r.root.position.clone()};this.callbacks.onTargetDisabled?.(e.id,1.05,n),this.emit(n),this.spawnExplosion(r.root.position,1.25),r.life=0;break}}r.life<=0&&(r.root.dispose(!1,!0),this.hazards.splice(n,1))}}updateEffects(e){for(let t=this.effects.length-1;t>=0;--t){let n=this.effects[t];n.life-=e;let r=Math.min(1,1-n.life/n.duration),i=n.root.getChildMeshes(!1);n.kind===`explosion`?(n.root.scaling.setAll((.25+r*3.4)*n.scale),i.forEach((t,n)=>{t.visibility=Math.max(0,1-r)*(n===0?.78:1),t.rotation.y+=e*(n%2==0?3:-2)})):n.kind===`emp`?(n.root.scaling.setAll(.45+r*15.5),i.forEach((t,n)=>{t.visibility=Math.max(0,1-r)*(1-n*.12),t.rotation.z+=e*(n%2==0?2.5:-3.2)})):n.kind===`shockwave`?(n.root.scaling.setAll(.6+r*5.5),H7(n.root,Math.max(0,1-r))):(n.root.scaling.setAll(.7+r*1.2),H7(n.root,Math.max(0,1-r))),n.life<=0&&(this.disposeEffect(n),this.effects.splice(t,1))}}spawnExplosion(e,t){let n=new wc(`utility-explosion`,this.scene);n.position.copyFrom(e),n.scaling.setAll(t);let r=vm.CreateSphere(`explosion-flash`,{diameter:.72,segments:10},this.scene);r.parent=n,r.material=this.materials.rocketGlow;for(let e=0;e<2;e+=1){let t=vm.CreateTorus(`explosion-ring`,{diameter:.9+e*.18,thickness:.075-e*.015,tessellation:28},this.scene);t.parent=n,t.rotation.x=e===0?Math.PI/2:0,t.material=e===0?this.materials.warning:this.materials.rocketGlow}let i=[this.createBurst(e,`flame_05.png`,fe.FromHexString(`#fff0a8ff`),fe.FromHexString(`#ff2a08ff`),46,.12,.46,7*t),this.createBurst(e,`smoke_04.png`,fe.FromHexString(`#6c737ddd`),fe.FromHexString(`#1d242c00`),24,.22,.72,4*t)];this.effects.push({root:n,particles:i,kind:`explosion`,duration:.72,scale:t,life:.72})}spawnEmpWave(e){let t=new wc(`arc-emp-wave`,this.scene);t.position.copyFrom(e);for(let e=0;e<3;e+=1){let n=vm.CreateTorus(`emp-ring`,{diameter:.75+e*.18,thickness:.055,tessellation:40},this.scene);n.parent=t,n.rotation.set(e===0?Math.PI/2:e*1.05,e*.7,0),n.material=this.materials.emp}let n=vm.CreateSphere(`emp-core-flash`,{diameter:.52,segments:12},this.scene);n.parent=t,n.material=this.materials.emp;let r=[this.createBurst(e,`light_02.png`,fe.FromHexString(`#d8ffffff`),fe.FromHexString(`#168dff00`),58,.08,.42,8)];this.effects.push({root:t,particles:r,kind:`emp`,duration:.62,scale:1,life:.62})}spawnShockwave(e){let t=new wc(`turbo-shockwave`,this.scene);t.position.copyFrom(e);let n=vm.CreateTorus(`turbo-shock-ring`,{diameter:.9,thickness:.07,tessellation:36},this.scene);n.parent=t,n.rotation.x=Math.PI/2,n.material=this.materials.turbo,this.effects.push({root:t,particles:[],kind:`shockwave`,duration:.38,scale:1,life:.38})}spawnDeployBurst(e,t){let n=new wc(`utility-deploy-burst`,this.scene);n.position.copyFrom(e);let r=vm.CreateTorus(`deploy-ring`,{diameter:.58,thickness:.045,tessellation:24},this.scene);r.parent=n,r.rotation.x=Math.PI/2,r.material=this.materials.rocketGlow;let i=[this.createBurst(e,`star_06.png`,t,t.scale(.2),18,.06,.3,3.6)];this.effects.push({root:n,particles:i,kind:`deploy`,duration:.34,scale:1,life:.34})}createTrail(e,t,n,r,i,a,o){let s=new RZ(`${e.name}-trail`,220,this.scene);return s.particleTexture=new W(`${p4e}${t}`,this.scene),s.emitter=e,s.color1=n,s.color2=r,s.colorDead=new fe(r.r,r.g,r.b,0),s.minSize=a,s.maxSize=o,s.minLifeTime=.1,s.maxLifeTime=.34,s.emitRate=i,s.minEmitPower=.5,s.maxEmitPower=2.4,s.direction1=new j(-.15,-.15,-2.2),s.direction2=new j(.15,.15,-3.8),s.minAngularSpeed=-4,s.maxAngularSpeed=4,s.blendMode=RZ.BLENDMODE_ADD,s.start(),s}createBurst(e,t,n,r,i,a,o,s){let c=new RZ(`utility-burst-particles`,Math.max(64,i*2),this.scene);return c.particleTexture=new W(`${p4e}${t}`,this.scene),c.emitter=e.clone(),c.color1=n,c.color2=r,c.colorDead=new fe(r.r,r.g,r.b,0),c.minSize=a,c.maxSize=o,c.minLifeTime=.16,c.maxLifeTime=.65,c.emitRate=0,c.minEmitPower=s*.45,c.maxEmitPower=s,c.direction1=new j(-1,-.15,-1),c.direction2=new j(1,1.2,1),c.gravity=new j(0,-2.2,0),c.minAngularSpeed=-5,c.maxAngularSpeed=5,c.blendMode=RZ.BLENDMODE_ADD,c.start(),c.manualEmitCount=i,c}createLockMarker(e){let t=new wc(`rocket-target-lock`,this.scene);t.position.copyFrom(e);for(let e=0;e<2;e+=1){let n=vm.CreateTorus(`target-lock-ring`,{diameter:1.35,thickness:.035,tessellation:32},this.scene);n.parent=t,n.rotation.x=e===0?Math.PI/2:0,n.material=this.materials.warning}return t}acquireTarget(e,t,n=this.activeTargets()){let r,i=1/0;for(let a of n){if(a.id===this.playerId)continue;let n=B7(a);if(!n)continue;let o=n.subtract(e),s=o.length();if(s>h4e||s<.01)continue;let c=j.Dot(o.scale(1/s),t);if(c<-.15)continue;let l=s*(1.35-Math.max(0,c)*.65);le.isActive?.()!==!1&&!!B7(e))}disposeProjectile(e){e.trails.forEach(e=>e.dispose()),e.lockMarker?.dispose(!1,!0),e.root.dispose(!1,!0)}disposeEffect(e){e.particles.forEach(e=>e.dispose()),e.root.dispose(!1,!0)}emit(e){this.callbacks.onAbilityUsed?.(e)}notifyInventory(){this.callbacks.onInventoryChange?.(this.state)}};function z7(e,t,n,r,i=1,a=!1){let o=new lg(t,e);return o.diffuseColor=P.FromHexString(n),o.emissiveColor=P.FromHexString(r),o.specularColor=a?P.Black():P.FromHexString(`#777777`),o.alpha=i,o.disableLighting=a,o}function _4e(e){let t=e.transformNode,n=t.absoluteRotationQuaternion??t.rotationQuaternion??A.Identity(),r=j.Forward().applyRotationQuaternion(n);return r.y=0,y4e(r,j.Forward())}function B7(e){return e.body?.transformNode.absolutePosition??e.getPosition?.()}function v4e(e,t,n,r){let i,a=r*r;for(let r of t){if(r.id===n)continue;let t=V7(e,r);t1e-4?e.normalize():t.clone()}function H7(e,t){e.getChildMeshes(!1).forEach(e=>{e.visibility=t})}var b4e={upsideDownDot:.05,autoRespawnDelay:2.8,stuckSpeed:.35,stuckThrottle:.65,stuckDelay:4.2,cooldown:.85,selfRightLift:.75,respawnLift:.45,manualPenaltyMs:750,autoPenaltyMs:2200},x4e=class{constructor(e,t,n,r={}){this.cooldownRemaining=0,this.invertedSeconds=0,this.stuckSeconds=0,this.manualWasDown=!1,this.teleportGeneration=0,this.scene=e,this.body=t,this.options={...b4e,...r},this.checkpoint=U7(n)}setCheckpoint(e){this.checkpoint=U7(e)}getCheckpoint(){return U7(this.checkpoint)}reset(e){e&&(this.checkpoint=U7(e)),this.cooldownRemaining=0,this.invertedSeconds=0,this.stuckSeconds=0,this.manualWasDown=!1}update(e,t){let n=S4e(e,0,.1);this.cooldownRemaining=Math.max(0,this.cooldownRemaining-n),this.invertedSeconds=t.upDot=this.options.stuckThrottle;this.stuckSeconds=r?this.stuckSeconds+n:0;let i=!!t.manualSelfRight&&!this.manualWasDown;return this.manualWasDown=!!t.manualSelfRight,i&&this.cooldownRemaining<=0?(this.teleport(this.checkpoint,this.options.respawnLift),this.result(`self-right`,this.options.manualPenaltyMs)):(t.outOfBounds||this.invertedSeconds>=this.options.autoRespawnDelay||this.stuckSeconds>=this.options.stuckDelay)&&this.cooldownRemaining<=0?(this.teleport(this.checkpoint,this.options.respawnLift),this.result(`auto-respawn`,this.options.autoPenaltyMs)):this.result(`none`,0)}forceRespawn(e=this.checkpoint){this.teleport(e,this.options.respawnLift)}teleport(e,t){let n=this.body.transformNode,r=this.body.getPrestepType(),i=++this.teleportGeneration;n.position.copyFrom(e.position).addInPlaceFromFloats(0,t,0),n.rotationQuaternion??=A.Identity(),n.rotationQuaternion.copyFrom(e.rotation),n.computeWorldMatrix(!0),this.body.setLinearVelocity(j.Zero()),this.body.setAngularVelocity(j.Zero()),this.body.setPrestepType(XO.TELEPORT),this.scene.onAfterPhysicsObservable.addOnce(()=>{i===this.teleportGeneration&&(this.body.setLinearVelocity(j.Zero()),this.body.setAngularVelocity(j.Zero()),this.body.setPrestepType(r))}),this.invertedSeconds=0,this.stuckSeconds=0,this.cooldownRemaining=this.options.cooldown}result(e,t){return{recovered:e!==`none`,kind:e,penaltyMs:t,cooldownRemaining:this.cooldownRemaining}}};function U7(e){return{position:e.position.clone(),rotation:e.rotation.clone()}}function S4e(e,t,n){return Math.max(t,Math.min(n,e))}var W7={asphalt:{type:`asphalt`,gripMultiplier:1,accelerationMultiplier:1,rollingResistance:.015,skidAudio:.35},grass:{type:`grass`,gripMultiplier:.58,accelerationMultiplier:.72,rollingResistance:.12,skidAudio:.08},wood:{type:`wood`,gripMultiplier:.82,accelerationMultiplier:.92,rollingResistance:.035,skidAudio:.22},oil:{type:`oil`,gripMultiplier:.16,accelerationMultiplier:.55,rollingResistance:.005,skidAudio:.05}},C4e=class{constructor(e,t){this.oilPatches=[],this.nextOilId=1,this.scene=e,this.ignoredBody=t}sample(e,t=.8,n=2.6){let r=performance.now();if(this.pruneOil(r),this.oilPatches.some(t=>E4e(e,t.position)<=t.radiusSquared))return W7.oil;let i=this.scene.getPhysicsEngine();if(i?.getPluginVersion()===2){let r=e.add(new j(0,t,0)),a=i.raycast(r,r.add(new j(0,-n,0)),{ignoreBody:this.ignoredBody,shouldHitTriggers:!1});if(a.hasHit&&a.body)return w4e(a.body.transformNode)}let a=new Wd(e.add(new j(0,t,0)),j.Down(),n),o=this.scene.pickWithRay(a,e=>e.isEnabled()&&e.isPickable);return o?.pickedMesh?w4e(o.pickedMesh):W7.asphalt}addOilPatch(e,t=2.25,n=9){this.oilPatches.length>=12&&this.oilPatches.shift();let r=this.nextOilId++;return this.oilPatches.push({id:r,position:e.clone(),radiusSquared:t*t,expiresAt:performance.now()+n*1e3}),r}removeOilPatch(e){let t=this.oilPatches.findIndex(t=>t.id===e);t>=0&&this.oilPatches.splice(t,1)}clear(){this.oilPatches.length=0}pruneOil(e){for(let t=this.oilPatches.length-1;t>=0;--t)this.oilPatches[t].expiresAt<=e&&this.oilPatches.splice(t,1)}};function G7(e,t){e.metadata={...e.metadata,surface:t}}function w4e(e){let t=e.metadata;if(t?.surface&&T4e(t.surface))return W7[t.surface];let n=`${e.name} ${e.material?.name??``}`.toLowerCase();return/oil|slick|slime/.test(n)?W7.oil:/grass|lawn|turf|garden|soil|dirt/.test(n)?W7.grass:/wood|plank|deck|floor|table/.test(n)?W7.wood:W7.asphalt}function T4e(e){return e===`asphalt`||e===`grass`||e===`wood`||e===`oil`}function E4e(e,t){let n=e.x-t.x,r=e.z-t.z;return n*n+r*r}var D4e={enterAlignment:-.25,exitAlignment:.12,enterDelay:.8,exitDelay:.35,minimumSpeed:1.3,blinkHz:2.7,searchRadiusSegments:3},O4e=class{constructor(e,t={}){if(this.nearestSegment=0,this.wrongSeconds=0,this.correctSeconds=0,this.elapsed=0,this.wrongWay=!1,e.length<2)throw Error(`WrongWayDetector requires at least two path points.`);this.path=e,this.options={...D4e,...t}}reset(e=0){this.nearestSegment=j4e(e,this.path.length),this.wrongSeconds=0,this.correctSeconds=0,this.elapsed=0,this.wrongWay=!1}update(e,t,n,r){let i=Math.max(0,Math.min(e,.1));this.elapsed+=i,this.nearestSegment=this.findNearestSegment(t);let a=this.path[this.nearestSegment],o=this.path[(this.nearestSegment+1)%this.path.length].subtract(a);o.y=0,o.normalize();let s=new j(n.x,0,n.z),c=s.length(),l=c>=this.options.minimumSpeed?s.scale(1/c):A4e(r??j.Zero()),u=l.lengthSquared()>.5?j.Dot(l,o):1;return c>=this.options.minimumSpeed&&u<=this.options.enterAlignment?(this.wrongSeconds+=i,this.correctSeconds=0):u>=this.options.exitAlignment&&(this.correctSeconds+=i,this.wrongSeconds=0),!this.wrongWay&&this.wrongSeconds>=this.options.enterDelay&&(this.wrongWay=!0),this.wrongWay&&this.correctSeconds>=this.options.exitDelay&&(this.wrongWay=!1),{wrongWay:this.wrongWay,blinkVisible:this.wrongWay&&Math.sin(this.elapsed*Math.PI*2*this.options.blinkHz)>=0,alignment:u,nearestSegment:this.nearestSegment,suggestedDirection:o}}findNearestSegment(e){let t=this.nearestSegment,n=1/0,r=Math.min(this.path.length-1,this.options.searchRadiusSegments);for(let i=-r;i<=r;i+=1){let r=j4e(this.nearestSegment+i,this.path.length),a=k4e(e,this.path[r],this.path[(r+1)%this.path.length]);a1e-4?Math.max(0,Math.min(1,j.Dot(e.subtract(t),r)/i)):0;return j.DistanceSquared(e,t.add(r.scale(a)))}function A4e(e){let t=new j(e.x,0,e.z);return t.lengthSquared()>.001?t.normalize():j.Zero()}function j4e(e,t){return(e%t+t)%t}var M4e={"turbo-battery":`Turbo Battery`,"pulse-rocket":`Pulse Rocket`,"oil-slick":`Oil Slick`,"proximity-mine":`Proximity Mine`,"arc-emp":`Arc EMP`};function N4e(e){let t=e>>>0;return()=>(t=t*1664525+1013904223>>>0,t/4294967295)}function K7(e,t,n,r,i){let a=new pg(t,{width:256,height:256},e,!1);return n(a.getContext(),256),a.update(!1),a.wrapU=W.WRAP_ADDRESSMODE,a.wrapV=W.WRAP_ADDRESSMODE,a.uScale=r,a.vScale=i,a.anisotropicFilteringLevel=4,a}function q7(e,t,n,r,i=.06){let a=new lg(t,e);return a.diffuseTexture=n,a.diffuseColor=P.FromHexString(r),a.specularColor.setAll(i),a.roughness=.92,a}function P4e(e){let t=N4e(334666),n=K7(e,`willow-grass-texture`,(e,n)=>{e.fillStyle=`#78a84f`,e.fillRect(0,0,n,n);for(let r=0;r<2100;r+=1){e.fillStyle=t()>.48?`rgba(184,214,105,${.12+t()*.22})`:`rgba(38,91,43,${.1+t()*.23})`;let r=t()*n,i=t()*n;e.fillRect(r,i,.7+t()*1.4,1.5+t()*4)}},22,22),r=K7(e,`willow-asphalt-texture`,(e,n)=>{e.fillStyle=`#41484b`,e.fillRect(0,0,n,n);for(let r=0;r<4e3;r+=1){let r=48+Math.floor(t()*54);e.fillStyle=`rgba(${r},${r+2},${r+2},${.18+t()*.32})`;let i=.25+t()*1.05;e.fillRect(t()*n,t()*n,i,i)}e.strokeStyle=`rgba(20,24,25,0.18)`,e.lineWidth=1.1,e.beginPath(),e.moveTo(18,256),e.bezierCurveTo(39,180,88,128,76,0),e.stroke()},5,5),i=K7(e,`willow-concrete-texture`,(e,n)=>{e.fillStyle=`#c9c3b4`,e.fillRect(0,0,n,n),e.strokeStyle=`rgba(92,84,72,0.32)`,e.lineWidth=2,e.strokeRect(1,1,n-2,n-2);for(let r=0;r<700;r+=1){let r=t()>.5?255:75;e.fillStyle=`rgba(${r},${r},${r},${.025+t()*.055})`,e.fillRect(t()*n,t()*n,1.2,1.2)}},8,2),a=K7(e,`willow-brick-texture`,(e,t)=>{e.fillStyle=`#9d5641`,e.fillRect(0,0,t,t),e.strokeStyle=`#d8b9a0`,e.lineWidth=4;for(let n=0;n<=t;n+=32){e.beginPath(),e.moveTo(0,n),e.lineTo(t,n),e.stroke();let r=n/32%2==0?0:32;for(let i=-r;i{e.fillStyle=`#9b7047`,e.fillRect(0,0,n,n);for(let t=0;t{let i=new lg(t,e);return i.diffuseColor=P.FromHexString(n),i.specularColor.setAll(r),i.roughness=.9,i},c=s(`willow-window-glass`,`#6fa8b7`,.35);return c.alpha=.84,{grass:q7(e,`willow-lawn`,n,`#b8d47d`),asphalt:q7(e,`willow-road`,r,`#848d8d`,.09),concrete:q7(e,`willow-concrete`,i,`#f2ebdc`,.08),brick:q7(e,`willow-house-brick`,a,`#e8b395`,.04),roof:s(`willow-roof`,`#354758`),wood:q7(e,`willow-fence-wood`,o,`#e3c18d`),white:s(`willow-road-white`,`#fff7df`,.08),yellow:s(`willow-road-yellow`,`#f3c94f`,.09),foliage:s(`willow-foliage`,`#3f7c46`),foliageLight:s(`willow-foliage-light`,`#6aa24c`),bark:s(`willow-bark`,`#654531`),glass:c,ramp:q7(e,`willow-ramp`,o,`#d7944e`)}}var F4e=class{constructor(e,t,n,r={}){this.containers=new Map,this.loadedContainers=new Set,this.instances=[],this.visibilityFrame=0,this.scene=e,this.parent=t,this.shadow=n,this.maxVisibleDistance=r.maxVisibleDistance,this.maxVisibleDistance&&(this.visibilityObserver=e.onBeforeRenderObservable.add(()=>this.updateVisibility()))}async preload(e){await Promise.all(e.map(e=>this.load(e)))}async instantiate(e){let t=(await this.load(e)).instantiateModelsToScene(t=>`${e.name}-${t}`),n=new wc(e.name,this.scene);n.parent=this.parent,n.position.copyFrom(e.position),e.rotation?n.rotation.copyFrom(e.rotation):n.rotation.y=e.rotationY??0,e.scale instanceof j?n.scaling.copyFrom(e.scale):n.scaling.setAll(e.scale??1),t.rootNodes.forEach(e=>{e.parent=n});let r=new Set;return n.getChildMeshes().forEach(t=>{t.isPickable=!1,t.receiveShadows=!0,t.useVertexColors=!1,t.hasVertexAlpha=!1;let n=t.material;e.pbrTuning&&n instanceof ZE&&!r.has(n)&&(n.unfreeze(),e.pbrTuning.metallic!==void 0&&(n.metallic=e.pbrTuning.metallic),e.pbrTuning.roughness!==void 0&&(n.roughness=e.pbrTuning.roughness),r.add(n)),e.castShadows!==!1&&this.shadow.addShadowCaster(t),t.computeWorldMatrix(!0),t.freezeWorldMatrix(),n?.freeze()}),this.instances.push(n),n}dispose(){this.visibilityObserver&&this.scene.onBeforeRenderObservable.remove(this.visibilityObserver),this.instances.forEach(e=>e.dispose(!1,!0)),this.instances.length=0,this.loadedContainers.forEach(e=>e.dispose()),this.loadedContainers.clear(),this.containers.clear()}updateVisibility(){if(this.visibilityFrame=(this.visibilityFrame+1)%8,this.visibilityFrame!==0)return;let e=this.scene.activeCamera;if(!e||!this.maxVisibleDistance)return;let t=this.maxVisibleDistance**2;for(let n of this.instances){let r=n.position.x-e.position.x,i=n.position.z-e.position.z;n.setEnabled(r*r+i*i<=t)}}load(e){let t=`${e.rootUrl}${e.file}`,n=this.containers.get(t);return n||(n=xD.LoadAssetContainerAsync(e.rootUrl,e.file,this.scene).then(e=>(this.loadedContainers.add(e),e)),this.containers.set(t,n)),n}},I4e=`Brick_90Angle_L.gltf,Brick_90Angle_R.gltf,Brick_BottomTrim.gltf,Brick_Column_RedBricks.gltf,Brick_Column_Small.gltf,Brick_Column_TrimBricks.gltf,Brick_CornerColumn_Bottom.gltf,Brick_CornerColumn_Cap.gltf,Brick_CornerColumn_CapShort.gltf,Brick_CornerColumn_Center.gltf,Brick_CornerColumn_Center_Half.gltf,Brick_CornerColumn_Top.gltf,Brick_Corner_Plain.gltf,Brick_HalfColumn_Bottom.gltf,Brick_HalfColumn_Center.gltf,Brick_HalfColumn_Top.gltf,Brick_HalfTrim.gltf,Brick_Inset.gltf,Brick_Inset_Window.gltf,Brick_Inset_Window_Curved.gltf,Brick_Inset_Window_Curved_Small.gltf,Brick_InteriorWall_1.gltf,Brick_InteriorWall_3.gltf,Brick_InteriorWall_4.gltf,Brick_Ornament_Horizontal.gltf,Brick_Plain_1.gltf,Brick_Plain_3.gltf,Brick_Plain_3_noWear.gltf,Brick_Plain_4.gltf,Brick_RedWhite_DoubleWindow.gltf,Brick_TopTrim.gltf,Brick_TopTrim_90Angle_L.gltf,Brick_TopTrim_90Angle_R.gltf,Brick_TopTrim_Corner.gltf,Brick_Window_CurvedDouble.gltf,Brick_Window_Square_Single.gltf,Brick_Window_Trim.gltf,Brick_Window_Trim_Single.gltf,Building_Large_2.gltf,Building_Medium_2_001.gltf,Building_Small_1.gltf,Cornice_Brick_90Angle_L.gltf,Cornice_Brick_90Angle_R.gltf,Cornice_Brick_Center.gltf,Cornice_Brick_L.gltf,Cornice_Brick_R.gltf,Cornice_Metal_90Angle_L.gltf,Cornice_Metal_90Angle_R.gltf,Cornice_Metal_Center.gltf,Cornice_Metal_L.gltf,Cornice_Metal_R.gltf,Cornice_Trim_90Angle_L.gltf,Cornice_Trim_90Angle_R.gltf,Cornice_Trim_Center.gltf,Cornice_Trim_L.gltf,Cornice_Trim_R.gltf,Decal_ArrowForwardLeft.gltf,Decal_ArrowForwardRight.gltf,Decal_ArrowStraight.gltf,Decal_ArrowTurnLeft.gltf,Decal_ArrowTurnRight.gltf,Decal_Bikelane.gltf,Decal_BrokenLine_Straight.gltf,Decal_Crosswalk.gltf,Decal_Crosswalk_Wide.gltf,Decal_Curve_2Lane_Stripe.gltf,Decal_Curve_4LaneShort.gltf,Decal_Curve_4LaneShort_DoubleYellow.gltf,Decal_Curve_4LaneShort_Stripe.gltf,Decal_DoubleYellow_Straight.gltf,Decal_Only.gltf,Decal_Slow.gltf,Decal_Stop.gltf,DoorFrame_Metal_Single.gltf,DoorFrame_Trim.gltf,DoorFrame_Wooden.gltf,Door_1.gltf,Door_2.gltf,Door_3.gltf,Entrance_Concrete_2x1.gltf,Entrance_Concrete_2x2.gltf,Floor_2x2.gltf,Floor_4x4.gltf,Floor_Inset.gltf,Metal_Column_Bottom.gltf,Metal_Column_Center.gltf,Metal_Column_Small_Bottom.gltf,Metal_Column_Small_Center.gltf,Metal_Column_Small_Top.gltf,Metal_Column_Top.gltf,Metal_FirstFloor_Wall.gltf,Metal_FirstFloor_Wall_1.gltf,Metal_FirstFloor_Window.gltf,Metal_FullWindow.gltf,Metal_Plain_1.gltf,Metal_Plain_3.gltf,Metal_Window.gltf,Metal_Window_Half.gltf,Prop_ACUnit.gltf,Prop_Bollard.gltf,Prop_Drain.gltf,Prop_ManholeCover.gltf,Prop_Planter_Single.gltf,Roof_2x2.gltf,Roof_2x2_90Angle_Center.gltf,Roof_2x2_90Angle_L.gltf,Roof_2x2_90Angle_R.gltf,Roof_4x4.gltf,Roof_SlateCornice_Center.gltf,Roof_SlateCornice_Corner.gltf,Roof_SlateCornice_InnerCorner.gltf,Roof_SlateCornice_Window_1.gltf,Roof_Slate_Center.gltf,Roof_Slate_Corner.gltf,Roof_Slate_InnerCorner.gltf,Roof_Slate_Window_1.gltf,Sidewalk_Corner_Flat_3m.gltf,Sidewalk_Corner_Flat_3m_Stripe.gltf,Sidewalk_Corner_Round_3m.gltf,Sidewalk_Corner_Round_3m_Stripe.gltf,Sidewalk_NoCurb_3m.gltf,Sidewalk_Planter.gltf,Sidewalk_Straight_3m.gltf,Sidewalk_Straight_3m_Stripe.gltf,Stairs_Entrance_Concrete.gltf,Stairs_Rails_Metal.gltf,Stairs_Rails_Metal_Straight_1.gltf,Stairs_Rails_Metal_Straight_2.gltf,Street_2Lane.gltf,Street_2Lane_noSidewalk.gltf,Street_4Lane.gltf,Street_4Lane_noSidewalk.gltf,Street_4WayIntersection.gltf,Street_Asphalt_6x6.gltf,Street_Asphalt_9x9.gltf,Street_Asphalt_Curve_2Lane.gltf,Street_Asphalt_Curve_4Lane_Short.gltf,Street_Curve_2Lane.gltf,Street_Curve_2Lane_Curb.gltf,Street_Curve_4LaneShort.gltf,Street_Curve_4Lane_Short_Curb.gltf,Street_TIntersection.gltf,Trim_90Angle_TopCover.gltf,Trim_Column_Bottom.gltf,Trim_Column_Center.gltf,Trim_Column_Top.gltf,Trim_Corner.gltf,Trim_FirstFloor_Wall.gltf,Trim_FirstFloor_Window_001.gltf,Trim_FirstFloor_Window_Columns.gltf,Trim_Plain_3.gltf,Trim_Wall_Guard.gltf,Trim_Window.gltf`.split(`,`),J7=`assets/kenney/city-suburban/models/`,Y7=`assets/kenney/car-kit/models/`,X7=`assets/kenney/city-roads/models/`,Z7=`assets/quaternius/downtown-city/`,Q7=`assets/custom/houses/`,$7=`assets/custom/nature/`,e9=`assets/custom/vehicles/`,t9=`assets/custom/street/`,L4e=[{id:`tripo-house-a`,label:`White porch house`,category:`houses`,rootUrl:Q7,file:`tripo-house-a.glb`,defaultScale:70,footprint:[70,55],swatch:`#ddd8ca`},{id:`tripo-house-b`,label:`Residential house`,category:`houses`,rootUrl:Q7,file:`tripo-house-b.glb`,defaultScale:70,footprint:[70,55],swatch:`#bcae91`},{id:`tripo-house-blue`,label:`Blue family house`,category:`houses`,rootUrl:Q7,file:`tripo-house-blue.glb`,defaultScale:70,footprint:[68,70],swatch:`#7893a7`,pbrTuning:{metallic:0,roughness:.58}},{id:`premium-farm-house`,label:`Premium farmhouse`,category:`houses`,rootUrl:Q7,file:`farm-house.glb`,defaultScale:3.75,footprint:[96,72],swatch:`#bcae91`},{id:`premium-house-1`,label:`Premium house 1`,category:`houses`,rootUrl:Q7,file:`house-1.obj`,defaultScale:27,footprint:[69,105],swatch:`#9c765d`},{id:`premium-house-2`,label:`Premium house 2`,category:`houses`,rootUrl:Q7,file:`house-2.obj`,defaultScale:27,footprint:[98,83],swatch:`#8d9298`},{id:`nature-tree-maple-2`,label:`Natural maple canopy A`,category:`nature`,rootUrl:$7,file:`MapleTree_2.gltf`,defaultScale:8.5,footprint:[58,54],swatch:`#4f7246`},{id:`nature-tree-maple-3`,label:`Natural maple canopy B`,category:`nature`,rootUrl:$7,file:`MapleTree_3.gltf`,defaultScale:8.2,footprint:[74,55],swatch:`#466c40`},{id:`nature-tree-birch-1`,label:`Natural birch tree`,category:`nature`,rootUrl:$7,file:`BirchTree_1.gltf`,defaultScale:10,footprint:[28,24],swatch:`#688660`},{id:`nature-bush`,label:`Natural garden shrub`,category:`nature`,rootUrl:$7,file:`Bush.gltf`,defaultScale:7.5,footprint:[10,10],swatch:`#55764a`},{id:`nature-bush-large`,label:`Natural hedge shrub`,category:`nature`,rootUrl:$7,file:`Bush_Large.gltf`,defaultScale:8,footprint:[18,12],swatch:`#4d7144`},{id:`nature-bush-flowers`,label:`Natural flowering shrub`,category:`nature`,rootUrl:$7,file:`Bush_Flowers.gltf`,defaultScale:7.5,footprint:[10,10],swatch:`#6b7e50`},...[`a`,`f`,`k`,`q`,`u`].map((e,t)=>({id:`house-${e}`,label:`Suburban house ${e.toUpperCase()}`,category:`houses`,rootUrl:J7,file:`building-type-${e}.glb`,defaultScale:96,footprint:[132,112],swatch:[`#d9d1bc`,`#aebdc0`,`#c7ad86`,`#b7c29a`,`#c6b6a8`][t]})),{id:`tree-large`,label:`Giant maple tree`,category:`nature`,rootUrl:J7,file:`tree-large.glb`,defaultScale:200,footprint:[42,48],swatch:`#608553`},{id:`tree-small`,label:`Giant young tree`,category:`nature`,rootUrl:J7,file:`tree-small.glb`,defaultScale:176,footprint:[37,43],swatch:`#759b61`},{id:`yard-planter`,label:`Oversized yard planter`,category:`nature`,rootUrl:J7,file:`planter.glb`,defaultScale:48,footprint:[34,34],swatch:`#7e9d62`},{id:`yard-stone-path`,label:`Garden stepping stones`,category:`nature`,rootUrl:J7,file:`path-stones-messy.glb`,defaultScale:60,footprint:[10,22],swatch:`#aaa393`},{id:`parked-sedan`,label:`Full-size sedan`,category:`vehicles`,rootUrl:Y7,file:`sedan-sports.glb`,defaultScale:18,footprint:[24,48],swatch:`#547b87`},{id:`parked-hatchback`,label:`Full-size hatchback`,category:`vehicles`,rootUrl:Y7,file:`hatchback-sports.glb`,defaultScale:18,footprint:[24,44],swatch:`#a95146`},{id:`parked-suv`,label:`Full-size SUV`,category:`vehicles`,rootUrl:Y7,file:`suv-luxury.glb`,defaultScale:18,footprint:[26,50],swatch:`#b49451`},{id:`custom-blue-car`,label:`Blue parked car`,category:`vehicles`,rootUrl:e9,file:`blue-car.glb`,defaultScale:50,footprint:[25,50],swatch:`#3978a8`,rotationOffset:90,pbrTuning:{metallic:0,roughness:.42}},{id:`custom-classic-car-a`,label:`Classic parked car A`,category:`vehicles`,rootUrl:e9,file:`classic-car-a.glb`,defaultScale:50,footprint:[22,49],swatch:`#aa654a`,rotationOffset:90,pbrTuning:{metallic:0,roughness:.42}},{id:`custom-classic-car-b`,label:`Classic parked car B`,category:`vehicles`,rootUrl:e9,file:`classic-car-b.glb`,defaultScale:50,footprint:[22,49],swatch:`#77776e`,pbrTuning:{metallic:0,roughness:.42}},{id:`driveway`,label:`Giant driveway`,category:`street`,rootUrl:J7,file:`driveway-long.glb`,defaultScale:58,footprint:[50,104],swatch:`#9a9992`},{id:`fence-low`,label:`Towering low fence`,category:`street`,rootUrl:J7,file:`fence-low.glb`,defaultScale:60,footprint:[76,6],swatch:`#d4cdbb`},{id:`fence-tall`,label:`Towering yard fence`,category:`street`,rootUrl:J7,file:`fence-1x4.glb`,defaultScale:60,footprint:[100,7],swatch:`#b9ac94`},{id:`fence-white-wood`,label:`White wooden fence`,category:`street`,rootUrl:t9,file:`white-wooden-fence.glb`,defaultScale:100,footprint:[98,5.5],swatch:`#e1ddd1`,pbrTuning:{metallic:0,roughness:.72}},{id:`fence-wooden-gate`,label:`Wooden gate fence`,category:`street`,rootUrl:t9,file:`wooden-gate.glb`,defaultScale:12,footprint:[12,1.3],swatch:`#8d603b`,pbrTuning:{metallic:0,roughness:.76}},{id:`wooden-bridge`,label:`Wooden bridge`,category:`structures`,rootUrl:t9,file:`wooden-bridge.glb`,defaultScale:28,footprint:[27.5,13.7],swatch:`#835a38`,meshCollision:!0,pbrTuning:{metallic:0,roughness:.74}},{id:`street-light`,label:`Giant street light`,category:`street`,rootUrl:X7,file:`light-curved.glb`,defaultScale:80,footprint:[4,4],swatch:`#677076`},{id:`tripo-street-light`,label:`Detailed street light`,category:`street`,rootUrl:t9,file:`tripo-street-light.glb`,defaultScale:55,footprint:[4,4],swatch:`#44484b`,pbrTuning:{metallic:.05,roughness:.48}},{id:`construction-cone`,label:`Traffic cone`,category:`props`,rootUrl:X7,file:`construction-cone.glb`,defaultScale:9.1,footprint:[.74,.74],swatch:`#d96e32`},{id:`construction-barrier`,label:`Construction barrier`,category:`props`,rootUrl:X7,file:`construction-barrier.glb`,defaultScale:10.1,footprint:[1.05,2.25],swatch:`#c69036`},{id:`construction-light`,label:`Construction warning light`,category:`props`,rootUrl:X7,file:`construction-light.glb`,defaultScale:10,footprint:[.75,.75],swatch:`#e2a93e`}],n9=[...I4e.map(e=>{let t=z4e(e),n=t===`roads`;return{id:`downtown-${e.replace(/\.gltf$/i,``).replace(/_/g,`-`).toLowerCase()}`,label:e.replace(/\.gltf$/i,``).replace(/_/g,` `),category:t,rootUrl:Z7,file:e,defaultScale:4,footprint:B4e(e),swatch:V4e(t),isRoad:n}}),...L4e],R4e=[{name:`Red brick`,url:`${Z7}T_RedBrick_BaseColor.png`},{name:`Concrete`,url:`${Z7}T_Concrete_BaseColor.png`},{name:`Metal concrete`,url:`${Z7}T_MetalConcrete_BaseColor.png`},{name:`Roof slate`,url:`${Z7}T_RoofSlate_BaseColor.png`},{name:`Trim`,url:`${Z7}T_Trim_BaseColor.png`},{name:`Ornaments`,url:`${Z7}T_Ornaments_BaseColor.png`},{name:`Dirt`,url:`${Z7}T_Dirt_BaseColor.png`},{name:`Road decals`,url:`${Z7}T_Street_Decals.png`},{name:`Kenney suburban palette`,url:`${J7}Textures/colormap.png`},{name:`Kenney vehicle palette`,url:`${Y7}Textures/colormap.png`},{name:`Natural maple leaves`,url:`${$7}MapleTree_Leaves.png`},{name:`Natural birch leaves`,url:`${$7}BirchTree_Leaves.png`},{name:`Natural shrub leaves`,url:`${$7}Bush_Leaves.png`},{name:`Natural flowers`,url:`${$7}Flowers.png`}];function r9(e){return n9.find(t=>t.id===e)}function z4e(e){return e.startsWith(`Street_`)?`roads`:e.startsWith(`Sidewalk_`)?`sidewalks`:e.startsWith(`Decal_`)?`markings`:e.startsWith(`Building_`)?`buildings`:e.startsWith(`Roof_`)?`roofs`:/^(Brick|Metal|Trim|Cornice)_/.test(e)?`facades`:/^(Door|DoorFrame|Entrance|Floor|Stairs)_/.test(e)?`structures`:`props`}function B4e(e){return e.includes(`4WayIntersection`)?[99,99]:e.includes(`TIntersection`)?[99,86]:/Curve/.test(e)&&e.startsWith(`Street_`)?[48,48]:/Curve/.test(e)&&e.startsWith(`Decal_`)?[40,40]:e===`Street_2Lane.gltf`?[24,48]:e===`Street_4Lane.gltf`?[24,72]:e===`Street_4Lane_noSidewalk.gltf`?[24,48]:e.startsWith(`Street_`)?[24,24]:e.startsWith(`Sidewalk_`)?[12,12]:e.startsWith(`Decal_`)?[24,24]:e.startsWith(`Building_Large`)?[84,68]:e.startsWith(`Building_Medium`)?[62,54]:e.startsWith(`Building_Small`)?[52,60]:e.startsWith(`Brick_`)?[16,1]:/^(Metal|Trim|Cornice)_/.test(e)?[12,1]:e.startsWith(`Roof_`)?[18,18]:[8,8]}function V4e(e){return{roads:`#55595d`,sidewalks:`#aaa59b`,markings:`#d8b650`,buildings:`#8b6255`,facades:`#9a6b5a`,roofs:`#55565e`,structures:`#777c7e`,props:`#6d756f`,houses:`#c4b9a6`,nature:`#66885c`,vehicles:`#657c85`,street:`#6b7074`}[e]}var i9=1.8;function a9(e){return{...e,objects:e.objects.map(e=>r9(e.assetId)?.isRoad?{...e,y:Math.max(e.y??1.8,i9)}:e)}}function o9(e){return{...e,objects:e.objects.filter(e=>!H4e(e))}}function H4e(e){return e.id.startsWith(`auto-route-road-`)||e.id.startsWith(`completed-route-road-`)}var U4e={version:3,id:`construction-loop-kit`,name:`Construction Loop`,presetRevision:19,seed:20260718,roadWidth:24,worldSize:700,route:[{x:-74.5,z:175.6},{x:-74.5,z:135},{x:-74.9,z:104.9},{x:-44.5,z:104.5},{x:65,z:104.3},{x:64.5,z:25.1},{x:65,z:-44.7},{x:131.9,z:-44.7},{x:193.9,z:-44.7},{x:194.1,z:-145.5},{x:-93.4,z:-145},{x:-211,z:-103.7},{x:-211,z:-19},{x:-211.7,z:141.5},{x:-212,z:215},{x:-74.4,z:216.9}],routeClosed:!0,objects:[{id:`ccdff0fb-3a6c-43c5-bc6d-14c77321d0a3`,assetId:`downtown-street-2lane`,x:-74.4,z:158.7,rotation:90,scale:1,y:1.8},{id:`0e81f90c-4d3a-42a0-8bfd-066a56be151f`,assetId:`downtown-street-curve-2lane`,x:-50.3,z:128.6,rotation:270,scale:1,y:1.8},{id:`1fb479b0-6675-42cb-b590-65125a117364`,assetId:`downtown-street-2lane`,x:-74.6,z:135.2,rotation:90,scale:1,y:1.8},{id:`b26d0779-efe7-43a2-9aba-7385b41f9619`,assetId:`downtown-street-2lane`,x:-38.6,z:104,rotation:0,scale:1,y:1.8},{id:`5db97cf0-6439-4611-af57-547ecdb3a0f5`,assetId:`downtown-street-2lane`,x:-14.9,z:104,rotation:0,scale:1,y:1.8},{id:`7a2fb3f2-cd36-4701-90db-f8386f9d8e95`,assetId:`downtown-street-2lane`,x:8.5,z:104,rotation:0,scale:1,y:1.8},{id:`25f56b6e-7fe2-4886-b383-5cf7a8e77854`,assetId:`downtown-street-2lane`,x:32,z:104,rotation:0,scale:1,y:1.8},{id:`0da346ed-22c8-42a5-a147-829e39bf40c5`,assetId:`downtown-street-curve-2lane`,x:43.9,z:80,rotation:90,scale:1,y:1.8},{id:`677382d1-d2ad-4b04-be6e-ca067f342e85`,assetId:`downtown-street-2lane`,x:68,z:69,rotation:90,scale:1,y:1.8},{id:`34ba61e6-a6bd-44b6-ba0e-23547e21607b`,assetId:`downtown-street-2lane`,x:68,z:44.9,rotation:90,scale:1,y:2},{id:`f345ea72-23d2-414f-9069-11a00893180b`,assetId:`downtown-street-2lane`,x:68,z:21.1,rotation:90,scale:1,y:1.8},{id:`1d4eaf47-ed9b-444d-840f-6b7e5d7f57cd`,assetId:`downtown-street-2lane`,x:68,z:-2.9,rotation:90,scale:1,y:1.8},{id:`f61582e9-e70e-41d9-a7b5-94673adabe4b`,assetId:`downtown-street-2lane`,x:175,z:-62.5,rotation:0,scale:1,y:1.8},{id:`34a30853-a44b-4f34-aa0f-4f5d6ccffec0`,assetId:`downtown-street-2lane`,x:151.6,z:-62.5,rotation:0,scale:1,y:1.8},{id:`b7299753-1487-4332-9515-c5cb39f1fdbd`,assetId:`downtown-street-2lane`,x:127.9,z:-62.5,rotation:0,scale:1,y:1.8},{id:`12e196fa-05b1-4d8f-afed-60e6731aec36`,assetId:`downtown-street-2lane`,x:104,z:-62.5,rotation:0,scale:1,y:1.8},{id:`c52ea94e-1ff8-4a12-8bca-297628fa6223`,assetId:`downtown-street-2lane`,x:68,z:-27,rotation:90,scale:1,y:1.8},{id:`81b9258d-a9a1-428b-ad47-ec0e7a9efc47`,assetId:`downtown-street-curve-2lane`,x:92,z:-38.6,rotation:270,scale:1,y:1.8},{id:`manual-road-finish-001`,assetId:`downtown-street-curve-2lane`,x:187,z:-86.5,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-002`,assetId:`downtown-street-2lane`,x:211,z:-98.5,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-003`,assetId:`downtown-street-2lane`,x:211,z:-122.5,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-004`,assetId:`downtown-street-curve-2lane`,x:187,z:-134.5,rotation:180,scale:1,y:1.8},{id:`manual-road-finish-005`,assetId:`downtown-street-2lane`,x:175,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-006`,assetId:`downtown-street-2lane`,x:151,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-007`,assetId:`downtown-street-2lane`,x:127,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-008`,assetId:`downtown-street-2lane`,x:103,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-009`,assetId:`downtown-street-2lane`,x:79,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-010`,assetId:`downtown-street-2lane`,x:55,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-011`,assetId:`downtown-street-2lane`,x:31,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-012`,assetId:`downtown-street-2lane`,x:7,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-013`,assetId:`downtown-street-2lane`,x:-17,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-014`,assetId:`downtown-street-2lane`,x:-41,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-015`,assetId:`downtown-street-2lane`,x:-65,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-016`,assetId:`downtown-street-2lane`,x:-89,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-017`,assetId:`downtown-street-2lane`,x:-111.8,z:-158.2,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`manual-road-finish-020`,assetId:`downtown-street-2lane`,x:-135.13,z:-158.22,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`manual-road-finish-021`,assetId:`downtown-street-curve-2lane`,x:-187,z:-134,rotation:270,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`manual-road-finish-022`,assetId:`downtown-street-2lane`,x:-211,z:-80,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-023`,assetId:`downtown-street-2lane`,x:-211,z:-56.3,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-024`,assetId:`downtown-street-2lane`,x:-211,z:-32.6,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-025`,assetId:`downtown-street-2lane`,x:-211,z:-8.8,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-026`,assetId:`downtown-street-2lane`,x:-211,z:14.9,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-027`,assetId:`downtown-street-2lane`,x:-211,z:38.6,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-028`,assetId:`downtown-street-2lane`,x:-211,z:62.4,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-029`,assetId:`downtown-street-2lane`,x:-211,z:86.1,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-030`,assetId:`downtown-street-2lane`,x:-211,z:109.8,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-031`,assetId:`downtown-street-2lane`,x:-211,z:133.6,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-032`,assetId:`downtown-street-2lane`,x:-211,z:157.3,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-033`,assetId:`downtown-street-2lane`,x:-211,z:181,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-035`,assetId:`downtown-street-curve-2lane`,x:-187,z:193,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-036`,assetId:`downtown-street-2lane`,x:-175,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-037`,assetId:`downtown-street-2lane`,x:-151.5,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-038`,assetId:`downtown-street-2lane`,x:-128,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-039`,assetId:`downtown-street-2lane`,x:-110.5,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-040`,assetId:`downtown-street-curve-2lane`,x:-98.5,z:193,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-041`,assetId:`downtown-street-2lane`,x:-74.5,z:181,rotation:90,scale:1,y:1.8},{id:`neighborhood-house-bottom-01`,assetId:`tripo-house-a`,x:-160,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-01-shrub-l`,assetId:`nature-bush-large`,x:-147.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-01-shrub-r`,assetId:`nature-bush-large`,x:-147.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-01-flowers`,assetId:`nature-bush-flowers`,x:-139.08,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-bottom-02`,assetId:`tripo-house-blue`,x:-55,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-02-shrub-l`,assetId:`nature-bush-large`,x:-42.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-02-shrub-r`,assetId:`nature-bush-large`,x:-42.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-02-flowers`,assetId:`nature-bush-flowers`,x:-34.08,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-bottom-03`,assetId:`tripo-house-a`,x:50,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-03-shrub-l`,assetId:`nature-bush-large`,x:62.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-03-shrub-r`,assetId:`nature-bush-large`,x:62.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-03-flowers`,assetId:`nature-bush-flowers`,x:70.92,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-bottom-04`,assetId:`tripo-house-a`,x:155,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-04-shrub-l`,assetId:`nature-bush-large`,x:167.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-04-shrub-r`,assetId:`nature-bush-large`,x:167.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-04-flowers`,assetId:`nature-bush-flowers`,x:175.92,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-west-01`,assetId:`tripo-house-a`,x:-284,z:-92,rotation:90,scale:.68},{id:`neighborhood-house-west-01-shrub-l`,assetId:`nature-bush-large`,x:-255.54,z:-103.26,rotation:90,scale:.58},{id:`neighborhood-house-west-01-shrub-r`,assetId:`nature-bush-large`,x:-255.54,z:-103.26,rotation:90,scale:.58},{id:`neighborhood-house-west-01-flowers`,assetId:`nature-bush-flowers`,x:-254.54,z:-111.26,rotation:105,scale:.62},{id:`neighborhood-house-west-02`,assetId:`tripo-house-blue`,x:-284,z:15,rotation:90,scale:.68},{id:`neighborhood-house-west-02-shrub-l`,assetId:`nature-bush-large`,x:-255.54,z:3.74,rotation:90,scale:.58},{id:`neighborhood-house-west-02-shrub-r`,assetId:`nature-bush-large`,x:-255.54,z:3.74,rotation:90,scale:.58},{id:`neighborhood-house-west-02-flowers`,assetId:`nature-bush-flowers`,x:-254.54,z:-4.26,rotation:105,scale:.62},{id:`neighborhood-house-west-03`,assetId:`tripo-house-a`,x:-284,z:122,rotation:90,scale:.68},{id:`neighborhood-house-west-03-shrub-l`,assetId:`nature-bush-large`,x:-255.54,z:110.74,rotation:90,scale:.58},{id:`neighborhood-house-west-03-shrub-r`,assetId:`nature-bush-large`,x:-255.54,z:110.74,rotation:90,scale:.58},{id:`neighborhood-house-west-03-flowers`,assetId:`nature-bush-flowers`,x:-254.54,z:102.74,rotation:105,scale:.62},{id:`neighborhood-house-northwest-01`,assetId:`tripo-house-a`,x:-135,z:135,rotation:0,scale:.62},{id:`neighborhood-house-northwest-01-shrub-l`,assetId:`nature-bush-large`,x:-124.73,z:172.55,rotation:0,scale:.58},{id:`neighborhood-house-northwest-01-shrub-r`,assetId:`nature-bush-large`,x:-124.73,z:172.55,rotation:0,scale:.58},{id:`neighborhood-house-northwest-01-flowers`,assetId:`nature-bush-flowers`,x:-116.73,z:173.55,rotation:15,scale:.62},{id:`neighborhood-house-north-01`,assetId:`tripo-house-a`,x:0,z:178,rotation:180,scale:.72},{id:`neighborhood-house-north-01-shrub-l`,assetId:`nature-bush-large`,x:-11.92,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-01-shrub-r`,assetId:`nature-bush-large`,x:-11.92,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-01-flowers`,assetId:`nature-bush-flowers`,x:-19.92,z:134.2,rotation:195,scale:.62},{id:`neighborhood-house-north-02`,assetId:`tripo-house-a`,x:133.29,z:135.07,rotation:235,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-north-02-shrub-l`,assetId:`nature-bush-large`,x:46.08,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-02-shrub-r`,assetId:`nature-bush-large`,x:46.08,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-02-flowers`,assetId:`nature-bush-flowers`,x:38.08,z:134.2,rotation:195,scale:.62},{id:`neighborhood-house-east-01`,assetId:`tripo-house-a`,x:148,z:12,rotation:180,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-east-01-shrub-l`,assetId:`nature-bush-large`,x:133.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-01-shrub-r`,assetId:`nature-bush-large`,x:133.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-01-flowers`,assetId:`nature-bush-flowers`,x:125.08,z:-31.8,rotation:195,scale:.62},{id:`neighborhood-house-east-02`,assetId:`tripo-house-blue`,x:233.01,z:-8.33,rotation:210,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-east-02-shrub-l`,assetId:`nature-bush-large`,x:193.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-02-shrub-r`,assetId:`nature-bush-large`,x:193.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-02-flowers`,assetId:`nature-bush-flowers`,x:185.08,z:-31.8,rotation:195,scale:.62},{id:`neighborhood-house-east-03`,assetId:`tripo-house-a`,x:277,z:-118,rotation:270,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-east-03-shrub-l`,assetId:`nature-bush-large`,x:255.16,z:-104.08,rotation:270,scale:.58},{id:`neighborhood-house-east-03-shrub-r`,assetId:`nature-bush-large`,x:255.16,z:-104.08,rotation:270,scale:.58},{id:`neighborhood-house-east-03-flowers`,assetId:`nature-bush-flowers`,x:254.16,z:-96.08,rotation:285,scale:.62},{id:`neighborhood-house-center-nw`,assetId:`tripo-house-b`,x:-144,z:30,rotation:270,scale:.62},{id:`neighborhood-house-center-nw-shrub-l`,assetId:`nature-bush-large`,x:-179.38,z:44.58,rotation:270,scale:.58},{id:`neighborhood-house-center-nw-shrub-r`,assetId:`nature-bush-large`,x:-179.38,z:44.58,rotation:270,scale:.58},{id:`neighborhood-house-center-nw-flowers`,assetId:`nature-bush-flowers`,x:-180.38,z:52.58,rotation:285,scale:.62},{id:`neighborhood-house-center-ne`,assetId:`tripo-house-a`,x:6,z:-29,rotation:90,scale:.62,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-center-ne-shrub-l`,assetId:`nature-bush-large`,x:-39.61,z:17.73,rotation:90,scale:.58},{id:`neighborhood-house-center-ne-shrub-r`,assetId:`nature-bush-large`,x:-39.61,z:17.73,rotation:90,scale:.58},{id:`neighborhood-house-center-ne-flowers`,assetId:`nature-bush-flowers`,x:-38.61,z:9.73,rotation:105,scale:.62},{id:`neighborhood-house-center-sw`,assetId:`tripo-house-b`,x:-70.66,z:-107.06,rotation:180,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-center-se`,assetId:`tripo-house-b`,x:38,z:-107,rotation:180,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-car-bottom-01`,assetId:`custom-blue-car`,x:-107,z:-211,rotation:0,scale:.88},{id:`neighborhood-car-bottom-02`,assetId:`custom-classic-car-a`,x:-2,z:-211,rotation:0,scale:.88},{id:`neighborhood-car-bottom-03`,assetId:`custom-classic-car-b`,x:103,z:-211,rotation:0,scale:.88},{id:`neighborhood-car-west-01`,assetId:`custom-classic-car-a`,x:-258,z:-39,rotation:90,scale:.88},{id:`neighborhood-car-west-02`,assetId:`custom-classic-car-b`,x:-258,z:68,rotation:90,scale:.88},{id:`neighborhood-car-east-01`,assetId:`custom-classic-car-a`,x:188,z:6,rotation:180,scale:.88,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-car-east-02`,assetId:`custom-classic-car-b`,x:251.5,z:-72.85,rotation:250,scale:.88,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-light-northwest-01`,assetId:`tripo-street-light`,x:-189,z:234,rotation:0,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-light-outer-east-01`,assetId:`tripo-street-light`,x:229,z:-116,rotation:90,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-birch-bottom-01`,assetId:`nature-tree-birch-1`,x:-205,z:-286,rotation:8,scale:.82},{id:`neighborhood-birch-bottom-02`,assetId:`nature-tree-birch-1`,x:-100,z:-310,rotation:342,scale:.78},{id:`neighborhood-birch-bottom-03`,assetId:`nature-tree-birch-1`,x:5,z:-310,rotation:18,scale:.8},{id:`neighborhood-birch-bottom-04`,assetId:`nature-tree-birch-1`,x:110,z:-310,rotation:350,scale:.8},{id:`neighborhood-birch-bottom-05`,assetId:`nature-tree-birch-1`,x:210,z:-286,rotation:12,scale:.82},{id:`neighborhood-birch-west-01`,assetId:`nature-tree-birch-1`,x:-342,z:-150,rotation:20,scale:.8},{id:`neighborhood-birch-west-02`,assetId:`nature-tree-birch-1`,x:-342,z:-35,rotation:340,scale:.82},{id:`neighborhood-birch-west-03`,assetId:`nature-tree-birch-1`,x:-342,z:78,rotation:14,scale:.78},{id:`neighborhood-birch-west-04`,assetId:`nature-tree-birch-1`,x:-342,z:176,rotation:350,scale:.8},{id:`neighborhood-birch-north-02`,assetId:`nature-tree-birch-1`,x:-50,z:230,rotation:345,scale:.78},{id:`neighborhood-birch-north-03`,assetId:`nature-tree-birch-1`,x:105,z:220,rotation:20,scale:.8},{id:`neighborhood-birch-east-01`,assetId:`nature-tree-birch-1`,x:300,z:40,rotation:338,scale:.8},{id:`neighborhood-birch-east-02`,assetId:`nature-tree-birch-1`,x:260,z:65,rotation:12,scale:.82},{id:`neighborhood-birch-east-03`,assetId:`nature-tree-birch-1`,x:326,z:-62,rotation:348,scale:.8},{id:`neighborhood-maple-center-01`,assetId:`nature-tree-maple-2`,x:-100,z:82,rotation:18,scale:.52},{id:`neighborhood-maple-east-01`,assetId:`nature-tree-maple-3`,x:238,z:92,rotation:348,scale:.46},{id:`neighborhood-path-center-nw`,assetId:`yard-stone-path`,x:-176,z:26,rotation:90,scale:.48,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-planter-east-01`,assetId:`yard-planter`,x:240,z:12,rotation:0,scale:.38},{id:`6b20414d-ac26-463a-9184-d6166e7250cf`,assetId:`fence-white-wood`,x:51.15,z:-271.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`6d8594de-7d7a-4e99-9391-f1607a8f57fa`,assetId:`fence-white-wood`,x:-53.85,z:-271.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`89e4b7bd-219a-4bf7-8ec0-41e51c752455`,assetId:`fence-white-wood`,x:-158.85,z:-270.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`a15829e2-00a3-4636-80e5-e41761417b81`,assetId:`fence-white-wood`,x:155.15,z:-271.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`47ae54fe-430a-4368-9b3a-1f69d39b9942`,assetId:`fence-white-wood`,x:-308.2,z:122.82,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`80e14273-7086-4e7b-a807-90c082029c93`,assetId:`fence-white-wood`,x:-309.2,z:-98.18,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`dacb208b-802e-4f8e-bb7f-1c8b152d97ba`,assetId:`fence-white-wood`,x:-309.2,z:9.82,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`f5fbf83b-7c3a-497c-9994-4b25082656fe`,assetId:`fence-white-wood`,x:229.69,z:-185.39,rotation:315,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`7cf3f086-f016-4528-b900-57ddd3f75b92`,assetId:`fence-white-wood`,x:155.75,z:53.31,rotation:15,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`ba11abaa-44c5-4ab7-8bc3-28dacd421539`,assetId:`fence-white-wood`,x:309.73,z:-60.68,rotation:70,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`83bf6b50-7565-42a1-9d18-45616d78bc72`,assetId:`fence-white-wood`,x:249.39,z:17.6,rotation:30,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`945691bd-8ddc-4067-a838-abd0565fe668`,assetId:`tripo-house-a`,x:60,z:180,rotation:180,scale:.72},{id:`859f9e0c-0e43-4c92-935d-6aef8aef0c02`,assetId:`tripo-house-b`,x:155.23,z:-109.94,rotation:0,scale:1,y:1,scaleX:.7,scaleY:.7,scaleZ:.7},{id:`57fd89de-aa12-4ebc-908c-0e4eef0f45b3`,assetId:`tripo-house-a`,x:-212.81,z:287.78,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`4f136565-70da-4926-9049-c70d3203e16a`,assetId:`tripo-house-a`,x:-92.81,z:289.78,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`b66ae187-96fb-4473-9b04-e5a86c40bdae`,assetId:`tripo-street-light`,x:-138,z:235,rotation:0,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`7df50282-9945-427d-bb43-214a356617bd`,assetId:`tripo-street-light`,x:-95,z:235,rotation:0,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`7395ce0a-42b7-4432-8ede-306fc6661356`,assetId:`tripo-street-light`,x:-229.91,z:176.78,rotation:270,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`093d89ea-e3ea-46f6-a844-cd3f9a843f1b`,assetId:`downtown-street-2lane`,x:-211,z:-104,rotation:90,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`b1b0f79d-2338-4c40-a3d6-a25036db3901`,assetId:`downtown-street-2lane`,x:-211,z:-124,rotation:90,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`4fbabcd5-50d0-4242-bc15-abd74cbeb9ab`,assetId:`downtown-street-2lane`,x:-154.13,z:-158.22,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`cf2f35a6-f03a-4139-91ae-c96ba8cb2c7c`,assetId:`downtown-street-2lane`,x:-176,z:-158.22,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`1876069d-2539-4bef-8540-b8450941b221`,assetId:`tripo-house-b`,x:5,z:46,rotation:0,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`9b4830e9-c7c8-4a19-a284-a8e33e876652`,assetId:`fence-white-wood`,x:23.86,z:207.82,rotation:0,scale:1,y:1,scaleX:1.4,scaleY:1,scaleZ:1},{id:`006eda1a-919c-4ad4-b2b6-67383c0e776d`,assetId:`fence-white-wood`,x:-94.14,z:313.82,rotation:0,scale:1,y:1,scaleX:1.4,scaleY:1,scaleZ:1},{id:`91391b83-48ba-4c26-885f-9cadb690452b`,assetId:`fence-white-wood`,x:-229.14,z:313.82,rotation:0,scale:1,y:1,scaleX:1.4,scaleY:1,scaleZ:1},{id:`74cb08e4-24bb-4c7e-9115-e1ccb13d0557`,assetId:`tripo-house-b`,x:-142,z:-69,rotation:270,scale:.62,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`b782aa56-4fa0-45df-ae1a-7b6673e63132`,assetId:`nature-tree-maple-2`,x:-72.91,z:31.55,rotation:0,scale:1},{id:`5379b885-a560-4539-8380-e557fd61e66b`,assetId:`nature-tree-maple-3`,x:-152.2,z:77.43,rotation:0,scale:1},{id:`0396a4da-2841-47d9-96ac-d28e0a37d558`,assetId:`nature-tree-maple-3`,x:-91.53,z:-38.47,rotation:0,scale:1},{id:`62e3caa1-8458-42c5-9244-43d11aa10e0a`,assetId:`nature-bush`,x:-248.65,z:-216.17,rotation:0,scale:1},{id:`116e8c24-13e9-4674-91be-d91a4eccafe0`,assetId:`nature-tree-maple-2`,x:-264.19,z:-161.81,rotation:0,scale:1},{id:`a7bdca4a-f504-47e1-8539-64db97064d52`,assetId:`nature-tree-maple-2`,x:-228.47,z:-184.43,rotation:0,scale:1},{id:`8f95ace1-b6e2-4ad0-8842-f09e29523c54`,assetId:`nature-tree-maple-2`,x:-262.15,z:-201.65,rotation:0,scale:1},{id:`0e1ed0aa-fc58-4224-b046-3089eea65ac1`,assetId:`nature-bush`,x:-281.73,z:-176.49,rotation:0,scale:1},{id:`97460682-f729-494f-a486-7e322fb11e48`,assetId:`nature-bush`,x:-244.59,z:-160.5,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`14b42bf5-71c7-4bca-805c-6704ce2d0d2f`,assetId:`nature-bush`,x:-209.9,z:-191.39,rotation:0,scale:1},{id:`e9da8030-59bb-4554-bdba-bce8941acbb2`,assetId:`nature-bush`,x:-249.52,z:-165.22,rotation:0,scale:1},{id:`6fbc4bd2-e138-4f38-a25c-22fa6ff6e696`,assetId:`nature-tree-maple-2`,x:259.01,z:-240.01,rotation:0,scale:1},{id:`551ed0a3-9915-44c1-ae64-94038acb6826`,assetId:`nature-tree-maple-3`,x:285.91,z:-215.2,rotation:0,scale:1},{id:`02ca1688-50f3-4482-a10a-df178eac2602`,assetId:`nature-tree-birch-1`,x:218.45,z:-214.48,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`f25d935b-b088-4fb9-8b74-68f61c2a1f26`,assetId:`nature-tree-birch-1`,x:240.32,z:-179.51,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`3194c866-34f2-400b-8a43-98b66f05f6a6`,assetId:`nature-tree-maple-3`,x:239.14,z:-253.23,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`b4b42d35-819f-4e6c-9a54-4de764fdd4c9`,assetId:`nature-tree-maple-3`,x:285.11,z:-173.68,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`696d7c7e-2c68-4006-98ce-0fa104a5e615`,assetId:`nature-tree-maple-3`,x:280.58,z:-40.72,rotation:0,scale:1},{id:`7141d01f-3554-458b-8895-9420b40d0345`,assetId:`nature-tree-maple-3`,x:296.59,z:-76.5,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`10469327-7035-493d-982b-adb75fe2805c`,assetId:`nature-tree-maple-2`,x:181.61,z:78.92,rotation:0,scale:1},{id:`4edd054f-3b2c-4faa-ae1c-938f37ba4c33`,assetId:`nature-tree-maple-3`,x:238.76,z:55.29,rotation:0,scale:1},{id:`a5509e55-f900-4734-a882-b46f1c3af768`,assetId:`nature-tree-birch-1`,x:161.33,z:112.95,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`185ba362-a06b-4995-a5d3-c4c96067b601`,assetId:`nature-tree-maple-3`,x:126.64,z:70.84,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`03cdd96c-d396-4b44-a0a9-f39115bde01e`,assetId:`nature-tree-maple-2`,x:101.3,z:15.17,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`54527822-675c-433f-b025-ae29cb97e588`,assetId:`nature-tree-maple-2`,x:108.17,z:194.16,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`4a0902df-a72e-4585-9bfe-aedd427ba27a`,assetId:`nature-tree-maple-3`,x:168.71,z:228.31,rotation:0,scale:1},{id:`209204ff-8246-4239-b5ea-5ad3f3c4c76f`,assetId:`nature-tree-birch-1`,x:206.53,z:192.17,rotation:0,scale:1},{id:`397c300c-2718-4a92-8691-ea3eea0518a7`,assetId:`nature-bush`,x:75.83,z:287.14,rotation:0,scale:1},{id:`1fc84d13-75d3-44c0-bc2d-8920d3a5f21a`,assetId:`nature-bush`,x:82.63,z:117.7,rotation:0,scale:1},{id:`958ab228-98a4-4eb2-a23c-5706c643d70b`,assetId:`nature-bush`,x:92.5,z:137.63,rotation:0,scale:1},{id:`9b4682dd-09fa-4b39-ab72-5350c020ddc9`,assetId:`nature-tree-birch-1`,x:29.11,z:153.02,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`0d087fd8-8970-4804-b915-166ec9773006`,assetId:`nature-tree-maple-3`,x:25.06,z:253.96,rotation:0,scale:1},{id:`a118cdf3-b543-429e-8424-bb8e9e62981b`,assetId:`nature-tree-maple-2`,x:-32.54,z:241.6,rotation:0,scale:1},{id:`af48bb2c-8bb3-4c69-bc08-de41afa6fd86`,assetId:`nature-tree-maple-2`,x:-12.72,z:284.52,rotation:0,scale:1},{id:`a17e6320-d7bf-4c7c-b42b-5298eb1fbfbb`,assetId:`nature-tree-maple-2`,x:-54.58,z:336.69,rotation:0,scale:1},{id:`853a0a5a-1278-4958-81b0-257b55b9d495`,assetId:`nature-tree-maple-3`,x:-145.67,z:338.42,rotation:0,scale:1},{id:`b0f327cc-d99f-44d7-ab60-4848270aed6b`,assetId:`nature-tree-maple-3`,x:-300.2,z:338.09,rotation:0,scale:1},{id:`785d0eed-0a18-4932-bbf3-26871951ca78`,assetId:`nature-tree-maple-3`,x:-319.9,z:291.87,rotation:0,scale:1},{id:`b497d273-ddfa-4fbf-b684-06140a08057a`,assetId:`nature-tree-maple-3`,x:-151,z:394.11,rotation:0,scale:1},{id:`c0de21d5-0ca1-4462-a23b-754a9e4232a9`,assetId:`nature-tree-maple-3`,x:-231.91,z:238.57,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`9df90ff6-cbc3-44d6-99ed-4f5c5cacd333`,assetId:`nature-tree-maple-3`,x:-253.78,z:200.14,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`bc4f58fd-0e29-4815-b11b-02f53f1b81e8`,assetId:`nature-tree-maple-3`,x:-261.46,z:171.97,rotation:0,scale:1},{id:`f63ad99a-cb09-4cec-86b1-a0d7ec898695`,assetId:`nature-bush`,x:-269.36,z:236.11,rotation:0,scale:1},{id:`168c17de-6126-44d4-a530-e5760205beb3`,assetId:`nature-bush-large`,x:-295.44,z:209.82,rotation:0,scale:1},{id:`3d2648ff-2851-4653-a69a-3c57dda83a5c`,assetId:`nature-bush-flowers`,x:-301.28,z:199.42,rotation:0,scale:1},{id:`5a354a23-d3f2-4395-9dd5-416463e66929`,assetId:`nature-bush-flowers`,x:-270.21,z:225.54,rotation:0,scale:1},{id:`404c9efd-dcef-4724-a87f-3654f3f9e668`,assetId:`nature-bush-flowers`,x:-253.06,z:208.5,rotation:0,scale:1},{id:`1c0c9540-e3fa-4074-8b5b-1c9ed616148b`,assetId:`nature-tree-maple-2`,x:-333.99,z:135.71,rotation:0,scale:1},{id:`591b76f6-bdb1-47f1-ab92-9ba09fe3a42f`,assetId:`nature-tree-maple-3`,x:-332.45,z:92.3,rotation:0,scale:1},{id:`ddfd9bf1-d959-4d4d-90b9-aeffcb5c5452`,assetId:`nature-tree-maple-3`,x:-339.44,z:38.78,rotation:85,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`9dfd557d-9137-49da-a878-2134a1097b14`,assetId:`nature-tree-maple-3`,x:-335.64,z:-20.81,rotation:130,scale:1},{id:`036d9e28-363c-4b60-b5f8-a7a8d6b4fe6c`,assetId:`nature-tree-maple-3`,x:-331.7,z:-59.72,rotation:265,scale:1},{id:`ed13d1a1-57e2-4d2e-a3a9-9281d6677fa1`,assetId:`nature-tree-maple-3`,x:-319.41,z:-99.51,rotation:0,scale:1},{id:`48049312-1d32-43c3-8c58-7f651f9ea00f`,assetId:`nature-bush`,x:-296.98,z:-42.18,rotation:0,scale:1},{id:`cb8348af-2f63-488c-b6f3-40de4db4dc4b`,assetId:`nature-bush`,x:-303.16,z:-48,rotation:0,scale:1},{id:`c1f64a2d-c066-4260-922b-0b966db7108d`,assetId:`nature-bush-large`,x:-308.56,z:-44.87,rotation:85,scale:1},{id:`6d112289-fbad-4c8d-8ed7-4e325493a4ca`,assetId:`nature-bush`,x:-169.85,z:-120.4,rotation:0,scale:1},{id:`d259bfe6-51e3-4594-a0a7-2c32a2ebdd92`,assetId:`nature-tree-birch-1`,x:-167.25,z:-109.25,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`36ef72dd-e706-4de0-bf0d-ca7c00741b79`,assetId:`nature-tree-maple-2`,x:-153.93,z:-125.53,rotation:0,scale:1},{id:`d5fb20e1-806f-4d50-9721-38d1d5f533b2`,assetId:`nature-tree-maple-3`,x:-140.98,z:-23.22,rotation:0,scale:1},{id:`99e651ce-c4a2-4150-9b2f-2087622b138a`,assetId:`nature-tree-maple-3`,x:-39.8,z:176.58,rotation:65,scale:1},{id:`3f7033ec-2e93-4737-bd6d-d40d84be079b`,assetId:`nature-bush-flowers`,x:20.67,z:75.01,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`18b23ad1-ff6a-493a-817c-6f8011e26f0d`,assetId:`nature-bush-large`,x:-49.48,z:76.56,rotation:0,scale:1},{id:`e3c5dd93-b536-4d52-8a3c-241cab129023`,assetId:`nature-bush-large`,x:-82.44,z:86.92,rotation:40,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`5efc5713-c06f-42ef-9a77-82ff0bb17309`,assetId:`nature-bush-large`,x:-67.92,z:80.05,rotation:20,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`cf4e5ae5-3246-40f5-861c-ef9c66506bee`,assetId:`nature-bush-large`,x:-18.48,z:77.56,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`ff432238-242a-4d44-94ed-e8ecb8e56bc0`,assetId:`nature-bush-large`,x:-33.48,z:76.56,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`f9438b5c-4be1-4a08-872b-77000f42e6a3`,assetId:`nature-bush`,x:11.86,z:74.84,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`22427270-18b0-4573-962f-2c0dd6656953`,assetId:`nature-bush-large`,x:.67,z:76.13,rotation:0,scale:1},{id:`25c5313d-2b87-4fbd-a1e8-a09afe9d4351`,assetId:`fence-white-wood`,x:-279.49,z:-217.56,rotation:50,scale:1,y:1,scaleX:1.9,scaleY:1,scaleZ:1},{id:`landscape-light-west-02`,assetId:`tripo-street-light`,x:-230,z:125,rotation:270,scale:.82,y:1},{id:`landscape-light-west-03`,assetId:`tripo-street-light`,x:-230,z:75,rotation:270,scale:.82,y:1},{id:`landscape-light-west-04`,assetId:`tripo-street-light`,x:-230,z:25,rotation:270,scale:.82,y:1},{id:`landscape-light-west-05`,assetId:`tripo-street-light`,x:-230,z:-25,rotation:270,scale:.82,y:1},{id:`landscape-light-west-06`,assetId:`tripo-street-light`,x:-230,z:-75,rotation:270,scale:.82,y:1},{id:`landscape-light-west-07`,assetId:`tripo-street-light`,x:-230,z:-125,rotation:270,scale:.82,y:1},{id:`landscape-light-bottom-01`,assetId:`tripo-street-light`,x:-145,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-light-bottom-02`,assetId:`tripo-street-light`,x:-45,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-light-bottom-03`,assetId:`tripo-street-light`,x:55,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-light-bottom-04`,assetId:`tripo-street-light`,x:155,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-center-southwest-hedge-01`,assetId:`nature-bush-large`,x:-93,z:-75,rotation:4,scale:.62,y:1},{id:`landscape-center-southwest-hedge-02`,assetId:`nature-bush-large`,x:-80,z:-75,rotation:356,scale:.62,y:1},{id:`landscape-center-southwest-hedge-03`,assetId:`nature-bush-large`,x:-67,z:-75,rotation:3,scale:.62,y:1},{id:`landscape-center-southwest-hedge-04`,assetId:`nature-bush-large`,x:-54,z:-75,rotation:358,scale:.62,y:1},{id:`landscape-center-southeast-hedge-01`,assetId:`nature-bush-large`,x:15,z:-75,rotation:2,scale:.62,y:1},{id:`landscape-center-southeast-hedge-02`,assetId:`nature-bush-large`,x:28,z:-75,rotation:357,scale:.62,y:1},{id:`landscape-center-southeast-hedge-03`,assetId:`nature-bush-large`,x:41,z:-75,rotation:4,scale:.62,y:1},{id:`landscape-center-southeast-hedge-04`,assetId:`nature-bush-large`,x:54,z:-75,rotation:359,scale:.62,y:1},{id:`landscape-center-southeast-hedge-05`,assetId:`nature-bush-large`,x:67,z:-75,rotation:3,scale:.62,y:1},{id:`landscape-center-flower-southwest-01`,assetId:`nature-bush-flowers`,x:-101,z:-74,rotation:18,scale:.68,y:1},{id:`landscape-center-flower-southwest-02`,assetId:`nature-bush-flowers`,x:-46,z:-74,rotation:339,scale:.68,y:1},{id:`landscape-center-flower-southeast-01`,assetId:`nature-bush-flowers`,x:7,z:-74,rotation:24,scale:.68,y:1},{id:`landscape-center-flower-southeast-02`,assetId:`nature-bush-flowers`,x:75,z:-74,rotation:344,scale:.68,y:1},{id:`landscape-center-garden-shrub-01`,assetId:`nature-bush`,x:-118,z:88,rotation:12,scale:.66,y:1},{id:`landscape-center-garden-shrub-02`,assetId:`nature-bush-flowers`,x:-85,z:95,rotation:325,scale:.66,y:1},{id:`landscape-center-garden-shrub-03`,assetId:`nature-bush`,x:-95,z:55,rotation:42,scale:.7,y:1},{id:`landscape-center-garden-shrub-04`,assetId:`nature-bush-flowers`,x:-65,z:55,rotation:307,scale:.7,y:1},{id:`landscape-center-garden-shrub-05`,assetId:`nature-bush`,x:66,z:91,rotation:8,scale:.66,y:1},{id:`landscape-center-garden-shrub-06`,assetId:`nature-bush-flowers`,x:96,z:92,rotation:331,scale:.66,y:1},{id:`landscape-center-garden-shrub-07`,assetId:`nature-bush`,x:123,z:88,rotation:21,scale:.64,y:1},{id:`landscape-center-stones-01`,assetId:`yard-stone-path`,x:-111,z:63,rotation:18,scale:.42,y:1},{id:`landscape-center-stones-02`,assetId:`yard-stone-path`,x:-53,z:36,rotation:282,scale:.4,y:1},{id:`landscape-center-stones-03`,assetId:`yard-stone-path`,x:63,z:18,rotation:72,scale:.4,y:1},{id:`landscape-center-stones-04`,assetId:`yard-stone-path`,x:89,z:61,rotation:15,scale:.42,y:1},{id:`landscape-center-understory-west-01`,assetId:`nature-bush-flowers`,x:-100,z:44,rotation:16,scale:.58,y:1},{id:`landscape-center-understory-west-02`,assetId:`nature-bush`,x:-83,z:42,rotation:338,scale:.6,y:1},{id:`landscape-center-understory-west-03`,assetId:`nature-bush-flowers`,x:-66,z:43,rotation:29,scale:.58,y:1},{id:`landscape-center-understory-west-04`,assetId:`nature-bush`,x:-49,z:48,rotation:351,scale:.6,y:1},{id:`landscape-center-understory-east-01`,assetId:`nature-bush-flowers`,x:47,z:27,rotation:22,scale:.55,y:1},{id:`landscape-center-understory-east-02`,assetId:`nature-bush`,x:48,z:43,rotation:342,scale:.56,y:1},{id:`landscape-center-understory-east-03`,assetId:`nature-bush-flowers`,x:47,z:59,rotation:13,scale:.55,y:1},{id:`landscape-center-lawn-west-01`,assetId:`nature-bush-flowers`,x:-95,z:25,rotation:17,scale:.7,y:1},{id:`landscape-center-lawn-west-02`,assetId:`nature-bush`,x:-75,z:24,rotation:337,scale:.72,y:1},{id:`landscape-center-lawn-west-03`,assetId:`nature-bush-flowers`,x:-55,z:26,rotation:31,scale:.68,y:1},{id:`landscape-center-courtyard-01`,assetId:`nature-bush`,x:-20,z:10,rotation:11,scale:.52,y:1},{id:`landscape-center-courtyard-02`,assetId:`nature-bush-flowers`,x:0,z:10,rotation:345,scale:.54,y:1},{id:`landscape-center-courtyard-03`,assetId:`nature-bush`,x:20,z:10,rotation:22,scale:.52,y:1}],updatedAt:`2026-07-19T11:50:00.000Z`},s9=`yardline.map-editor.document.v3`;function c9(){let e=l9(U4e);if(!e)throw Error(`The bundled Construction Loop map document is invalid.`);return{...e,route:e.route.map(e=>({...e})),objects:e.objects.map(e=>({...e})),updatedAt:new Date().toISOString()}}function l9(e){if(!e||typeof e!=`object`)return null;let t=e;return t.version!==3||typeof t.name!=`string`||!Array.isArray(t.route)||!Array.isArray(t.objects)||!t.route.every(u9)||!t.objects.every(G4e)?null:{version:3,id:typeof t.id==`string`?t.id:`construction-loop-kit`,name:t.name,presetRevision:Number.isSafeInteger(t.presetRevision)?t.presetRevision:void 0,seed:f9(t.seed,20260718),roadWidth:p9(f9(t.roadWidth,24),8,60),worldSize:p9(f9(t.worldSize,440),160,800),route:t.route,routeClosed:t.routeClosed===!0,roadPaths:Array.isArray(t.roadPaths)&&t.roadPaths.every(W4e)?t.roadPaths.map(e=>({points:e.points,width:p9(f9(e.width,f9(t.roadWidth,24)),12,40),sidewalks:e.sidewalks!==!1})):void 0,objects:t.objects,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:new Date().toISOString()}}function W4e(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.points)&&t.points.length>=2&&t.points.every(u9)&&Number.isFinite(t.width)&&(t.sidewalks===void 0||typeof t.sidewalks==`boolean`)}function u9(e){if(!e||typeof e!=`object`)return!1;let t=e;return Number.isFinite(t.x)&&Number.isFinite(t.z)}function G4e(e){if(!u9(e))return!1;let t=e;return typeof t.id==`string`&&typeof t.assetId==`string`&&Number.isFinite(t.rotation)&&d9(t.rotationX)&&d9(t.rotationZ)&&Number.isFinite(t.scale)&&d9(t.y)&&d9(t.scaleX)&&d9(t.scaleY)&&d9(t.scaleZ)}function d9(e){return e===void 0||typeof e==`number`&&Number.isFinite(e)}function f9(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function p9(e,t,n){return Math.max(t,Math.min(n,e))}var m9=null,h9=null,g9=new Set;function K4e(e,t){m9=e,h9=t,_9()}function q4e(e){h9=e,_9()}function J4e(e){m9===e&&(m9=null,h9=null,_9())}function Y4e(e){return g9.add(e),e(h9??X4e(),m9),()=>{g9.delete(e)}}function _9(){let e=h9??X4e();g9.forEach(t=>t(e,m9))}function X4e(){return{mode:`move`,snapEnabled:!0,dirty:!1,canUndo:!1,objectCount:0,status:`Loading 3D editor`,selection:null}}var Z4e=`yardlineMapEditor`,Q4e=60,$4e=class{constructor(e,t){this.history=[],this.selectedId=null,this.mode=`move`,this.snapEnabled=!0,this.dirty=!1,this.status=`Click any object to edit it`,this.dragHistoryCaptured=!1,this.onKeyDown=e=>{e3e(e.target)||((e.metaKey||e.ctrlKey)&&e.code===`KeyS`&&(e.preventDefault(),this.save()),(e.metaKey||e.ctrlKey)&&e.code===`KeyZ`&&(e.preventDefault(),this.undo()),(e.metaKey||e.ctrlKey)&&e.code===`KeyD`&&(e.preventDefault(),this.duplicateSelected()),(e.code===`Delete`||e.code===`Backspace`)&&(e.preventDefault(),this.deleteSelected()),e.code===`Escape`&&this.deselect(),e.code===`KeyF`&&this.frameSelected())},this.scene=e,this.root=t.root,this.instances=t.instances,this.instantiate=t.instantiate,this.document=v9(t.document),this.highlight=new dk(`map-fly-editor-selection`,e,{blurHorizontalSize:.6,blurVerticalSize:.6}),this.highlight.innerGlow=!1,this.highlight.outerGlow=!0,this.gizmos=new lhe(e,1.35),this.gizmos.usePointerToAttachGizmos=!1,this.gizmos.clearGizmoOnEmptyPointerEvent=!1,this.gizmos.scaleRatio=.8,this.setMode(`move`),this.pointerObserver=e.onPointerObservable.add(e=>{if(e.type!==hn.POINTERDOWN||e.event.button!==0||this.gizmos.isHovered||this.gizmos.isDragging)return;let t=e.pickInfo?.pickedMesh,n=t?this.findEditableInstance(t):null;n?this.select(this.metadataFor(n)?.objectId??null):this.deselect()}),window.addEventListener(`keydown`,this.onKeyDown),K4e(this,this.getState())}dispose(){window.removeEventListener(`keydown`,this.onKeyDown),this.scene.onPointerObservable.remove(this.pointerObserver),J4e(this),this.highlight.dispose(),this.gizmos.dispose()}setMode(e){this.mode=e,this.gizmos.positionGizmoEnabled=e===`move`,this.gizmos.rotationGizmoEnabled=e===`rotate`,this.gizmos.scaleGizmoEnabled=e===`scale`,this.configureGizmoEvents(),this.applySnapSettings(),this.attachSelectedGizmo(),this.status=`${e[0].toUpperCase()}${e.slice(1)} tool active`,this.publish()}setSnapEnabled(e){this.snapEnabled=e,this.applySnapSettings(),this.status=e?`Snapping enabled`:`Free transform enabled`,this.publish()}updateSelected(e){let t=this.selectedObject(),n=this.selectedInstance(),r=t?r9(t.assetId):null;if(!t||!n||!r)return;this.captureHistory(),e.x!==void 0&&(t.x=y9(e.x,t.x)),e.y!==void 0&&(t.y=y9(e.y,t.y??0)),e.z!==void 0&&(t.z=y9(e.z,t.z)),e.rotationX!==void 0&&(t.rotationX=x9(y9(e.rotationX,t.rotationX??0))),e.rotation!==void 0&&(t.rotation=x9(y9(e.rotation,t.rotation))),e.rotationZ!==void 0&&(t.rotationZ=x9(y9(e.rotationZ,t.rotationZ??0)));let i=b9(t.scale,1);e.scaleX!==void 0&&(t.scaleX=b9(e.scaleX/i,t.scaleX??1)),e.scaleY!==void 0&&(t.scaleY=b9(e.scaleY/i,t.scaleY??1)),e.scaleZ!==void 0&&(t.scaleZ=b9(e.scaleZ/i,t.scaleZ??1)),r3e(n,t,r),this.markChanged(`Transform updated`)}deselect(){this.selectedId=null,this.gizmos.attachToNode(null),this.highlight.removeAllMeshes(),this.status=`Click any object to edit it`,this.publish()}frameSelected(){let e=this.selectedInstance(),t=this.scene.activeCamera;if(!e||!t||typeof Reflect.get(t,`setTarget`)!=`function`)return;let n=e.getHierarchyBoundingVectors(!0),r=n.min.add(n.max).scale(.5),i=Math.max(4,n.max.subtract(n.min).length()),a=t.position.subtract(r).normalize();t.position.copyFrom(r.add(a.scale(Math.max(10,i*1.35)))),t.setTarget(r),this.status=`Focused selected object`,this.publish()}save(){this.document.updatedAt=new Date().toISOString(),localStorage.setItem(s9,JSON.stringify(this.document)),this.dirty=!1,this.status=`3D draft saved locally`,this.publish()}async undo(){let e=this.history.pop();e&&(await this.restoreDocument(e),this.dirty=!0,this.status=`Undo complete`,this.publish())}async duplicateSelected(){let e=this.selectedObject();if(!e)return;this.captureHistory();let t={...e,id:o3e(),x:S9(e.x+2),z:S9(e.z+2)};this.document.objects.push(t);let n=await this.instantiate(t);n&&this.instances.set(t.id,n),this.select(t.id),this.markChanged(`Object duplicated`)}deleteSelected(){let e=this.selectedId;e&&(this.captureHistory(),this.document.objects=this.document.objects.filter(t=>t.id!==e),this.instances.get(e)?.dispose(!1,!1),this.instances.delete(e),this.selectedId=null,this.gizmos.attachToNode(null),this.highlight.removeAllMeshes(),this.markChanged(`Object deleted`))}async addObject(e){let t=r9(e),n=this.scene.activeCamera;if(!t||!n)return;let r=n.getForwardRay(),i=Math.abs(r.direction.y)>.001?(1-r.origin.y)/r.direction.y:24,a=i>2?Math.min(i,500):24,o=r.origin.add(r.direction.scale(a));await this.placeObject(t,o.x,o.z)}async addObjectAt(e,t,n){let r=r9(e),i=this.scene.activeCamera;if(!r||!i)return;let a=this.scene.createPickingRay(t,n,null,i),o=r.isRoad?i9:1,s=Math.abs(a.direction.y)>.001?(o-a.origin.y)/a.direction.y:-1;if(s<=0||s>2e3){await this.addObject(e);return}let c=a.origin.add(a.direction.scale(s));await this.placeObject(r,c.x,c.z)}async placeObject(e,t,n){this.captureHistory();let r={id:o3e(),assetId:e.id,x:S9(t),z:S9(n),rotation:0,scale:1,...e.isRoad?{y:i9}:{}};this.document.objects.push(r);let i=await this.instantiate(r);i&&this.instances.set(r.id,i),this.select(r.id),this.markChanged(`${e.label} placed — drag the gizmo to fine-tune`)}async replaceSelected(e){let t=this.selectedObject(),n=r9(e);if(!t||!n)return;this.captureHistory();let r=t.id;this.instances.get(r)?.dispose(!1,!1),this.instances.delete(r),t.assetId=e,n.isRoad&&t.y===void 0&&(t.y=i9);let i=await this.instantiate(t);i&&this.instances.set(r,i),this.select(r),this.markChanged(`Replaced with ${n.label}`)}testDrive(){this.save(),window.location.href=`/?map=construction-loop&editorDraft=1&seed=${this.document.seed}`}select(e){if(!e||!this.instances.has(e)){this.deselect();return}this.selectedId=e,this.highlight.removeAllMeshes(),this.instances.get(e).getChildMeshes().forEach(e=>{e.getTotalVertices()>0&&this.highlight.addMesh(e,P.FromHexString(`#e0a15d`))}),this.attachSelectedGizmo();let t=this.selectedAsset()?.label??`Object`;this.status=`${t} selected`,this.publish()}attachSelectedGizmo(){this.gizmos.attachToNode(this.selectedInstance())}configureGizmoEvents(){let e=this.mode===`move`?this.gizmos.gizmos.positionGizmo:this.mode===`rotate`?this.gizmos.gizmos.rotationGizmo:this.gizmos.gizmos.scaleGizmo;!e||Reflect.get(e,`__yardlineBound`)||(Reflect.set(e,`__yardlineBound`,!0),e.onDragStartObservable.add(()=>{this.dragHistoryCaptured||=(this.captureHistory(),!0)}),e.onDragEndObservable.add(()=>{this.dragHistoryCaptured=!1,this.syncSelectedFromScene(),this.markChanged(`Transform updated`)}))}applySnapSettings(){let e=this.gizmos.gizmos.positionGizmo,t=this.gizmos.gizmos.rotationGizmo,n=this.gizmos.gizmos.scaleGizmo;e&&(e.snapDistance=+!!this.snapEnabled),t&&(t.snapDistance=this.snapEnabled?Math.PI/12:0),n&&(n.snapDistance=this.snapEnabled?.05:0,n.incrementalSnap=!0)}syncSelectedFromScene(){let e=this.selectedObject(),t=this.selectedInstance(),n=e?r9(e.assetId):null;if(!e||!t||!n)return;e.x=S9(t.position.x),e.y=S9(a3e(n,t.position.y)),e.z=S9(t.position.z);let r=t.rotationQuaternion?.toEulerAngles()??t.rotation;e.rotationX=S9(x9(r.x*180/Math.PI)),e.rotation=S9(x9(r.y*180/Math.PI-(n.rotationOffset??0))),e.rotationZ=S9(x9(r.z*180/Math.PI));let i=n.defaultScale*e.scale;e.scaleX=S9(b9(t.scaling.x/i,1)),e.scaleY=S9(b9(t.scaling.y/i,1)),e.scaleZ=S9(b9(t.scaling.z/i,1))}captureHistory(){this.history.push(v9(this.document)),this.history.length>Q4e&&this.history.shift()}async restoreDocument(e){let t=new Set(e.objects.map(e=>e.id));for(let[e,n]of this.instances)t.has(e)||(n.dispose(!1,!1),this.instances.delete(e));this.document=v9(e);for(let e of this.document.objects){let t=this.instances.get(e.id),n=t?this.metadataFor(t):null;if(t&&n?.assetId===e.assetId){let n=r9(e.assetId);n&&r3e(t,e,n);continue}t?.dispose(!1,!1);let r=await this.instantiate(e);r&&this.instances.set(e.id,r)}this.selectedId&&this.instances.has(this.selectedId)?this.select(this.selectedId):this.deselect()}findEditableInstance(e){let t=e;for(;t&&t!==this.root;){if(this.metadataFor(t))return t;t=t.parent}return null}metadataFor(e){let t=e.metadata?.[Z4e];return!t||typeof t!=`object`?null:t}selectedObject(){return this.selectedId?this.document.objects.find(e=>e.id===this.selectedId)??null:null}selectedInstance(){return this.selectedId?this.instances.get(this.selectedId)??null:null}selectedAsset(){let e=this.selectedObject();return e?r9(e.assetId)??null:null}markChanged(e){this.dirty=!0,this.status=e,this.document.updatedAt=new Date().toISOString(),this.publish()}getState(){let e=this.selectedObject(),t=e?r9(e.assetId):null;return{mode:this.mode,snapEnabled:this.snapEnabled,dirty:this.dirty,canUndo:this.history.length>0,objectCount:this.document.objects.length,status:this.status,selection:e&&t?n3e(e,t):null}}publish(){q4e(this.getState())}};function e3e(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable||!!e.closest(`[contenteditable="true"]`)}function t3e(e,t){e.metadata={...e.metadata,[Z4e]:{objectId:t.id,assetId:t.assetId}},e.getChildMeshes().forEach(e=>{e.unfreezeWorldMatrix(),e.isPickable=!0})}function n3e(e,t){return{id:e.id,assetId:e.assetId,label:t.label,x:S9(e.x),y:S9(e.y??0),z:S9(e.z),rotationX:S9(e.rotationX??0),rotation:S9(e.rotation),rotationZ:S9(e.rotationZ??0),scaleX:S9(e.scale*(e.scaleX??1)),scaleY:S9(e.scale*(e.scaleY??1)),scaleZ:S9(e.scale*(e.scaleZ??1))}}function r3e(e,t,n){e.position.set(t.x,i3e(n,t),t.z),e.rotationQuaternion=A.FromEulerAngles((t.rotationX??0)*Math.PI/180,(t.rotation+(n.rotationOffset??0))*Math.PI/180,(t.rotationZ??0)*Math.PI/180);let r=n.defaultScale*t.scale;e.scaling.set(r*(t.scaleX??1),r*(t.scaleY??1),r*(t.scaleZ??1)),e.computeWorldMatrix(!0)}function i3e(e,t){let n=t.y??1;return e.category===`roads`?t.y??1.8:e.category===`markings`?t.y??1.24:e.category===`sidewalks`?(t.y??0)+1.18:e.id===`driveway`||e.id.startsWith(`downtown-floor-`)?n+.025:n+.03}function a3e(e,t){return e.category===`roads`||e.category===`markings`?t:e.category===`sidewalks`?t-1.18:e.id===`driveway`||e.id.startsWith(`downtown-floor-`)?t-.025:t-.03}function v9(e){return structuredClone(e)}function o3e(){return typeof crypto.randomUUID==`function`?crypto.randomUUID():`object-${Date.now()}-${Math.random()}`}function y9(e,t){return Number.isFinite(e)?e:t}function b9(e,t){return Number.isFinite(e)?Math.max(.05,e):t}function x9(e){return(e%360+360)%360}function S9(e){return Math.round(e*100)/100}var C9={mass:0,friction:.98,restitution:.01},w9=1,s3e=1.18,c3e=.18,l3e=1.18,u3e=1.24,d3e=[{x:-80,z:-80},{x:80,z:-80},{x:80,z:80},{x:-80,z:80}];async function f3e(e,t,n,r){let i=(t.route.length>=4?t.route:d3e).map(e=>new j(e.x,1.9,e.z)),a=t.roadPaths??(t.route.length>=2?[{points:t.route,width:t.roadWidth,sidewalks:!0}]:[]),o=new wc(`${r}-${n}`,e),s=new URLSearchParams(window.location.search).get(`fly`)===`1`;e.clearColor=fe.FromHexString(`#75b7d2ff`),e.ambientColor=P.FromHexString(`#91a99a`),e.fogMode=x.FOGMODE_LINEAR,e.fogStart=s?t.worldSize*1.05:270,e.fogEnd=s?t.worldSize*1.75:455,e.fogColor=P.FromHexString(s?`#a6c5ce`:`#82bad0`);let c=new K_(`${r}-sky`,new j(.12,1,.08),e);c.intensity=.7,c.diffuse=P.FromHexString(`#fffbed`),c.groundColor=P.FromHexString(`#43574b`);let l=new GC(`${r}-sun`,new j(-.5,-1,.36),e);l.position.set(t.worldSize*.35,160,-t.worldSize*.45),l.intensity=1.12,l.diffuse=P.FromHexString(`#fff3d6`);let u=new jT(1536,l);u.usePercentageCloserFiltering=!0,u.filteringQuality=jT.QUALITY_MEDIUM,u.bias=8e-4,u.normalBias=.025;let d=P4e(e);d.grass.diffuseColor=P.FromHexString(`#8eaa68`),d.asphalt.diffuseColor=P.FromHexString(`#697173`),d.concrete.diffuseColor=P.FromHexString(`#ddd8cc`);let f=vm.CreateBox(`${r}-ground`,{width:t.worldSize,height:.4,depth:t.worldSize},e);f.position.y=w9-.4,f.material=d.grass,f.receiveShadows=!0,f.parent=o,G7(f,`grass`);let p=[new ZO(f,YO.BOX,C9,e)],m=h3e(e,`${r}-construction-dirt`);t.id.startsWith(`construction-loop`)&&g3e(e,o,m,p);let h=new F4e(e,o,u,{maxVisibleDistance:s?void 0:470}),g=t.objects.flatMap(e=>{let t=r9(e.assetId);return t?[{object:e,asset:t}]:[]}),_=new Map;await h.preload(g.map(({asset:e})=>e));let v=async(e,t)=>{let n=await h.instantiate({rootUrl:t.rootUrl,file:t.file,name:`${r}-${e.id}`,position:new j(e.x,_3e(t,e),e.z),rotation:new j((e.rotationX??0)*Math.PI/180,(e.rotation+(t.rotationOffset??0))*Math.PI/180,(e.rotationZ??0)*Math.PI/180),scale:v3e(t,e),castShadows:!t.isRoad&&t.category!==`markings`,pbrTuning:t.pbrTuning});return s&&(t3e(n,e),_.set(e.id,n)),n};for(let{object:t,asset:n}of g){let r=await v(t,n);if(n.isRoad||n.category===`sidewalks`||n.meshCollision){r.getChildMeshes().forEach(e=>{e.getTotalVertices()>0&&G7(e,`asphalt`)}),p3e(e,r,p);continue}let i=y3e(e,o,t,n);i&&p.push(new ZO(i,YO.BOX,C9,e))}g.some(({asset:e})=>e.isRoad)||m3e(e,o,a,p,d.asphalt);let y=s?new $4e(e,{document:t,root:o,instances:_,instantiate:async e=>{let t=r9(e.assetId);return t?v(e,t):null}}):void 0,b=i[1].subtract(i[0]).normalize(),S=new j(b.z,0,-b.x),C=Math.atan2(b.x,b.z),w=i[0].add(b.scale(12));return{root:o,trackPoints:i,checkpoints:i,spawnPositions:Array.from({length:8},(e,t)=>{if(t===0)return w.add(new j(0,.34,0));let n=t-1,r=Math.floor(n/2)+1,i=n%2==0?-1:1;return w.add(S.scale(i*1.7)).add(b.scale(-r*5.6)).add(new j(0,.34,0))}),startHeading:C,collectiblePositions:i.filter((e,t)=>t%4==0).map(e=>e.add(new j(0,.65,0))),seed:n,shadowGenerator:u,dispose:()=>{y?.dispose(),p.forEach(e=>e.dispose()),h.dispose(),m.dispose(!0,!0),Object.values(d).forEach(e=>e.dispose(!0,!0)),u.dispose(),c.dispose(),l.dispose(),o.dispose(!1,!0)}}}function p3e(e,t,n){t.getChildMeshes().forEach(t=>{t.getTotalVertices()!==0&&n.push(new ZO(t,YO.MESH,C9,e))})}function m3e(e,t,n,r,i){n.forEach((n,a)=>{for(let o=0;ob3e(e,t.seed)},S3e=[E9],C3e=E9.metadata.id,w3e=S3e,T3e=new Map(S3e.map(e=>[e.metadata.id,e]));function D9(e){return e?T3e.get(e)??E9:E9}function E3e(e,t){return Number.isSafeInteger(t)?t>>>0:e.defaultSeed>>>0}async function D3e(e,t,n){let r=D9(t),i=E3e(r,n),a=await r.build(e,{seed:i});return O3e(r,a.trackPoints,a.spawnPositions,a.collectiblePositions),{definition:r,seed:i,world:a}}function O3e(e,t,n,r){let i=`Map "${e.metadata.id}"`;if(t.length<4)throw Error(`${i} needs at least four track points.`);if(n.length<8)throw Error(`${i} needs at least eight spawn positions.`);if(r.length===0)throw Error(`${i} needs at least one collectible position.`);if([...t,...n,...r].some(e=>![e.x,e.y,e.z].every(Number.isFinite)))throw Error(`${i} contains a non-finite position.`)}var O9=1/60,k9=4,k3e=1e3/15;function A3e(){let e=new URLSearchParams(window.location.search),t=Number(e.get(`seed`));return{mapId:e.get(`map`),seed:Number.isSafeInteger(t)?t:void 0}}function j3e(){return new URLSearchParams(window.location.search).get(`fly`)===`1`}var M3e=class{constructor(e,t={}){this.lastTelemetryAt=0,this.lastCheckpoint=1,this.selectedCarId=`sports-car`,this.currentMapId=C3e,this.currentMapSeed=0,this.currentSurface=`asphalt`,this.surfaceGripMultiplier=1,this.surfaceAccelerationMultiplier=1,this.turboMultiplier=1,this.utilityStunSeconds=0,this.wrongWayVisible=!1,this.disposed=!1,this.onEscape=e=>{e.code===`Escape`&&this.togglePause()},this.onVisibility=()=>{document.hidden&&this.race?.getPhase()===`racing`&&this.togglePause()},this.onResize=()=>this.engine?.resize(),this.canvas=e,this.callbacks=t}async initialize(){if(!(this.engine||this.disposed))try{let e=new Ih(this.canvas,!0,{adaptToDeviceRatio:!1,audioEngine:!0,antialias:!0,preserveDrawingBuffer:!1,stencil:!0,powerPreference:`high-performance`,deterministicLockstep:!0,lockstepMaxSteps:k9,timeStep:O9});this.engine=e;let t=Math.max(1,window.devicePixelRatio||1),n=matchMedia(`(pointer: coarse)`).matches;e.setHardwareScalingLevel(n?Math.max(1,t/1.45):Math.max(1,t/1.75));let r=new x(e);this.scene=r,r.skipPointerMovePicking=!0,r.autoClear=!0,r.getEngine().enableOfflineSupport=!0;let i=await ts();if(this.disposed)return;let a=new Uze(!1,i);r.enablePhysics(new j(0,-9.81,0),a),r.getPhysicsEngine()?.setTimeStep(O9);let o=A3e(),s=await D3e(r,o.mapId,o.seed),c=s.world;if(this.world=c,this.currentMapId=s.definition.metadata.id,this.currentMapSeed=s.seed,j3e()){c.root.setEnabled(!0),r.physicsEnabled=!1,this.flyCamera=new N2e(r,this.canvas,c.trackPoints),window.addEventListener(`resize`,this.onResize),e.runRenderLoop(()=>{this.disposed||!this.scene||this.scene.render()}),this.callbacks.onReady?.(),this.callbacks.onPhaseChange?.(`menu`);return}c.root.setEnabled(!1);let l=c.spawnPositions[0],u=v2e(r,c.shadowGenerator,l);this.car=u,u.chassis.rotationQuaternion=A.RotationAxis(j.Up(),c.startHeading),u.presentationRoot.rotationQuaternion=u.chassis.rotationQuaternion.clone(),this.presenter=new y2e(r,u.chassis,u.presentationRoot,O9,k9),this.driftVisual=new S2e(r,u.presentationRoot,u.driftRoot),this.disposeImportedCar=await _7(u,r,c.shadowGenerator,this.selectedCarId),this.controller=this.buildVehicleController(this.selectedCarId),this.input=new F2e;let d={position:l.clone(),rotation:A.RotationAxis(j.Up(),c.startHeading)};this.recovery=new x4e(r,u.aggregate.body,d),this.surfaces=new C4e(r,u.aggregate.body),this.wrongWay=new O4e(c.trackPoints),this.abilities=new g4e(r,u.aggregate.body,{getTargets:()=>[{id:`player`,body:u.aggregate.body,radius:.72},...this.opponents?.abilityTargets??[]],callbacks:{onInventoryChange:e=>{e.rolling?this.callbacks.onPowerup?.(`SELECTING…`,0,!0):this.callbacks.onPowerup?.(e.item?M4e[e.item]:null,e.charges,!1)},onTurboChanged:(e,t)=>{this.turboMultiplier=t},onTargetDisabled:(e,t)=>{e===`player`?this.utilityStunSeconds=Math.max(this.utilityStunSeconds,t):this.opponents?.disable(e,t)},onOilContact:(e,t,n)=>{e!==`player`&&this.opponents?.slow(e,t,n)},onAbilityUsed:e=>{e.type===`oil-slick`&&!e.targetId&&this.surfaces?.addOilPatch(e.position,1.85,11)}}});let f=new gh(`menu-camera`,Math.PI*1.18,Math.PI*.34,58,new j(8,0,2),r);f.lowerRadiusLimit=34,f.upperRadiusLimit=70,f.lowerBetaLimit=.35,f.upperBetaLimit=1.35,f.minZ=.08,f.maxZ=260,f.fov=.72,this.menuCamera=f;let p=new $2e(r,{initialCarId:this.selectedCarId,quality:n?`low`:`balanced`});this.frontend=p,await p.initialize(),p.setMode(`attract`,!0);let m=new E2e(r,this.canvas,u.presentationRoot,{enableMotionBlur:!n});this.followCamera=m,r.activeCamera=p.camera,this.installRaceSystems(c),r.onBeforePhysicsObservable.add(()=>this.beforePhysics()),r.onAfterPhysicsObservable.add(()=>this.afterPhysics()),window.addEventListener(`resize`,this.onResize),window.addEventListener(`keydown`,this.onEscape),document.addEventListener(`visibilitychange`,this.onVisibility),e.runRenderLoop(()=>{this.disposed||!this.scene||(this.presenter?.beginFrame(Math.min(e.getDeltaTime()/1e3,O9*k9)),this.scene.render())}),this.callbacks.onReady?.(),this.callbacks.onPhaseChange?.(`menu`)}catch(e){let t=e instanceof Error?e:Error(`Unable to initialize the game runtime.`);this.callbacks.onError?.(t)}}async startRace(e){if(e?.mapId&&await this.loadMap(e.mapId,e.seed),!this.race||!this.controller||!this.scene||!this.followCamera)return;e?.laps&&this.race.setTotalLaps(e.laps),e?.carId&&h7(e.carId)&&e.carId!==this.selectedCarId&&(this.selectedCarId=e.carId,this.disposeImportedCar?.(),this.car&&this.world&&(this.disposeImportedCar=await _7(this.car,this.scene,this.world.shadowGenerator,this.selectedCarId),this.controller=this.buildVehicleController(this.selectedCarId)));let t=this.world?.spawnPositions[0],n=this.world?.startHeading;!t||n===void 0||(this.controller.respawn({position:t.clone(),rotation:A.RotationAxis(j.Up(),n)}),this.presenter?.resetToPhysicsPose(),this.driftVisual?.reset(),this.lastCheckpoint=1,this.opponents?.reset(),this.pickups?.reset(),this.abilities?.reset(),this.surfaces?.clear(),this.recovery?.reset({position:t.clone(),rotation:A.RotationAxis(j.Up(),n)}),this.wrongWay?.reset(),this.currentSurface=`asphalt`,this.surfaceGripMultiplier=1,this.surfaceAccelerationMultiplier=1,this.turboMultiplier=1,this.utilityStunSeconds=0,this.wrongWayVisible=!1,this.callbacks.onPowerup?.(null),this.world?.root.setEnabled(!0),this.followCamera.activate(),this.frontend?.setMode(`hidden`),this.race.start())}setFrontendPreview(e,t){!this.frontend||this.race?.getPhase()!==`menu`||(this.world?.root.setEnabled(!1),t&&h7(t)&&this.frontend.selectCar(t),this.frontend.setMode(e))}togglePause(){this.race&&this.race.togglePause()}setTouchDrive(e,t){this.input?.setTouchDrive(e,t)}setTouchBrake(e){this.input?.setTouchBrake(e)}setTouchHandbrake(e){this.input?.setTouchHandbrake(e)}requestReset(){this.input?.requestReset()}usePowerup(){this.input?.requestUsePowerup()}returnToMenu(){!this.scene||!this.menuCamera||!this.race||!this.world||(this.scene.physicsEnabled=!0,this.world.root.setEnabled(!1),this.frontend?.setMode(`attract`,!0),this.scene.activeCamera=this.frontend?.camera??this.menuCamera,this.controller?.respawn({position:this.world.spawnPositions[0].clone(),rotation:A.RotationAxis(j.Up(),this.world.startHeading)}),this.presenter?.resetToPhysicsPose(),this.driftVisual?.reset(),this.race.returnToMenu())}setGraphicsQuality(e){if(!this.engine)return;let t=Math.max(1,window.devicePixelRatio||1),n=e===`performance`?1:e===`balanced`?1.45:2;this.engine.setHardwareScalingLevel(Math.max(1,t/n)),this.world&&(this.world.shadowGenerator.getShadowMap().refreshRate=e===`performance`?2:1)}dispose(){this.disposed||(this.disposed=!0,window.removeEventListener(`resize`,this.onResize),window.removeEventListener(`keydown`,this.onEscape),document.removeEventListener(`visibilitychange`,this.onVisibility),this.disposeImportedCar?.(),this.input?.dispose(),this.opponents?.dispose(),this.pickups?.dispose(),this.abilities?.dispose(),this.followCamera?.dispose(),this.presenter?.dispose(),this.driftVisual?.dispose(),this.flyCamera?.dispose(),this.frontend?.dispose(),this.car?.dispose(),this.world?.dispose(),this.scene?.dispose(),this.engine?.dispose())}beforePhysics(){if(!this.controller||!this.input||!this.race||!this.car)return;let e=this.race.getPhase(),t=this.input.sample();this.utilityStunSeconds=Math.max(0,this.utilityStunSeconds-O9);let n=e===`racing`&&this.utilityStunSeconds<=0;n&&t.usePowerup&&this.abilities?.use(),this.abilities?.update(O9);let r=this.surfaces?.sample(this.car.chassis.absolutePosition);r&&(this.currentSurface=r.type,this.surfaceGripMultiplier=r.gripMultiplier,this.surfaceAccelerationMultiplier=r.accelerationMultiplier),this.controller.setDriveMultipliers(this.surfaceAccelerationMultiplier*this.turboMultiplier,this.surfaceGripMultiplier);let i=n?{throttle:t.throttle,steer:t.steering,brake:t.brake,handbrake:t.handbrake,reset:!1}:{throttle:0,steer:0,brake:1,handbrake:!1,reset:!1};if(this.controller.update(O9,i),this.opponents?.update(O9,this.car.chassis.absolutePosition),n){let e=this.recovery?.update(O9,{upDot:this.controller.state.upDot,speed:this.controller.state.speed,throttle:t.throttle,grounded:!this.controller.state.airborne,outOfBounds:this.car.chassis.absolutePosition.y<-3,manualSelfRight:t.reset});e?.penaltyMs&&this.race.addPenalty(e.penaltyMs)}}installRaceSystems(e){if(!this.scene)return;let t=this.scene;this.race=new I2e({checkpoints:e.checkpoints,totalLaps:3,onPhaseChange:e=>{t.physicsEnabled=e!==`paused`,this.opponents?.setRacing(e===`racing`),this.callbacks.onPhaseChange?.(e)},onResult:this.callbacks.onResult}),this.opponents=new W2e(t,e.shadowGenerator,e.trackPoints,e.spawnPositions.slice(1),e.startHeading),this.opponents.load(7),this.pickups=new J2e(t,e.collectiblePositions,()=>this.abilities?.collect(void 0,1)??!1)}async loadMap(e,t){if(!this.scene||!this.car)return;let n=D9(e),r=E3e(n,t);if(n.metadata.id===this.currentMapId&&r===this.currentMapSeed)return;let i=this.scene,a=i.physicsEnabled;i.physicsEnabled=!1;try{let n=await D3e(i,e,t),r=n.world;r.root.setEnabled(!1),this.opponents?.dispose(),this.pickups?.dispose(),this.world?.dispose(),this.world=r,this.currentMapId=n.definition.metadata.id,this.currentMapSeed=n.seed;let a=r.spawnPositions[0],o={position:a.clone(),rotation:A.RotationAxis(j.Up(),r.startHeading)};this.car.chassis.position.copyFrom(a),this.car.chassis.rotationQuaternion=o.rotation.clone(),this.presenter?.resetToPhysicsPose(),this.driftVisual?.reset(),this.disposeImportedCar?.(),this.disposeImportedCar=await _7(this.car,i,r.shadowGenerator,this.selectedCarId),this.controller=this.buildVehicleController(this.selectedCarId),this.recovery=new x4e(i,this.car.aggregate.body,o),this.surfaces=new C4e(i,this.car.aggregate.body),this.wrongWay=new O4e(r.trackPoints),this.installRaceSystems(r)}finally{i.physicsEnabled=a}}buildVehicleController(e){if(!this.scene||!this.car||!this.world)throw Error(`Vehicle controller cannot be built before the world and car exist.`);let t=g7(e);this.car.aggregate.body.setMassProperties({mass:t.physics.mass}),this.car.aggregate.shape.material={friction:t.physics.friction,restitution:t.physics.restitution};let n=this.car.wheelVisuals;return new r4e(this.scene,this.car.aggregate.body,{config:f2e(t),wheelVisuals:n,spawnPose:{position:this.world.spawnPositions[0].clone(),rotation:A.RotationAxis(j.Up(),this.world.startHeading)}})}afterPhysics(){if(this.presenter?.capturePhysicsPose(),!this.controller||!this.car||!this.race)return;this.driftVisual?.setVehicleState(this.controller.state);let e=performance.now(),t=this.race.getPhase();(t===`countdown`||t===`racing`)&&this.race.update(this.car.chassis.absolutePosition,e);let n=this.race.telemetry(this.controller.speedKph,this.controller.airborne,e);n.racers=8,n.surface=this.currentSurface,n.boost=Math.min(1,(this.abilities?.state.activeTurboSeconds??0)/2.65),n.direction=N3e(this.world?.trackPoints,this.car.chassis.absolutePosition);let r=this.wrongWay?.update(O9,this.car.chassis.absolutePosition,this.car.aggregate.body.getLinearVelocity());if(this.wrongWayVisible=!!(r?.wrongWay&&r.blinkVisible),n.wrongWay=this.wrongWayVisible,n.checkpoint!==this.lastCheckpoint&&t===`racing`){this.lastCheckpoint=n.checkpoint;let e=this.world?.trackPoints;if(!e)return;let t=n.checkpoint===0?e.length-1:Math.max(0,n.checkpoint-1),r=e[t],i=e[(t+1)%e.length],a=Math.atan2(i.x-r.x,i.z-r.z);this.controller.setCheckpoint({position:r.add(new j(0,.9,0)),rotation:A.RotationAxis(j.Up(),a)}),this.recovery?.setCheckpoint({position:r.add(new j(0,.9,0)),rotation:A.RotationAxis(j.Up(),a)})}e-this.lastTelemetryAt>=k3e&&(this.lastTelemetryAt=e,this.callbacks.onTelemetry?.(n)),this.pickups?.update(O9,this.car.chassis.absolutePosition,t===`racing`)}};function N3e(e,t){if(!e||e.length<3)return`straight`;let n=0,r=1/0;for(let i=0;i0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.z-a.z)*c)/l)):0,d=t.x-(a.x+s*u),f=t.z-(a.z+c*u),p=d*d+f*f;p2.45?`u-turn`:l>0?`right`:`left`}var A9={brand:`_brand_z92v3_1`,mark:`_mark_z92v3_11`,type:`_type_z92v3_28`,compact:`_compact_z92v3_48`,inverted:`_inverted_z92v3_65`},P3e=r((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),$=r(((e,t)=>{t.exports=P3e()}))();function F3e({compact:e=!1,className:t=``,inverted:n=!1}){return(0,$.jsxs)(`div`,{className:`${A9.brand} ${e?A9.compact:``} ${n?A9.inverted:``} ${t}`,"aria-label":`Yardline RC`,children:[(0,$.jsxs)(`svg`,{className:A9.mark,viewBox:`0 0 56 56`,"aria-hidden":`true`,children:[(0,$.jsx)(`path`,{d:`M8 12h29l11 10v22H19L8 33V12Z`}),(0,$.jsx)(`path`,{d:`m16 20 10 9h15M26 29v10`}),(0,$.jsx)(`path`,{d:`M38 12v10h10`})]}),(0,$.jsxs)(`span`,{className:A9.type,children:[(0,$.jsx)(`strong`,{children:`YARDLINE`}),(0,$.jsx)(`small`,{children:`RC RACING CLUB`})]})]})}function j9(e,t,n){return Math.min(n,Math.max(t,e))}function M9(e){if(e===void 0||!Number.isFinite(e))return`--:--.---`;let t=Math.max(0,e),n=Math.floor(t/6e4),r=Math.floor(t%6e4/1e3),i=Math.floor(t%1e3);return`${n}:${r.toString().padStart(2,`0`)}.${i.toString().padStart(3,`0`)}`}function I3e(e){return e===void 0||!Number.isFinite(e)?`—`:e===0?`WINNER`:`+${(Math.max(0,e)/1e3).toFixed(3)}`}var N9={hud:`_hud_wiqib_1`,topLeft:`_topLeft_wiqib_25`,topRight:`_topRight_wiqib_26`,positionBlock:`_positionBlock_wiqib_27`,speedBlock:`_speedBlock_wiqib_28`,directionMarker:`_directionMarker_wiqib_29`,alert:`_alert_wiqib_30`,minimap:`_minimap_wiqib_31`,lapPanel:`_lapPanel_wiqib_44`,powerSlot:`_powerSlot_wiqib_45`,timePanel:`_timePanel_wiqib_46`,boostTrack:`_boostTrack_wiqib_99`,"power-slot-pulse":`_power-slot-pulse_wiqib_1`,"power-slot-roulette":`_power-slot-roulette_wiqib_1`,connection:`_connection_wiqib_195`,pauseButton:`_pauseButton_wiqib_207`,"route-cue-life":`_route-cue-life_wiqib_1`,"route-u-turn":`_route-u-turn_wiqib_1`},L3e=2e3;function R3e({phase:e=`racing`,position:t,racerCount:n,lap:r,totalLaps:i,lapProgress:a=0,speedKph:o,elapsedMs:s,bestLapMs:c,currentLapMs:l,boost:u=0,direction:d=`straight`,powerup:f,minimap:p,alert:m,connection:h=`good`,onPause:g}){let _=j9(a,0,1),v=j9(u,0,1),[y,b]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(e!==`racing`){b(null);return}b(d);let t=window.setTimeout(()=>{b(null)},L3e);return()=>window.clearTimeout(t)},[d,e]),(0,$.jsxs)(`section`,{className:N9.hud,"aria-label":`Race information`,"data-phase":e,children:[(0,$.jsxs)(`div`,{className:N9.topLeft,children:[(0,$.jsxs)(`div`,{className:N9.lapPanel,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(lo,{size:15,weight:`fill`}),` LAP`]}),(0,$.jsxs)(`strong`,{children:[Math.max(1,r),(0,$.jsxs)(`small`,{children:[`/ `,Math.max(1,i)]})]}),(0,$.jsx)(`i`,{"aria-hidden":`true`,children:(0,$.jsx)(`b`,{style:{transform:`scaleX(${_})`}})})]}),(0,$.jsxs)(`div`,{className:N9.powerSlot,"data-loaded":f?`true`:`false`,"data-rolling":f?.rolling?`true`:`false`,children:[f?.icon??(0,$.jsx)(bo,{size:25,weight:`fill`}),(0,$.jsx)(`span`,{children:f?.name??`NO ITEM`}),(f?.charges??1)>1&&(0,$.jsxs)(`b`,{children:[`×`,f?.charges]})]})]}),(0,$.jsxs)(`div`,{className:N9.topRight,children:[(0,$.jsxs)(`div`,{className:N9.timePanel,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`THIS LAP`}),(0,$.jsx)(`strong`,{children:M9(l)})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Ko,{size:14,weight:`bold`}),(0,$.jsx)(`small`,{children:`RACE`}),(0,$.jsx)(`strong`,{children:M9(s)})]}),c!==void 0&&(0,$.jsxs)(`em`,{children:[`BEST `,M9(c)]})]}),(0,$.jsx)(`span`,{className:N9.connection,"data-quality":h,"aria-label":`Connection ${h}`}),(0,$.jsx)(`button`,{type:`button`,className:N9.pauseButton,onClick:g,"aria-label":`Pause race`,children:(0,$.jsx)(Mo,{size:20,weight:`fill`})})]}),y&&(0,$.jsxs)(`div`,{className:N9.directionMarker,"data-direction":y,"aria-label":`Track direction: ${y}`,children:[y===`left`&&(0,$.jsx)(La,{size:30,weight:`bold`}),y===`right`&&(0,$.jsx)(za,{size:30,weight:`bold`}),y===`u-turn`&&(0,$.jsx)(Fa,{size:30,weight:`bold`}),y===`straight`&&(0,$.jsx)(Va,{size:30,weight:`bold`})]},y),m&&(0,$.jsx)(`div`,{className:N9.alert,role:`status`,children:m}),p&&(0,$.jsx)(`div`,{className:N9.minimap,children:p}),(0,$.jsxs)(`div`,{className:N9.positionBlock,children:[(0,$.jsx)(`small`,{children:`POSITION`}),(0,$.jsx)(`strong`,{children:Math.max(1,t)}),(0,$.jsxs)(`span`,{children:[`/ `,Math.max(1,n)]})]}),(0,$.jsxs)(`div`,{className:N9.speedBlock,children:[(0,$.jsx)(`div`,{className:N9.boostTrack,"aria-label":`Boost ${Math.round(v*100)} percent`,children:(0,$.jsx)(`span`,{style:{transform:`scaleX(${v})`}})}),(0,$.jsx)(`small`,{children:`SPEED`}),(0,$.jsx)(`strong`,{children:Math.max(0,Math.round(o))}),(0,$.jsx)(`span`,{children:`KM/H`})]})]})}var P9={countdown:`_countdown_4aya2_1`,"line-in":`_line-in_4aya2_1`,"line-in-right":`_line-in-right_4aya2_1`,countdownValue:`_countdownValue_4aya2_29`,"count-in":`_count-in_4aya2_1`,countdownGo:`_countdownGo_4aya2_66`,resultsBackdrop:`_resultsBackdrop_4aya2_80`,resultsPanel:`_resultsPanel_4aya2_103`,"panel-in":`_panel-in_4aya2_1`,resultsHeader:`_resultsHeader_4aya2_115`,resultPosition:`_resultPosition_4aya2_148`,resultsBody:`_resultsBody_4aya2_163`,resultList:`_resultList_4aya2_169`,"row-in":`_row-in_4aya2_1`,localResult:`_localResult_4aya2_188`,rank:`_rank_4aya2_201`,driver:`_driver_4aya2_208`,resultTime:`_resultTime_4aya2_209`,points:`_points_4aya2_242`,resultsActions:`_resultsActions_4aya2_248`,continueButton:`_continueButton_4aya2_273`,resultMessage:`_resultMessage_4aya2_284`,skeletonList:`_skeletonList_4aya2_298`,skeleton:`_skeleton_4aya2_298`};function z3e({value:e,visible:t=!0,subtitle:n}){if(!t)return null;let r=e===`GO`;return(0,$.jsx)(`div`,{className:P9.countdown,"aria-live":`assertive`,"aria-atomic":`true`,children:(0,$.jsxs)(`div`,{className:`${P9.countdownValue} ${r?P9.countdownGo:``}`,children:[(0,$.jsx)(`span`,{children:e}),n&&(0,$.jsx)(`small`,{children:n})]},e)})}function B3e(){return(0,$.jsx)(`div`,{className:P9.skeletonList,"aria-label":`Loading race results`,children:[0,1,2,3].map(e=>(0,$.jsx)(`span`,{style:{animationDelay:`${e*80}ms`}},e))})}function V3e({open:e,entries:t,status:n=`ready`,errorMessage:r=`The final standings could not be verified.`,trackName:i=`Workshop After Dark`,raceLabel:a=`Circuit complete`,onRematch:o,onContinue:s}){if(!e)return null;let c=t.findIndex(e=>e.isLocal),l=c>=0?c+1:void 0;return(0,$.jsx)(`div`,{className:P9.resultsBackdrop,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`race-results-title`,children:(0,$.jsxs)(`section`,{className:P9.resultsPanel,children:[(0,$.jsxs)(`header`,{className:P9.resultsHeader,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:a}),(0,$.jsx)(`h2`,{id:`race-results-title`,children:`Final standings`}),(0,$.jsx)(`p`,{children:i})]}),l&&(0,$.jsxs)(`div`,{className:P9.resultPosition,children:[(0,$.jsx)(Xo,{size:22,weight:`fill`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:l}),` / `,t.length]})]})]}),(0,$.jsxs)(`div`,{className:P9.resultsBody,children:[n===`loading`&&(0,$.jsx)(B3e,{}),n===`error`&&(0,$.jsxs)(`div`,{className:P9.resultMessage,role:`alert`,children:[(0,$.jsx)(`strong`,{children:`Results pending`}),(0,$.jsx)(`p`,{children:r})]}),n===`ready`&&t.length===0&&(0,$.jsxs)(`div`,{className:P9.resultMessage,children:[(0,$.jsx)(Eo,{size:30,weight:`duotone`}),(0,$.jsx)(`strong`,{children:`No classified racers`}),(0,$.jsx)(`p`,{children:`The session ended before a finishing time was recorded.`})]}),n===`ready`&&t.length>0&&(0,$.jsx)(`ol`,{className:P9.resultList,children:t.map((e,t)=>(0,$.jsxs)(`li`,{className:e.isLocal?P9.localResult:``,style:{animationDelay:`${t*55}ms`},children:[(0,$.jsx)(`span`,{className:P9.rank,children:String(t+1).padStart(2,`0`)}),(0,$.jsxs)(`span`,{className:P9.driver,children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsx)(`small`,{children:e.carName??`Unregistered car`})]}),(0,$.jsxs)(`span`,{className:P9.resultTime,children:[(0,$.jsx)(`strong`,{children:e.disconnected?`DNF`:M9(e.timeMs)}),(0,$.jsx)(`small`,{children:e.disconnected?`Disconnected`:I3e(t===0?0:e.gapMs)})]}),e.points!==void 0&&(0,$.jsxs)(`b`,{className:P9.points,children:[`+`,e.points,` PTS`]})]},e.id))})]}),(0,$.jsxs)(`footer`,{className:P9.resultsActions,children:[(0,$.jsxs)(`button`,{type:`button`,className:P9.rematchButton,onClick:o,children:[(0,$.jsx)(Na,{size:19,weight:`bold`}),` Rematch`]}),(0,$.jsxs)(`button`,{type:`button`,className:P9.continueButton,onClick:s,children:[`Continue `,(0,$.jsx)(Ga,{size:19,weight:`bold`})]})]})]})})}var F9={backdrop:`_backdrop_g9j2v_1`,panel:`_panel_g9j2v_22`,"pause-in":`_pause-in_g9j2v_1`,content:`_content_g9j2v_53`,resume:`_resume_g9j2v_88`,quit:`_quit_g9j2v_91`,settings:`_settings_g9j2v_93`,sliderRow:`_sliderRow_g9j2v_108`,toggleRow:`_toggleRow_g9j2v_120`,segments:`_segments_g9j2v_160`},H3e=[{value:`performance`,label:`Fast`},{value:`balanced`,label:`Balanced`},{value:`quality`,label:`Quality`}];function U3e({open:e,settings:t,canRestart:n=!0,onSettingsChange:r,onResume:i,onRestart:a,onQuit:o}){return e?(0,$.jsx)(`div`,{className:F9.backdrop,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pause-title`,children:(0,$.jsxs)(`section`,{className:F9.panel,children:[(0,$.jsxs)(`header`,{children:[(0,$.jsx)(`span`,{children:`Race interrupted`}),(0,$.jsx)(`h2`,{id:`pause-title`,children:`Paused`})]}),(0,$.jsxs)(`div`,{className:F9.content,children:[(0,$.jsxs)(`nav`,{"aria-label":`Pause actions`,children:[(0,$.jsxs)(`button`,{type:`button`,className:F9.resume,onClick:i,children:[(0,$.jsx)(Po,{size:21,weight:`fill`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Back to track`}),(0,$.jsx)(`strong`,{children:`Resume race`})]}),(0,$.jsx)(Ga,{size:18,weight:`bold`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:a,disabled:!n,children:[(0,$.jsx)(Fa,{size:21,weight:`bold`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Return to grid`}),(0,$.jsx)(`strong`,{children:`Restart race`})]}),(0,$.jsx)(Ga,{size:18,weight:`bold`})]}),(0,$.jsxs)(`button`,{type:`button`,className:F9.quit,onClick:o,children:[(0,$.jsx)(Ro,{size:21,weight:`bold`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Progress will be lost`}),(0,$.jsx)(`strong`,{children:`Leave session`})]}),(0,$.jsx)(Ga,{size:18,weight:`bold`})]})]}),(0,$.jsxs)(`div`,{className:F9.settings,children:[(0,$.jsx)(`h3`,{children:`Race settings`}),(0,$.jsxs)(`label`,{className:F9.sliderRow,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Bo,{size:18,weight:`bold`}),` Master volume`]}),(0,$.jsx)(`output`,{children:Math.round(t.masterVolume*100)}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.01`,value:t.masterVolume,onChange:e=>r({masterVolume:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:F9.sliderRow,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Bo,{size:18,weight:`duotone`}),` Music volume`]}),(0,$.jsx)(`output`,{children:Math.round(t.musicVolume*100)}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.01`,value:t.musicVolume,onChange:e=>r({musicVolume:Number(e.target.value)})})]}),(0,$.jsxs)(`fieldset`,{children:[(0,$.jsxs)(`legend`,{children:[(0,$.jsx)(Oo,{size:18,weight:`bold`}),` Graphics`]}),(0,$.jsx)(`div`,{className:F9.segments,children:H3e.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":t.graphicsQuality===e.value,onClick:()=>r({graphicsQuality:e.value}),children:e.label},e.value))})]}),(0,$.jsxs)(`label`,{className:F9.toggleRow,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Ho,{size:18,weight:`bold`}),` Steering assist`]}),(0,$.jsx)(`input`,{type:`checkbox`,checked:t.steeringAssist,onChange:e=>r({steeringAssist:e.target.checked})}),(0,$.jsx)(`i`,{"aria-hidden":`true`})]})]})]})]})}):null}var I9={controls:`_controls_qvrdm_1`,steeringZone:`_steeringZone_qvrdm_20`,actionZone:`_actionZone_qvrdm_21`,pedalZone:`_pedalZone_qvrdm_22`,controlLabel:`_controlLabel_qvrdm_33`,stickBase:`_stickBase_qvrdm_39`,stickAxis:`_stickAxis_qvrdm_71`,stickKnob:`_stickKnob_qvrdm_79`,resetButton:`_resetButton_qvrdm_134`,powerupButton:`_powerupButton_qvrdm_151`,handbrakeButton:`_handbrakeButton_qvrdm_192`,brakeButton:`_brakeButton_qvrdm_208`,throttleButton:`_throttleButton_qvrdm_209`},L9={steering:0,throttle:0,brake:0,handbrake:!1};function W3e({disabled:e=!1,alwaysVisible:t=!1,powerupLabel:n=`Use power-up`,powerupCharges:r=1,className:i=``,onControlsChange:a,onUsePowerup:o,onResetCar:s}){let c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)({...L9}),p=(0,G.useRef)(a),m=(0,G.useRef)(null);(0,G.useEffect)(()=>{p.current=a},[a]);let h=()=>{m.current===null&&(m.current=requestAnimationFrame(()=>{m.current=null,p.current({...f.current})}))},g=e=>{f.current={...f.current,...e},h()},_=()=>{u.current=null,d.current=null,l.current&&(l.current.style.transform=`translate3d(0, 0, 0)`),g({steering:0})};(0,G.useEffect)(()=>{e&&(f.current={...L9},l.current&&(l.current.style.transform=`translate3d(0, 0, 0)`),p.current({...L9}))},[e]),(0,G.useEffect)(()=>()=>{m.current!==null&&cancelAnimationFrame(m.current),p.current({...L9})},[]);let v=t=>{if(e||u.current!==t.pointerId)return;let n=d.current;if(!n)return;let r=n.left+n.width/2,i=n.top+n.height/2,a=n.width*.31,o=t.clientX-r,s=t.clientY-i,c=Math.hypot(o,s),f=c>a?a/c:1,p=o*f,m=s*f;l.current&&(l.current.style.transform=`translate3d(${p}px, ${m}px, 0)`);let h=j9(o/a,-1,1);g({steering:Math.abs(h)<.035?0:h})},y=t=>{e||u.current!==null||(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),u.current=t.pointerId,d.current=c.current?.getBoundingClientRect()??null,v(t))},b=e=>{u.current===e.pointerId&&(e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),_())},x=(t,n)=>{e||(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),g(n))},S=(e,t)=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),g(t)},C=(e,t,n)=>{e.key!==` `&&e.key!==`Enter`||(e.preventDefault(),g(t?n:{throttle:n.throttle===void 0?f.current.throttle:0,brake:n.brake===void 0?f.current.brake:0,handbrake:n.handbrake===void 0&&f.current.handbrake}))};return(0,$.jsxs)(`section`,{className:`${I9.controls} ${i}`,"data-always-visible":t?`true`:`false`,"data-disabled":e?`true`:`false`,"aria-label":`Touch driving controls`,children:[(0,$.jsxs)(`div`,{className:I9.steeringZone,children:[(0,$.jsx)(`span`,{className:I9.controlLabel,children:`STEER`}),(0,$.jsxs)(`div`,{ref:c,className:I9.stickBase,role:`slider`,"aria-label":`Steering`,"aria-valuemin":-1,"aria-valuemax":1,"aria-valuenow":Math.round(f.current.steering*100)/100,tabIndex:e?-1:0,onPointerDown:y,onPointerMove:v,onPointerUp:b,onPointerCancel:b,onLostPointerCapture:_,onContextMenu:e=>e.preventDefault(),children:[(0,$.jsx)(`span`,{className:I9.stickAxis,"aria-hidden":`true`}),(0,$.jsx)(`div`,{ref:l,className:I9.stickKnob,"aria-hidden":`true`,children:(0,$.jsx)(`span`,{})})]})]}),(0,$.jsxs)(`div`,{className:I9.actionZone,children:[(0,$.jsxs)(`button`,{type:`button`,className:I9.resetButton,disabled:e,onClick:s,"aria-label":`Reset car`,children:[(0,$.jsx)(Fa,{size:19,weight:`bold`}),(0,$.jsx)(`span`,{children:`RESET`})]}),(0,$.jsxs)(`button`,{type:`button`,className:I9.powerupButton,disabled:e||!o||r<1,onPointerDown:e=>{e.preventDefault(),o?.()},"aria-label":n,children:[(0,$.jsx)(bo,{size:27,weight:`fill`}),r>1&&(0,$.jsxs)(`b`,{children:[`×`,r]})]})]}),(0,$.jsxs)(`div`,{className:I9.pedalZone,children:[(0,$.jsxs)(`button`,{type:`button`,className:I9.handbrakeButton,disabled:e,onPointerDown:e=>x(e,{handbrake:!0}),onPointerUp:e=>S(e,{handbrake:!1}),onPointerCancel:e=>S(e,{handbrake:!1}),onKeyDown:e=>C(e,!0,{handbrake:!0}),onKeyUp:e=>C(e,!1,{handbrake:!0}),children:[(0,$.jsx)(go,{size:20,weight:`bold`}),(0,$.jsx)(`span`,{children:`SLIDE`})]}),(0,$.jsxs)(`button`,{type:`button`,className:I9.brakeButton,disabled:e,onPointerDown:e=>x(e,{brake:1,throttle:-1}),onPointerUp:e=>S(e,{brake:0,throttle:0}),onPointerCancel:e=>S(e,{brake:0,throttle:0}),onKeyDown:e=>C(e,!0,{brake:1,throttle:-1}),onKeyUp:e=>C(e,!1,{brake:1,throttle:-1}),children:[(0,$.jsx)(`small`,{children:`BRAKE`}),(0,$.jsx)(`strong`,{children:`II`})]}),(0,$.jsxs)(`button`,{type:`button`,className:I9.throttleButton,disabled:e,onPointerDown:e=>x(e,{throttle:1}),onPointerUp:e=>S(e,{throttle:0}),onPointerCancel:e=>S(e,{throttle:0}),onKeyDown:e=>C(e,!0,{throttle:1}),onKeyUp:e=>C(e,!1,{throttle:1}),children:[(0,$.jsx)(`small`,{children:`DRIVE`}),(0,$.jsx)(`strong`,{children:`III`})]})]})]})}var R9={frontend:`_frontend_1ml5a_3`,screen:`_screen_1ml5a_25`,screenTransition:`_screenTransition_1ml5a_26`,screenIn:`_screenIn_1ml5a_1`,scanlines:`_scanlines_1ml5a_28`,noise:`_noise_1ml5a_29`,eyebrow:`_eyebrow_1ml5a_39`,mainScreen:`_mainScreen_1ml5a_42`,mainBackdrop:`_mainBackdrop_1ml5a_54`,sunDisc:`_sunDisc_1ml5a_56`,cityBlocks:`_cityBlocks_1ml5a_57`,racingStripes:`_racingStripes_1ml5a_60`,mainContent:`_mainContent_1ml5a_61`,logoSuffix:`_logoSuffix_1ml5a_64`,mainMenu:`_mainMenu_1ml5a_65`,menuItem:`_menuItem_1ml5a_66`,menuPointer:`_menuPointer_1ml5a_68`,menuItemActive:`_menuItemActive_1ml5a_69`,mainHint:`_mainHint_1ml5a_71`,sceneHeader:`_sceneHeader_1ml5a_74`,headerTitle:`_headerTitle_1ml5a_75`,stepCounter:`_stepCounter_1ml5a_76`,backButton:`_backButton_1ml5a_77`,confirmButton:`_confirmButton_1ml5a_79`,garageScreen:`_garageScreen_1ml5a_83`,carRail:`_carRail_1ml5a_84`,railLabel:`_railLabel_1ml5a_85`,railCar:`_railCar_1ml5a_86`,railCarActive:`_railCarActive_1ml5a_88`,carStageLabel:`_carStageLabel_1ml5a_89`,carouselDock:`_carouselDock_1ml5a_90`,carSpecs:`_carSpecs_1ml5a_92`,specTag:`_specTag_1ml5a_93`,modelClass:`_modelClass_1ml5a_94`,carQuote:`_carQuote_1ml5a_96`,carMeta:`_carMeta_1ml5a_97`,meters:`_meters_1ml5a_98`,meter:`_meter_1ml5a_98`,meterTrack:`_meterTrack_1ml5a_98`,racePreset:`_racePreset_1ml5a_99`,trackScreen:`_trackScreen_1ml5a_102`,trackHero:`_trackHero_1ml5a_103`,trackTag:`_trackTag_1ml5a_104`,trackSwitcher:`_trackSwitcher_1ml5a_105`,trackDescription:`_trackDescription_1ml5a_106`,trackFacts:`_trackFacts_1ml5a_107`,raceSummary:`_raceSummary_1ml5a_108`,summaryKicker:`_summaryKicker_1ml5a_108`,loadingScreen:`_loadingScreen_1ml5a_111`,loadingContent:`_loadingContent_1ml5a_111`,loadingTrack:`_loadingTrack_1ml5a_111`,loadingMeta:`_loadingMeta_1ml5a_111`,loadingTip:`_loadingTip_1ml5a_111`},G3e={"sports-car":`Road Sports`,"orange-off-road":`Off-Road 4×4`,"pickup-truck":`Racing Pickup`,"modified-sports-car":`Modified Coupe`,"voltage-bandit":`Street Buggy`,"kestrel-gt":`Touring RC`,"pocket-rocket":`Mini Sprint`,"iron-howl":`Heavy Rally`,"circuit-wasp":`Pro Prototype`},z9=m7.map(e=>({id:e.id,name:e.name,className:G3e[e.id],quote:e.tagline,speed:e.displayStats.speed,acceleration:e.displayStats.acceleration,maneuver:e.displayStats.handling,weight:e.displayStats.weight,rating:e.class,engine:e.engine,drivetrain:e.drivetrain})),K3e={id:`construction-loop`,name:`Construction Loop`,location:`Neighborhood Construction Site`,length:`1183 m`,difficulty:`Easy`,surface:`Asphalt / Concrete / Grass`,description:`A toy-scale suburban neighborhood loop with finished houses, yard trees and roadside construction set dressing.`},B9=[`Start Race`,`Time Trials`,`Championship`,`Workshop`,`Options`],V9=3,H9=8;function U9(e,t){return(e+t)%t}function q3e({onClick:e,label:t=`Back`}){return(0,$.jsxs)(`button`,{className:R9.backButton,type:`button`,onClick:e,children:[(0,$.jsx)(La,{size:20,weight:`bold`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:t})]})}function W9({label:e,value:t}){let n={"--meter-value":`${t}%`};return(0,$.jsxs)(`div`,{className:R9.meter,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`div`,{className:R9.meterTrack,role:`meter`,"aria-label":e,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,children:(0,$.jsx)(`i`,{style:n})}),(0,$.jsx)(`b`,{children:t})]})}function J3e({onStartRace:e,onCancel:t,initialScreen:n=`main`,initialTrackId:r,tracks:i=[K3e],babylonPreview:a=!1,onPreviewChange:o}){let[s,c]=(0,G.useState)(n),[l,u]=(0,G.useState)(0),[d,f]=(0,G.useState)(0),[p,m]=(0,G.useState)(()=>{let e=i.findIndex(e=>e.id===r);return e>=0?e:0}),[h,g]=(0,G.useState)(0),_=z9[d],v=i[p]??K3e,y=v.name.split(/\s+/),b=y.slice(0,-1).join(` `)||y[0],x=y.length>1?y.at(-1):``,S=(0,G.useMemo)(()=>({mode:`single-race`,laps:V9,carCount:H9,carId:_.id,carName:_.name,trackId:v.id,trackName:v.name}),[_,v.id,v.name]);(0,G.useEffect)(()=>{o?.({screen:s,mode:s===`car`?`garage`:s===`track`||s===`loading`?`track`:`attract`,carId:_.id,trackId:v.id})},[_.id,o,s,v.id]);let C=(0,G.useCallback)(()=>{if(s!==`loading`){if(s===`main`){t?.();return}c(s===`track`?`car`:`main`)}},[t,s]),w=(0,G.useCallback)(e=>{f(t=>U9(t+e,z9.length))},[]),T=(0,G.useCallback)(e=>{m(t=>U9(t+e,i.length))},[i.length]);return(0,G.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),C();return}s===`main`?(e.key===`ArrowUp`&&u(e=>U9(e-1,B9.length)),e.key===`ArrowDown`&&u(e=>U9(e+1,B9.length)),e.key===`Enter`&&l===0&&c(`car`)):s===`car`?((e.key===`ArrowLeft`||e.key===`ArrowUp`)&&w(-1),(e.key===`ArrowRight`||e.key===`ArrowDown`)&&w(1),e.key===`Enter`&&c(`track`)):s===`track`&&e.key===`Enter`&&c(`loading`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,C,s,w]),(0,G.useEffect)(()=>{if(s!==`loading`)return;g(4);let t=!1,n=performance.now(),r=window.setInterval(()=>{let i=performance.now()-n,a=Math.min(1,i/1500),o=1-(1-a)**3;g(Math.round(4+o*96)),a>=1&&!t&&(t=!0,window.clearInterval(r),window.setTimeout(()=>e(S),160))},50);return()=>window.clearInterval(r)},[e,s,S]),(0,$.jsxs)(`main`,{className:R9.frontend,"data-babylon-preview":a?`true`:`false`,"aria-label":`Yardline RC racing game`,children:[(0,$.jsx)(`div`,{className:R9.scanlines,"aria-hidden":`true`}),(0,$.jsx)(`div`,{className:R9.noise,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{className:R9.screenTransition,children:[s===`main`&&(0,$.jsxs)(`section`,{className:`${R9.screen} ${R9.mainScreen}`,"aria-labelledby":`main-title`,children:[(0,$.jsxs)(`div`,{className:R9.mainBackdrop,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:R9.sunDisc}),(0,$.jsxs)(`div`,{className:R9.cityBlocks,children:[(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{})]}),(0,$.jsx)(`div`,{className:R9.racingStripes})]}),(0,$.jsxs)(`div`,{className:R9.mainContent,children:[(0,$.jsx)(`p`,{className:R9.eyebrow,children:`Radio-controlled racing league`}),(0,$.jsxs)(`h1`,{id:`main-title`,children:[(0,$.jsx)(`span`,{children:`YARD`}),(0,$.jsx)(`span`,{children:`LINE`})]}),(0,$.jsx)(`p`,{className:R9.logoSuffix,children:`R/C RACING`}),(0,$.jsx)(`nav`,{className:R9.mainMenu,"aria-label":`Main menu`,children:B9.map((e,t)=>{let n=t!==0;return(0,$.jsxs)(`button`,{className:`${R9.menuItem} ${l===t?R9.menuItemActive:``}`,type:`button`,onMouseEnter:()=>u(t),onFocus:()=>u(t),onClick:()=>t===0&&c(`car`),"aria-disabled":n,children:[(0,$.jsx)(za,{className:R9.menuPointer,weight:`fill`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e}),n&&(0,$.jsx)(`small`,{children:`Coming soon`})]},e)})}),(0,$.jsx)(`p`,{className:R9.mainHint,children:`Arrow keys to select\xA0\xA0 / \xA0\xA0Enter to confirm`})]})]}),s===`car`&&(0,$.jsxs)(`section`,{className:`${R9.screen} ${R9.garageScreen}`,"aria-labelledby":`car-title`,children:[(0,$.jsxs)(`header`,{className:R9.sceneHeader,children:[(0,$.jsx)(q3e,{onClick:C,label:`Main menu`}),(0,$.jsxs)(`div`,{className:R9.headerTitle,children:[(0,$.jsx)(`span`,{children:`Yardline RC Works`}),(0,$.jsx)(`h2`,{id:`car-title`,children:`Select Car`})]}),(0,$.jsxs)(`span`,{className:R9.stepCounter,children:[String(d+1).padStart(2,`0`),` / `,String(z9.length).padStart(2,`0`)]})]}),(0,$.jsxs)(`aside`,{className:R9.carRail,"aria-label":`Available cars`,children:[(0,$.jsx)(`span`,{className:R9.railLabel,children:`Garage inventory`}),z9.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:`${R9.railCar} ${t===d?R9.railCarActive:``}`,onClick:()=>f(t),"aria-current":t===d?`true`:void 0,children:[(0,$.jsx)(`b`,{children:String(t+1).padStart(2,`0`)}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsx)(`small`,{children:e.className})]})]},e.id))]}),(0,$.jsxs)(`div`,{className:R9.carStageLabel,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{children:`LIVE MODEL`}),(0,$.jsx)(`b`,{children:`ROTATING DISPLAY`})]}),(0,$.jsxs)(`div`,{className:R9.carouselDock,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>w(-1),"aria-label":`Previous car: ${z9[U9(d-1,z9.length)].name}`,children:(0,$.jsx)(La,{size:24,weight:`bold`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:`Model`}),(0,$.jsxs)(`strong`,{children:[String(d+1).padStart(2,`0`),` / `,String(z9.length).padStart(2,`0`)]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>w(1),"aria-label":`Next car: ${z9[U9(d+1,z9.length)].name}`,children:(0,$.jsx)(za,{size:24,weight:`bold`})})]}),(0,$.jsxs)(`aside`,{className:R9.carSpecs,children:[(0,$.jsxs)(`span`,{className:R9.specTag,children:[(0,$.jsx)(qa,{weight:`fill`}),` Ready to race`]}),(0,$.jsx)(`p`,{className:R9.modelClass,children:_.className}),(0,$.jsx)(`h3`,{children:_.name}),(0,$.jsx)(`p`,{className:R9.carQuote,children:_.quote}),(0,$.jsxs)(`div`,{className:R9.carMeta,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Rating`}),(0,$.jsx)(`b`,{children:_.rating})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Engine`}),(0,$.jsx)(`b`,{children:_.engine})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Drive`}),(0,$.jsx)(`b`,{children:_.drivetrain})]})]}),(0,$.jsxs)(`div`,{className:R9.meters,children:[(0,$.jsx)(W9,{label:`Speed`,value:_.speed}),(0,$.jsx)(W9,{label:`Acceleration`,value:_.acceleration}),(0,$.jsx)(W9,{label:`Maneuver`,value:_.maneuver}),(0,$.jsx)(W9,{label:`Weight`,value:_.weight})]}),(0,$.jsxs)(`div`,{className:R9.racePreset,children:[(0,$.jsx)(lo,{size:18,weight:`fill`}),(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`b`,{children:[V9,` laps`]}),(0,$.jsxs)(`small`,{children:[H9,`-car local field`]})]})]}),(0,$.jsxs)(`button`,{className:R9.confirmButton,type:`button`,onClick:()=>c(`track`),children:[(0,$.jsxs)(`span`,{children:[`Choose `,_.name]}),(0,$.jsx)(za,{size:24,weight:`bold`})]})]})]}),s===`track`&&(0,$.jsxs)(`section`,{className:`${R9.screen} ${R9.trackScreen}`,"aria-labelledby":`track-title`,children:[(0,$.jsxs)(`header`,{className:R9.sceneHeader,children:[(0,$.jsx)(q3e,{onClick:C,label:`Garage`}),(0,$.jsxs)(`div`,{className:R9.headerTitle,children:[(0,$.jsx)(`span`,{children:`Saturday feature`}),(0,$.jsx)(`h2`,{children:`Track Preview`})]}),(0,$.jsxs)(`span`,{className:R9.stepCounter,children:[String(p+1).padStart(2,`0`),` / `,String(i.length).padStart(2,`0`)]})]}),(0,$.jsxs)(`div`,{className:R9.trackHero,children:[(0,$.jsx)(`span`,{className:R9.trackTag,children:i.length>1?`Registered circuit`:`Only demo circuit`}),(0,$.jsx)(`p`,{children:v.location}),(0,$.jsxs)(`h2`,{id:`track-title`,children:[(0,$.jsx)(`span`,{children:b}),x&&(0,$.jsx)(`span`,{children:x})]}),(0,$.jsx)(`p`,{className:R9.trackDescription,children:v.description}),i.length>1&&(0,$.jsxs)(`div`,{className:R9.trackSwitcher,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Previous track: ${i[U9(p-1,i.length)].name}`,onClick:()=>T(-1),children:(0,$.jsx)(La,{size:18,weight:`bold`})}),(0,$.jsxs)(`strong`,{children:[p+1,` / `,i.length]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Next track: ${i[U9(p+1,i.length)].name}`,onClick:()=>T(1),children:(0,$.jsx)(za,{size:18,weight:`bold`})})]}),(0,$.jsxs)(`div`,{className:R9.trackFacts,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(mo,{size:22,weight:`bold`}),(0,$.jsx)(`small`,{children:`Length`}),(0,$.jsx)(`b`,{children:v.length})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Ho,{size:22,weight:`bold`}),(0,$.jsx)(`small`,{children:`Difficulty`}),(0,$.jsx)(`b`,{children:v.difficulty})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(bo,{size:22,weight:`fill`}),(0,$.jsx)(`small`,{children:`Surface`}),(0,$.jsx)(`b`,{children:v.surface})]})]})]}),(0,$.jsxs)(`aside`,{className:R9.raceSummary,children:[(0,$.jsx)(`span`,{className:R9.summaryKicker,children:`Race ready`}),(0,$.jsx)(`h3`,{children:_.name}),(0,$.jsxs)(`dl`,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Format`}),(0,$.jsx)(`dd`,{children:`Single race`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Laps`}),(0,$.jsx)(`dd`,{children:V9})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Grid`}),(0,$.jsxs)(`dd`,{children:[H9,` cars`]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Conditions`}),(0,$.jsx)(`dd`,{children:`Dry / Late day`})]})]}),(0,$.jsxs)(`button`,{className:R9.confirmButton,type:`button`,onClick:()=>c(`loading`),children:[(0,$.jsxs)(`span`,{children:[`Race `,v.name]}),(0,$.jsx)(lo,{size:24,weight:`fill`})]})]})]}),s===`loading`&&(0,$.jsx)(`section`,{className:`${R9.screen} ${R9.loadingScreen}`,"aria-labelledby":`loading-title`,children:(0,$.jsxs)(`div`,{className:R9.loadingContent,children:[(0,$.jsx)(`span`,{className:R9.specTag,children:`Saturday feature`}),(0,$.jsx)(`p`,{children:v.location}),(0,$.jsxs)(`h2`,{id:`loading-title`,children:[b,x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),x]})]}),(0,$.jsx)(`div`,{className:R9.loadingTrack,"aria-label":`Loading ${h}%`,children:(0,$.jsx)(`i`,{style:{transform:`scaleX(${h/100})`}})}),(0,$.jsxs)(`div`,{className:R9.loadingMeta,children:[(0,$.jsx)(`span`,{children:`Warming radio channel`}),(0,$.jsxs)(`strong`,{children:[h,`%`]})]}),(0,$.jsx)(`p`,{className:R9.loadingTip,children:`Tip: save your power-up for the narrow garden exit.`})]})})]},s)]})}var G9={editorShell:`_editorShell_xa6qr_1`,topbar:`_topbar_xa6qr_14`,brand:`_brand_xa6qr_23`,brandGlyph:`_brandGlyph_xa6qr_34`,projectTitle:`_projectTitle_xa6qr_50`,toolbarActions:`_toolbarActions_xa6qr_54`,modeBar:`_modeBar_xa6qr_56`,panelTabs:`_panelTabs_xa6qr_57`,categoryStrip:`_categoryStrip_xa6qr_58`,wideButton:`_wideButton_xa6qr_59`,resetButton:`_resetButton_xa6qr_60`,dangerButton:`_dangerButton_xa6qr_61`,secondaryButton:`_secondaryButton_xa6qr_68`,testButton:`_testButton_xa6qr_69`,iconButton:`_iconButton_xa6qr_70`,hiddenInput:`_hiddenInput_xa6qr_73`,workspace:`_workspace_xa6qr_75`,libraryPanel:`_libraryPanel_xa6qr_76`,inspectorPanel:`_inspectorPanel_xa6qr_77`,searchField:`_searchField_xa6qr_85`,selectedPreviewHeader:`_selectedPreviewHeader_xa6qr_94`,assetList:`_assetList_xa6qr_97`,assetRow:`_assetRow_xa6qr_98`,assetThumbnail:`_assetThumbnail_xa6qr_101`,thumbnailSkeleton:`_thumbnailSkeleton_xa6qr_103`,"thumbnail-shimmer":`_thumbnail-shimmer_xa6qr_1`,thumbnailError:`_thumbnailError_xa6qr_104`,emptyState:`_emptyState_xa6qr_109`,preview:`_preview_xa6qr_111`,previewStatus:`_previewStatus_xa6qr_113`,previewHint:`_previewHint_xa6qr_114`,previewError:`_previewError_xa6qr_115`,textureGrid:`_textureGrid_xa6qr_122`,canvasPanel:`_canvasPanel_xa6qr_127`,canvasReadout:`_canvasReadout_xa6qr_132`,zoomControls:`_zoomControls_xa6qr_133`,mapStage:`_mapStage_xa6qr_138`,canvasGround:`_canvasGround_xa6qr_142`,gridFill:`_gridFill_xa6qr_143`,minorGrid:`_minorGrid_xa6qr_144`,majorGrid:`_majorGrid_xa6qr_145`,routeCenter:`_routeCenter_xa6qr_146`,routeNode:`_routeNode_xa6qr_148`,mapObject:`_mapObject_xa6qr_150`,scaleLegend:`_scaleLegend_xa6qr_155`,modeHint:`_modeHint_xa6qr_156`,statusbar:`_statusbar_xa6qr_161`,statusDot:`_statusDot_xa6qr_163`,inspectorHeader:`_inspectorHeader_xa6qr_165`,sectionLabel:`_sectionLabel_xa6qr_167`,inspectorBody:`_inspectorBody_xa6qr_169`,fieldPair:`_fieldPair_xa6qr_171`,fieldTriple:`_fieldTriple_xa6qr_172`,textField:`_textField_xa6qr_177`,nudgeRow:`_nudgeRow_xa6qr_185`,formField:`_formField_xa6qr_188`,toggleField:`_toggleField_xa6qr_191`,helpText:`_helpText_xa6qr_198`};function Y3e({asset:e}){let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(`loading`);return(0,G.useEffect)(()=>{let n=t.current;if(!n)return;let i=!1,a=new Ih(n,!0,{preserveDrawingBuffer:!1,stencil:!0}),o=new x(a);o.clearColor=new fe(.075,.08,.085,1);let s=new gh(`asset-camera`,Math.PI*.72,Math.PI*.34,5.6,j.Zero(),o);s.lowerRadiusLimit=2.8,s.upperRadiusLimit=11,s.wheelPrecision=45,s.panningSensibility=0,s.attachControl(n,!0);let c=new K_(`asset-fill`,new j(.2,1,.1),o);c.intensity=1.5,c.groundColor=new P(.18,.19,.2);let l=new GC(`asset-key`,new j(-.6,-1,.5),o);l.intensity=1.8,r(`loading`),xD.ImportMeshAsync(``,e.rootUrl,e.file,o).then(({meshes:e})=>{if(i)return;let t=new wc(`asset-pivot`,o);for(let n of e)n.parent||=t,n.useVertexColors=!1,n.hasVertexAlpha=!1,n.computeWorldMatrix(!0);let n=new j(1/0,1/0,1/0),a=new j(-1/0,-1/0,-1/0);for(let t of e){let e=t.getBoundingInfo?.().boundingBox;e&&(n=j.Minimize(n,e.minimumWorld),a=j.Maximize(a,e.maximumWorld))}let s=a.subtract(n),c=Math.max(s.x,s.y,s.z,.001);t.scaling.setAll(3.2/c),t.position=n.add(a).scale(.5).scale(-3.2/c),t.rotation.y=-.35,r(`ready`)}).catch(()=>{i||r(`error`)}),a.runRenderLoop(()=>{i||o.render()});let u=new ResizeObserver(()=>a.resize());return u.observe(n),()=>{i=!0,u.disconnect(),a.stopRenderLoop(),o.dispose(),a.dispose()}},[e]),(0,$.jsxs)(`div`,{className:G9.preview,children:[(0,$.jsx)(`canvas`,{ref:t,"aria-label":`3D preview of ${e.label}`}),n===`loading`&&(0,$.jsx)(`span`,{className:G9.previewStatus,children:`Loading model…`}),n===`error`&&(0,$.jsx)(`span`,{className:`${G9.previewStatus} ${G9.previewError}`,children:`Preview unavailable`}),n===`ready`&&(0,$.jsx)(`span`,{className:G9.previewHint,children:`Drag to orbit · Scroll to zoom`})]})}var K9=new Map;function X3e({asset:e}){let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(()=>K9.get(e.id)),[o,s]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{a(K9.get(e.id)),s(!1)},[e.id]),(0,G.useEffect)(()=>{let e=t.current;if(!e)return;let n=new IntersectionObserver(([e])=>r(e?.isIntersecting??!1),{rootMargin:`80px`,threshold:.01});return n.observe(e),()=>n.disconnect()},[]),(0,G.useEffect)(()=>{if(!n||i||o)return;let t=!1,r=!1,c=window.document.createElement(`canvas`);c.width=160,c.height=112;let l=new Ih(c,!1,{preserveDrawingBuffer:!0,stencil:!1}),u=new x(l);u.clearColor=new fe(.075,.085,.09,1);let d=new gh(`thumbnail-camera`,Math.PI*.72,Math.PI*.34,5.6,j.Zero(),u);d.fov=.72;let f=new K_(`thumbnail-fill`,new j(.2,1,.1),u);f.intensity=1.5,f.groundColor=new P(.18,.19,.2);let p=new GC(`thumbnail-key`,new j(-.6,-1,.5),u);p.intensity=1.7;let m=()=>{r||(r=!0,u.dispose(),l.dispose())};return xD.ImportMeshAsync(``,e.rootUrl,e.file,u).then(async({meshes:n})=>{if(t)return;let r=new wc(`thumbnail-pivot`,u);for(let e of n)e.parent||=r,e.useVertexColors=!1,e.hasVertexAlpha=!1,e.computeWorldMatrix(!0);let i=new j(1/0,1/0,1/0),o=new j(-1/0,-1/0,-1/0);for(let e of n){if(e.getTotalVertices()===0)continue;let t=e.getBoundingInfo().boundingBox;i=j.Minimize(i,t.minimumWorld),o=j.Maximize(o,t.maximumWorld)}let s=o.subtract(i),l=Math.max(s.x,s.y,s.z,.001);if(r.scaling.setAll(3.25/l),r.position=i.add(o).scale(-.5*3.25/l),r.rotation.y=-.35,await u.whenReadyAsync(),u.render(),t)return;let d=c.toDataURL(`image/webp`,.82);K9.set(e.id,d),a(d)}).catch(()=>{t||s(!0)}).finally(m),()=>{t=!0,m()}},[e,o,i,n]),(0,$.jsxs)(`span`,{ref:t,className:G9.assetThumbnail,"aria-hidden":`true`,children:[i&&(0,$.jsx)(`img`,{src:i,alt:``}),!i&&!o&&(0,$.jsx)(`span`,{className:G9.thumbnailSkeleton}),o&&(0,$.jsx)(`span`,{className:G9.thumbnailError,children:`No preview`})]})}var Z3e=.35,Q3e=5,$3e=[{id:`all`,label:`All`},{id:`roads`,label:`Roads`},{id:`sidewalks`,label:`Sidewalks`},{id:`markings`,label:`Markings`},{id:`buildings`,label:`Buildings`},{id:`facades`,label:`Facades`},{id:`roofs`,label:`Roofs`},{id:`structures`,label:`Structure`},{id:`props`,label:`Props`},{id:`houses`,label:`Houses`},{id:`nature`,label:`Nature`},{id:`vehicles`,label:`Vehicles`},{id:`street`,label:`Street`}];function e6e(){let e=c9();try{let t=localStorage.getItem(s9);if(!t)return e;let n=l9(JSON.parse(t));return n?t6e(n,e)?(localStorage.setItem(s9,JSON.stringify(e)),e):o9(a9({...n,presetRevision:e.presetRevision})):e}catch{return e}}function t6e(e,t){return e.id===t.id&&(e.presetRevision??0)<(t.presetRevision??0)}function q9(e){return a9({...e,presetRevision:c9().presetRevision})}function J9(e){return-e}function n6e(){return typeof crypto.randomUUID==`function`?crypto.randomUUID():`object-${Date.now()}-${Math.random()}`}function r6e(){let[e,t]=(0,G.useState)(e6e),[n,r]=(0,G.useState)(`select`),[i,a]=(0,G.useState)(`assets`),[o,s]=(0,G.useState)(`roads`),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`downtown-street-2lane`),[f,p]=(0,G.useState)([]),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(null),[b,x]=(0,G.useState)(1),[S,C]=(0,G.useState)({x:0,z:0}),[w,T]=(0,G.useState)(`Ready`),E=(0,G.useRef)(null),ee=(0,G.useRef)(null),D=(0,G.useRef)([]),te=r9(u)??n9[0],O=f.map(t=>e.objects.find(e=>e.id===t)).filter(e=>!!e),ne=O[0]??null,re=e.objects.some(e=>e.id.startsWith(`auto-route-road-`)||e.id.startsWith(`completed-route-road-`)),k=(0,G.useMemo)(()=>{let e=c.trim().toLowerCase();return n9.filter(t=>(o===`all`||t.category===o)&&(!e||t.label.toLowerCase().includes(e)))},[o,c]),ie=(0,G.useCallback)((e,n=!0)=>{t(t=>(n&&(D.current=[...D.current.slice(-79),t]),{...e(t),updatedAt:new Date().toISOString()}))},[]),A=(0,G.useCallback)(()=>{let e=D.current.at(-1);if(!e){T(`Nothing to undo`);return}D.current=D.current.slice(0,-1),t(e),p(t=>t.filter(t=>e.objects.some(e=>e.id===t))),h(null),T(`Undo`)},[]),j=(e,t)=>{x(n=>{let r=a6e(e,Z3e,Q3e);if(t){let e=n/r;C(n=>({x:Y9(t.x-(t.x-n.x)*e),z:Y9(t.z-(t.z-n.z)*e)}))}return r})},ae=(e,t)=>{let n=E.current;if(!n)return null;let r=n.getScreenCTM();if(!r)return null;let i=n.createSVGPoint();i.x=e,i.y=t;let a=i.matrixTransform(r.inverse());return{x:Math.round(a.x*10)/10,z:Math.round(-a.y*10)/10}},oe=t=>{if(t.target!==t.currentTarget&&t.target.closest(`[data-map-object]`))return;let r=ae(t.clientX,t.clientY);if(r){if(t.button===1||n===`select`){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),y({pointerId:t.pointerId,startClientX:t.clientX,startClientY:t.clientY,startCenter:S,viewSize:e.worldSize/b}),!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&p([]),T(`Panning canvas`);return}if(n===`route`){ie(e=>({...e,route:[...e.route,r]})),T(`Route point ${e.route.length+1} added`);return}if(n===`place`){let e=te.isRoad||te.category===`sidewalks`||te.category===`markings`?12:1,t={id:n6e(),assetId:te.id,x:Math.round(r.x/e)*e,z:Math.round(r.z/e)*e,rotation:0,scale:1,...te.isRoad?{y:i9}:{}};ie(e=>({...e,objects:[...e.objects,t]})),p([t.id]),T(`${te.label} placed`);return}!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&p([])}},se=(t,r)=>{if(n!==`select`)return;t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId);let i=t.shiftKey||t.metaKey||t.ctrlKey,a=f.includes(r),o=i?a?f.filter(e=>e!==r):[...f,r]:a?f:[r];if(p(o),i&&a)return;let s=ae(t.clientX,t.clientY);s&&(D.current=[...D.current.slice(-79),e],h({ids:o,startPoint:s,starts:Object.fromEntries(e.objects.filter(e=>o.includes(e.id)).map(e=>[e.id,{x:e.x,z:e.z}]))}))},M=(t,n)=>{t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId);let r=ae(t.clientX,t.clientY);r&&(D.current=[...D.current.slice(-79),e],_({index:n,startPoint:r,startRoute:e.route.map(e=>({...e}))}),T(`Moving route node ${n+1}`))},ce=e=>{if(v&&v.pointerId===e.pointerId){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-v.startClientX)/t.width*v.viewSize,r=(e.clientY-v.startClientY)/t.height*v.viewSize;C({x:Y9(v.startCenter.x-n),z:Y9(v.startCenter.z+r)});return}if(g){let t=ae(e.clientX,e.clientY);if(!t)return;let n=t.x-g.startPoint.x,r=t.z-g.startPoint.z;ie(e=>({...e,route:e.route.map((e,t)=>{let i=g.startRoute[t];return t===g.index&&i?{x:Y9(i.x+n),z:Y9(i.z+r)}:e})}),!1);return}if(!m)return;let t=ae(e.clientX,e.clientY);if(!t)return;let n=t.x-m.startPoint.x,r=t.z-m.startPoint.z;ie(e=>({...e,objects:e.objects.map(e=>{let t=m.starts[e.id];return t?{...e,x:Y9(t.x+n),z:Y9(t.z+r)}:e})}),!1)},le=e=>{f.length!==0&&ie(t=>({...t,objects:t.objects.map(t=>f.includes(t.id)?{...t,...e}:t)}))},N=(0,G.useCallback)(()=>{f.length!==0&&(ie(e=>({...e,objects:e.objects.filter(e=>!f.includes(e.id))})),p([]),T(`${f.length} object${f.length===1?``:`s`} removed`))},[f,ie]),ue=e=>{e.preventDefault();let t=ae(e.clientX,e.clientY),n=e.deltaY>0?.88:1.14;j(b*n,t??void 0)};(0,G.useEffect)(()=>{re&&(t(e=>{let t={...o9(a9(e)),updatedAt:new Date().toISOString()};return localStorage.setItem(s9,JSON.stringify(q9(t))),t}),p(e=>e.filter(e=>!e.startsWith(`auto-route-road-`)&&!e.startsWith(`completed-route-road-`))),T(`Removed auto road pieces`))},[re]),(0,G.useEffect)(()=>{let e=e=>{let t=i6e(e.target);if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){e.preventDefault(),A();return}if(!t){if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),N();return}if(e.key===`+`||e.key===`=`){e.preventDefault(),j(b*1.18);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),j(b/1.18);return}e.key.toLowerCase()===`v`&&r(`select`),e.key.toLowerCase()===`b`&&r(`place`),e.key.toLowerCase()===`p`&&r(`route`)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,A,b]);let de=()=>{let n=o9(q9(e));t(n),localStorage.setItem(s9,JSON.stringify(n)),T(`Saved locally`)},fe=()=>{let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=window.document.createElement(`a`);r.href=n,r.download=`${e.id||`yardline-map`}.json`,r.click(),URL.revokeObjectURL(n),T(`Map exported`)},pe=async e=>{let n=e.target.files?.[0];if(e.target.value=``,n)try{let e=l9(JSON.parse(await n.text()));if(!e)throw Error(`Invalid map file`);t(o9(a9(e))),p([]),T(`Imported ${e.name}`)}catch{T(`Import failed — choose a Yardline map JSON file`)}},P=()=>{let e=c9();t(e),p([]),T(`Starter map restored`)},F=()=>{let n=o9(q9(e));t(n),localStorage.setItem(s9,JSON.stringify(n)),window.location.href=`/?map=construction-loop&editorDraft=1&seed=${n.seed}`},me=()=>{let e=!!v,t=!!g;h(null),_(null),y(null),(e||t)&&T(`Ready`)},he=()=>{let n=o9(q9(e));t(n),localStorage.setItem(s9,JSON.stringify(n)),window.location.href=`/?map=construction-loop&editorDraft=1&seed=${n.seed}&fly=1`},ge=()=>{ie(o9),p(e=>e.filter(e=>!e.startsWith(`auto-route-road-`)&&!e.startsWith(`completed-route-road-`))),T(`Auto road pieces removed`)},_e=e.worldSize/2,ve=e.worldSize/b,ye=ve/2,be=(e.routeClosed&&e.route.length>2?[...e.route,e.route[0]]:e.route).map(e=>`${e.x},${J9(e.z)}`).join(` `);return(0,$.jsxs)(`main`,{className:G9.editorShell,children:[(0,$.jsxs)(`header`,{className:G9.topbar,children:[(0,$.jsxs)(`a`,{className:G9.brand,href:`/`,"aria-label":`Back to Yardline Racing`,children:[(0,$.jsx)(`span`,{className:G9.brandGlyph,children:`YL`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:`MAP WORKBENCH`}),(0,$.jsx)(`small`,{children:`RC WORLD BUILDER · ALPHA`})]})]}),(0,$.jsxs)(`div`,{className:G9.projectTitle,children:[(0,$.jsx)(`span`,{children:`ACTIVE MAP`}),(0,$.jsx)(`input`,{value:e.name,"aria-label":`Map name`,onChange:e=>ie(t=>({...t,name:e.target.value}))})]}),(0,$.jsxs)(`div`,{className:G9.toolbarActions,children:[(0,$.jsxs)(`button`,{type:`button`,className:G9.secondaryButton,onClick:de,children:[(0,$.jsx)(fo,{size:18}),`Save`]}),(0,$.jsx)(`button`,{type:`button`,className:G9.iconButton,title:`Import JSON`,onClick:()=>ee.current?.click(),children:(0,$.jsx)(Qo,{size:19})}),(0,$.jsx)(`button`,{type:`button`,className:G9.iconButton,title:`Export JSON`,onClick:fe,children:(0,$.jsx)(ao,{size:19})}),(0,$.jsx)(`input`,{ref:ee,className:G9.hiddenInput,type:`file`,accept:`application/json,.json`,onChange:pe}),(0,$.jsxs)(`button`,{type:`button`,className:G9.secondaryButton,onClick:he,children:[(0,$.jsx)(so,{size:18}),`Fly review`]}),(0,$.jsxs)(`button`,{type:`button`,className:G9.testButton,onClick:F,children:[(0,$.jsx)(Po,{size:18,weight:`fill`}),`Test drive`]})]})]}),(0,$.jsxs)(`section`,{className:G9.workspace,children:[(0,$.jsxs)(`aside`,{className:G9.libraryPanel,"aria-label":`Map asset library`,children:[(0,$.jsxs)(`div`,{className:G9.panelTabs,children:[(0,$.jsxs)(`button`,{type:`button`,"data-active":i===`assets`,onClick:()=>a(`assets`),children:[(0,$.jsx)(to,{size:17}),`Models`]}),(0,$.jsxs)(`button`,{type:`button`,"data-active":i===`textures`,onClick:()=>a(`textures`),children:[(0,$.jsx)(vo,{size:17}),`Textures`]})]}),i===`assets`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:G9.searchField,children:[(0,$.jsx)(wo,{size:17}),(0,$.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Search ${n9.length} models`})]}),(0,$.jsx)(`div`,{className:G9.categoryStrip,children:$3e.map(e=>(0,$.jsx)(`button`,{type:`button`,"data-active":o===e.id,onClick:()=>s(e.id),children:e.label},e.id))}),(0,$.jsxs)(`div`,{className:G9.selectedPreviewHeader,children:[(0,$.jsx)(`span`,{children:`SELECTED MODEL`}),(0,$.jsx)(`strong`,{children:te.label})]}),(0,$.jsx)(Y3e,{asset:te}),(0,$.jsxs)(`div`,{className:G9.assetList,children:[k.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:G9.assetRow,"data-active":e.id===te.id,onClick:()=>{d(e.id),r(`place`)},children:[(0,$.jsx)(X3e,{asset:e}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.label}),(0,$.jsxs)(`small`,{children:[e.category,` · `,e.footprint[0],` × `,e.footprint[1],` units`]})]})]},e.id)),k.length===0&&(0,$.jsx)(`p`,{className:G9.emptyState,children:`No models match this filter.`})]})]}):(0,$.jsx)(`div`,{className:G9.textureGrid,children:R4e.map(e=>(0,$.jsxs)(`figure`,{children:[(0,$.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`}),(0,$.jsx)(`figcaption`,{children:e.name})]},e.url))})]}),(0,$.jsxs)(`section`,{className:G9.canvasPanel,"aria-label":`Map canvas`,children:[(0,$.jsxs)(`div`,{className:G9.modeBar,children:[(0,$.jsxs)(`button`,{type:`button`,"data-active":n===`select`,onClick:()=>r(`select`),children:[(0,$.jsx)(ro,{size:18}),`Select `,(0,$.jsx)(`kbd`,{children:`V`})]}),(0,$.jsxs)(`button`,{type:`button`,"data-active":n===`place`,onClick:()=>r(`place`),children:[(0,$.jsx)(to,{size:18}),`Place `,(0,$.jsx)(`kbd`,{children:`B`})]}),(0,$.jsxs)(`button`,{type:`button`,"data-active":n===`route`,onClick:()=>r(`route`),children:[(0,$.jsx)(Ao,{size:18}),`Route `,(0,$.jsx)(`kbd`,{children:`P`})]}),(0,$.jsxs)(`div`,{className:G9.zoomControls,"aria-label":`Canvas zoom controls`,children:[(0,$.jsx)(`button`,{type:`button`,title:`Zoom out`,onClick:()=>j(b/1.2),children:`−`}),(0,$.jsxs)(`span`,{children:[Math.round(b*100),`%`]}),(0,$.jsx)(`button`,{type:`button`,title:`Zoom in`,onClick:()=>j(b*1.2),children:`+`})]}),(0,$.jsxs)(`span`,{className:G9.canvasReadout,children:[e.objects.length,` OBJECTS · `,e.route.length,` ROUTE NODES`]})]}),(0,$.jsxs)(`div`,{className:G9.mapStage,"data-mode":n,children:[(0,$.jsxs)(`svg`,{ref:E,viewBox:`${S.x-ye} ${J9(S.z)-ye} ${ve} ${ve}`,onPointerDown:oe,onPointerMove:ce,onPointerUp:me,onPointerLeave:me,onWheel:ue,role:`img`,"aria-label":`Top-down map editing canvas`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(`pattern`,{id:`minor-grid`,width:`10`,height:`10`,patternUnits:`userSpaceOnUse`,children:(0,$.jsx)(`path`,{d:`M 10 0 L 0 0 0 10`,className:G9.minorGrid})}),(0,$.jsxs)(`pattern`,{id:`major-grid`,width:`50`,height:`50`,patternUnits:`userSpaceOnUse`,children:[(0,$.jsx)(`rect`,{width:`50`,height:`50`,fill:`url(#minor-grid)`}),(0,$.jsx)(`path`,{d:`M 50 0 L 0 0 0 50`,className:G9.majorGrid})]})]}),(0,$.jsx)(`rect`,{className:G9.canvasGround,x:-_e,y:-_e,width:e.worldSize,height:e.worldSize}),(0,$.jsx)(`rect`,{className:G9.gridFill,x:-_e,y:-_e,width:e.worldSize,height:e.worldSize}),e.route.length>1&&(0,$.jsx)(`polyline`,{className:G9.routeCenter,points:be}),e.route.map((e,t)=>(0,$.jsxs)(`g`,{className:G9.routeNode,"data-route-node":!0,transform:`translate(${e.x} ${J9(e.z)})`,onPointerDown:e=>M(e,t),children:[(0,$.jsx)(`circle`,{r:`5.5`}),(0,$.jsx)(`text`,{y:`1.7`,children:t+1})]},`${e.x}-${e.z}-${t}`)),e.objects.map(e=>{let t=r9(e.assetId);if(!t)return null;let n=t.footprint[0]*e.scale*(e.scaleX??1),r=t.footprint[1]*e.scale*(e.scaleZ??1);return(0,$.jsxs)(`g`,{"data-map-object":!0,className:G9.mapObject,"data-selected":f.includes(e.id),transform:`translate(${e.x} ${J9(e.z)}) rotate(${e.rotation})`,onPointerDown:t=>se(t,e.id),children:[(0,$.jsx)(`rect`,{x:-n/2,y:-r/2,width:n,height:r,rx:`2`,style:{"--asset-color":t.swatch}}),(0,$.jsx)(`path`,{d:`M 0 ${-r/2+2} L 3 ${-r/2+7} L -3 ${-r/2+7} Z`})]},e.id)})]}),(0,$.jsxs)(`div`,{className:G9.scaleLegend,children:[(0,$.jsx)(`span`,{}),`50 world units`]}),(0,$.jsx)(`div`,{className:G9.modeHint,children:n===`place`?`Click to place ${te.label}`:n===`route`?`Click to append route nodes`:`Click and drag an object to move it`})]}),(0,$.jsxs)(`footer`,{className:G9.statusbar,children:[(0,$.jsx)(`span`,{className:G9.statusDot}),w,(0,$.jsxs)(`span`,{children:[`WORLD `,e.worldSize,` × `,e.worldSize]}),(0,$.jsx)(`span`,{children:`TOY SCALE ≈ 1:18`})]})]}),(0,$.jsxs)(`aside`,{className:G9.inspectorPanel,"aria-label":`Map inspector`,children:[(0,$.jsxs)(`div`,{className:G9.inspectorHeader,children:[(0,$.jsx)(`span`,{children:`INSPECTOR`}),(0,$.jsx)(`strong`,{children:O.length>1?`${O.length} objects selected`:ne?r9(ne.assetId)?.label:`Map settings`})]}),ne?(0,$.jsxs)(`div`,{className:G9.inspectorBody,children:[(0,$.jsx)(`p`,{className:G9.sectionLabel,children:`TRANSFORM`}),(0,$.jsxs)(`div`,{className:G9.fieldTriple,children:[(0,$.jsxs)(`label`,{children:[`X`,(0,$.jsx)(`input`,{type:`number`,step:`1`,value:ne.x,onChange:e=>le({x:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{children:[`Y`,(0,$.jsx)(`input`,{type:`number`,step:`0.25`,value:ne.y??0,onChange:e=>le({y:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{children:[`Z`,(0,$.jsx)(`input`,{type:`number`,step:`1`,value:ne.z,onChange:e=>le({z:Number(e.target.value)})})]})]}),(0,$.jsxs)(`div`,{className:G9.nudgeRow,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>le({y:Y9((ne.y??0)-.25)}),children:`Y −0.25`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>le({y:0}),children:`Y 0`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>le({y:Y9((ne.y??0)+.25)}),children:`Y +0.25`})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Elevation `,(0,$.jsxs)(`span`,{children:[(ne.y??0).toFixed(2),`u`]}),(0,$.jsx)(`input`,{type:`range`,min:`-20`,max:`40`,step:`0.25`,value:ne.y??0,onChange:e=>le({y:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Rotation X `,(0,$.jsxs)(`span`,{children:[ne.rotationX??0,`°`]}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`359`,value:ne.rotationX??0,onChange:e=>le({rotationX:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Rotation Y `,(0,$.jsxs)(`span`,{children:[ne.rotation,`°`]}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`359`,value:ne.rotation,onChange:e=>le({rotation:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Rotation Z `,(0,$.jsxs)(`span`,{children:[ne.rotationZ??0,`°`]}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`359`,value:ne.rotationZ??0,onChange:e=>le({rotationZ:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Scale `,(0,$.jsxs)(`span`,{children:[ne.scale.toFixed(2),`×`]}),(0,$.jsx)(`input`,{type:`range`,min:`0.25`,max:`3`,step:`0.05`,value:ne.scale,onChange:e=>le({scale:Number(e.target.value)})})]}),(0,$.jsxs)(`button`,{type:`button`,className:G9.dangerButton,onClick:()=>{N()},children:[(0,$.jsx)(Jo,{size:17}),`Delete selected`]})]}):(0,$.jsxs)(`div`,{className:G9.inspectorBody,children:[(0,$.jsx)(`p`,{className:G9.sectionLabel,children:`WORLD`}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`World size `,(0,$.jsxs)(`span`,{children:[e.worldSize,` units`]}),(0,$.jsx)(`input`,{type:`range`,min:`160`,max:`800`,step:`20`,value:e.worldSize,onChange:e=>ie(t=>({...t,worldSize:Number(e.target.value)}))})]}),(0,$.jsxs)(`label`,{className:G9.textField,children:[`Map ID`,(0,$.jsx)(`input`,{value:e.id,onChange:e=>ie(t=>({...t,id:e.target.value.replace(/[^a-z0-9-]/g,`-`)}))})]}),(0,$.jsxs)(`label`,{className:G9.textField,children:[`Generation seed`,(0,$.jsx)(`input`,{type:`number`,value:e.seed,onChange:e=>ie(t=>({...t,seed:Number(e.target.value)}))})]}),(0,$.jsx)(`p`,{className:G9.sectionLabel,children:`ROUTE`}),(0,$.jsx)(`p`,{className:G9.helpText,children:`Roads are kit models. The route is only the racing line used by checkpoints and AI drivers.`}),(0,$.jsxs)(`label`,{className:G9.toggleField,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.routeClosed===!0,disabled:e.route.length<3,onChange:e=>ie(t=>({...t,routeClosed:e.target.checked}))}),`Connect last node to first`]}),(0,$.jsx)(`button`,{type:`button`,className:G9.wideButton,disabled:!re,onClick:ge,children:`Remove auto roads`}),(0,$.jsx)(`button`,{type:`button`,className:G9.wideButton,disabled:e.route.length===0,onClick:()=>ie(e=>({...e,route:e.route.slice(0,-1)})),children:`Remove last route node`}),(0,$.jsx)(`p`,{className:G9.helpText,children:`Route nodes are optional while editing. Add them when you are ready to test checkpoints and AI.`}),(0,$.jsxs)(`button`,{type:`button`,className:G9.resetButton,onClick:P,children:[(0,$.jsx)(Fa,{size:17}),`Restore starter map`]})]})]})]})]})}function i6e(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function a6e(e,t,n){return Math.max(t,Math.min(n,e))}function Y9(e){return Math.round(e*100)/100}var X9={shell:`_shell_1s4wv_1`,dropSurface:`_dropSurface_1s4wv_14`,toolbar:`_toolbar_1s4wv_59`,identity:`_identity_1s4wv_78`,toolGroup:`_toolGroup_1s4wv_118`,toolbarActions:`_toolbarActions_1s4wv_119`,assetActions:`_assetActions_1s4wv_162`,inspectorActions:`_inspectorActions_1s4wv_163`,saveButton:`_saveButton_1s4wv_173`,driveButton:`_driveButton_1s4wv_174`,navigationHelp:`_navigationHelp_1s4wv_185`,assetDock:`_assetDock_1s4wv_186`,inspector:`_inspector_1s4wv_163`,emptyInspector:`_emptyInspector_1s4wv_188`,panelHeader:`_panelHeader_1s4wv_207`,sectionTitle:`_sectionTitle_1s4wv_208`,searchField:`_searchField_1s4wv_269`,dragHint:`_dragHint_1s4wv_281`,assetResults:`_assetResults_1s4wv_297`,noAssets:`_noAssets_1s4wv_370`,objectId:`_objectId_1s4wv_422`,fieldGrid:`_fieldGrid_1s4wv_463`,wideField:`_wideField_1s4wv_470`,deleteButton:`_deleteButton_1s4wv_505`,statusBar:`_statusBar_1s4wv_539`},o6e={mode:`move`,snapEnabled:!0,dirty:!1,canUndo:!1,objectCount:0,status:`Loading 3D editor`,selection:null},s6e=[{id:`move`,label:`Move`,icon:Ua},{id:`rotate`,label:`Rotate`,icon:Na},{id:`scale`,label:`Scale`,icon:Za}];function c6e(){let[e,t]=(0,G.useState)(o6e),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(`street`),[o,s]=(0,G.useState)(`downtown-street-2lane`),[c,l]=(0,G.useState)(null);(0,G.useEffect)(()=>Y4e((e,n)=>{t(e),r(n)}),[]),(0,G.useEffect)(()=>{if(!c)return;let e=()=>l(null),t=t=>{t.code===`Escape`&&e()},r=e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},i=t=>{t.preventDefault();let r=t.dataTransfer?.getData(`application/x-yardline-map-asset`)||c;e(),r&&n?.addObjectAt(r,t.clientX,t.clientY)};return window.addEventListener(`dragover`,r),window.addEventListener(`drop`,i),window.addEventListener(`dragend`,e),window.addEventListener(`blur`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`dragover`,r),window.removeEventListener(`drop`,i),window.removeEventListener(`dragend`,e),window.removeEventListener(`blur`,e),window.removeEventListener(`keydown`,t)}},[n,c]);let u=(0,G.useMemo)(()=>{let e=i.trim().toLowerCase();return n9.filter(t=>!e||t.label.toLowerCase().includes(e)||t.category.toLowerCase().includes(e)).slice(0,8)},[i]);return(0,$.jsxs)(`div`,{className:X9.shell,"aria-label":`3D map editor`,children:[(0,$.jsxs)(`div`,{className:X9.dropSurface,"data-active":!!c,children:[(0,$.jsx)(`span`,{children:`DROP TO PLACE`}),(0,$.jsx)(`small`,{children:`The model will land at this map position`})]}),(0,$.jsxs)(`header`,{className:X9.toolbar,children:[(0,$.jsxs)(`div`,{className:X9.identity,children:[(0,$.jsx)(`span`,{children:`YL`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{children:`3D MAP EDITOR`}),(0,$.jsxs)(`small`,{children:[`CONSTRUCTION LOOP · `,e.objectCount,` OBJECTS`]})]})]}),(0,$.jsxs)(`div`,{className:X9.toolGroup,"aria-label":`Transform tools`,children:[s6e.map(({id:t,label:r,icon:i})=>(0,$.jsxs)(`button`,{type:`button`,"data-active":e.mode===t,disabled:!n,onClick:()=>n?.setMode(t),title:`${r} selected object`,children:[(0,$.jsx)(i,{size:18,weight:`bold`}),(0,$.jsx)(`span`,{children:r})]},t)),(0,$.jsxs)(`button`,{type:`button`,"data-active":e.snapEnabled,disabled:!n,onClick:()=>n?.setSnapEnabled(!e.snapEnabled),title:`Toggle transform snapping`,children:[(0,$.jsx)(So,{size:18,weight:`bold`}),(0,$.jsx)(`span`,{children:`Snap`})]})]}),(0,$.jsxs)(`div`,{className:X9.toolbarActions,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!e.canUndo||!n,onClick:()=>void n?.undo(),title:`Undo`,children:(0,$.jsx)(Fa,{size:18,weight:`bold`})}),(0,$.jsx)(`button`,{type:`button`,disabled:!e.selection||!n,onClick:()=>void n?.duplicateSelected(),title:`Duplicate selected`,children:(0,$.jsx)(Ya,{size:18,weight:`bold`})}),(0,$.jsxs)(`button`,{type:`button`,className:X9.saveButton,disabled:!n,onClick:()=>n?.save(),children:[(0,$.jsx)(fo,{size:18,weight:`bold`}),(0,$.jsx)(`span`,{children:e.dirty?`Save changes`:`Saved`})]}),(0,$.jsxs)(`button`,{type:`button`,className:X9.driveButton,disabled:!n,onClick:()=>n?.testDrive(),children:[(0,$.jsx)(Po,{size:17,weight:`fill`}),(0,$.jsx)(`span`,{children:`Test drive`})]})]})]}),(0,$.jsxs)(`aside`,{className:X9.navigationHelp,children:[(0,$.jsx)(`span`,{children:`FLY + EDIT`}),(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`kbd`,{children:`WASD`}),` move · `,(0,$.jsx)(`kbd`,{children:`Q`}),(0,$.jsx)(`kbd`,{children:`E`}),` descend / rise · right-drag look`]}),(0,$.jsxs)(`p`,{children:[`Left-click object · `,(0,$.jsx)(`kbd`,{children:`F`}),` focus · `,(0,$.jsx)(`kbd`,{children:`Esc`}),` clear`]}),(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`kbd`,{children:`⌘S`}),` save · `,(0,$.jsx)(`kbd`,{children:`⌘Z`}),` undo · `,(0,$.jsx)(`kbd`,{children:`⌘D`}),` duplicate · `,(0,$.jsx)(`kbd`,{children:`Del`}),` remove`]}),(0,$.jsx)(`a`,{href:`/map-editor`,onClick:()=>n?.save(),children:`Open 2D editor`})]}),(0,$.jsx)(l6e,{query:i,chosenAssetId:o,visibleAssets:u,selection:e.selection,disabled:!n,onQueryChange:a,onChoose:s,onDragStart:(e,t)=>{n&&(s(e),l(e),t.dataTransfer.effectAllowed=`copy`,t.dataTransfer.setData(`application/x-yardline-map-asset`,e),t.dataTransfer.setData(`text/plain`,e))},onDragEnd:()=>l(null),onAdd:()=>void n?.addObject(o),onReplace:()=>void n?.replaceSelected(o)}),e.selection?(0,$.jsx)(u6e,{selection:e.selection,actions:n}):(0,$.jsxs)(`aside`,{className:X9.emptyInspector,children:[(0,$.jsx)($a,{size:25,weight:`duotone`}),(0,$.jsx)(`span`,{children:`NO OBJECT SELECTED`}),(0,$.jsx)(`strong`,{children:`Click a model in the world`}),(0,$.jsx)(`p`,{children:`Roads, houses, props, trees, and sidewalks can all be edited directly.`})]}),(0,$.jsxs)(`div`,{className:X9.statusBar,"data-dirty":e.dirty,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(`strong`,{children:e.dirty?`UNSAVED`:`DRAFT CURRENT`}),(0,$.jsx)(`p`,{children:e.status})]})]})}function l6e({query:e,chosenAssetId:t,visibleAssets:n,selection:r,disabled:i,onQueryChange:a,onChoose:o,onDragStart:s,onDragEnd:c,onAdd:l,onReplace:u}){return(0,$.jsxs)(`aside`,{className:X9.assetDock,children:[(0,$.jsxs)(`div`,{className:X9.panelHeader,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:`MODEL LIBRARY`}),(0,$.jsx)(`strong`,{children:`Place or replace`})]}),(0,$.jsx)(to,{size:20,weight:`duotone`})]}),(0,$.jsx)(`p`,{className:X9.dragHint,children:`Drag any model card directly onto the map.`}),(0,$.jsxs)(`label`,{className:X9.searchField,children:[(0,$.jsx)(wo,{size:16}),(0,$.jsx)(`input`,{value:e,onChange:e=>a(e.target.value),placeholder:`Search ${n9.length} models`})]}),(0,$.jsxs)(`div`,{className:X9.assetResults,children:[n.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:i,draggable:!i,"data-active":t===e.id,onClick:()=>o(e.id),onDragStart:t=>s(e.id,t),onDragEnd:c,title:`Drag onto the map to place`,children:[(0,$.jsx)(`i`,{style:{background:e.swatch}}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.label}),(0,$.jsxs)(`small`,{children:[e.category,` · `,e.footprint[0],` × `,e.footprint[1]]})]})]},e.id)),n.length===0&&(0,$.jsx)(`p`,{className:X9.noAssets,children:`No models match this search.`})]}),(0,$.jsxs)(`div`,{className:X9.assetActions,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:l,children:[(0,$.jsx)(Io,{size:16,weight:`bold`}),`Place new`]}),(0,$.jsxs)(`button`,{type:`button`,disabled:i||!r,onClick:u,children:[(0,$.jsx)(Wo,{size:16,weight:`bold`}),`Replace`]})]})]})}function u6e({selection:e,actions:t}){return(0,$.jsxs)(`aside`,{className:X9.inspector,children:[(0,$.jsxs)(`div`,{className:X9.panelHeader,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:`SELECTED OBJECT`}),(0,$.jsx)(`strong`,{children:e.label})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t?.deselect(),"aria-label":`Clear selection`,children:`×`})]}),(0,$.jsx)(`p`,{className:X9.objectId,children:e.id}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:X9.sectionTitle,children:[(0,$.jsx)(`span`,{children:`POSITION`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>t?.frameSelected(),children:[(0,$.jsx)($a,{size:15}),`Focus`]})]}),(0,$.jsxs)(`div`,{className:X9.fieldGrid,children:[(0,$.jsx)(Z9,{label:`X`,value:e.x,onChange:e=>t?.updateSelected({x:e})}),(0,$.jsx)(Z9,{label:`Y`,value:e.y,onChange:e=>t?.updateSelected({y:e})}),(0,$.jsx)(Z9,{label:`Z`,value:e.z,onChange:e=>t?.updateSelected({z:e})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:X9.sectionTitle,children:[(0,$.jsx)(`span`,{children:`ROTATION`}),(0,$.jsx)(`small`,{children:`LOCAL AXES`})]}),(0,$.jsxs)(`div`,{className:X9.fieldGrid,children:[(0,$.jsx)(Z9,{label:`X`,value:e.rotationX,step:5,onChange:e=>t?.updateSelected({rotationX:e})}),(0,$.jsx)(Z9,{label:`Y`,value:e.rotation,step:5,onChange:e=>t?.updateSelected({rotation:e})}),(0,$.jsx)(Z9,{label:`Z`,value:e.rotationZ,step:5,onChange:e=>t?.updateSelected({rotationZ:e})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:X9.sectionTitle,children:[(0,$.jsx)(`span`,{children:`SCALE`}),(0,$.jsx)(`small`,{children:`LOCAL AXES`})]}),(0,$.jsxs)(`div`,{className:X9.fieldGrid,children:[(0,$.jsx)(Z9,{label:`X`,value:e.scaleX,step:.05,onChange:e=>t?.updateSelected({scaleX:e})}),(0,$.jsx)(Z9,{label:`Y`,value:e.scaleY,step:.05,onChange:e=>t?.updateSelected({scaleY:e})}),(0,$.jsx)(Z9,{label:`Z`,value:e.scaleZ,step:.05,onChange:e=>t?.updateSelected({scaleZ:e})})]})]}),(0,$.jsxs)(`div`,{className:X9.inspectorActions,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void t?.duplicateSelected(),children:[(0,$.jsx)(Ya,{size:16}),`Duplicate`]}),(0,$.jsxs)(`button`,{type:`button`,className:X9.deleteButton,onClick:()=>t?.deleteSelected(),children:[(0,$.jsx)(Jo,{size:16}),`Delete`]})]})]})}function Z9({label:e,value:t,step:n=.5,wide:r=!1,onChange:i}){return(0,$.jsxs)(`label`,{className:r?X9.wideField:void 0,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`input`,{type:`number`,value:t,step:n,onChange:e=>i(Number(e.target.value))})]})}var d6e={masterVolume:.84,musicVolume:.62,graphicsQuality:`balanced`,steeringAssist:!0},f6e=new URLSearchParams(window.location.search).get(`map`),Q9=new URLSearchParams(window.location.search).get(`fly`)===`1`,$9=D9(f6e).metadata,p6e=w3e.map(({metadata:e})=>({id:e.id,name:e.name,location:e.location,length:`${e.lengthMeters} m`,difficulty:e.difficulty[0].toUpperCase()+e.difficulty.slice(1),surface:e.surfaces.map(e=>e[0].toUpperCase()+e.slice(1)).join(` / `),description:e.description})),m6e={phase:`booting`,speedKph:0,lap:1,totalLaps:3,position:1,racers:8,elapsedMs:0,bestLapMs:null,currentLapMs:0,countdown:null,checkpoint:1,checkpointCount:11,airborne:!1,wrongWay:!1,surface:`asphalt`,boost:0,direction:`straight`},h6e=e=>e===`countdown`?`countdown`:e===`finished`?`finished`:e===`menu`||e===`booting`?`grid`:`racing`;function g6e(){let e=(0,G.useRef)(null),t=(0,G.useRef)(null),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(`booting`),[o,s]=(0,G.useState)(m6e),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(d6e),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)({mode:`single-race`,laps:3,carCount:8,carId:`sports-car`,carName:`Sports Car`,trackId:$9.id,trackName:$9.name}),[v]=(0,G.useState)(()=>matchMedia(`(max-width: 900px)`).matches);(0,G.useEffect)(()=>{if(!e.current)return;let n=new M3e(e.current,{onReady:()=>r(!0),onPhaseChange:e=>a(e),onTelemetry:s,onResult:l,onPowerup:(e,t=0,n=!1)=>p(e?{name:e,charges:t,rolling:n}:null),onError:e=>h(e.message)});return t.current=n,n.initialize(),()=>{n.dispose(),t.current=null}},[]);let y=(0,G.useCallback)((e=g)=>{_(e),l(null),t.current?.startRace({laps:e.laps,carId:e.carId,mapId:e.trackId})},[g]),b=(0,G.useCallback)(()=>{l(null),t.current?.returnToMenu()},[]),x=(0,G.useCallback)(e=>{let n=t.current;n?.setTouchDrive(e.throttle,e.steering),n?.setTouchBrake(e.brake),n?.setTouchHandbrake(e.handbrake)},[]),S=(0,G.useCallback)(e=>{d(n=>{let r={...n,...e};return e.graphicsQuality&&t.current?.setGraphicsQuality(e.graphicsQuality),r})},[]),C=[`countdown`,`racing`,`paused`,`finished`].includes(i),w=o.checkpointCount>0?o.checkpoint===0?1:o.checkpoint/o.checkpointCount:0;return(0,$.jsxs)(`main`,{className:`game-shell`,"data-phase":i,"data-review-mode":Q9||void 0,children:[(0,$.jsx)(`canvas`,{ref:e,className:`game-canvas`,"aria-label":Q9?`Construction Loop fly review`:`Yardline RC racing game`,tabIndex:Q9?0:-1}),!n&&!m&&(0,$.jsxs)(`section`,{className:`loading-screen`,"aria-live":`polite`,children:[(0,$.jsx)(F3e,{}),(0,$.jsx)(`div`,{className:`loading-track`,children:(0,$.jsx)(`span`,{})}),(0,$.jsx)(`p`,{children:`Preparing ${$9.name}`})]}),m&&(0,$.jsxs)(`section`,{className:`error-screen`,role:`alert`,children:[(0,$.jsx)(es,{size:34,weight:`duotone`}),(0,$.jsx)(`span`,{children:`Runtime unavailable`}),(0,$.jsx)(`h1`,{children:`The workshop could not open.`}),(0,$.jsx)(`p`,{children:m}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:`Try again`})]}),n&&i===`menu`&&!Q9&&(0,$.jsx)(J3e,{babylonPreview:!0,initialTrackId:$9.id,tracks:p6e,onStartRace:y,onPreviewChange:({mode:e,carId:n})=>t.current?.setFrontendPreview(e,n)}),n&&Q9&&(0,$.jsx)(c6e,{}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R3e,{phase:h6e(i),position:o.position,racerCount:o.racers,lap:o.lap,totalLaps:o.totalLaps,lapProgress:w,speedKph:o.speedKph,elapsedMs:o.elapsedMs,bestLapMs:o.bestLapMs??void 0,currentLapMs:o.currentLapMs,boost:o.boost,direction:o.direction,powerup:f??void 0,alert:o.wrongWay?`WRONG WAY`:o.airborne?`AIR CONTROL`:o.surface===`grass`?`LOW GRIP`:void 0,connection:`good`,onPause:()=>t.current?.togglePause()}),(0,$.jsx)(z3e,{visible:i===`countdown`,value:o.countdown===null?`READY`:o.countdown||`GO`,subtitle:g.trackName}),(0,$.jsx)(W3e,{disabled:i!==`racing`,alwaysVisible:v,onControlsChange:x,powerupLabel:f?.name??`No power-up`,powerupCharges:f?.charges??0,onUsePowerup:()=>t.current?.usePowerup(),onResetCar:()=>t.current?.requestReset()}),(0,$.jsx)(U3e,{open:i===`paused`,settings:u,onSettingsChange:S,onResume:()=>t.current?.togglePause(),onRestart:()=>y(),onQuit:b}),(0,$.jsx)(V3e,{open:i===`finished`,entries:c?[{id:`local-player`,name:`Rookie 17`,carName:g.carName,timeMs:c.totalTimeMs,points:240,isLocal:!0}]:[],status:c?`ready`:`loading`,onRematch:()=>y(),onContinue:b})]})]})}function _6e(){return window.location.pathname===`/map-editor`||new URLSearchParams(window.location.search).get(`tool`)===`map-editor`?(0,$.jsx)(r6e,{}):(0,$.jsx)(g6e,{})}(0,Gi.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(G.StrictMode,{children:(0,$.jsx)(_6e,{})}));export{cie as $,Kj as A,Qk as B,SM as C,Hu as Ct,sM as D,lM as E,$ye as F,jk as G,Wk as H,tbe as I,yk as J,Ek as K,zve as L,Lj as M,Fj as N,nM as O,jj as P,vv as Q,KA as R,EM as S,Wu as St,mM as T,Su as Tt,Bk as U,qk as V,Pk as W,Hae as X,Ev as Y,Wae as Z,fP as _,$g as _t,aK as a,j_ as at,YM as b,Wg as bt,YG as c,T_ as ct,NH as d,__ as dt,V_ as et,DH as f,m_ as ft,dL as g,n_ as gt,yB as h,a_ as ht,oAe as i,N_ as it,Vj as j,eM as k,GG as l,C_ as lt,EH as m,c_ as mt,wK as n,L_ as nt,nK as o,k_ as ot,OH as p,d_ as pt,Ck as q,cAe as r,F_ as rt,$G as s,D_ as st,w2 as t,z_ as tt,FH as u,x_ as ut,_Se as v,Xg as vt,bM as w,Au as wt,WM as x,Bg as xt,ZM as y,qg as yt,tA as z}; \ No newline at end of file +`),s=[],c=[];s.push(c);for(let t=0;t=7){let e=parseFloat(r[4]),t=parseFloat(r[5]),n=parseFloat(r[6]);this._colors.push(new fe(e>1?e/255:e,t>1?t/255:t,n>1?n/255:n,r.length===7||r[7]===void 0?1:parseFloat(r[7])))}else this._colors.push(this._grayColor)}else if((r=e.NormalPattern.exec(n))!==null)this._normals.push(new j(parseFloat(r[1]),parseFloat(r[2]),parseFloat(r[3])));else if((r=e.UVPattern.exec(n))!==null)this._uvs.push(new O(parseFloat(r[1])*this._loadingOptions.UVScaling.x,parseFloat(r[2])*this._loadingOptions.UVScaling.y));else if((r=e.FacePattern3.exec(n))!==null)this._setDataForCurrentFaceWithPattern3(r[1].trim().split(` `),1);else if((r=e.FacePattern4.exec(n))!==null)this._setDataForCurrentFaceWithPattern4(r[1].trim().split(` `),1);else if((r=e.FacePattern5.exec(n))!==null)this._setDataForCurrentFaceWithPattern5(r[1].trim().split(` `),1);else if((r=e.FacePattern2.exec(n))!==null)this._setDataForCurrentFaceWithPattern2(r[1].trim().split(` `),1);else if((r=e.FacePattern1.exec(n))!==null)this._setDataForCurrentFaceWithPattern1(r[1].trim().split(` `),1);else if((r=e.LinePattern1.exec(n))!==null)this._setDataForCurrentFaceWithPattern1(r[1].trim().split(` `),0),this._hasLineData=!0;else if((r=e.LinePattern2.exec(n))!==null)this._setDataForCurrentFaceWithPattern2(r[1].trim().split(` `),0),this._hasLineData=!0;else if(r=e._GetZbrushMRGB(n,!this._loadingOptions.importVertexColors))for(let e of r)this._extColors.push(e);else if((r=e.LinePattern3.exec(n))!==null)this._setDataForCurrentFaceWithPattern3(r[1].trim().split(` `),0),this._hasLineData=!0;else if(e.GroupDescriptor.test(n)||e.ObjectDescriptor.test(n)){let t={name:n.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:e.ObjectDescriptor.test(n)};this._addPreviousObjMesh(),this._meshesFromObj.push(t),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else if(e.UseMtlDescriptor.test(n)){if(this._materialNameFromObj=n.substring(7).trim(),!this._isFirstMaterial||!this._hasMeshes){this._addPreviousObjMesh();let e={name:(this._objMeshName||`mesh`)+`_mm`+this._increment.toString(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:!1};this._increment++,this._meshesFromObj.push(e),this._hasMeshes=!0}this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)}else e.MtlLibGroupDescriptor.test(n)?a(n.substring(7).trim()):e.SmoothDescriptor.test(n)||F.Log(`Unhandled expression at line : `+n)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon),this._handledMesh.hasLines=this._hasLineData),!this._hasMeshes){let e=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(let e of this._positions)this._unwrappedPositionsForBabylon.push(e.x,e.y,e.z);if(this._normals.length)for(let e of this._normals)this._unwrappedNormalsForBabylon.push(e.x,e.y,e.z);if(this._uvs.length)for(let e of this._uvs)this._unwrappedUVForBabylon.push(e.x,e.y);if(this._extColors.length)for(let e of this._extColors)this._unwrappedColorsForBabylon.push(e.r,e.g,e.b,e.a);else if(this._colors.length)for(let e of this._colors)this._unwrappedColorsForBabylon.push(e.r,e.g,e.b,e.a);this._materialNameFromObj||(e=new lg(il.RandomId(),r),e.pointsCloud=!0,this._materialNameFromObj=e.name,this._normals.length||(e.disableLighting=!0,e.emissiveColor=P.White()))}this._meshesFromObj.push({name:il.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:e,isObject:!0,hasLines:this._hasLineData})}for(let e=0;e=0;--t)if(this._meshesFromObj[t].isObject&&this._meshesFromObj[t]._babylonMesh){n.parent=this._meshesFromObj[t]._babylonMesh;break}}if(this._materialToUse.push(this._meshesFromObj[e].materialName),this._handledMesh.hasLines&&(n._internalMetadata??={},n._internalMetadata._isLine=!0),this._handledMesh.positions?.length===0){this._babylonMeshesArray.push(n);continue}let a=new Fc;if(a.indices=this._handledMesh.indices,a.positions=this._handledMesh.positions,this._loadingOptions.computeNormals||!this._handledMesh.normals?.length){let e=[];Fc.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,e),a.normals=e}else a.normals=this._handledMesh.normals;this._handledMesh.uvs?.length&&(a.uvs=this._handledMesh.uvs),this._handledMesh.colors?.length&&(a.colors=this._handledMesh.colors),a.applyToMesh(n),this._loadingOptions.invertY&&(n.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(n),this._babylonMeshesArray.push(n),this._handledMesh.directMaterial&&(n.material=this._handledMesh.directMaterial)}}};s7.ObjectDescriptor=/^o/,s7.GroupDescriptor=/^g/,s7.MtlLibGroupDescriptor=/^mtllib /,s7.UseMtlDescriptor=/^usemtl /,s7.SmoothDescriptor=/^s /,s7.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/,s7.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,s7.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,s7.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/,s7.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,s7.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,s7.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,s7.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,s7.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/,s7.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,s7.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/;var c7={name:`obj`,extensions:`.obj`},l7=class e{static get INVERT_TEXTURE_Y(){return o7.INVERT_TEXTURE_Y}static set INVERT_TEXTURE_Y(e){o7.INVERT_TEXTURE_Y=e}constructor(t){this.name=c7.name,this.extensions=c7.extensions,this._assetContainer=null,this._loadingOptions={...e._DefaultLoadingOptions,...t??{}}}static get _DefaultLoadingOptions(){return{computeNormals:e.COMPUTE_NORMALS,optimizeNormals:e.OPTIMIZE_NORMALS,importVertexColors:e.IMPORT_VERTEX_COLORS,invertY:e.INVERT_Y,invertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,materialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:e.OPTIMIZE_WITH_UV,skipMaterials:e.SKIP_MATERIALS,useLegacyBehavior:e.USE_LEGACY_BEHAVIOR}}_loadMTL(e,t,n,r){let i=t+e;ge.LoadFile(i,n,void 0,void 0,!1,(e,t)=>{r(i,t)})}createPlugin(t){return new e(t[c7.name])}canDirectLoad(){return!1}importMeshAsync(e,t,n,r){return this._parseSolidAsync(e,t,n,r).then(e=>({meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))}loadAsync(e,t,n){return this.importMeshAsync(null,e,t,n).then(()=>{})}loadAssetContainerAsync(e,t,n){let r=new Bl(e);return this._assetContainer=r,this.importMeshAsync(null,e,t,n).then(e=>(e.meshes.forEach(e=>r.meshes.push(e)),e.meshes.forEach(e=>{let t=e.material;t&&r.materials.indexOf(t)==-1&&(r.materials.push(t),t.getActiveTextures().forEach(e=>{r.textures.indexOf(e)==-1&&r.textures.push(e)}))}),this._assetContainer=null,r)).catch(e=>{throw this._assetContainer=null,e})}_parseSolidAsync(e,t,n,r){let i=``,a=new o7,o=[],s=[];n=n.replace(/#.*$/gm,``).trim(),new s7(o,s,this._loadingOptions).parse(e,n,t,this._assetContainer,e=>{i=e});let c=[];return i!==``&&!this._loadingOptions.skipMaterials&&c.push(new Promise((e,n)=>{this._loadMTL(i,r,c=>{try{a.parseMTL(t,c,r,this._assetContainer);for(let e=0;e-1;)n.push(r),t=r+1;if(r===-1&&n.length===0)a.materials[e].dispose();else for(let t=0;t{ge.Warn(`Error downloading MTL file: '${i}'`),this._loadingOptions.materialLoadingFailsSilently?e():n(r)})})),Promise.all(c).then(()=>{let e=e=>!!(e._internalMetadata?._isLine??!1);return s.forEach(n=>{if(e(n)){let r=n.material??new lg(n.name+`_line`,t);r.getBindedMeshes().filter(t=>!e(t)).length>0&&(r=r.clone(r.name+`_line`)??r),r.wireframe=!0,n.material=r,n._internalMetadata&&(n._internalMetadata._isLine=void 0)}}),s})}};l7.OPTIMIZE_WITH_UV=!0,l7.INVERT_Y=!1,l7.IMPORT_VERTEX_COLORS=!1,l7.COMPUTE_NORMALS=!1,l7.OPTIMIZE_NORMALS=!1,l7.UV_SCALING=new O(1,1),l7.SKIP_MATERIALS=!1,l7.MATERIAL_LOADING_FAILS_SILENTLY=!0,l7.USE_LEGACY_BEHAVIOR=!1;var Q0e=!1;function $0e(){Q0e||(Q0e=!0,hD(new l7))}$0e();function e2e(e={}){let t=e.wheelbase??1.7,n=(e.trackWidth??1.25)*.5,r=e.suspensionOriginY??-.22,i=e.wheelRadius??.28,a=e.suspensionRestLength??.24,o=e.suspensionTravel??.14,s=t*.5,c=-s,l=e.allWheelDrive===!1?0:1,u=(e,t,n,s,c,l)=>({id:e,originLocal:new j(t,r,n),radius:i,restLength:a,travel:o,steerFactor:s,driveFactor:c,brakeFactor:1,handbrakeFactor:l});return[u(`frontLeft`,-n,s,1,l,0),u(`frontRight`,n,s,1,l,0),u(`rearLeft`,-n,c,0,1,1),u(`rearRight`,n,c,0,1,1)]}var t2e={wheels:e2e(),suspensionStrength:145,suspensionDamping:11,maxSuspensionAcceleration:38,gripCoefficient:1.7,lateralGrip:10,frontGripMultiplier:1,rearGripMultiplier:1.05,handbrakeGripMultiplier:.28,centerOfMassOffset:new j(0,-.28,-.05),tireForceApplicationHeight:.72,antiRollStrength:46,antiFlipMultiplier:3.2,rollingResistance:.32,engineAcceleration:24,reverseAccelerationMultiplier:.55,brakeDeceleration:34,handbrakeDeceleration:22,maxForwardSpeed:27,maxReverseSpeed:10,maxSteerAngle:Math.PI*.19,highSpeedSteerMultiplier:.42,steerResponse:7.5,yawResponse:1,maxYawRate:2.9,handbrakeYawResponseMultiplier:.18,throttleResponse:7,brakeResponse:10,directionChangeBrakeSpeed:1.2,downforceCoefficient:.018,maxDownforceAcceleration:14,groundUprightStrength:12,groundUprightDamping:2.8,airYawControl:2.6,airPitchControl:2.2,linearDamping:.08,angularDamping:.16};function n2e(e={}){return{...t2e,...e,wheels:e.wheels??t2e.wheels}}var u7=`assets/kenney/car-kit/models/`,r2e=`assets/custom/rc-sport-car/`,d7=`assets/custom/player-cars/`,i2e=1.28,a2e=1.16;function f7(e,t){let n=e2e({wheelbase:t.wheelbase,trackWidth:t.trackWidth,wheelRadius:t.radius,suspensionOriginY:t.originY,suspensionRestLength:t.restLength,suspensionTravel:t.travel}),r=t=>{let n=t.steerFactor>0;return e===`FWD`?+!!n:e===`RWD`?+!n:n?.46:.54};return n.map(e=>({...e,driveFactor:r(e)}))}var o2e={mass:2.25,friction:.78,restitution:.025,chassisSize:[2.05,.7,3.5],controller:{wheels:f7(`4WD`,{wheelbase:2.25,trackWidth:1.78,radius:.43,originY:-.14,restLength:.3,travel:.18}),suspensionStrength:150,suspensionDamping:11.2,maxSuspensionAcceleration:39,gripCoefficient:1.92,lateralGrip:9.8,frontGripMultiplier:1,rearGripMultiplier:1.07,centerOfMassOffset:new j(0,-.29,-.04),tireForceApplicationHeight:.74,antiRollStrength:48,antiFlipMultiplier:3.4,engineAcceleration:23.5,brakeDeceleration:35,handbrakeDeceleration:22,maxForwardSpeed:25.5,maxSteerAngle:Math.PI*.2,highSpeedSteerMultiplier:.44,steerResponse:7.7,yawResponse:.95,maxYawRate:2.75,throttleResponse:7.2,airYawControl:2.8,airPitchControl:2.55,groundUprightStrength:22,groundUprightDamping:4.8,angularDamping:.18}},s2e={mass:2.5,friction:.75,restitution:.02,chassisSize:[2.08,.68,3.62],controller:{wheels:f7(`FWD`,{wheelbase:2.34,trackWidth:1.76,radius:.42,originY:-.15,restLength:.28,travel:.16}),suspensionStrength:154,suspensionDamping:11.4,maxSuspensionAcceleration:40,gripCoefficient:1.78,lateralGrip:9.5,frontGripMultiplier:.94,rearGripMultiplier:1.08,centerOfMassOffset:new j(0,-.32,.02),tireForceApplicationHeight:.77,antiRollStrength:54,antiFlipMultiplier:3.7,engineAcceleration:26,brakeDeceleration:37,handbrakeDeceleration:23,maxForwardSpeed:28,maxSteerAngle:Math.PI*.185,highSpeedSteerMultiplier:.4,steerResponse:8,yawResponse:.8,maxYawRate:2.55,throttleResponse:7.8,airYawControl:2.45,airPitchControl:2.25,groundUprightStrength:24,groundUprightDamping:5.1,downforceCoefficient:.021}},c2e={mass:1.82,friction:.68,restitution:.035,chassisSize:[1.9,.66,3.2],controller:{wheels:f7(`RWD`,{wheelbase:2.02,trackWidth:1.65,radius:.4,originY:-.13,restLength:.29,travel:.19}),suspensionStrength:164,suspensionDamping:11.4,maxSuspensionAcceleration:43,gripCoefficient:1.55,lateralGrip:8.25,frontGripMultiplier:1,rearGripMultiplier:1.12,centerOfMassOffset:new j(0,-.23,-.09),tireForceApplicationHeight:.64,antiRollStrength:34,antiFlipMultiplier:2.6,handbrakeGripMultiplier:.22,engineAcceleration:30.5,brakeDeceleration:33,handbrakeDeceleration:24,maxForwardSpeed:30.5,maxSteerAngle:Math.PI*.22,highSpeedSteerMultiplier:.46,steerResponse:9,yawResponse:1.2,maxYawRate:3.4,handbrakeYawResponseMultiplier:.12,throttleResponse:9,airYawControl:3.65,airPitchControl:3.35,groundUprightStrength:18,groundUprightDamping:4.1,angularDamping:.14}},p7={mass:3.25,friction:.84,restitution:.018,chassisSize:[2.2,.84,3.72],controller:{wheels:f7(`4WD`,{wheelbase:2.38,trackWidth:1.9,radius:.48,originY:-.18,restLength:.34,travel:.23}),suspensionStrength:182,suspensionDamping:14.2,maxSuspensionAcceleration:46,gripCoefficient:2.08,lateralGrip:10.4,frontGripMultiplier:.98,rearGripMultiplier:1.08,centerOfMassOffset:new j(0,-.39,-.05),tireForceApplicationHeight:.83,antiRollStrength:68,antiFlipMultiplier:4.3,rollingResistance:.36,engineAcceleration:22.5,brakeDeceleration:40,handbrakeDeceleration:27,maxForwardSpeed:27.5,maxSteerAngle:Math.PI*.12,highSpeedSteerMultiplier:.28,steerResponse:5.8,yawResponse:.4,maxYawRate:1.65,throttleResponse:6.4,airYawControl:1.95,airPitchControl:1.75,groundUprightStrength:31,groundUprightDamping:6.2,maxDownforceAcceleration:16,angularDamping:.22}},l2e={mass:2.14,friction:.73,restitution:.015,chassisSize:[2.04,.62,3.7],controller:{wheels:f7(`RWD`,{wheelbase:2.42,trackWidth:1.78,radius:.41,originY:-.17,restLength:.25,travel:.14}),suspensionStrength:172,suspensionDamping:13.5,maxSuspensionAcceleration:44,gripCoefficient:1.72,lateralGrip:8.7,frontGripMultiplier:1,rearGripMultiplier:1.1,centerOfMassOffset:new j(0,-.35,-.1),tireForceApplicationHeight:.81,antiRollStrength:60,antiFlipMultiplier:3.9,handbrakeGripMultiplier:.2,rollingResistance:.28,engineAcceleration:29.5,brakeDeceleration:39,handbrakeDeceleration:26,maxForwardSpeed:34,maxSteerAngle:Math.PI*.182,highSpeedSteerMultiplier:.38,steerResponse:8.5,yawResponse:1,maxYawRate:3,handbrakeYawResponseMultiplier:.13,throttleResponse:8.1,airYawControl:3.05,airPitchControl:2.75,groundUprightStrength:28,groundUprightDamping:5.6,downforceCoefficient:.026,maxDownforceAcceleration:18,linearDamping:.065,angularDamping:.145}},m7=[{id:`sports-car`,name:`Sports Car`,tagline:`Low, clean, and built for speed.`,description:`A planted rear-drive sports car with high-speed grip and a sharp racing line.`,class:`Advanced`,engine:`Electric`,drivetrain:`RWD`,model:{assetRootUrl:d7,fileName:`sports-car.glb`,scale:[3.78,3.78,3.78],offset:[0,-.46,0],rotation:[0,Math.PI/2,0],wheelNodeNames:{frontLeft:`tripo_part_3`,frontRight:`tripo_part_7`,rearLeft:`tripo_part_1`,rearRight:`tripo_part_15`},wheelCenters:{frontLeft:[-.2982,.069,-.1611],frontRight:[-.3011,.0693,.1608],rearLeft:[.2551,.0813,-.1758],rearRight:[.2557,.0809,.1759]},wheelSpinAxis:[0,0,1],wheelSteerAxis:[0,1,0],replacementWheelScale:.0182,hasEmbeddedWheels:!0},physics:l2e,displayStats:{speed:94,acceleration:88,handling:84,weight:48,toughness:51}},{id:`orange-off-road`,name:`Orange Off-Road`,tagline:`Take the line nobody else can.`,description:`A high-clearance 4WD bruiser tuned for grass, curbs, and hard landings.`,class:`Semi-Pro`,engine:`Glow`,drivetrain:`4WD`,model:{assetRootUrl:d7,fileName:`orange-off-road.glb`,scale:[3.79,3.79,3.79],offset:[0,-.48,0],rotation:[0,Math.PI/2,0],wheelNodeNames:{frontLeft:`tripo_part_2`,frontRight:`tripo_part_7`,rearLeft:`tripo_part_4`,rearRight:`tripo_part_3`},wheelCenters:{frontLeft:[-.2912,.0894,-.188],frontRight:[-.2934,.0927,.1941],rearLeft:[.276,.0945,-.1909],rearRight:[.2689,.0939,.1934]},wheelSpinAxis:[0,0,1],wheelSteerAxis:[0,1,0],replacementWheelScale:.0242,hasEmbeddedWheels:!0},physics:p7,displayStats:{speed:72,acceleration:64,handling:55,weight:83,toughness:95}},{id:`pickup-truck`,name:`Pickup Truck`,tagline:`Torque first. Questions later.`,description:`A stable all-wheel-drive pickup that trades rotation for durability and traction.`,class:`Amateur`,engine:`Electric`,drivetrain:`4WD`,model:{assetRootUrl:d7,fileName:`pickup-truck.glb`,scale:[3.83,3.83,3.83],offset:[0,-.48,0],rotation:[0,Math.PI/2+1.029+Math.PI,0],wheelNodeNames:{frontLeft:`tripo_part_1`,frontRight:`tripo_part_4`,rearLeft:`tripo_part_5`,rearRight:`tripo_part_6`},wheelCenters:{frontLeft:[.0162,.0892,-.271],frontRight:[-.247,.0896,-.1131],rearLeft:[.2983,.0891,.1984],rearRight:[.035,.089,.3563]},wheelSpinAxis:[-.8569,0,.5155],wheelSteerAxis:[0,1,0],hasEmbeddedWheels:!0},physics:p7,displayStats:{speed:68,acceleration:61,handling:50,weight:90,toughness:92}},{id:`modified-sports-car`,name:`Modified Sports`,tagline:`Street tuned. Track proven.`,description:`A light modified coupe with fast turn-in, strong acceleration, and a lively rear end.`,class:`Pro`,engine:`Glow`,drivetrain:`RWD`,model:{assetRootUrl:d7,fileName:`modified-sports-car.glb`,scale:[3.65,3.65,3.65],offset:[0,-.46,0],rotation:[0,Math.PI/2,0],hasEmbeddedWheels:!0},physics:c2e,displayStats:{speed:91,acceleration:94,handling:90,weight:35,toughness:43}},{id:`voltage-bandit`,name:`Voltage Bandit`,tagline:`Light feet. Loud attitude.`,description:`A forgiving all-wheel-drive buggy with predictable grip and soft landings.`,class:`Rookie`,engine:`Electric`,drivetrain:`4WD`,model:{assetRootUrl:r2e,fileName:`10600_RC_Car_animated.obj`,scale:[.075,.1,.075],offset:[-.01,-.36,-.18],rotation:[-Math.PI/2,0,0],wheelSuspensionAxis:[0,0,1],wheelCenters:{frontLeft:[-11.5765,-14.126,3.996],frontRight:[11.9005,-14.126,3.996],rearLeft:[-11.5355,8.2535,4.0095],rearRight:[11.929,8.2535,4.0095]}},physics:o2e,displayStats:{speed:70,acceleration:76,handling:78,weight:43,toughness:55}},{id:`kestrel-gt`,name:`Kestrel GT`,tagline:`Corners are invitations.`,description:`A precise electric tourer. Front drive rewards clean entries but pushes wide under power.`,class:`Amateur`,engine:`Electric`,drivetrain:`FWD`,model:{assetRootUrl:u7,fileName:`sedan-sports.glb`,scale:[1.39,1.39,1.39],offset:[0,-.46,0],rotation:[0,0,0]},physics:s2e,displayStats:{speed:76,acceleration:84,handling:68,weight:54,toughness:58}},{id:`pocket-rocket`,name:`Pocket Rocket`,tagline:`Small target. Serious trouble.`,description:`An explosive rear-drive glow car with quick rotation, long jumps, and little patience.`,class:`Advanced`,engine:`Glow`,drivetrain:`RWD`,model:{assetRootUrl:u7,fileName:`hatchback-sports.glb`,scale:[1.34,1.34,1.34],offset:[0,-.43,0],rotation:[0,0,0]},physics:c2e,displayStats:{speed:86,acceleration:91,handling:92,weight:29,toughness:38}},{id:`iron-howl`,name:`Iron Howl`,tagline:`The shortcut is straight through.`,description:`A heavy 4WD glow bruiser built to absorb landings and win contact at the apex.`,class:`Semi-Pro`,engine:`Glow`,drivetrain:`4WD`,model:{assetRootUrl:u7,fileName:`suv-luxury.glb`,scale:[1.5,1.5,1.5],offset:[0,-.54,0],rotation:[0,0,0]},physics:p7,displayStats:{speed:70,acceleration:58,handling:48,weight:91,toughness:96}},{id:`circuit-wasp`,name:`Circuit Wasp`,tagline:`Blink and you missed the apex.`,description:`A low-slung pro prototype: fastest on clean lines, lively on throttle, ruthless at speed.`,class:`Pro`,engine:`Electric`,drivetrain:`RWD`,model:{assetRootUrl:u7,fileName:`race-future.glb`,scale:[1.4,1.4,1.4],offset:[0,-.45,0],rotation:[0,0,0]},physics:l2e,displayStats:{speed:98,acceleration:88,handling:86,weight:47,toughness:51}}],u2e=new Map(m7.map(e=>[e.id,e]));function h7(e){return u2e.has(e)}function d2e(e){return h7(e)?u2e.get(e):void 0}function g7(e){let t=d2e(e);if(!t)throw Error(`Unknown car profile: ${e}`);return t}function f2e(e){let t=typeof e==`string`?g7(e).physics.controller:e.physics.controller;return{...t,engineAcceleration:(t.engineAcceleration??24)*a2e,maxForwardSpeed:(t.maxForwardSpeed??27)*i2e,maxReverseSpeed:(t.maxReverseSpeed??10)*1.12}}var p2e=[[`frontLeft`,`wheel-front-left`],[`frontRight`,`wheel-front-right`],[`rearLeft`,`wheel-back-left`],[`rearRight`,`wheel-back-right`]],m2e=`assets/custom/rc-sport-car/`,h2e=`RC_Wheel_Kit.obj`;async function _7(e,t,n,r=`voltage-bandit`){y7(e,`full`);try{let i=g7(r),a=await xD.ImportMeshAsync(``,i.model.assetRootUrl,i.model.fileName,t),o=a.meshes.find(e=>e.name===`__root__`),s=o??new wc(`${r}-imported-root`,t);o||a.meshes.forEach(e=>{e.parent||=s}),s.parent=e.driftRoot,s.position.set(...i.model.offset),s.rotationQuaternion=null,s.rotation.set(...i.model.rotation),s.scaling.set(...i.model.scale),a.meshes.forEach(e=>{e.isPickable=!1,e.receiveShadows=!0,n.addShadowCaster(e)});let c=[...a.meshes,...a.transformNodes],l=i.model.wheelSuspensionAxis?new j(...i.model.wheelSuspensionAxis).normalize():j.Up(),u=Math.max(1e-4,Math.hypot(l.x*i.model.scale[0],l.y*i.model.scale[1],l.z*i.model.scale[2])),d=p2e.flatMap(([e,n],r)=>{let a=i.model.wheelNodeNames?.[e]??n,o=c.find(e=>e.name.toLowerCase()===a),s=i.model.wheelCenters?.[e];if(!o)return[];let d=i.model.wheelNodeNames&&s?_2e(t,o,s,e):o;!i.model.wheelNodeNames&&s&&o.position.set(...s);let f=i.model.wheelSteerAxis?new j(...i.model.wheelSteerAxis):j.Forward(),p=i.model.wheelSpinAxis?new j(...i.model.wheelSpinAxis):j.Right();return o?[{wheelId:e,node:d,followSuspension:!1,suspensionScale:1/u,suspensionAxis:l,steerAxis:f,spinAxis:p,spinDirection:r%2==0?-1:1}]:[]});if(i.model.replacementWheelScale&&d.length===4){let e=await g2e(t,n,s,i.model.wheelCenters??{},i.model.replacementWheelScale,1/u,l);e.length===4&&(d.forEach(e=>e.node.getChildMeshes().forEach(e=>e.setEnabled(!1))),d=e)}return e.wheelPivots.forEach(e=>e.scaling.setAll(1)),d.length===4?(e.wheelVisuals=d,y7(e,`hidden`)):i.model.hasEmbeddedWheels?(e.wheelVisuals=[],y7(e,`hidden`)):(e.wheelVisuals=v7(e),y7(e,`wheels`)),()=>{s.dispose(!1,!0),e.wheelVisuals=v7(e),y7(e,`full`)}}catch(t){return console.warn(`The detailed car model could not be loaded; using the built-in fallback.`,t),e.wheelVisuals=v7(e),y7(e,`full`),()=>void 0}}async function g2e(e,t,n,r,i,a,o){let s=await xD.ImportMeshAsync(``,m2e,h2e,e),c=[...s.meshes,...s.transformNodes],l=A.RotationAxis(new j(1,1,1).normalize(),-2*Math.PI/3);return p2e.flatMap(([s,u],d)=>{let f=c.find(e=>e.name.toLowerCase()===u),p=r[s];if(!f||!p)return[];let m=new wc(`${s}-replacement-wheel-pivot`,e);m.parent=n,m.position.set(...p);let h=new wc(`${s}-replacement-wheel-geometry`,e);return h.parent=m,h.rotationQuaternion=l.clone(),h.scaling.setAll(i),f.parent=h,f.position.setAll(0),f.rotation.setAll(0),f.rotationQuaternion=A.Identity(),f.getChildMeshes(!1).forEach(e=>{e.isPickable=!1,e.receiveShadows=!0,t.addShadowCaster(e)}),f instanceof K&&(f.isPickable=!1,f.receiveShadows=!0,t.addShadowCaster(f)),[{wheelId:s,node:m,followSuspension:!1,suspensionScale:a,suspensionAxis:o,steerAxis:j.Up(),spinAxis:j.Forward(),spinDirection:d%2==0?-1:1}]})}function _2e(e,t,n,r){let i=new wc(`${r}-imported-wheel-pivot`,e);return i.parent=t.parent,i.position.set(...n),t.parent=i,t.position.subtractInPlace(i.position),i}function v7(e,t=.19){let n=[`frontLeft`,`frontRight`,`rearLeft`,`rearRight`];return e.wheelPivots.map((e,r)=>({wheelId:n[r],node:e,positionOffset:new j(r%2==0?-t:t,.02,r<2?.025:-.025),spinDirection:r%2==0?-1:1}))}function y7(e,t){e.visualRoot.setEnabled(t!==`hidden`);let n=new Set(e.wheelMeshes);e.visualRoot.getChildMeshes().forEach(e=>{e.setEnabled(t===`full`||t===`wheels`&&n.has(e))})}function b7(e,t,n,r=.25){let i=new lg(t,e);return i.diffuseColor=P.FromHexString(n),i.specularColor=new P(r,r,r),i}function v2e(e,t,n){let r=b7(e,`car-shell`,`#c45f31`,.48),i=b7(e,`car-shell-dark`,`#71361f`,.32),a=b7(e,`tire-rubber`,`#17191c`,.08),o=b7(e,`wheel-rim`,`#b5b0a5`,.62),s=b7(e,`car-glass`,`#263f49`,.72),c=b7(e,`car-light`,`#f0d49a`,.8),l=vm.CreateBox(`car-physics-chassis`,{width:2.15,height:.72,depth:3.65},e);l.position.copyFrom(n),l.isVisible=!1;let u=new wc(`car-presentation-root`,e);u.position.copyFrom(n),u.rotationQuaternion=A.Identity();let d=new wc(`car-drift-root`,e);d.parent=u,d.rotationQuaternion=A.Identity();let f=new wc(`car-visual-root`,e);f.parent=d;let p=vm.CreateBox(`car-lower-shell`,{width:2.2,height:.58,depth:3.7},e);p.position.y=.03,p.material=r,p.parent=f,p.edgesWidth=.6;let m=vm.CreateBox(`car-nose`,{width:2.05,height:.35,depth:1.05},e);m.position.set(0,.34,1.3),m.rotation.x=-.08,m.material=r,m.parent=f;let h=vm.CreateBox(`car-cabin`,{width:1.56,height:.72,depth:1.45},e);h.position.set(0,.64,-.25),h.scaling.z=.92,h.material=s,h.parent=f;let g=vm.CreateBox(`car-roof`,{width:1.48,height:.16,depth:1.1},e);g.position.set(0,1.05,-.28),g.material=i,g.parent=f;let _=vm.CreateBox(`car-spoiler`,{width:2.15,height:.12,depth:.42},e);_.position.set(0,.83,-1.68),_.material=i,_.parent=f;for(let t of[-.65,.65]){let n=vm.CreateBox(`spoiler-mount-${t}`,{width:.12,height:.48,depth:.13},e);n.position.set(t,.58,-1.58),n.material=i,n.parent=f}for(let t of[-.72,.72]){let n=vm.CreateBox(`headlight-${t}`,{width:.42,height:.18,depth:.08},e);n.position.set(t,.28,1.87),n.material=c,n.parent=f}let v=[],y=[],b=[[-1.08,-.05,1.15,!0],[1.08,-.05,1.15,!0],[-1.08,-.05,-1.15,!1],[1.08,-.05,-1.15,!1]];b.forEach(([t,n,r,i],s)=>{let c=new wc(`wheel-pivot-${s}`,e);c.position.set(t,n,r),c.parent=f;let l=vm.CreateCylinder(`wheel-${s}`,{diameter:.88,height:.5,tessellation:24},e);l.rotation.z=Math.PI/2,l.material=a,l.parent=c;let u=vm.CreateCylinder(`wheel-hub-${s}`,{diameter:.36,height:.52,tessellation:16},e);u.rotation.z=Math.PI/2,u.material=o,u.parent=c,y.push(l,u),i&&v.push(c)});let x=vm.CreateCylinder(`antenna`,{diameter:.055,height:2.1,tessellation:10},e);x.position.set(.58,1.47,-.8),x.rotation.z=-.14,x.material=i,x.parent=f;let S=vm.CreateSphere(`antenna-tip`,{diameter:.18,segments:12},e);S.position.set(.73,2.49,-.8),S.material=r,S.parent=f,f.getChildMeshes().forEach(e=>t.addShadowCaster(e));let C=new ZO(l,YO.BOX,{mass:2.4,friction:.72,restitution:.02},e);C.body.setLinearDamping(.18),C.body.setAngularDamping(.72);let w={chassis:l,aggregate:C,presentationRoot:u,driftRoot:d,visualRoot:f,frontWheelPivots:v,wheelPivots:b.map((t,n)=>e.getTransformNodeByName(`wheel-pivot-${n}`)),wheelMeshes:y,wheelVisuals:[],dispose:()=>{C.dispose(),l.dispose(!1,!0),u.dispose(!1,!0)}};return w.wheelVisuals=v7(w),w}var y2e=class{constructor(e,t,n,r,i){this.previousPosition=new j,this.currentPosition=new j,this.previousRotation=new A,this.currentRotation=new A,this.accumulator=0,this.scene=e,this.physicsNode=t,this.presentationNode=n,this.fixedStep=r,this.maximumAccumulator=r*i,this.resetToPhysicsPose(),this.observer=e.onBeforeRenderObservable.add(()=>this.present())}beginFrame(e){this.scene.physicsEnabled&&(this.accumulator=Math.min(this.maximumAccumulator,this.accumulator+Math.max(0,e)))}capturePhysicsPose(){let e=this.physicsNode.position,t=this.physicsNode.rotationQuaternion??A.Identity();if(j.DistanceSquared(e,this.currentPosition)>16){this.previousPosition.copyFrom(e),this.currentPosition.copyFrom(e),this.previousRotation.copyFrom(t),this.currentRotation.copyFrom(t),this.accumulator=0;return}this.previousPosition.copyFrom(this.currentPosition),this.previousRotation.copyFrom(this.currentRotation),this.currentPosition.copyFrom(e),this.currentRotation.copyFrom(t),this.accumulator=Math.max(0,this.accumulator-this.fixedStep)}resetToPhysicsPose(){let e=this.physicsNode.rotationQuaternion??A.Identity();this.previousPosition.copyFrom(this.physicsNode.position),this.currentPosition.copyFrom(this.physicsNode.position),this.previousRotation.copyFrom(e),this.currentRotation.copyFrom(e),this.presentationNode.position.copyFrom(this.physicsNode.position),this.presentationNode.rotationQuaternion??=A.Identity(),this.presentationNode.rotationQuaternion.copyFrom(e),this.accumulator=0}dispose(){this.scene.onBeforeRenderObservable.remove(this.observer)}present(){let e=Math.max(0,Math.min(1,this.accumulator/this.fixedStep));j.LerpToRef(this.previousPosition,this.currentPosition,e,this.presentationNode.position),this.presentationNode.rotationQuaternion??=A.Identity(),A.SlerpToRef(this.previousRotation,this.currentRotation,e,this.presentationNode.rotationQuaternion)}},b2e=7*Math.PI/180,x2e=3.5*Math.PI/180,S2e=class{constructor(e,t,n){this.targetYaw=0,this.targetRoll=0,this.targetAmount=0,this.yaw=0,this.roll=0,this.amount=0,this.scene=e,this.visualRoot=n,this.visualRoot.rotationQuaternion??=A.Identity(),this.smoke=[-.78,.78].map((n,r)=>{let i=new K(`drift-smoke-emitter-${r}`,e);i.isVisible=!1,i.parent=t,i.position.set(n,-.28,-1.32);let a=new RZ(`drift-smoke-${r}`,120,e);return a.particleTexture=new W(`assets/kenney/particle-pack/sprites/smoke_04.png`,e),a.emitter=i,a.minEmitBox.set(-.08,-.02,-.08),a.maxEmitBox.set(.08,.04,.08),a.color1=new fe(.74,.77,.78,.3),a.color2=new fe(.5,.53,.54,.18),a.colorDead=new fe(.42,.44,.45,0),a.minSize=.12,a.maxSize=.32,a.minLifeTime=.24,a.maxLifeTime=.58,a.emitRate=0,a.direction1=new j(-.25,.45,-.35),a.direction2=new j(.25,.85,.15),a.minEmitPower=.4,a.maxEmitPower=1.05,a.updateSpeed=.012,a.start(),a}),this.observer=e.onBeforeRenderObservable.add(()=>this.update())}setVehicleState(e){let t=Math.abs(e.forwardSpeed),n=x7((t-2.5)/8,0,1),r=Math.atan2(e.lateralSpeed,Math.max(t,2)),i=x7((Math.abs(r)-.04)/.25,0,1),a=+(e.groundedWheelCount>=2);this.targetAmount=n*i*a,this.targetYaw=x7(-r*.55,-b2e,b2e)*n*a,this.targetRoll=x7(-e.lateralSpeed*.018,-x2e,x2e)*n*a}reset(){this.targetYaw=0,this.targetRoll=0,this.targetAmount=0,this.yaw=0,this.roll=0,this.amount=0,this.visualRoot.rotationQuaternion??=A.Identity(),this.visualRoot.rotationQuaternion.copyFrom(A.Identity()),this.smoke.forEach(e=>{e.emitRate=0})}dispose(){this.scene.onBeforeRenderObservable.remove(this.observer),this.smoke.forEach(e=>{let t=e.emitter;e.dispose(),t instanceof wc&&t.dispose()})}update(){let e=Math.min(.05,this.scene.getEngine().getDeltaTime()/1e3),t=1-Math.exp(-10*e),n=1-Math.exp(-7*e);this.yaw+=(this.targetYaw-this.yaw)*t,this.roll+=(this.targetRoll-this.roll)*t,this.amount+=(this.targetAmount-this.amount)*n,this.visualRoot.rotationQuaternion??=A.Identity(),A.FromEulerAnglesToRef(0,this.yaw,this.roll,this.visualRoot.rotationQuaternion),this.smoke.forEach(e=>{e.emitRate=this.amount*34})}};function x7(e,t,n){return Math.max(t,Math.min(n,e))}var C2e=4.6,w2e=1.85,T2e=5.4,S7=Math.PI*.82,E2e=class{constructor(e,t,n,r={}){this.smoothedLookAt=new j,this.previousForward=j.Forward(),this.orbitYaw=0,this.heightAdjustment=0,this.distance=C2e,this.dragging=!1,this.pointerId=null,this.lastPointerX=0,this.lastPointerY=0,this.lastInteractionAt=0,this.filteredYawRate=0,this.motionBlurPending=!1,this.onPointerDown=e=>{this.scene.activeCamera===this.camera&&(e.isPrimary===!1||e.pointerType===`mouse`&&e.button!==0||this.dragging||(this.dragging=!0,this.pointerId=e.pointerId,this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.lastInteractionAt=performance.now(),this.canvas.focus({preventScroll:!0}),this.canvas.setPointerCapture?.(e.pointerId),e.preventDefault()))},this.onPointerMove=e=>{if(!this.dragging||e.pointerId!==this.pointerId)return;let t=e.clientX-this.lastPointerX,n=e.clientY-this.lastPointerY;this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.applyDrag(t,n),e.preventDefault()},this.onPointerUp=e=>{e.pointerId===this.pointerId&&(this.dragging=!1,this.pointerId=null,this.lastInteractionAt=performance.now(),this.canvas.hasPointerCapture?.(e.pointerId)&&this.canvas.releasePointerCapture(e.pointerId))},this.onMouseDown=e=>{this.scene.activeCamera!==this.camera||e.button!==0||this.dragging||(this.dragging=!0,this.pointerId=null,this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.lastInteractionAt=performance.now(),this.canvas.focus({preventScroll:!0}),e.preventDefault())},this.onMouseMove=e=>{if(!this.dragging||this.pointerId!==null)return;let t=e.clientX-this.lastPointerX,n=e.clientY-this.lastPointerY;this.lastPointerX=e.clientX,this.lastPointerY=e.clientY,this.applyDrag(t,n),e.preventDefault()},this.onMouseUp=e=>{!this.dragging||this.pointerId!==null||e.button!==0||(this.dragging=!1,this.lastInteractionAt=performance.now())},this.onWindowBlur=()=>{this.dragging=!1,this.pointerId=null,this.lastInteractionAt=performance.now()},this.onWheel=e=>{this.scene.activeCamera===this.camera&&(this.distance=xq.Clamp(this.distance+e.deltaY*.004,3.35,6.8),this.lastInteractionAt=performance.now(),e.preventDefault())},this.scene=e,this.canvas=t,this.target=n,this.enableMotionBlur=r.enableMotionBlur??!1,this.camera=new mh(`race-camera`,j.Zero(),e),this.camera.minZ=.06,this.camera.maxZ=500,this.camera.fov=65*Math.PI/180,this.camera.inertia=0,t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),window.addEventListener(`pointerup`,this.onPointerUp),window.addEventListener(`pointercancel`,this.onPointerUp),t.addEventListener(`mousedown`,this.onMouseDown),window.addEventListener(`mousemove`,this.onMouseMove),window.addEventListener(`mouseup`,this.onMouseUp),window.addEventListener(`blur`,this.onWindowBlur),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.beforeRenderObserver=e.onBeforeRenderObservable.add(()=>this.update()),this.snapToTarget()}activate(){this.snapToTarget(),this.scene.activeCamera=this.camera,!(!this.enableMotionBlur||this.motionBlur||this.motionBlurPending)&&(this.motionBlurPending=!0,this.scene.onAfterRenderObservable.addOnce(()=>{this.motionBlurPending=!1,!(this.scene.isDisposed||this.scene.activeCamera!==this.camera)&&(this.motionBlur=new T1(`race-camera-motion-blur`,this.scene,1,this.camera),this.motionBlur.isObjectBased=!1,this.motionBlur.motionStrength=.16,this.motionBlur.motionBlurSamples=8)}))}snapToTarget(){this.orbitYaw=0,this.heightAdjustment=0,this.filteredYawRate=0;let e=this.calculatePose();this.camera.position.copyFrom(e.position),this.smoothedLookAt.copyFrom(e.lookAt),this.camera.setTarget(this.smoothedLookAt),this.previousForward.copyFrom(e.forward)}dispose(){this.canvas.removeEventListener(`pointerdown`,this.onPointerDown),this.canvas.removeEventListener(`pointermove`,this.onPointerMove),window.removeEventListener(`pointerup`,this.onPointerUp),window.removeEventListener(`pointercancel`,this.onPointerUp),this.canvas.removeEventListener(`mousedown`,this.onMouseDown),window.removeEventListener(`mousemove`,this.onMouseMove),window.removeEventListener(`mouseup`,this.onMouseUp),window.removeEventListener(`blur`,this.onWindowBlur),this.canvas.removeEventListener(`wheel`,this.onWheel),this.scene.onBeforeRenderObservable.remove(this.beforeRenderObserver),this.motionBlur?.dispose(this.camera),this.camera.dispose()}applyDrag(e,t){this.orbitYaw=xq.Clamp(this.orbitYaw+e*.005,-S7,S7),this.heightAdjustment=xq.Clamp(this.heightAdjustment-t*.006,-.65,1.05),this.lastInteractionAt=performance.now()}update(){if(this.scene.activeCamera!==this.camera)return;let e=xq.Clamp(this.scene.getEngine().getDeltaTime()/1e3,1/240,1/20);if(!this.dragging&&performance.now()-this.lastInteractionAt>500){let t=1-Math.exp(-2.35*e);this.orbitYaw=xq.Lerp(this.orbitYaw,0,t),this.heightAdjustment=xq.Lerp(this.heightAdjustment,0,t)}let t=this.calculatePose();j.LerpToRef(this.camera.position,t.position,1-Math.exp(-7.5*e),this.camera.position),j.LerpToRef(this.smoothedLookAt,t.lookAt,1-Math.exp(-10.5*e),this.smoothedLookAt),this.camera.setTarget(this.smoothedLookAt);let n=Math.atan2(this.previousForward.x,this.previousForward.z),r=Math.atan2(t.forward.x,t.forward.z),i=Math.atan2(Math.sin(r-n),Math.cos(r-n));this.filteredYawRate=xq.Lerp(this.filteredYawRate,i/e,1-Math.exp(-5*e));let a=xq.Clamp(-this.filteredYawRate*.012,-.035,.035);this.camera.rotation.z=xq.Lerp(this.camera.rotation.z,a,1-Math.exp(-4.5*e)),this.previousForward.copyFrom(t.forward)}calculatePose(){this.target.computeWorldMatrix(!0);let e=this.target.getAbsolutePosition(),t=this.target.getDirection(j.Forward());t.y=0,t.lengthSquared()<1e-4&&t.copyFrom(j.Forward()),t.normalize();let n=j.TransformNormal(t,M.RotationY(this.orbitYaw)).normalize(),r=e.subtract(n.scale(this.distance)).addInPlaceFromFloats(0,w2e+this.heightAdjustment,0),i=T2e*(1-Math.min(1,Math.abs(this.orbitYaw)/S7)*.82);return{position:r,lookAt:e.add(t.scale(i)).addInPlaceFromFloats(0,.42,0),forward:t}}},D2e=87,O2e=65,k2e=83,A2e=68,j2e=81,M2e=69,N2e=class{constructor(e,t,n){this.boostActive=!1,this.keyboardSuspended=!1,this.disposed=!1,this.focusCanvas=()=>this.canvas.focus({preventScroll:!0}),this.preventContextMenu=e=>e.preventDefault(),this.onKeyDown=e=>{this.scene.activeCamera===this.camera&&(C7(e.target)||((e.code===`ShiftLeft`||e.code===`ShiftRight`)&&(this.boostActive=!0),(e.code===`KeyR`||e.code===`Digit1`)&&!e.repeat&&this.resetView(),e.code===`Digit2`&&!e.repeat&&this.focusPoint(new j(-102,0,157),78),e.code===`Digit3`&&!e.repeat&&this.focusPoint(new j(-16,0,56),92),e.code===`Digit4`&&!e.repeat&&this.focusPoint(new j(70,0,-116),118),e.code===`Digit5`&&!e.repeat&&this.focusPointFrom(new j(158,0,-55),new j(-92,68,-38)),e.code===`Digit6`&&!e.repeat&&this.focusPointFrom(new j(20,0,-207),new j(58,66,92)),e.code===`Digit7`&&!e.repeat&&this.focusPointFrom(new j(-184,0,70),new j(92,74,-76)),e.code===`Digit8`&&!e.repeat&&this.focusPointFrom(new j(0,13,112),new j(0,14,-58)),e.code===`Digit9`&&!e.repeat&&this.focusPointFrom(new j(70,15,-132),new j(0,15,-58)),e.code===`Digit0`&&!e.repeat&&this.focusPointFrom(new j(-98,13,84),new j(0,14,58)),e.code===`KeyH`&&!e.repeat&&this.focusPointFrom(new j(-35,13,8),new j(58,14,0))))},this.onKeyUp=e=>{(e.code===`ShiftLeft`||e.code===`ShiftRight`)&&(this.boostActive=!1)},this.onFocusIn=e=>{!C7(e.target)||this.keyboardSuspended||(this.keyboardInput?.detachControl(),this.keyboardSuspended=!0,this.boostActive=!1)},this.onFocusOut=()=>{queueMicrotask(()=>{this.disposed||!this.keyboardSuspended||C7(document.activeElement)||(this.keyboardInput?.attachControl(!1),this.keyboardSuspended=!1)})},this.scene=e,this.canvas=t;let r=P2e(n);this.initialPosition=r.position,this.initialTarget=r.target,this.normalSpeed=r.speed;let i=new vh(`map-fly-review-camera`,r.position.clone(),e);this.camera=i,i.minZ=.08,i.maxZ=Math.max(2e3,r.span*8),i.fov=67*Math.PI/180,i.inertia=.38,i.angularSensibility=1600,i.speed=this.normalSpeed,i.keysUp.push(D2e),i.keysDown.push(k2e),i.keysLeft.push(O2e),i.keysRight.push(A2e),i.keysUpward.push(M2e),i.keysDownward.push(j2e),i.setTarget(this.initialTarget),i.attachControl(t,!1),this.keyboardInput=i.inputs.attached.keyboard;let a=i.inputs.attached.mouse;a&&(a.buttons=[1,2]),e.activeCamera=i,t.addEventListener(`pointerdown`,this.focusCanvas),t.addEventListener(`contextmenu`,this.preventContextMenu),window.addEventListener(`keydown`,this.onKeyDown),window.addEventListener(`keyup`,this.onKeyUp),document.addEventListener(`focusin`,this.onFocusIn),document.addEventListener(`focusout`,this.onFocusOut),this.beforeRenderObserver=e.onBeforeRenderObservable.add(()=>this.updateSpeed())}dispose(){this.disposed=!0,this.canvas.removeEventListener(`pointerdown`,this.focusCanvas),this.canvas.removeEventListener(`contextmenu`,this.preventContextMenu),window.removeEventListener(`keydown`,this.onKeyDown),window.removeEventListener(`keyup`,this.onKeyUp),document.removeEventListener(`focusin`,this.onFocusIn),document.removeEventListener(`focusout`,this.onFocusOut),this.scene.onBeforeRenderObservable.remove(this.beforeRenderObserver),this.camera.detachControl(),this.camera.dispose()}updateSpeed(){let e=this.normalSpeed*(this.boostActive?5.5:1);this.camera.speed=xq.Lerp(this.camera.speed,e,.24)}resetView(){this.camera.position.copyFrom(this.initialPosition),this.camera.cameraDirection.setAll(0),this.camera.cameraRotation.setAll(0),this.camera.setTarget(this.initialTarget)}focusPoint(e,t){this.focusPointFrom(e,new j(t*.62,t*.72,-t*.62))}focusPointFrom(e,t){this.camera.position.copyFrom(e.add(t)),this.camera.cameraDirection.setAll(0),this.camera.cameraRotation.setAll(0),this.camera.setTarget(e)}};function C7(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable||!!e.closest(`[contenteditable="true"]`)}function P2e(e){if(e.length===0)return{position:new j(80,100,-80),target:j.Zero(),speed:3.2,span:180};let t=1/0,n=-1/0,r=1/0,i=-1/0,a=0;e.forEach(e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.z),i=Math.max(i,e.z),a=Math.max(a,e.y)});let o=new j((t+n)/2,a+1,(r+i)/2),s=Math.max(80,n-t,i-r)*1.28;return{position:o.add(new j(s*.34,s*.68,-s*.56)),target:o,speed:xq.Clamp(s/92,2.4,7.4),span:s}}var w7=(e,t=-1,n=1)=>Math.min(n,Math.max(t,e)),F2e=class{constructor(){window.__scInput=this,this.keys=new Set,this.touchThrottle=0,this.touchSteering=0,this.touchBrake=0,this.touchHandbrake=!1,this.resetRequested=!1,this.powerupRequested=!1,this.gamepadPowerupWasDown=!1,this.disposed=!1,this.onKeyDown=e=>{[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`].includes(e.code)&&e.preventDefault(),this.keys.add(e.code),e.code===`KeyR`&&(this.resetRequested=!0),e.code===`KeyE`&&!e.repeat&&(this.powerupRequested=!0)},this.onKeyUp=e=>{this.keys.delete(e.code)},window.addEventListener(`keydown`,this.onKeyDown,{passive:!1}),window.addEventListener(`keyup`,this.onKeyUp)}setTouchDrive(e,t){this.touchThrottle=w7(e),this.touchSteering=w7(t)}setTouchBrake(e){this.touchBrake=w7(e,0,1)}setTouchHandbrake(e){this.touchHandbrake=e}requestReset(){this.resetRequested=!0}requestUsePowerup(){this.powerupRequested=!0}sample(){let e=Number(this.keys.has(`KeyW`)||this.keys.has(`ArrowUp`))-Number(this.keys.has(`KeyS`)||this.keys.has(`ArrowDown`)),t=Number(this.keys.has(`KeyD`)||this.keys.has(`ArrowRight`))-Number(this.keys.has(`KeyA`)||this.keys.has(`ArrowLeft`)),n=Number(this.keys.has(`ShiftLeft`)||this.keys.has(`ShiftRight`)),r=this.keys.has(`Space`),i=navigator.getGamepads?.()[0];if(i){let a=.12,o=Math.abs(i.axes[0]??0)>a?i.axes[0]:0,s=Math.abs(i.axes[1]??0)>a?-(i.axes[1]??0):0;t=Math.abs(o)>Math.abs(t)?o:t,e=Math.abs(s)>Math.abs(e)?s:e,n=Math.max(n,i.buttons[6]?.value??0),r||=i.buttons[0]?.pressed??!1;let c=i.buttons[1]?.pressed??!1;c&&!this.gamepadPowerupWasDown&&(this.powerupRequested=!0),this.gamepadPowerupWasDown=c,i.buttons[9]?.pressed&&(this.resetRequested=!0)}else this.gamepadPowerupWasDown=!1;Math.abs(this.touchThrottle)>Math.abs(e)&&(e=this.touchThrottle),Math.abs(this.touchSteering)>Math.abs(t)&&(t=this.touchSteering),n=Math.max(n,this.touchBrake),r||=this.touchHandbrake;let a=this.resetRequested;this.resetRequested=!1;let o=this.powerupRequested;return this.powerupRequested=!1,{throttle:w7(e),steering:w7(t),brake:w7(n,0,1),handbrake:r,reset:a,usePowerup:o}}dispose(){this.disposed||(this.disposed=!0,window.removeEventListener(`keydown`,this.onKeyDown),window.removeEventListener(`keyup`,this.onKeyUp))}},I2e=class{constructor(e){window.__scRace=this,this.phase=`menu`,this.raceStartedAt=0,this.countdownStartedAt=0,this.lapStartedAt=0,this.pausedAt=0,this.penaltyMs=0,this.currentCheckpoint=1,this.currentLap=1,this.lapTimes=[],this.checkpoints=e.checkpoints,this.totalLaps=e.totalLaps??3;let t=e.checkpointRadius??5.25;this.checkpointRadiusSquared=t*t,this.onPhaseChange=e.onPhaseChange,this.onResult=e.onResult}getPhase(){return this.phase}setTotalLaps(e){this.phase!==`menu`&&this.phase!==`finished`||(this.totalLaps=Math.max(1,Math.min(9,Math.round(e))))}start(e=performance.now()){this.lapTimes.length=0,this.currentCheckpoint=1,this.currentLap=1,this.countdownStartedAt=e,this.raceStartedAt=0,this.lapStartedAt=0,this.penaltyMs=0,this.setPhase(`countdown`)}addPenalty(e){this.penaltyMs+=Math.max(0,e)}returnToMenu(){this.setPhase(`menu`)}togglePause(e=performance.now()){if(this.phase===`racing`)this.pausedAt=e,this.setPhase(`paused`);else if(this.phase===`paused`){let t=e-this.pausedAt;this.raceStartedAt+=t,this.lapStartedAt+=t,this.pausedAt=0,this.setPhase(`racing`)}}update(e,t=performance.now()){if(this.phase===`countdown`){t-this.countdownStartedAt>=3200&&(this.raceStartedAt=t,this.lapStartedAt=t,this.setPhase(`racing`));return}if(this.phase!==`racing`)return;let n=this.checkpoints[this.currentCheckpoint],r=e.x-n.x,i=e.z-n.z;if(r*r+i*i>this.checkpointRadiusSquared)return;if(this.currentCheckpoint!==0){this.currentCheckpoint+=1,this.currentCheckpoint>=this.checkpoints.length&&(this.currentCheckpoint=0);return}let a=t-this.lapStartedAt;if(this.lapTimes.push(a),this.currentLap>=this.totalLaps){this.setPhase(`finished`),this.onResult?.({totalTimeMs:t-this.raceStartedAt+this.penaltyMs,bestLapMs:Math.min(...this.lapTimes),lapTimes:[...this.lapTimes]});return}this.currentLap+=1,this.currentCheckpoint=1,this.lapStartedAt=t}telemetry(e,t,n=performance.now()){let r=n-this.countdownStartedAt,i=this.phase===`countdown`?Math.max(0,Math.ceil((3e3-r)/1e3)):null,a=this.raceStartedAt>0?n-this.raceStartedAt+this.penaltyMs:0;return{phase:this.phase,speedKph:e,lap:this.currentLap,totalLaps:this.totalLaps,position:1,racers:1,elapsedMs:a,bestLapMs:this.lapTimes.length?Math.min(...this.lapTimes):null,currentLapMs:this.lapStartedAt>0?n-this.lapStartedAt:0,countdown:i,checkpoint:this.currentCheckpoint,checkpointCount:this.checkpoints.length,airborne:t,wrongWay:!1,surface:`asphalt`,boost:0,direction:`straight`}}setPhase(e){e!==this.phase&&(this.phase=e,this.onPhaseChange?.(e))}},L2e={killHeight:-20,upsideDownUpDot:-.2,upsideDownDelay:3,cooldown:.6,lift:.18},R2e=class{constructor(e,t,n,r={}){this._upsideDownTime=0,this._cooldownRemaining=0,this._teleportGeneration=0,this._preTeleportType=null,this._scene=e,this._body=t,this.options={...L2e,...r},this._checkpoint=T7(n)}setCheckpoint(e){this._checkpoint=T7(e)}getCheckpoint(){return T7(this._checkpoint)}update(e,t,n=!1){let r=Math.max(0,Math.min(e,.1));this._cooldownRemaining=Math.max(0,this._cooldownRemaining-r),t=this.options.upsideDownDelay;return(n||i||a)&&this._cooldownRemaining<=0?(this.respawn(),!0):!1}respawn(e=this._checkpoint){let t=this._body.transformNode,n=e.position.add(new j(0,this.options.lift,0)),r=this._preTeleportType??this._body.getPrestepType();this._preTeleportType=r;let i=++this._teleportGeneration;t.position.copyFrom(n),t.rotationQuaternion??=A.Identity(),t.rotationQuaternion.copyFrom(e.rotation),t.computeWorldMatrix(!0),this._body.setLinearVelocity(j.Zero()),this._body.setAngularVelocity(j.Zero()),this._body.setPrestepType(XO.TELEPORT),this._scene.onAfterPhysicsObservable.addOnce(()=>{i===this._teleportGeneration&&(this._body.setLinearVelocity(j.Zero()),this._body.setAngularVelocity(j.Zero()),this._body.setPrestepType(r),this._preTeleportType=null)}),this._upsideDownTime=0,this._cooldownRemaining=this.options.cooldown}};function z2e(e){let t=e.transformNode;return{position:t.position.clone(),rotation:(t.rotationQuaternion??A.Identity()).clone()}}function T7(e){return{position:e.position.clone(),rotation:e.rotation.clone()}}var B2e=[`hatchback-sports.glb`,`race-future.glb`,`sedan-sports.glb`,`suv-luxury.glb`,`race.glb`],V2e=1.9,H2e=.72,U2e=3.35,W2e=class{constructor(e,t,n,r,i){this.opponents=[],this.segmentLengths=[],this.totalLength=0,this.racing=!1,this.raceTime=0,this.scene=e,this.shadow=t,this.path=n,this.grid=r,this.startHeading=i;for(let e=0;ethis.loadOpponent(t));(await Promise.allSettled(t)).forEach(e=>{e.status===`fulfilled`?this.opponents.push(e.value):console.warn(`An opponent model could not be loaded.`,e.reason)})}setRacing(e){this.racing=e}reset(){this.raceTime=0,this.opponents.forEach(e=>{e.distance=this.distanceAlongPath(e.spawnPosition),e.disabledUntil=0,e.slowedUntil=0,e.slowMultiplier=1,e.laneOffset=e.preferredLane,e.targetLaneOffset=e.preferredLane,e.respawn.respawn({position:e.spawnPosition,rotation:A.RotationAxis(j.Up(),this.startHeading)})}),this.racing=!1}update(e,t){let n=E7(e,0,.05),r=performance.now();this.racing&&(this.raceTime+=n);for(let e of this.opponents){let i=e.aggregate.body,a=i.getLinearVelocity(),o=e.root.rotationQuaternion??A.Identity(),s=G2e(j.Up(),o);if(e.respawn.update(n,s.y,!1)){e.distance=this.distanceAlongPath(e.spawnPosition);continue}if(!this.racing){i.setLinearVelocity(new j(0,Math.min(0,a.y),0)),i.setAngularVelocity(j.Zero());continue}let c=this.samplePath(e.distance),l=j.Dot(a,c.forward);e.distance+=E7(l,2.5,e.baseSpeed*1.18)*n;let u=7.5+Math.max(0,l)*.24,d=this.samplePath(e.distance+u),f=this.samplePath(e.distance+19),p=E7(j.Dot(d.forward,f.forward),-1,1),m=.68+.32*Math.sqrt(Math.max(0,(p+1)*.5)),h=this.findBlockingRacer(e,c,t),g=e.preferredLane+Math.sin(this.raceTime*.55+e.rhythm)*.22;e.targetLaneOffset=h?E7(g+(h.side<=0?2.15:-2.15),-2.45,2.45):g,e.laneOffset=K2e(e.laneOffset,e.targetLaneOffset,n*(1.7+e.aggression));let _=d.position.add(d.right.scale(e.laneOffset)).subtract(e.root.absolutePosition);_.y=0,_.lengthSquared()<.001?_.copyFrom(d.forward):_.normalize();let v=rw*w&&C.normalize().scaleInPlace(w),i.applyForce(C.scale(e.mass),i.getObjectCenterWorld()),i.applyForce(new j(0,-e.mass*3.2,0),i.getObjectCenterWorld());let T=G2e(j.Forward(),o),E=Math.atan2(T.x,T.z),ee=q2e(Math.atan2(_.x,_.z)-E),D=i.getAngularVelocity();i.setAngularVelocity(new j(D.x*.12,E7(ee*(3.8+e.aggression*.4),-2.8,2.8),D.z*.12))}}get positions(){return this.opponents.map(e=>e.root.position)}get abilityTargets(){return this.opponents.map(e=>({id:e.id,body:e.aggregate.body,radius:.96}))}disable(e,t){let n=this.opponents.find(t=>t.id===e);n&&(n.disabledUntil=Math.max(n.disabledUntil,performance.now()+t*1e3))}slow(e,t,n){let r=this.opponents.find(t=>t.id===e);if(!r)return;let i=performance.now();r.slowMultiplier=i{e.aggregate.dispose(),e.root.dispose(!1,!0)}),this.opponents.length=0}async loadOpponent(e){let t=B2e[e%B2e.length],n=await xD.ImportMeshAsync(``,`assets/kenney/car-kit/models/`,t,this.scene),r=(this.grid[e]??this.samplePath(8-e*5).position).clone(),i=vm.CreateBox(`opponent-${e}-body`,{width:V2e,height:H2e,depth:U2e},this.scene);i.position.copyFrom(r),i.rotationQuaternion=A.RotationAxis(j.Up(),this.startHeading),i.isVisible=!1,i.isPickable=!1;let a=new wc(`opponent-${e}-visual`,this.scene);a.parent=i;let o=n.meshes.find(e=>e.name===`__root__`)??n.meshes[0];o&&(o.parent=a,o.position.set(0,-.48,0),o.rotationQuaternion=null,o.rotation.set(0,0,0),o.scaling.setAll(1.42)),n.meshes.forEach(e=>{e.isPickable=!1,e.receiveShadows=!0,this.shadow.addShadowCaster(e)});let s=2.15+e%3*.16,c=new ZO(i,YO.BOX,{mass:s,friction:.72,restitution:.04},this.scene);c.body.setLinearDamping(.12),c.body.setAngularDamping(.82);let l=new R2e(this.scene,c.body,{position:r,rotation:A.RotationAxis(j.Up(),this.startHeading)},{killHeight:-3.5,upsideDownDelay:1.8,lift:.3}),u=(e%2==0?-1:1)*(1.15+e%3*.12);return{id:`opponent-${e}`,root:i,aggregate:c,respawn:l,spawnPosition:r,distance:this.distanceAlongPath(r),baseSpeed:21.5+e%4*1.25+Math.floor(e/4)*.7,mass:s,disabledUntil:0,slowedUntil:0,slowMultiplier:1,preferredLane:u,laneOffset:u,targetLaneOffset:u,aggression:.55+e%5*.11,rhythm:e*1.73}}findBlockingRacer(e,t,n){let r,i=n=>{let i=n.subtract(e.root.absolutePosition),a=j.Dot(i,t.forward),o=j.Dot(i,t.right);a<=.5||a>11||Math.abs(o)>2.35||(!r||a{t!==e&&i(t.root.absolutePosition)}),n&&i(n),r}distanceAlongPath(e){let t=0,n=1/0,r=0;for(let i=0;i0?E7(j.Dot(c,o)/s,0,1):0,u=a.add(o.scale(l)),d=j.DistanceSquared(e,u);dthis.segmentLengths[n];)t-=this.segmentLengths[n],n+=1;let r=this.path[n],i=this.path[(n+1)%this.path.length],a=this.segmentLengths[n],o=a>0?t/a:0,s=j.Lerp(r,i,o),c=i.subtract(r).normalize();return{position:s,heading:Math.atan2(c.x,c.z),forward:c,right:new j(c.z,0,-c.x)}}};function G2e(e,t){let n=j.Zero();return e.rotateByQuaternionToRef(t,n),n}function E7(e,t,n){return Math.max(t,Math.min(n,e))}function K2e(e,t,n){return Math.abs(t-e)<=n?t:e+Math.sign(t-e)*n}function q2e(e){return Math.atan2(Math.sin(e),Math.cos(e))}var J2e=class{constructor(e,t,n){this.pickups=[],this.elapsed=0,this.onCollect=n;let r=new lg(`pickup-shell`,e);r.diffuseColor=P.FromHexString(`#e3b51e`),r.emissiveColor=P.FromHexString(`#8d4f06`),r.specularColor=P.FromHexString(`#fff3a8`);let i=new lg(`pickup-core`,e);i.diffuseColor=P.FromHexString(`#de352a`),i.emissiveColor=P.FromHexString(`#7d100e`),t.forEach((t,n)=>{let a=vm.CreatePolyhedron(`powerup-${n}`,{type:1,size:.82},e);a.position.copyFrom(t),a.material=n%2==0?r:i,a.isPickable=!1;let o=vm.CreateTorus(`powerup-ring-${n}`,{diameter:1.75,thickness:.09,tessellation:24},e);o.position.copyFrom(t),o.rotation.x=Math.PI/2,o.material=r,o.isPickable=!1,this.pickups.push({mesh:a,ring:o,home:t.clone(),active:!0,respawnAt:0,phase:n*.71})}),this.burst=new RZ(`powerup-burst`,72,e),this.burst.particleTexture=new W(`assets/kenney/particle-pack/sprites/star_06.png`,e),this.burst.color1=fe.FromHexString(`#ffdf42ff`),this.burst.color2=fe.FromHexString(`#ef382bff`),this.burst.colorDead=fe.FromHexString(`#1a56b000`),this.burst.minSize=.12,this.burst.maxSize=.38,this.burst.minLifeTime=.18,this.burst.maxLifeTime=.55,this.burst.emitRate=0,this.burst.manualEmitCount=0,this.burst.minEmitPower=2.5,this.burst.maxEmitPower=5.5,this.burst.gravity=new j(0,-5,0),this.burst.direction1=new j(-1,.8,-1),this.burst.direction2=new j(1,2.8,1),this.burst.disposeOnStop=!1,this.burst.start()}update(e,t,n){this.elapsed+=e;let r=performance.now();for(let i of this.pickups){if(!i.active){r>=i.respawnAt&&(i.active=!0,i.mesh.setEnabled(!0),i.ring.setEnabled(!0));continue}let a=Math.sin(this.elapsed*2.7+i.phase)*.16;i.mesh.position.y=i.home.y+a,i.ring.position.y=i.home.y+a,i.mesh.rotation.y+=e*1.8,i.mesh.rotation.x+=e*.55,i.ring.rotation.z-=e*1.25,!(!n||j.DistanceSquared(t,i.mesh.position)>2.7)&&(this.onCollect&&!this.onCollect()||(i.active=!1,i.respawnAt=r+7500,i.mesh.setEnabled(!1),i.ring.setEnabled(!1),this.burst.emitter=i.mesh.position.clone(),this.burst.manualEmitCount=54))}}reset(){this.pickups.forEach(e=>{e.active=!0,e.respawnAt=0,e.mesh.setEnabled(!0),e.ring.setEnabled(!0)})}dispose(){this.burst.dispose(),this.pickups.forEach(e=>{e.mesh.dispose(),e.ring.dispose()}),this.pickups.length=0}},Y2e={"sports-car":`#d9252a`,"orange-off-road":`#ef7f25`,"pickup-truck":`#c8a56a`,"modified-sports-car":`#7d62c7`,"voltage-bandit":`#e7af32`,"kestrel-gt":`#4a90c7`,"pocket-rocket":`#e5532f`,"iron-howl":`#718c63`,"circuit-wasp":`#d9ded8`},D7=m7.map(e=>({id:e.id,name:e.name,subtitle:e.tagline,assetRootUrl:e.model.assetRootUrl,assetFile:e.model.fileName,modelRotation:e.model.rotation,wheelCenters:e.model.wheelCenters,accent:Y2e[e.id],className:e.class,drivetrain:e.drivetrain,engine:e.engine,stats:{speed:e.displayStats.speed,acceleration:e.displayStats.acceleration,handling:e.displayStats.handling,weight:e.displayStats.weight}})),X2e=[[`frontLeft`,`wheel-front-left`],[`frontRight`,`wheel-front-right`],[`rearLeft`,`wheel-back-left`],[`rearRight`,`wheel-back-right`]],O7=new j(620,34,620),k7=new j(0,.72,0),A7=new j(17,.58,0),j7={attract:{alpha:Math.PI*1.16,beta:Math.PI*.34,radius:14.8,target:O7.add(new j(-.4,1.6,0))},garage:{alpha:Math.PI*1.25,beta:Math.PI*.38,radius:11.6,target:O7.add(new j(0,1.55,0))},"track-preview":{alpha:Math.PI*1.17,beta:Math.PI*.3,radius:16.8,target:O7.add(A7).add(new j(0,.85,0))}};function Z2e(e){return P.FromHexString(e)}function M7(e,t,n,r=.8){let i=new lg(t,e);return i.diffuseColor=Z2e(n),i.specularColor=new P(1-r,1-r,1-r),i}function N7(e,t,n,r,i,a){let o=vm.CreateBox(n,r,e);return o.parent=t,o.position.copyFrom(i),o.material=a,o.isPickable=!1,o}function Q2e(e,t,n,r){let i=new wc(`${r}-placeholder`,e);i.parent=t;let a=M7(e,`${r}-placeholder-paint`,n,.36),o=M7(e,`${r}-placeholder-trim`,`#191b1d`,.58),s=M7(e,`${r}-placeholder-glass`,`#35474c`,.22);N7(e,i,`${r}-placeholder-body`,{width:2.1,height:.55,depth:4.2},new j(0,.65,0),a),N7(e,i,`${r}-placeholder-cabin`,{width:1.72,height:.68,depth:1.82},new j(0,1.19,-.22),s),N7(e,i,`${r}-placeholder-bumper`,{width:2.22,height:.18,depth:.2},new j(0,.45,-2.06),o);for(let t of[-1.05,1.05])for(let n of[-1.35,1.35]){let a=vm.CreateCylinder(`${r}-placeholder-wheel`,{diameter:.8,height:.34,tessellation:18},e);a.parent=i,a.position.set(t,.43,n),a.rotation.z=Math.PI*.5,a.material=o,a.isPickable=!1}return i}var $2e=class{constructor(e,t={}){this.cars=D7,this.loadedCars=[],this.previousCamera=null,this.observer=null,this.mode=`hidden`,this.selectedIndex=0,this.desiredPose=j7.attract,this.elapsed=0,this.disposed=!1,this.initializePromise=null,this.scene=e,this.options=t,this.assetRootUrl=t.assetRootUrl,this.quality=t.quality??this.detectQuality(),this.selectedIndex=Math.max(0,D7.findIndex(e=>e.id===t.initialCarId)),this.root=new wc(`yardline-frontend-root`,e),this.root.position.copyFrom(O7),this.garage=new wc(`yardline-garage`,e),this.garage.parent=this.root,this.diorama=new wc(`yardline-track-diorama`,e),this.diorama.parent=this.root,this.diorama.position.copyFrom(A7),this.carPivot=new wc(`yardline-selected-car-pivot`,e),this.carPivot.parent=this.root,this.carPivot.position.copyFrom(k7),this.camera=new gh(`yardline-frontend-camera`,j7.attract.alpha,j7.attract.beta,j7.attract.radius,j7.attract.target,e),this.camera.minZ=.05,this.camera.maxZ=180,this.camera.fov=.7,this.camera.lowerRadiusLimit=6.8,this.camera.upperRadiusLimit=24,this.camera.lowerBetaLimit=.35,this.camera.upperBetaLimit=1.34,this.camera.inputs.clear(),this.buildGarage(),this.buildDiorama(),this.createLights(),this.createCarSlots(),this.root.setEnabled(!1),t.autoUpdate!==!1&&(this.observer=e.onBeforeRenderObservable.add(()=>this.update()))}initialize(){return this.initializePromise||=this.loadCars(),this.initializePromise}getMode(){return this.mode}getQuality(){return this.quality}getSelectedCar(){return D7[this.selectedIndex]}getSelectedIndex(){return this.selectedIndex}setMode(e,t=!1){if(this.disposed||e===this.mode)return;if(e===`hidden`){this.mode=e,this.root.setEnabled(!1),this.scene.activeCamera===this.camera&&this.previousCamera&&(this.scene.activeCamera=this.previousCamera);return}this.mode===`hidden`&&(this.previousCamera=this.scene.activeCamera),this.mode=e,this.root.setEnabled(!0),this.scene.activeCamera=this.camera;let n=e===`track`?`track-preview`:e;this.desiredPose=j7[n],this.garage.setEnabled(n!==`track-preview`),this.diorama.setEnabled(n===`track-preview`),n===`track-preview`?(this.carPivot.position.copyFrom(A7.add(new j(-3.2,.58,1.1))),this.carPivot.scaling.setAll(.42),this.carPivot.rotation.y=Math.PI*.44):(this.carPivot.position.copyFrom(k7),this.carPivot.scaling.setAll(1)),this.applyCarLayout(n),t&&this.applyPose(this.desiredPose)}setVisible(e){e?this.setMode(this.mode===`hidden`?`attract`:this.mode):this.setMode(`hidden`)}selectCar(e){let t=typeof e==`number`?(e%D7.length+D7.length)%D7.length:D7.findIndex(t=>t.id===e);if(t<0||t===this.selectedIndex)return this.getSelectedCar();this.selectedIndex=t;let n=this.mode===`track`?`track-preview`:this.mode===`hidden`?`attract`:this.mode;this.applyCarLayout(n);let r=this.getSelectedCar();return this.options.onSelectionChange?.(r,t),r}stepCar(e){return this.selectCar(this.selectedIndex+e)}setQuality(e){this.quality=e;let t=e!==`low`;for(let e of this.diorama.getChildMeshes())e.metadata?.frontendDetail===`secondary`&&e.setEnabled(t)}dispose(){this.disposed||(this.disposed=!0,this.observer&&this.scene.onBeforeRenderObservable.remove(this.observer),this.observer=null,this.scene.activeCamera===this.camera&&this.previousCamera&&(this.scene.activeCamera=this.previousCamera),this.camera.dispose(),this.root.dispose(!1,!0),this.loadedCars.length=0)}detectQuality(){let e=typeof matchMedia<`u`&&matchMedia(`(pointer: coarse)`).matches,t=typeof navigator<`u`?navigator.hardwareConcurrency??4:4;return e||t<=4?`low`:t>=10?`high`:`balanced`}createCarSlots(){for(let e=0;e{if(!this.disposed){try{let t=this.assetRootUrl??n.definition.assetRootUrl,r=await xD.ImportMeshAsync(``,t,n.definition.assetFile,this.scene);if(this.disposed){r.meshes.forEach(e=>e.dispose(!1,!0));return}let i=[...r.meshes,...r.transformNodes],a=new Set(i);for(let e of i)(!e.parent||!a.has(e.parent))&&(e.parent=n.modelRoot);n.importedNodes=i,this.normalizeImportedCar(n,r.meshes),n.placeholder.dispose(!1,!0),n.loaded=!0,e+=1}catch(e){n.failed=!0,t+=1,console.warn(`[Yardline frontend] Failed to load ${n.definition.assetFile}; using fallback.`,e)}this.emitLoading(e,t,e+t===D7.length)}});await Promise.allSettled(n);let r=this.mode===`track`?`track-preview`:this.mode===`hidden`?`attract`:this.mode;this.applyCarLayout(r)}normalizeImportedCar(e,t){let n=t.filter(e=>e.getTotalVertices()>0);if(n.length===0)return;for(let[t,r]of X2e){let i=n.find(e=>e.name.toLowerCase()===r),a=e.definition.wheelCenters?.[t];i&&a&&i.position.set(...a)}e.modelRoot.rotation.set(...e.definition.modelRotation),e.modelRoot.computeWorldMatrix(!0);let r=new j(1/0,1/0,1/0),i=new j(-1/0,-1/0,-1/0);for(let e of n){e.computeWorldMatrix(!0);let t=e.getBoundingInfo().boundingBox;r=j.Minimize(r,t.minimumWorld),i=j.Maximize(i,t.maximumWorld),e.isPickable=!1}let a=i.subtract(r),o=4.55/Math.max(a.x,a.z,.01),s=r.add(i).scale(.5),c=e.root.getAbsolutePosition(),l=s.subtract(c),u=r.y-c.y;e.modelRoot.scaling.setAll(o),e.modelRoot.position.set(-l.x*o,-u*o,-l.z*o)}emitLoading(e,t,n){this.options.onLoadingState?.({loaded:e,failed:t,total:D7.length,complete:n})}update(e){if(this.mode===`hidden`||this.disposed)return;let t=Math.min(e??this.scene.getEngine().getDeltaTime()/1e3,.05);this.elapsed+=t;let n=1-Math.exp(-t*6.5);this.camera.alpha+=(this.desiredPose.alpha-this.camera.alpha)*n,this.camera.beta+=(this.desiredPose.beta-this.camera.beta)*n,this.camera.radius+=(this.desiredPose.radius-this.camera.radius)*n;let r=this.camera.getTarget();this.camera.setTarget(j.Lerp(r,this.desiredPose.target,n));let i=this.loadedCars[this.selectedIndex]?.root;this.mode===`attract`?(this.camera.alpha+=t*.055,i&&(i.rotation.y+=t*.19)):this.mode===`garage`?(i&&(i.rotation.y+=t*.34),this.carPivot.position.y=k7.y+Math.sin(this.elapsed*1.15)*.018):this.camera.alpha+=Math.sin(this.elapsed*.23)*t*.012}applyPose(e){this.camera.alpha=e.alpha,this.camera.beta=e.beta,this.camera.radius=e.radius,this.camera.setTarget(e.target)}applyCarLayout(e){let t=this.loadedCars.length;if(t!==0)for(let n=0;nMath.floor(t/2)?i-t:i;if(r.root.rotation.set(0,0,0),e!==`garage`){let e=n===this.selectedIndex;r.root.setEnabled(e),r.root.position.set(0,0,0),r.root.scaling.setAll(1);continue}r.root.setEnabled(!0),a===0?(r.root.position.set(0,0,0),r.root.scaling.setAll(1)):Math.abs(a)===1?(r.root.position.set(a*5.25,.92,1.5),r.root.scaling.setAll(.43),r.root.rotation.y=a*-.38):(r.root.position.set(a*3.9,3.32,4.65),r.root.scaling.setAll(.29),r.root.rotation.y=a*-.2)}}buildGarage(){let e=M7(this.scene,`frontend-floor-dark`,`#6c4b2d`,.62),t=M7(this.scene,`frontend-floor-light`,`#8f6841`,.58),n=M7(this.scene,`frontend-wall`,`#111c2b`,.9),r=M7(this.scene,`frontend-beam`,`#090e16`,.62),i=M7(this.scene,`frontend-yardline-orange`,`#d86131`,.55),a=M7(this.scene,`frontend-shelf-brass`,`#9b7136`,.38),o=[M7(this.scene,`frontend-box-red`,`#b64d38`,.82),M7(this.scene,`frontend-box-cream`,`#c5ad7b`,.86),M7(this.scene,`frontend-box-blue`,`#3f6072`,.84),M7(this.scene,`frontend-box-yellow`,`#c5912e`,.82)],s=new ZE(`frontend-turntable-metal`,this.scene);s.albedoColor=Z2e(`#60686a`),s.metallic=.64,s.roughness=.34,N7(this.scene,this.garage,`frontend-garage-floor`,{width:25,height:.3,depth:18},new j(0,-.22,0),e);for(let n=0;n<22;n+=1)N7(this.scene,this.garage,`frontend-floor-plank-${n}`,{width:1.08,height:.025,depth:17.4},new j(-11.35+n*1.08,-.055,0),n%2?e:t);N7(this.scene,this.garage,`frontend-garage-back-wall`,{width:25,height:9,depth:.35},new j(0,4.25,5.8),n),N7(this.scene,this.garage,`frontend-garage-left-wall`,{width:.35,height:9,depth:18},new j(-12.3,4.25,0),n),N7(this.scene,this.garage,`frontend-garage-beam-top`,{width:25,height:.45,depth:.55},new j(0,7.8,5.35),r);for(let e of[-11,-7.2,-3.6,0,3.6,7.2,11])N7(this.scene,this.garage,`frontend-garage-beam`,{width:.24,height:8.2,depth:.44},new j(e,3.75,5.3),r);for(let e of[2.35,4.55,6.75])N7(this.scene,this.garage,`frontend-toy-shelf`,{width:23.5,height:.18,depth:1.45},new j(0,e,4.75),a);for(let e=0;e<2;e+=1)for(let t=0;t<11;t+=1){if(e===0&&t>3&&t<7)continue;let n=t%3==0?1.42:1.62,r=e===0?1.32:1.45;N7(this.scene,this.garage,`frontend-product-box-${e}-${t}`,{width:n,height:r,depth:1.05},new j(-10.2+t*2.02,3.12+e*2.2,4.58),o[(e+t)%o.length])}let c=vm.CreateCylinder(`frontend-turntable`,{diameter:6.5,height:.5,tessellation:64},this.scene);c.parent=this.garage,c.position.y=.12,c.material=s,c.isPickable=!1;let l=vm.CreateTorus(`frontend-turntable-ring`,{diameter:6.58,thickness:.12,tessellation:64},this.scene);l.parent=this.garage,l.position.y=.42,l.material=i,l.isPickable=!1;let u=vm.CreatePlane(`frontend-yardline-sign`,{width:7.8,height:1.75},this.scene);u.parent=this.garage,u.position.set(0,7.15,5.58),u.rotation.y=Math.PI,u.material=this.createSignMaterial(),u.isPickable=!1}createSignMaterial(){let e=new pg(`frontend-yardline-sign-texture`,{width:1024,height:256},this.scene,!1);e.hasAlpha=!1;let t=e.getContext();t.fillStyle=`#171b1c`,t.fillRect(0,0,1024,256),t.fillStyle=`#d86131`,t.fillRect(0,0,28,256),t.font=`800 104px Arial`,t.fillStyle=`#f0efe8`,t.fillText(`YARDLINE RC`,72,139),t.font=`600 27px Arial`,t.fillStyle=`#8d9797`,t.fillText(`WORKSHOP / CLUB RACING DIVISION`,78,194),e.update();let n=new lg(`frontend-yardline-sign-material`,this.scene);return n.diffuseTexture=e,n.emissiveColor=new P(.24,.24,.22),n.specularColor=P.Black(),n}buildDiorama(){let e=M7(this.scene,`frontend-diorama-lawn`,`#668352`,.96),t=M7(this.scene,`frontend-diorama-asphalt`,`#3f4547`,.94),n=M7(this.scene,`frontend-diorama-curb-light`,`#d9d9cf`,.84),r=M7(this.scene,`frontend-diorama-curb-accent`,`#c95632`,.7),i=[M7(this.scene,`frontend-house-cream`,`#c7b990`,.9),M7(this.scene,`frontend-house-clay`,`#a65f48`,.88),M7(this.scene,`frontend-house-blue`,`#64808a`,.9)];N7(this.scene,this.diorama,`frontend-diorama-base`,{width:22,height:.55,depth:16},new j(0,-.42,0),e);let a=[new j(-6.6,0,2.6),new j(-4.2,0,-4.6),new j(2.7,0,-5),new j(6.8,0,-1.8),new j(5.2,0,4.3),new j(-1.6,0,5.2)];for(let e=0;e0&&(e.node.position.copyFrom(e.basePosition),t.grounded&&e.suspensionReference===void 0&&(e.suspensionReference=t.suspensionLength),e.suspensionReference!==void 0&&e.node.position.addInPlace(e.suspensionAxis.scale((e.suspensionReference-t.suspensionLength)*e.suspensionScale)));let r=A.RotationAxis(e.steerAxis,t.steerAngle),i=A.RotationAxis(e.spinAxis,t.rotationAngle*e.spinDirection);r.multiply(i).multiplyToRef(e.baseRotation,e.node.rotationQuaternion)}}},r4e=class{constructor(e,t,n={}){this._input=e4e(),this._smoothedThrottle=0,this._smoothedSteer=0,this._smoothedBrake=0,this._resetWasPressed=!1,this._respawnRequested=!1,this._engineMultiplier=1,this._gripMultiplier=1,this._state={speed:0,speedKph:0,forwardSpeed:0,lateralSpeed:0,groundedWheelCount:0,airborne:!0,upDot:1},this._body=t;let r=e.getPhysicsEngine();if(!r||r.getPluginVersion()!==2)throw Error(`ArcadeVehicleController requires an enabled Babylon Physics V2 engine.`);if(this._physicsEngine=r,this.config=n2e(n.config),this.config.wheels.length===0)throw Error(`ArcadeVehicleController requires at least one wheel.`);let i=new Set;for(let e of this.config.wheels){if(i.has(e.id))throw Error(`Duplicate wheel id: ${e.id}`);i.add(e.id)}this._inputSource=n.inputSource,this._mass=Math.max(.001,t.getMassProperties().mass??1);let a=t.getMassProperties();t.setMassProperties({...a,mass:this._mass,centerOfMass:this.config.centerOfMassOffset.clone()}),this._wheelbase=a4e(this.config.wheels),this._antiRollPairs=o4e(this.config.wheels),this._driveFactorTotal=F7(this.config.wheels,`driveFactor`),this._brakeFactorTotal=F7(this.config.wheels,`brakeFactor`),this._handbrakeFactorTotal=F7(this.config.wheels,`handbrakeFactor`),this._wheelStates=this.config.wheels.map(i4e),this._wheelVisualController=n.wheelVisuals?new n4e(this.config.wheels,n.wheelVisuals):void 0,t.setLinearDamping(this.config.linearDamping),t.setAngularDamping(this.config.angularDamping);let o=n.spawnPose??z2e(t);this.respawnController=new R2e(e,t,o,n.respawn)}update(e,t){let n=Math.max(1/240,Math.min(e,.05));t?t4e(t,this._input):this._inputSource?(this._inputSource.readInput(this._input),t4e(this._input,this._input)):Object.assign(this._input,e4e()),this._smoothedThrottle=L7(this._smoothedThrottle,this._input.throttle,this.config.throttleResponse*n),this._smoothedSteer=L7(this._smoothedSteer,this._input.steer,this.config.steerResponse*n),this._smoothedBrake=L7(this._smoothedBrake,this._input.brake,this.config.brakeResponse*n);let r=this._input.reset&&!this._resetWasPressed;this._resetWasPressed=this._input.reset,this._simulateWheels(n);let i=r||this._respawnRequested;this._respawnRequested=!1,this.respawnController.update(n,this._state.upDot,i)&&this._clearControlSmoothing(),this._wheelVisualController?.update(this._wheelStates)}requestRespawn(){this._respawnRequested=!0}setDriveMultipliers(e=1,t=1){this._engineMultiplier=R7(e,.1,2.5),this._gripMultiplier=R7(t,.05,2)}respawn(e){this.respawnController.respawn(e),this._clearControlSmoothing()}setCheckpoint(e){this.respawnController.setCheckpoint(e)}get state(){return this._state}get speed(){return this._state.speed}get speedKph(){return this._state.speedKph}get airborne(){return this._state.airborne}get wheelStates(){return this._wheelStates}_simulateWheels(e){let t=this._body.transformNode;t.computeWorldMatrix(!0);let n=t.absolutePosition,r=t.absoluteRotationQuaternion??t.rotationQuaternion??A.Identity(),i=I7(j.Up(),r).normalize(),a=I7(j.Forward(),r).normalize(),o=I7(j.Right(),r).normalize(),s=i.scale(-1),c=this._body.getLinearVelocity(),l=this._body.getAngularVelocity(),u=this._body.getObjectCenterWorld(),d=c.length(),f=j.Dot(c,a),p=j.Dot(c,o),m=R7(Math.abs(f)/this.config.maxForwardSpeed,0,1),h=d4e(1,this.config.highSpeedSteerMultiplier,m*m),g=this._smoothedSteer*this.config.maxSteerAngle*h,_=0,v=j.Zero();for(let t=0;t.001?this.config.frontGripMultiplier:this.config.rearGripMultiplier,D=this._input.handbrake&&o.handbrakeFactor>0?this.config.handbrakeGripMultiplier:1,te=-d.lateralSpeed*this._mass*this.config.lateralGrip*ee*D*this._gripMultiplier/this.config.wheels.length,O=w.scale(E).addInPlace(T.scale(te)),ne=C*this.config.gripCoefficient*ee*this._gripMultiplier;O.lengthSquared()>ne*ne&&O.normalize().scaleInPlace(ne);let re=s4e(d.contactPoint,u,i,this.config.tireForceApplicationHeight);this._body.applyForce(O,re)}_>0?(v.scaleInPlace(1/_).normalize(),this._applyAntiRoll(i),this._applyGroundStability(i,v,l),this._applyGroundYawControl(v,l,f,g)):this._applyAirControl(a,o,i),this._applyDownforce(i,d,u),this._state={speed:d,speedKph:d*3.6,forwardSpeed:f,lateralSpeed:p,groundedWheelCount:_,airborne:_===0,upDot:j.Dot(i,j.Up())}}_longitudinalForce(e,t,n,r){let i=this._smoothedThrottle,a=this._smoothedBrake;Math.abs(n)>this.config.directionChangeBrakeSpeed&&Math.sign(i)!==Math.sign(n)&&(a=Math.max(a,Math.abs(i)),i=0);let o=0;if(e.driveFactor>0&&this._driveFactorTotal>0&&i!==0){let t=i>0?this.config.maxForwardSpeed:this.config.maxReverseSpeed,r=i>0?1:this.config.reverseAccelerationMultiplier,a=R7(1-Math.max(0,n*Math.sign(i))/t,0,1)**.72;o+=this._mass*this.config.engineAcceleration*this._engineMultiplier*r*i*a*(e.driveFactor/this._driveFactorTotal)}let s=e.brakeFactor>0&&this._brakeFactorTotal>0?e.brakeFactor/this._brakeFactorTotal:0,c=e.handbrakeFactor>0&&this._handbrakeFactorTotal>0?e.handbrakeFactor/this._handbrakeFactorTotal:0,l=this._mass*(this.config.brakeDeceleration*a*s+(this._input.handbrake?this.config.handbrakeDeceleration*c:0));if(l>0&&Math.abs(t)>.01){let e=this._mass*Math.abs(t)/r/this.config.wheels.length;o-=Math.sign(t)*Math.min(l,e)}return o-=t*this._mass*this.config.rollingResistance/this.config.wheels.length,o}_applyGroundStability(e,t,n){let r=j.Cross(e,t),i=1+R7((.94-R7(j.Dot(e,t),-1,1))/.7,0,1)*this.config.antiFlipMultiplier,a=n.subtract(t.scale(j.Dot(n,t))),o=r.scale(this._mass*this.config.groundUprightStrength*i).subtractInPlace(a.scale(this._mass*this.config.groundUprightDamping*Math.sqrt(i)));this._body.applyTorque(o)}_applyAntiRoll(e){let t=this._mass*22;for(let[n,r]of this._antiRollPairs){let i=this._wheelStates[n],a=this._wheelStates[r];if(!i.grounded||!a.grounded)continue;let o=R7((i.compression-a.compression)*this.config.antiRollStrength*this._mass,-t,t);this._body.applyForce(e.scale(o),i.contactPoint),this._body.applyForce(e.scale(-o),a.contactPoint)}}_applyGroundYawControl(e,t,n,r){let i=R7(Math.abs(n)/2.4,0,1);if(i<=0)return;let a=R7(n/this._wheelbase*Math.tan(r),-this.config.maxYawRate,this.config.maxYawRate),o=j.Dot(t,e),s=this._input.handbrake?this.config.handbrakeYawResponseMultiplier:1,c=(a-o)*this.config.yawResponse*i*s;this._body.applyTorque(e.scale(this._mass*c))}_applyAirControl(e,t,n){let r=n.scale(this._smoothedSteer*this._mass*this.config.airYawControl),i=t.scale(-this._smoothedThrottle*this._mass*this.config.airPitchControl),a=e.scale(-this._smoothedSteer*this._mass*this.config.airPitchControl*.35);this._body.applyTorque(r.addInPlace(i).addInPlace(a))}_applyDownforce(e,t,n){let r=Math.min(this.config.maxDownforceAcceleration,t*t*this.config.downforceCoefficient);r>0&&this._body.applyForce(e.scale(-this._mass*r),n)}_clearControlSmoothing(){this._smoothedThrottle=0,this._smoothedSteer=0,this._smoothedBrake=0}};function i4e(e){return{id:e.id,grounded:!1,suspensionLength:e.restLength+e.travel,compression:0,steerAngle:0,rotationAngle:0,contactPoint:j.Zero(),contactNormal:j.Up(),longitudinalSpeed:0,lateralSpeed:0}}function F7(e,t){return e.reduce((e,n)=>e+Math.max(0,n[t]),0)}function a4e(e){let t=-1/0,n=1/0;for(let r of e)t=Math.max(t,r.originLocal.z),n=Math.min(n,r.originLocal.z);return Math.max(.5,t-n)}function o4e(e){let t=[],n=e.map((e,t)=>({wheel:e,index:t})).filter(({wheel:e})=>e.originLocal.x>0);return e.forEach((e,r)=>{if(e.originLocal.x>=0)return;let i;for(let t of n){let n=Math.abs(t.wheel.originLocal.z-e.originLocal.z);(!i||n[]),this.callbacks=n.callbacks??{},this.random=n.random??Math.random,this.maxProjectiles=n.maxProjectiles??6,this.maxHazards=n.maxHazards??10,this.materials={rocketBody:z7(e,`rocket-body`,`#d92d20`,`#6f0805`),rocketNose:z7(e,`rocket-nose`,`#f1eee0`,`#4a4538`),rocketFin:z7(e,`rocket-fin`,`#242c35`,`#111820`),rocketGlow:z7(e,`rocket-glow`,`#ffae27`,`#ff6a0a`,.9,!0),oil:z7(e,`oil-puddle`,`#090c12`,`#060912`,.9),oilSheen:z7(e,`oil-sheen`,`#26374c`,`#264f65`,.42,!0),mine:z7(e,`mine-shell`,`#d9aa17`,`#704507`),mineDark:z7(e,`mine-dark`,`#242a31`,`#10151b`),warning:z7(e,`mine-warning`,`#ff3528`,`#ff1208`,.98,!0),emp:z7(e,`emp-energy`,`#54eaff`,`#188cff`,.62,!0),turbo:z7(e,`turbo-flame`,`#fff1a0`,`#ff7919`,.92,!0),smoke:z7(e,`effect-smoke`,`#4d5966`,`#131820`,.5)},this.materials.oil.backFaceCulling=!1,this.materials.oilSheen.backFaceCulling=!1}get state(){return{item:this.item,charges:this.charges,activeTurboSeconds:this.turboSeconds,rolling:this.rouletteSeconds>0||this.pendingItem!==null}}collect(e,t=1){return this.disposed||this.item||this.pendingItem||this.collectionCooldownSeconds>0?!1:(this.pendingItem=e??f4e[Math.floor(this.random()*f4e.length)],this.pendingCharges=Math.max(1,Math.min(3,Math.floor(t))),this.rouletteSeconds=1.15,this.notifyInventory(),!0)}clearInventory(){this.item=null,this.charges=0,this.pendingItem=null,this.pendingCharges=0,this.rouletteSeconds=0,this.collectionCooldownSeconds=0,this.notifyInventory()}use(){if(!this.item||this.charges<=0||this.disposed)return!1;let e=this.item,t=this.playerBody.transformNode.absolutePosition.clone(),n=_4e(this.playerBody),r=t;switch(e){case`turbo-battery`:this.turboSeconds=Math.max(this.turboSeconds,2.65),this.callbacks.onTurboChanged?.(!0,1.42),this.startTurboVisual(t);break;case`pulse-rocket`:this.spawnRocket(t.add(n.scale(1.8)).addInPlaceFromFloats(0,.3,0),n);break;case`oil-slick`:r=this.spawnHazard(`oil-slick`,t.subtract(n.scale(2.2)));break;case`proximity-mine`:r=this.spawnHazard(`proximity-mine`,t.subtract(n.scale(2)));break;case`arc-emp`:this.fireEmp(t);break}return this.emit({type:e,sourceId:this.playerId,position:r.clone()}),--this.charges,this.charges<=0&&(this.item=null,this.collectionCooldownSeconds=Math.max(this.collectionCooldownSeconds,.7)),this.notifyInventory(),!0}update(e){if(this.disposed)return;let t=Math.max(0,Math.min(e,.05));this.collectionCooldownSeconds=Math.max(0,this.collectionCooldownSeconds-t),this.rouletteSeconds>0&&(this.rouletteSeconds=Math.max(0,this.rouletteSeconds-t),this.rouletteSeconds===0&&this.pendingItem&&(this.item=this.pendingItem,this.charges=this.pendingCharges,this.pendingItem=null,this.pendingCharges=0,this.notifyInventory())),this.turboSeconds>0&&(this.turboSeconds=Math.max(0,this.turboSeconds-t),this.updateTurboVisual(),this.turboSeconds===0&&(this.callbacks.onTurboChanged?.(!1,1),this.stopTurboVisual())),this.updateProjectiles(t),this.updateHazards(t),this.updateEffects(t)}reset(){this.clearInventory(),this.turboSeconds>0&&this.callbacks.onTurboChanged?.(!1,1),this.turboSeconds=0,this.stopTurboVisual();for(let e of this.projectiles)this.disposeProjectile(e);for(let e of this.hazards)e.root.dispose(!1,!0);for(let e of this.effects)this.disposeEffect(e);this.projectiles.length=0,this.hazards.length=0,this.effects.length=0}dispose(){this.disposed||=(this.reset(),Object.values(this.materials).forEach(e=>e.dispose()),!0)}spawnRocket(e,t){if(this.projectiles.length>=this.maxProjectiles){let e=this.projectiles.shift();e&&this.disposeProjectile(e)}let n=new wc(`pulse-rocket`,this.scene);n.position.copyFrom(e),n.rotationQuaternion=A.FromLookDirectionLH(t,j.Up());let r=vm.CreateCylinder(`rocket-fuselage`,{height:.86,diameter:.25,tessellation:16},this.scene);r.parent=n,r.rotation.x=Math.PI/2,r.material=this.materials.rocketBody;let i=vm.CreateCylinder(`rocket-nose`,{height:.34,diameterTop:0,diameterBottom:.25,tessellation:16},this.scene);i.parent=n,i.position.z=.6,i.rotation.x=Math.PI/2,i.material=this.materials.rocketNose;let a=vm.CreateTorus(`rocket-band`,{diameter:.27,thickness:.035,tessellation:16},this.scene);a.parent=n,a.position.z=.25,a.rotation.x=Math.PI/2,a.material=this.materials.rocketNose;for(let[e,t]of[[.2,0],[-.2,0],[0,.2],[0,-.2]]){let r=vm.CreateBox(`rocket-fin`,{width:.08,height:.25,depth:.34},this.scene);r.parent=n,r.position.set(e,t,-.3),e===0&&(r.rotation.z=Math.PI/2),r.material=this.materials.rocketFin}let o=vm.CreateSphere(`rocket-engine-glow`,{diameter:.25,segments:10},this.scene);o.parent=n,o.position.z=-.52,o.scaling.z=1.7,o.material=this.materials.rocketGlow;let s=[this.createTrail(o,`flame_05.png`,fe.FromHexString(`#fff3adff`),fe.FromHexString(`#ff3d08ff`),62,.06,.22),this.createTrail(o,`smoke_07.png`,fe.FromHexString(`#87909a99`),fe.FromHexString(`#252c3500`),24,.13,.36)],c=this.acquireTarget(e,t),l={root:n,engineGlow:o,trails:s,velocity:t.scale(m4e*.72),sourceId:this.playerId,targetId:c?.id,age:0,life:4.4};c&&(l.lockMarker=this.createLockMarker(B7(c))),this.projectiles.push(l),this.spawnDeployBurst(e,fe.FromHexString(`#ff9a28ff`))}spawnHazard(e,t){this.hazards.length>=this.maxHazards&&this.hazards.shift()?.root.dispose(!1,!0);let n=new wc(e,this.scene);n.position.copyFrom(t),n.position.y-=e===`oil-slick`?.48:.36;let r,i;if(e===`oil-slick`){for(let[e,t,r,i]of[[0,0,1.38,1.08],[.72,.2,.88,.68],[-.66,.18,.92,.72],[.28,-.48,.78,.62],[-.36,-.47,.72,.6]]){let a=vm.CreateDisc(`oil-lobe`,{radius:1.05,tessellation:28,sideOrientation:K.DOUBLESIDE},this.scene);a.parent=n,a.position.set(e,0,t),a.rotation.x=Math.PI/2,a.rotation.z=this.random()*Math.PI,a.scaling.set(r,i,1),a.material=this.materials.oil}for(let e=0;e<3;e+=1){let t=vm.CreateTorus(`oil-rainbow-sheen`,{diameter:.48+e*.26,thickness:.025,tessellation:24},this.scene);t.parent=n,t.position.set(-.25+e*.21,.025,.12-e*.15),t.scaling.z=.55,t.material=this.materials.oilSheen}}else{let e=vm.CreateSphere(`mine-core`,{diameter:.7,segments:12},this.scene);e.parent=n,e.material=this.materials.mineDark;for(let e=0;e<8;e+=1){let t=e*Math.PI/4,r=vm.CreateCylinder(`mine-spike`,{height:.45,diameterTop:.03,diameterBottom:.14,tessellation:8},this.scene);r.parent=n,r.position.set(Math.sin(t)*.42,.02,Math.cos(t)*.42),r.rotation.z=Math.PI/2,r.rotation.y=t,r.material=this.materials.mine}r=vm.CreateSphere(`mine-warning-light`,{diameter:.22,segments:10},this.scene),r.parent=n,r.position.y=.42,r.material=this.materials.warning,i=vm.CreateTorus(`mine-arming-ring`,{diameter:1.25,thickness:.045,tessellation:28},this.scene),i.parent=n,i.position.y=-.25,i.material=this.materials.warning}return n.scaling.setAll(.12),this.hazards.push({root:n,kind:e,sourceId:this.playerId,baseY:n.position.y,life:e===`oil-slick`?11:13,armedIn:e===`oil-slick`?.12:.72,age:0,touched:new Set,signal:r,ring:i}),this.spawnDeployBurst(n.position,e===`oil-slick`?fe.FromHexString(`#27394aaa`):fe.FromHexString(`#ffad20ff`)),n.position.clone()}fireEmp(e){this.spawnEmpWave(e);for(let t of this.activeTargets()){if(t.id===this.playerId||V7(e,t)>8.4**2)continue;let n={type:`arc-emp`,sourceId:this.playerId,targetId:t.id,position:e.clone()};this.callbacks.onTargetDisabled?.(t.id,1.7,n),this.emit(n)}}startTurboVisual(e){if(this.turboVisual)return;let t=this.playerBody.transformNode,n=[],r=[];for(let e of[-.43,.43]){let i=vm.CreateCylinder(`turbo-exhaust`,{height:.82,diameterTop:.08,diameterBottom:.3,tessellation:12},this.scene);i.parent=t,i.position.set(e,.04,-1.08),i.rotation.x=Math.PI/2,i.material=this.materials.turbo,r.push(i),n.push(this.createTrail(i,`flame_06.png`,fe.FromHexString(`#d9fbffff`),fe.FromHexString(`#ff6411ff`),88,.08,.25))}this.turboVisual={particles:n,flames:r},this.spawnShockwave(e)}updateTurboVisual(){if(!this.turboVisual)return;let e=.82+Math.sin(performance.now()*.032)*.18;for(let t=0;te.dispose()),this.turboVisual.flames.forEach(e=>e.dispose()),void 0)}updateProjectiles(e){let t=this.activeTargets();for(let n=this.projectiles.length-1;n>=0;--n){let r=this.projectiles[n];r.life-=e,r.age+=e;let i=r.root.position,a=r.targetId?t.find(e=>e.id===r.targetId):void 0;!a&&r.age<.85&&(a=this.acquireTarget(i,r.velocity.normalize(),t),r.targetId=a?.id,a&&!r.lockMarker&&(r.lockMarker=this.createLockMarker(B7(a))));let o=Math.min(m4e,r.velocity.length()+e*16);if(a){let t=B7(a);if(t){let n=t.subtract(i).normalize(),a=r.velocity.normalize(),s=Math.min(1,e*(r.age<.2?2.2:5.4));j.LerpToRef(a,n,s,r.velocity),r.velocity.normalize().scaleInPlace(o),r.lockMarker?.position.copyFrom(t),r.lockMarker&&(r.lockMarker.rotation.y+=e*3.8,r.lockMarker.scaling.setAll(.9+Math.sin(r.age*15)*.08))}}else r.velocity.normalize().scaleInPlace(o);i.addInPlace(r.velocity.scale(e));let s=r.velocity.normalize();r.root.rotationQuaternion=A.FromLookDirectionLH(s,j.Up()),r.root.rotate(j.Forward(),e*8,0);let c=.85+Math.sin(r.age*38)*.18;r.engineGlow.scaling.set(1,1,1.5+c);let l=v4e(i,t,r.sourceId,1.2);if(l){let e=B7(l)??i;l.body&&l.body.applyImpulse(s.scale(4.2),l.body.getObjectCenterWorld());let t={type:`pulse-rocket`,sourceId:r.sourceId,targetId:l.id,position:e.clone()};this.callbacks.onTargetDisabled?.(l.id,.85,t),this.emit(t),this.spawnExplosion(i,1),r.life=0}r.life<=0&&(l||this.spawnExplosion(i,.55),this.disposeProjectile(r),this.projectiles.splice(n,1))}}updateHazards(e){let t=this.activeTargets();for(let n=this.hazards.length-1;n>=0;--n){let r=this.hazards[n];r.life-=e,r.age+=e,r.armedIn=Math.max(0,r.armedIn-e);let i=Math.min(1,r.age/.28),a=1+Math.sin(i*Math.PI)*.28;if(r.root.scaling.setAll(i*a),r.kind===`oil-slick`)r.root.rotation.y+=e*.07,r.root.position.y=r.baseY+Math.sin(r.age*2.3)*.008,r.life<1&&H7(r.root,Math.max(0,r.life));else{r.root.rotation.y+=e*(r.armedIn>0?2.5:.65),r.root.position.y=r.baseY+Math.sin(r.age*4.2)*.035;let t=r.armedIn>0?.25+Math.sin(r.age*18)*.2:.65+Math.sin(r.age*8)*.35;if(r.signal&&r.signal.scaling.setAll(Math.max(.18,t)),r.ring){let e=r.age*1.8%1;r.ring.scaling.setAll(.65+e*.72),r.ring.visibility=r.armedIn>0?.2:.72*(1-e)}}for(let e of t){if(e.id===r.sourceId&&r.life>10.5)continue;let t=r.kind===`oil-slick`?1.85:1.72;if(!(!(V7(r.root.position,e)<=(t+(e.radius??.55))**2)||r.armedIn>0))if(r.kind===`oil-slick`)r.touched.has(e.id)||(r.touched.add(e.id),this.callbacks.onOilContact?.(e.id,.24,1.55),this.emit({type:`oil-slick`,sourceId:r.sourceId,targetId:e.id,position:r.root.position.clone()}));else{let t=B7(e);if(e.body&&t){let n=y4e(t.subtract(r.root.position),j.Up());e.body.applyImpulse(n.scale(5.3).addInPlaceFromFloats(0,2.4,0),e.body.getObjectCenterWorld())}let n={type:`proximity-mine`,sourceId:r.sourceId,targetId:e.id,position:r.root.position.clone()};this.callbacks.onTargetDisabled?.(e.id,1.05,n),this.emit(n),this.spawnExplosion(r.root.position,1.25),r.life=0;break}}r.life<=0&&(r.root.dispose(!1,!0),this.hazards.splice(n,1))}}updateEffects(e){for(let t=this.effects.length-1;t>=0;--t){let n=this.effects[t];n.life-=e;let r=Math.min(1,1-n.life/n.duration),i=n.root.getChildMeshes(!1);n.kind===`explosion`?(n.root.scaling.setAll((.25+r*3.4)*n.scale),i.forEach((t,n)=>{t.visibility=Math.max(0,1-r)*(n===0?.78:1),t.rotation.y+=e*(n%2==0?3:-2)})):n.kind===`emp`?(n.root.scaling.setAll(.45+r*15.5),i.forEach((t,n)=>{t.visibility=Math.max(0,1-r)*(1-n*.12),t.rotation.z+=e*(n%2==0?2.5:-3.2)})):n.kind===`shockwave`?(n.root.scaling.setAll(.6+r*5.5),H7(n.root,Math.max(0,1-r))):(n.root.scaling.setAll(.7+r*1.2),H7(n.root,Math.max(0,1-r))),n.life<=0&&(this.disposeEffect(n),this.effects.splice(t,1))}}spawnExplosion(e,t){let n=new wc(`utility-explosion`,this.scene);n.position.copyFrom(e),n.scaling.setAll(t);let r=vm.CreateSphere(`explosion-flash`,{diameter:.72,segments:10},this.scene);r.parent=n,r.material=this.materials.rocketGlow;for(let e=0;e<2;e+=1){let t=vm.CreateTorus(`explosion-ring`,{diameter:.9+e*.18,thickness:.075-e*.015,tessellation:28},this.scene);t.parent=n,t.rotation.x=e===0?Math.PI/2:0,t.material=e===0?this.materials.warning:this.materials.rocketGlow}let i=[this.createBurst(e,`flame_05.png`,fe.FromHexString(`#fff0a8ff`),fe.FromHexString(`#ff2a08ff`),46,.12,.46,7*t),this.createBurst(e,`smoke_04.png`,fe.FromHexString(`#6c737ddd`),fe.FromHexString(`#1d242c00`),24,.22,.72,4*t)];this.effects.push({root:n,particles:i,kind:`explosion`,duration:.72,scale:t,life:.72})}spawnEmpWave(e){let t=new wc(`arc-emp-wave`,this.scene);t.position.copyFrom(e);for(let e=0;e<3;e+=1){let n=vm.CreateTorus(`emp-ring`,{diameter:.75+e*.18,thickness:.055,tessellation:40},this.scene);n.parent=t,n.rotation.set(e===0?Math.PI/2:e*1.05,e*.7,0),n.material=this.materials.emp}let n=vm.CreateSphere(`emp-core-flash`,{diameter:.52,segments:12},this.scene);n.parent=t,n.material=this.materials.emp;let r=[this.createBurst(e,`light_02.png`,fe.FromHexString(`#d8ffffff`),fe.FromHexString(`#168dff00`),58,.08,.42,8)];this.effects.push({root:t,particles:r,kind:`emp`,duration:.62,scale:1,life:.62})}spawnShockwave(e){let t=new wc(`turbo-shockwave`,this.scene);t.position.copyFrom(e);let n=vm.CreateTorus(`turbo-shock-ring`,{diameter:.9,thickness:.07,tessellation:36},this.scene);n.parent=t,n.rotation.x=Math.PI/2,n.material=this.materials.turbo,this.effects.push({root:t,particles:[],kind:`shockwave`,duration:.38,scale:1,life:.38})}spawnDeployBurst(e,t){let n=new wc(`utility-deploy-burst`,this.scene);n.position.copyFrom(e);let r=vm.CreateTorus(`deploy-ring`,{diameter:.58,thickness:.045,tessellation:24},this.scene);r.parent=n,r.rotation.x=Math.PI/2,r.material=this.materials.rocketGlow;let i=[this.createBurst(e,`star_06.png`,t,t.scale(.2),18,.06,.3,3.6)];this.effects.push({root:n,particles:i,kind:`deploy`,duration:.34,scale:1,life:.34})}createTrail(e,t,n,r,i,a,o){let s=new RZ(`${e.name}-trail`,220,this.scene);return s.particleTexture=new W(`${p4e}${t}`,this.scene),s.emitter=e,s.color1=n,s.color2=r,s.colorDead=new fe(r.r,r.g,r.b,0),s.minSize=a,s.maxSize=o,s.minLifeTime=.1,s.maxLifeTime=.34,s.emitRate=i,s.minEmitPower=.5,s.maxEmitPower=2.4,s.direction1=new j(-.15,-.15,-2.2),s.direction2=new j(.15,.15,-3.8),s.minAngularSpeed=-4,s.maxAngularSpeed=4,s.blendMode=RZ.BLENDMODE_ADD,s.start(),s}createBurst(e,t,n,r,i,a,o,s){let c=new RZ(`utility-burst-particles`,Math.max(64,i*2),this.scene);return c.particleTexture=new W(`${p4e}${t}`,this.scene),c.emitter=e.clone(),c.color1=n,c.color2=r,c.colorDead=new fe(r.r,r.g,r.b,0),c.minSize=a,c.maxSize=o,c.minLifeTime=.16,c.maxLifeTime=.65,c.emitRate=0,c.minEmitPower=s*.45,c.maxEmitPower=s,c.direction1=new j(-1,-.15,-1),c.direction2=new j(1,1.2,1),c.gravity=new j(0,-2.2,0),c.minAngularSpeed=-5,c.maxAngularSpeed=5,c.blendMode=RZ.BLENDMODE_ADD,c.start(),c.manualEmitCount=i,c}createLockMarker(e){let t=new wc(`rocket-target-lock`,this.scene);t.position.copyFrom(e);for(let e=0;e<2;e+=1){let n=vm.CreateTorus(`target-lock-ring`,{diameter:1.35,thickness:.035,tessellation:32},this.scene);n.parent=t,n.rotation.x=e===0?Math.PI/2:0,n.material=this.materials.warning}return t}acquireTarget(e,t,n=this.activeTargets()){let r,i=1/0;for(let a of n){if(a.id===this.playerId)continue;let n=B7(a);if(!n)continue;let o=n.subtract(e),s=o.length();if(s>h4e||s<.01)continue;let c=j.Dot(o.scale(1/s),t);if(c<-.15)continue;let l=s*(1.35-Math.max(0,c)*.65);le.isActive?.()!==!1&&!!B7(e))}disposeProjectile(e){e.trails.forEach(e=>e.dispose()),e.lockMarker?.dispose(!1,!0),e.root.dispose(!1,!0)}disposeEffect(e){e.particles.forEach(e=>e.dispose()),e.root.dispose(!1,!0)}emit(e){this.callbacks.onAbilityUsed?.(e)}notifyInventory(){this.callbacks.onInventoryChange?.(this.state)}};function z7(e,t,n,r,i=1,a=!1){let o=new lg(t,e);return o.diffuseColor=P.FromHexString(n),o.emissiveColor=P.FromHexString(r),o.specularColor=a?P.Black():P.FromHexString(`#777777`),o.alpha=i,o.disableLighting=a,o}function _4e(e){let t=e.transformNode,n=t.absoluteRotationQuaternion??t.rotationQuaternion??A.Identity(),r=j.Forward().applyRotationQuaternion(n);return r.y=0,y4e(r,j.Forward())}function B7(e){return e.body?.transformNode.absolutePosition??e.getPosition?.()}function v4e(e,t,n,r){let i,a=r*r;for(let r of t){if(r.id===n)continue;let t=V7(e,r);t1e-4?e.normalize():t.clone()}function H7(e,t){e.getChildMeshes(!1).forEach(e=>{e.visibility=t})}var b4e={upsideDownDot:.05,autoRespawnDelay:2.8,stuckSpeed:.35,stuckThrottle:.65,stuckDelay:4.2,cooldown:.85,selfRightLift:.75,respawnLift:.45,manualPenaltyMs:750,autoPenaltyMs:2200},x4e=class{constructor(e,t,n,r={}){this.cooldownRemaining=0,this.invertedSeconds=0,this.stuckSeconds=0,this.manualWasDown=!1,this.teleportGeneration=0,this.scene=e,this.body=t,this.options={...b4e,...r},this.checkpoint=U7(n)}setCheckpoint(e){this.checkpoint=U7(e)}getCheckpoint(){return U7(this.checkpoint)}reset(e){e&&(this.checkpoint=U7(e)),this.cooldownRemaining=0,this.invertedSeconds=0,this.stuckSeconds=0,this.manualWasDown=!1}update(e,t){let n=S4e(e,0,.1);this.cooldownRemaining=Math.max(0,this.cooldownRemaining-n),this.invertedSeconds=t.upDot=this.options.stuckThrottle;this.stuckSeconds=r?this.stuckSeconds+n:0;let i=!!t.manualSelfRight&&!this.manualWasDown;return this.manualWasDown=!!t.manualSelfRight,i&&this.cooldownRemaining<=0?(this.teleport(this.checkpoint,this.options.respawnLift),this.result(`self-right`,this.options.manualPenaltyMs)):(t.outOfBounds||this.invertedSeconds>=this.options.autoRespawnDelay||this.stuckSeconds>=this.options.stuckDelay)&&this.cooldownRemaining<=0?(this.teleport(this.checkpoint,this.options.respawnLift),this.result(`auto-respawn`,this.options.autoPenaltyMs)):this.result(`none`,0)}forceRespawn(e=this.checkpoint){this.teleport(e,this.options.respawnLift)}teleport(e,t){let n=this.body.transformNode,r=this.body.getPrestepType(),i=++this.teleportGeneration;n.position.copyFrom(e.position).addInPlaceFromFloats(0,t,0),n.rotationQuaternion??=A.Identity(),n.rotationQuaternion.copyFrom(e.rotation),n.computeWorldMatrix(!0),this.body.setLinearVelocity(j.Zero()),this.body.setAngularVelocity(j.Zero()),this.body.setPrestepType(XO.TELEPORT),this.scene.onAfterPhysicsObservable.addOnce(()=>{i===this.teleportGeneration&&(this.body.setLinearVelocity(j.Zero()),this.body.setAngularVelocity(j.Zero()),this.body.setPrestepType(r))}),this.invertedSeconds=0,this.stuckSeconds=0,this.cooldownRemaining=this.options.cooldown}result(e,t){return{recovered:e!==`none`,kind:e,penaltyMs:t,cooldownRemaining:this.cooldownRemaining}}};function U7(e){return{position:e.position.clone(),rotation:e.rotation.clone()}}function S4e(e,t,n){return Math.max(t,Math.min(n,e))}var W7={asphalt:{type:`asphalt`,gripMultiplier:1,accelerationMultiplier:1,rollingResistance:.015,skidAudio:.35},grass:{type:`grass`,gripMultiplier:.58,accelerationMultiplier:.72,rollingResistance:.12,skidAudio:.08},wood:{type:`wood`,gripMultiplier:.82,accelerationMultiplier:.92,rollingResistance:.035,skidAudio:.22},oil:{type:`oil`,gripMultiplier:.16,accelerationMultiplier:.55,rollingResistance:.005,skidAudio:.05}},C4e=class{constructor(e,t){this.oilPatches=[],this.nextOilId=1,this.scene=e,this.ignoredBody=t}sample(e,t=.8,n=2.6){let r=performance.now();if(this.pruneOil(r),this.oilPatches.some(t=>E4e(e,t.position)<=t.radiusSquared))return W7.oil;let i=this.scene.getPhysicsEngine();if(i?.getPluginVersion()===2){let r=e.add(new j(0,t,0)),a=i.raycast(r,r.add(new j(0,-n,0)),{ignoreBody:this.ignoredBody,shouldHitTriggers:!1});if(a.hasHit&&a.body)return w4e(a.body.transformNode)}let a=new Wd(e.add(new j(0,t,0)),j.Down(),n),o=this.scene.pickWithRay(a,e=>e.isEnabled()&&e.isPickable);return o?.pickedMesh?w4e(o.pickedMesh):W7.asphalt}addOilPatch(e,t=2.25,n=9){this.oilPatches.length>=12&&this.oilPatches.shift();let r=this.nextOilId++;return this.oilPatches.push({id:r,position:e.clone(),radiusSquared:t*t,expiresAt:performance.now()+n*1e3}),r}removeOilPatch(e){let t=this.oilPatches.findIndex(t=>t.id===e);t>=0&&this.oilPatches.splice(t,1)}clear(){this.oilPatches.length=0}pruneOil(e){for(let t=this.oilPatches.length-1;t>=0;--t)this.oilPatches[t].expiresAt<=e&&this.oilPatches.splice(t,1)}};function G7(e,t){e.metadata={...e.metadata,surface:t}}function w4e(e){let t=e.metadata;if(t?.surface&&T4e(t.surface))return W7[t.surface];let n=`${e.name} ${e.material?.name??``}`.toLowerCase();return/oil|slick|slime/.test(n)?W7.oil:/grass|lawn|turf|garden|soil|dirt/.test(n)?W7.grass:/wood|plank|deck|floor|table/.test(n)?W7.wood:W7.asphalt}function T4e(e){return e===`asphalt`||e===`grass`||e===`wood`||e===`oil`}function E4e(e,t){let n=e.x-t.x,r=e.z-t.z;return n*n+r*r}var D4e={enterAlignment:-.25,exitAlignment:.12,enterDelay:.8,exitDelay:.35,minimumSpeed:1.3,blinkHz:2.7,searchRadiusSegments:3},O4e=class{constructor(e,t={}){if(this.nearestSegment=0,this.wrongSeconds=0,this.correctSeconds=0,this.elapsed=0,this.wrongWay=!1,e.length<2)throw Error(`WrongWayDetector requires at least two path points.`);this.path=e,this.options={...D4e,...t}}reset(e=0){this.nearestSegment=j4e(e,this.path.length),this.wrongSeconds=0,this.correctSeconds=0,this.elapsed=0,this.wrongWay=!1}update(e,t,n,r){let i=Math.max(0,Math.min(e,.1));this.elapsed+=i,this.nearestSegment=this.findNearestSegment(t);let a=this.path[this.nearestSegment],o=this.path[(this.nearestSegment+1)%this.path.length].subtract(a);o.y=0,o.normalize();let s=new j(n.x,0,n.z),c=s.length(),l=c>=this.options.minimumSpeed?s.scale(1/c):A4e(r??j.Zero()),u=l.lengthSquared()>.5?j.Dot(l,o):1;return c>=this.options.minimumSpeed&&u<=this.options.enterAlignment?(this.wrongSeconds+=i,this.correctSeconds=0):u>=this.options.exitAlignment&&(this.correctSeconds+=i,this.wrongSeconds=0),!this.wrongWay&&this.wrongSeconds>=this.options.enterDelay&&(this.wrongWay=!0),this.wrongWay&&this.correctSeconds>=this.options.exitDelay&&(this.wrongWay=!1),{wrongWay:this.wrongWay,blinkVisible:this.wrongWay&&Math.sin(this.elapsed*Math.PI*2*this.options.blinkHz)>=0,alignment:u,nearestSegment:this.nearestSegment,suggestedDirection:o}}findNearestSegment(e){let t=this.nearestSegment,n=1/0,r=Math.min(this.path.length-1,this.options.searchRadiusSegments);for(let i=-r;i<=r;i+=1){let r=j4e(this.nearestSegment+i,this.path.length),a=k4e(e,this.path[r],this.path[(r+1)%this.path.length]);a1e-4?Math.max(0,Math.min(1,j.Dot(e.subtract(t),r)/i)):0;return j.DistanceSquared(e,t.add(r.scale(a)))}function A4e(e){let t=new j(e.x,0,e.z);return t.lengthSquared()>.001?t.normalize():j.Zero()}function j4e(e,t){return(e%t+t)%t}var M4e={"turbo-battery":`Turbo Battery`,"pulse-rocket":`Pulse Rocket`,"oil-slick":`Oil Slick`,"proximity-mine":`Proximity Mine`,"arc-emp":`Arc EMP`};function N4e(e){let t=e>>>0;return()=>(t=t*1664525+1013904223>>>0,t/4294967295)}function K7(e,t,n,r,i){let a=new pg(t,{width:256,height:256},e,!1);return n(a.getContext(),256),a.update(!1),a.wrapU=W.WRAP_ADDRESSMODE,a.wrapV=W.WRAP_ADDRESSMODE,a.uScale=r,a.vScale=i,a.anisotropicFilteringLevel=4,a}function q7(e,t,n,r,i=.06){let a=new lg(t,e);return a.diffuseTexture=n,a.diffuseColor=P.FromHexString(r),a.specularColor.setAll(i),a.roughness=.92,a}function P4e(e){let t=N4e(334666),n=K7(e,`willow-grass-texture`,(e,n)=>{e.fillStyle=`#78a84f`,e.fillRect(0,0,n,n);for(let r=0;r<2100;r+=1){e.fillStyle=t()>.48?`rgba(184,214,105,${.12+t()*.22})`:`rgba(38,91,43,${.1+t()*.23})`;let r=t()*n,i=t()*n;e.fillRect(r,i,.7+t()*1.4,1.5+t()*4)}},22,22),r=K7(e,`willow-asphalt-texture`,(e,n)=>{e.fillStyle=`#41484b`,e.fillRect(0,0,n,n);for(let r=0;r<4e3;r+=1){let r=48+Math.floor(t()*54);e.fillStyle=`rgba(${r},${r+2},${r+2},${.18+t()*.32})`;let i=.25+t()*1.05;e.fillRect(t()*n,t()*n,i,i)}e.strokeStyle=`rgba(20,24,25,0.18)`,e.lineWidth=1.1,e.beginPath(),e.moveTo(18,256),e.bezierCurveTo(39,180,88,128,76,0),e.stroke()},5,5),i=K7(e,`willow-concrete-texture`,(e,n)=>{e.fillStyle=`#c9c3b4`,e.fillRect(0,0,n,n),e.strokeStyle=`rgba(92,84,72,0.32)`,e.lineWidth=2,e.strokeRect(1,1,n-2,n-2);for(let r=0;r<700;r+=1){let r=t()>.5?255:75;e.fillStyle=`rgba(${r},${r},${r},${.025+t()*.055})`,e.fillRect(t()*n,t()*n,1.2,1.2)}},8,2),a=K7(e,`willow-brick-texture`,(e,t)=>{e.fillStyle=`#9d5641`,e.fillRect(0,0,t,t),e.strokeStyle=`#d8b9a0`,e.lineWidth=4;for(let n=0;n<=t;n+=32){e.beginPath(),e.moveTo(0,n),e.lineTo(t,n),e.stroke();let r=n/32%2==0?0:32;for(let i=-r;i{e.fillStyle=`#9b7047`,e.fillRect(0,0,n,n);for(let t=0;t{let i=new lg(t,e);return i.diffuseColor=P.FromHexString(n),i.specularColor.setAll(r),i.roughness=.9,i},c=s(`willow-window-glass`,`#6fa8b7`,.35);return c.alpha=.84,{grass:q7(e,`willow-lawn`,n,`#b8d47d`),asphalt:q7(e,`willow-road`,r,`#848d8d`,.09),concrete:q7(e,`willow-concrete`,i,`#f2ebdc`,.08),brick:q7(e,`willow-house-brick`,a,`#e8b395`,.04),roof:s(`willow-roof`,`#354758`),wood:q7(e,`willow-fence-wood`,o,`#e3c18d`),white:s(`willow-road-white`,`#fff7df`,.08),yellow:s(`willow-road-yellow`,`#f3c94f`,.09),foliage:s(`willow-foliage`,`#3f7c46`),foliageLight:s(`willow-foliage-light`,`#6aa24c`),bark:s(`willow-bark`,`#654531`),glass:c,ramp:q7(e,`willow-ramp`,o,`#d7944e`)}}var F4e=class{constructor(e,t,n,r={}){this.containers=new Map,this.loadedContainers=new Set,this.instances=[],this.visibilityFrame=0,this.scene=e,this.parent=t,this.shadow=n,this.maxVisibleDistance=r.maxVisibleDistance,this.maxVisibleDistance&&(this.visibilityObserver=e.onBeforeRenderObservable.add(()=>this.updateVisibility()))}async preload(e){await Promise.all(e.map(e=>this.load(e)))}async instantiate(e){let t=(await this.load(e)).instantiateModelsToScene(t=>`${e.name}-${t}`),n=new wc(e.name,this.scene);n.parent=this.parent,n.position.copyFrom(e.position),e.rotation?n.rotation.copyFrom(e.rotation):n.rotation.y=e.rotationY??0,e.scale instanceof j?n.scaling.copyFrom(e.scale):n.scaling.setAll(e.scale??1),t.rootNodes.forEach(e=>{e.parent=n});let r=new Set;return n.getChildMeshes().forEach(t=>{t.isPickable=!1,t.receiveShadows=!0,t.useVertexColors=!1,t.hasVertexAlpha=!1;let n=t.material;e.pbrTuning&&n instanceof ZE&&!r.has(n)&&(n.unfreeze(),e.pbrTuning.metallic!==void 0&&(n.metallic=e.pbrTuning.metallic),e.pbrTuning.roughness!==void 0&&(n.roughness=e.pbrTuning.roughness),r.add(n)),e.castShadows!==!1&&this.shadow.addShadowCaster(t),t.computeWorldMatrix(!0),t.freezeWorldMatrix(),n?.freeze()}),this.instances.push(n),n}dispose(){this.visibilityObserver&&this.scene.onBeforeRenderObservable.remove(this.visibilityObserver),this.instances.forEach(e=>e.dispose(!1,!0)),this.instances.length=0,this.loadedContainers.forEach(e=>e.dispose()),this.loadedContainers.clear(),this.containers.clear()}updateVisibility(){if(this.visibilityFrame=(this.visibilityFrame+1)%8,this.visibilityFrame!==0)return;let e=this.scene.activeCamera;if(!e||!this.maxVisibleDistance)return;let t=this.maxVisibleDistance**2;for(let n of this.instances){let r=n.position.x-e.position.x,i=n.position.z-e.position.z;n.setEnabled(r*r+i*i<=t)}}load(e){let t=`${e.rootUrl}${e.file}`,n=this.containers.get(t);return n||(n=xD.LoadAssetContainerAsync(e.rootUrl,e.file,this.scene).then(e=>(this.loadedContainers.add(e),e)),this.containers.set(t,n)),n}},I4e=`Brick_90Angle_L.gltf,Brick_90Angle_R.gltf,Brick_BottomTrim.gltf,Brick_Column_RedBricks.gltf,Brick_Column_Small.gltf,Brick_Column_TrimBricks.gltf,Brick_CornerColumn_Bottom.gltf,Brick_CornerColumn_Cap.gltf,Brick_CornerColumn_CapShort.gltf,Brick_CornerColumn_Center.gltf,Brick_CornerColumn_Center_Half.gltf,Brick_CornerColumn_Top.gltf,Brick_Corner_Plain.gltf,Brick_HalfColumn_Bottom.gltf,Brick_HalfColumn_Center.gltf,Brick_HalfColumn_Top.gltf,Brick_HalfTrim.gltf,Brick_Inset.gltf,Brick_Inset_Window.gltf,Brick_Inset_Window_Curved.gltf,Brick_Inset_Window_Curved_Small.gltf,Brick_InteriorWall_1.gltf,Brick_InteriorWall_3.gltf,Brick_InteriorWall_4.gltf,Brick_Ornament_Horizontal.gltf,Brick_Plain_1.gltf,Brick_Plain_3.gltf,Brick_Plain_3_noWear.gltf,Brick_Plain_4.gltf,Brick_RedWhite_DoubleWindow.gltf,Brick_TopTrim.gltf,Brick_TopTrim_90Angle_L.gltf,Brick_TopTrim_90Angle_R.gltf,Brick_TopTrim_Corner.gltf,Brick_Window_CurvedDouble.gltf,Brick_Window_Square_Single.gltf,Brick_Window_Trim.gltf,Brick_Window_Trim_Single.gltf,Building_Large_2.gltf,Building_Medium_2_001.gltf,Building_Small_1.gltf,Cornice_Brick_90Angle_L.gltf,Cornice_Brick_90Angle_R.gltf,Cornice_Brick_Center.gltf,Cornice_Brick_L.gltf,Cornice_Brick_R.gltf,Cornice_Metal_90Angle_L.gltf,Cornice_Metal_90Angle_R.gltf,Cornice_Metal_Center.gltf,Cornice_Metal_L.gltf,Cornice_Metal_R.gltf,Cornice_Trim_90Angle_L.gltf,Cornice_Trim_90Angle_R.gltf,Cornice_Trim_Center.gltf,Cornice_Trim_L.gltf,Cornice_Trim_R.gltf,Decal_ArrowForwardLeft.gltf,Decal_ArrowForwardRight.gltf,Decal_ArrowStraight.gltf,Decal_ArrowTurnLeft.gltf,Decal_ArrowTurnRight.gltf,Decal_Bikelane.gltf,Decal_BrokenLine_Straight.gltf,Decal_Crosswalk.gltf,Decal_Crosswalk_Wide.gltf,Decal_Curve_2Lane_Stripe.gltf,Decal_Curve_4LaneShort.gltf,Decal_Curve_4LaneShort_DoubleYellow.gltf,Decal_Curve_4LaneShort_Stripe.gltf,Decal_DoubleYellow_Straight.gltf,Decal_Only.gltf,Decal_Slow.gltf,Decal_Stop.gltf,DoorFrame_Metal_Single.gltf,DoorFrame_Trim.gltf,DoorFrame_Wooden.gltf,Door_1.gltf,Door_2.gltf,Door_3.gltf,Entrance_Concrete_2x1.gltf,Entrance_Concrete_2x2.gltf,Floor_2x2.gltf,Floor_4x4.gltf,Floor_Inset.gltf,Metal_Column_Bottom.gltf,Metal_Column_Center.gltf,Metal_Column_Small_Bottom.gltf,Metal_Column_Small_Center.gltf,Metal_Column_Small_Top.gltf,Metal_Column_Top.gltf,Metal_FirstFloor_Wall.gltf,Metal_FirstFloor_Wall_1.gltf,Metal_FirstFloor_Window.gltf,Metal_FullWindow.gltf,Metal_Plain_1.gltf,Metal_Plain_3.gltf,Metal_Window.gltf,Metal_Window_Half.gltf,Prop_ACUnit.gltf,Prop_Bollard.gltf,Prop_Drain.gltf,Prop_ManholeCover.gltf,Prop_Planter_Single.gltf,Roof_2x2.gltf,Roof_2x2_90Angle_Center.gltf,Roof_2x2_90Angle_L.gltf,Roof_2x2_90Angle_R.gltf,Roof_4x4.gltf,Roof_SlateCornice_Center.gltf,Roof_SlateCornice_Corner.gltf,Roof_SlateCornice_InnerCorner.gltf,Roof_SlateCornice_Window_1.gltf,Roof_Slate_Center.gltf,Roof_Slate_Corner.gltf,Roof_Slate_InnerCorner.gltf,Roof_Slate_Window_1.gltf,Sidewalk_Corner_Flat_3m.gltf,Sidewalk_Corner_Flat_3m_Stripe.gltf,Sidewalk_Corner_Round_3m.gltf,Sidewalk_Corner_Round_3m_Stripe.gltf,Sidewalk_NoCurb_3m.gltf,Sidewalk_Planter.gltf,Sidewalk_Straight_3m.gltf,Sidewalk_Straight_3m_Stripe.gltf,Stairs_Entrance_Concrete.gltf,Stairs_Rails_Metal.gltf,Stairs_Rails_Metal_Straight_1.gltf,Stairs_Rails_Metal_Straight_2.gltf,Street_2Lane.gltf,Street_2Lane_noSidewalk.gltf,Street_4Lane.gltf,Street_4Lane_noSidewalk.gltf,Street_4WayIntersection.gltf,Street_Asphalt_6x6.gltf,Street_Asphalt_9x9.gltf,Street_Asphalt_Curve_2Lane.gltf,Street_Asphalt_Curve_4Lane_Short.gltf,Street_Curve_2Lane.gltf,Street_Curve_2Lane_Curb.gltf,Street_Curve_4LaneShort.gltf,Street_Curve_4Lane_Short_Curb.gltf,Street_TIntersection.gltf,Trim_90Angle_TopCover.gltf,Trim_Column_Bottom.gltf,Trim_Column_Center.gltf,Trim_Column_Top.gltf,Trim_Corner.gltf,Trim_FirstFloor_Wall.gltf,Trim_FirstFloor_Window_001.gltf,Trim_FirstFloor_Window_Columns.gltf,Trim_Plain_3.gltf,Trim_Wall_Guard.gltf,Trim_Window.gltf`.split(`,`),J7=`assets/kenney/city-suburban/models/`,Y7=`assets/kenney/car-kit/models/`,X7=`assets/kenney/city-roads/models/`,Z7=`assets/quaternius/downtown-city/`,Q7=`assets/custom/houses/`,$7=`assets/custom/nature/`,e9=`assets/custom/vehicles/`,t9=`assets/custom/street/`,L4e=[{id:`tripo-house-a`,label:`White porch house`,category:`houses`,rootUrl:Q7,file:`tripo-house-a.glb`,defaultScale:70,footprint:[70,55],swatch:`#ddd8ca`},{id:`tripo-house-b`,label:`Residential house`,category:`houses`,rootUrl:Q7,file:`tripo-house-b.glb`,defaultScale:70,footprint:[70,55],swatch:`#bcae91`},{id:`tripo-house-blue`,label:`Blue family house`,category:`houses`,rootUrl:Q7,file:`tripo-house-blue.glb`,defaultScale:70,footprint:[68,70],swatch:`#7893a7`,pbrTuning:{metallic:0,roughness:.58}},{id:`premium-farm-house`,label:`Premium farmhouse`,category:`houses`,rootUrl:Q7,file:`farm-house.glb`,defaultScale:3.75,footprint:[96,72],swatch:`#bcae91`},{id:`premium-house-1`,label:`Premium house 1`,category:`houses`,rootUrl:Q7,file:`house-1.obj`,defaultScale:27,footprint:[69,105],swatch:`#9c765d`},{id:`premium-house-2`,label:`Premium house 2`,category:`houses`,rootUrl:Q7,file:`house-2.obj`,defaultScale:27,footprint:[98,83],swatch:`#8d9298`},{id:`nature-tree-maple-2`,label:`Natural maple canopy A`,category:`nature`,rootUrl:$7,file:`MapleTree_2.gltf`,defaultScale:8.5,footprint:[58,54],swatch:`#4f7246`},{id:`nature-tree-maple-3`,label:`Natural maple canopy B`,category:`nature`,rootUrl:$7,file:`MapleTree_3.gltf`,defaultScale:8.2,footprint:[74,55],swatch:`#466c40`},{id:`nature-tree-birch-1`,label:`Natural birch tree`,category:`nature`,rootUrl:$7,file:`BirchTree_1.gltf`,defaultScale:10,footprint:[28,24],swatch:`#688660`},{id:`nature-bush`,label:`Natural garden shrub`,category:`nature`,rootUrl:$7,file:`Bush.gltf`,defaultScale:7.5,footprint:[10,10],swatch:`#55764a`},{id:`nature-bush-large`,label:`Natural hedge shrub`,category:`nature`,rootUrl:$7,file:`Bush_Large.gltf`,defaultScale:8,footprint:[18,12],swatch:`#4d7144`},{id:`nature-bush-flowers`,label:`Natural flowering shrub`,category:`nature`,rootUrl:$7,file:`Bush_Flowers.gltf`,defaultScale:7.5,footprint:[10,10],swatch:`#6b7e50`},...[`a`,`f`,`k`,`q`,`u`].map((e,t)=>({id:`house-${e}`,label:`Suburban house ${e.toUpperCase()}`,category:`houses`,rootUrl:J7,file:`building-type-${e}.glb`,defaultScale:96,footprint:[132,112],swatch:[`#d9d1bc`,`#aebdc0`,`#c7ad86`,`#b7c29a`,`#c6b6a8`][t]})),{id:`tree-large`,label:`Giant maple tree`,category:`nature`,rootUrl:J7,file:`tree-large.glb`,defaultScale:200,footprint:[42,48],swatch:`#608553`},{id:`tree-small`,label:`Giant young tree`,category:`nature`,rootUrl:J7,file:`tree-small.glb`,defaultScale:176,footprint:[37,43],swatch:`#759b61`},{id:`yard-planter`,label:`Oversized yard planter`,category:`nature`,rootUrl:J7,file:`planter.glb`,defaultScale:48,footprint:[34,34],swatch:`#7e9d62`},{id:`yard-stone-path`,label:`Garden stepping stones`,category:`nature`,rootUrl:J7,file:`path-stones-messy.glb`,defaultScale:60,footprint:[10,22],swatch:`#aaa393`},{id:`parked-sedan`,label:`Full-size sedan`,category:`vehicles`,rootUrl:Y7,file:`sedan-sports.glb`,defaultScale:18,footprint:[24,48],swatch:`#547b87`},{id:`parked-hatchback`,label:`Full-size hatchback`,category:`vehicles`,rootUrl:Y7,file:`hatchback-sports.glb`,defaultScale:18,footprint:[24,44],swatch:`#a95146`},{id:`parked-suv`,label:`Full-size SUV`,category:`vehicles`,rootUrl:Y7,file:`suv-luxury.glb`,defaultScale:18,footprint:[26,50],swatch:`#b49451`},{id:`custom-blue-car`,label:`Blue parked car`,category:`vehicles`,rootUrl:e9,file:`blue-car.glb`,defaultScale:50,footprint:[25,50],swatch:`#3978a8`,rotationOffset:90,pbrTuning:{metallic:0,roughness:.42}},{id:`custom-classic-car-a`,label:`Classic parked car A`,category:`vehicles`,rootUrl:e9,file:`classic-car-a.glb`,defaultScale:50,footprint:[22,49],swatch:`#aa654a`,rotationOffset:90,pbrTuning:{metallic:0,roughness:.42}},{id:`custom-classic-car-b`,label:`Classic parked car B`,category:`vehicles`,rootUrl:e9,file:`classic-car-b.glb`,defaultScale:50,footprint:[22,49],swatch:`#77776e`,pbrTuning:{metallic:0,roughness:.42}},{id:`driveway`,label:`Giant driveway`,category:`street`,rootUrl:J7,file:`driveway-long.glb`,defaultScale:58,footprint:[50,104],swatch:`#9a9992`},{id:`fence-low`,label:`Towering low fence`,category:`street`,rootUrl:J7,file:`fence-low.glb`,defaultScale:60,footprint:[76,6],swatch:`#d4cdbb`},{id:`fence-tall`,label:`Towering yard fence`,category:`street`,rootUrl:J7,file:`fence-1x4.glb`,defaultScale:60,footprint:[100,7],swatch:`#b9ac94`},{id:`fence-white-wood`,label:`White wooden fence`,category:`street`,rootUrl:t9,file:`white-wooden-fence.glb`,defaultScale:100,footprint:[98,5.5],swatch:`#e1ddd1`,pbrTuning:{metallic:0,roughness:.72}},{id:`fence-wooden-gate`,label:`Wooden gate fence`,category:`street`,rootUrl:t9,file:`wooden-gate.glb`,defaultScale:12,footprint:[12,1.3],swatch:`#8d603b`,pbrTuning:{metallic:0,roughness:.76}},{id:`wooden-bridge`,label:`Wooden bridge`,category:`structures`,rootUrl:t9,file:`wooden-bridge.glb`,defaultScale:28,footprint:[27.5,13.7],swatch:`#835a38`,meshCollision:!0,pbrTuning:{metallic:0,roughness:.74}},{id:`street-light`,label:`Giant street light`,category:`street`,rootUrl:X7,file:`light-curved.glb`,defaultScale:80,footprint:[4,4],swatch:`#677076`},{id:`tripo-street-light`,label:`Detailed street light`,category:`street`,rootUrl:t9,file:`tripo-street-light.glb`,defaultScale:55,footprint:[4,4],swatch:`#44484b`,pbrTuning:{metallic:.05,roughness:.48}},{id:`construction-cone`,label:`Traffic cone`,category:`props`,rootUrl:X7,file:`construction-cone.glb`,defaultScale:9.1,footprint:[.74,.74],swatch:`#d96e32`},{id:`construction-barrier`,label:`Construction barrier`,category:`props`,rootUrl:X7,file:`construction-barrier.glb`,defaultScale:10.1,footprint:[1.05,2.25],swatch:`#c69036`},{id:`construction-light`,label:`Construction warning light`,category:`props`,rootUrl:X7,file:`construction-light.glb`,defaultScale:10,footprint:[.75,.75],swatch:`#e2a93e`}],n9=[...I4e.map(e=>{let t=z4e(e),n=t===`roads`;return{id:`downtown-${e.replace(/\.gltf$/i,``).replace(/_/g,`-`).toLowerCase()}`,label:e.replace(/\.gltf$/i,``).replace(/_/g,` `),category:t,rootUrl:Z7,file:e,defaultScale:4,footprint:B4e(e),swatch:V4e(t),isRoad:n}}),...L4e],R4e=[{name:`Red brick`,url:`${Z7}T_RedBrick_BaseColor.png`},{name:`Concrete`,url:`${Z7}T_Concrete_BaseColor.png`},{name:`Metal concrete`,url:`${Z7}T_MetalConcrete_BaseColor.png`},{name:`Roof slate`,url:`${Z7}T_RoofSlate_BaseColor.png`},{name:`Trim`,url:`${Z7}T_Trim_BaseColor.png`},{name:`Ornaments`,url:`${Z7}T_Ornaments_BaseColor.png`},{name:`Dirt`,url:`${Z7}T_Dirt_BaseColor.png`},{name:`Road decals`,url:`${Z7}T_Street_Decals.png`},{name:`Kenney suburban palette`,url:`${J7}Textures/colormap.png`},{name:`Kenney vehicle palette`,url:`${Y7}Textures/colormap.png`},{name:`Natural maple leaves`,url:`${$7}MapleTree_Leaves.png`},{name:`Natural birch leaves`,url:`${$7}BirchTree_Leaves.png`},{name:`Natural shrub leaves`,url:`${$7}Bush_Leaves.png`},{name:`Natural flowers`,url:`${$7}Flowers.png`}];function r9(e){return n9.find(t=>t.id===e)}function z4e(e){return e.startsWith(`Street_`)?`roads`:e.startsWith(`Sidewalk_`)?`sidewalks`:e.startsWith(`Decal_`)?`markings`:e.startsWith(`Building_`)?`buildings`:e.startsWith(`Roof_`)?`roofs`:/^(Brick|Metal|Trim|Cornice)_/.test(e)?`facades`:/^(Door|DoorFrame|Entrance|Floor|Stairs)_/.test(e)?`structures`:`props`}function B4e(e){return e.includes(`4WayIntersection`)?[99,99]:e.includes(`TIntersection`)?[99,86]:/Curve/.test(e)&&e.startsWith(`Street_`)?[48,48]:/Curve/.test(e)&&e.startsWith(`Decal_`)?[40,40]:e===`Street_2Lane.gltf`?[24,48]:e===`Street_4Lane.gltf`?[24,72]:e===`Street_4Lane_noSidewalk.gltf`?[24,48]:e.startsWith(`Street_`)?[24,24]:e.startsWith(`Sidewalk_`)?[12,12]:e.startsWith(`Decal_`)?[24,24]:e.startsWith(`Building_Large`)?[84,68]:e.startsWith(`Building_Medium`)?[62,54]:e.startsWith(`Building_Small`)?[52,60]:e.startsWith(`Brick_`)?[16,1]:/^(Metal|Trim|Cornice)_/.test(e)?[12,1]:e.startsWith(`Roof_`)?[18,18]:[8,8]}function V4e(e){return{roads:`#55595d`,sidewalks:`#aaa59b`,markings:`#d8b650`,buildings:`#8b6255`,facades:`#9a6b5a`,roofs:`#55565e`,structures:`#777c7e`,props:`#6d756f`,houses:`#c4b9a6`,nature:`#66885c`,vehicles:`#657c85`,street:`#6b7074`}[e]}var i9=1.8;function a9(e){return{...e,objects:e.objects.map(e=>r9(e.assetId)?.isRoad?{...e,y:Math.max(e.y??1.8,i9)}:e)}}function o9(e){return{...e,objects:e.objects.filter(e=>!H4e(e))}}function H4e(e){return e.id.startsWith(`auto-route-road-`)||e.id.startsWith(`completed-route-road-`)}var U4e={version:3,id:`construction-loop-kit`,name:`Construction Loop`,presetRevision:19,seed:20260718,roadWidth:24,worldSize:700,route:[{x:-74.5,z:175.6},{x:-74.5,z:135},{x:-74.9,z:104.9},{x:-44.5,z:104.5},{x:65,z:104.3},{x:64.5,z:25.1},{x:65,z:-44.7},{x:131.9,z:-44.7},{x:193.9,z:-44.7},{x:194.1,z:-145.5},{x:-93.4,z:-145},{x:-211,z:-103.7},{x:-211,z:-19},{x:-211.7,z:141.5},{x:-212,z:215},{x:-74.4,z:216.9}],routeClosed:!0,objects:[{id:`ccdff0fb-3a6c-43c5-bc6d-14c77321d0a3`,assetId:`downtown-street-2lane`,x:-74.4,z:158.7,rotation:90,scale:1,y:1.8},{id:`0e81f90c-4d3a-42a0-8bfd-066a56be151f`,assetId:`downtown-street-curve-2lane`,x:-50.3,z:128.6,rotation:270,scale:1,y:1.8},{id:`1fb479b0-6675-42cb-b590-65125a117364`,assetId:`downtown-street-2lane`,x:-74.6,z:135.2,rotation:90,scale:1,y:1.8},{id:`b26d0779-efe7-43a2-9aba-7385b41f9619`,assetId:`downtown-street-2lane`,x:-38.6,z:104,rotation:0,scale:1,y:1.8},{id:`5db97cf0-6439-4611-af57-547ecdb3a0f5`,assetId:`downtown-street-2lane`,x:-14.9,z:104,rotation:0,scale:1,y:1.8},{id:`7a2fb3f2-cd36-4701-90db-f8386f9d8e95`,assetId:`downtown-street-2lane`,x:8.5,z:104,rotation:0,scale:1,y:1.8},{id:`25f56b6e-7fe2-4886-b383-5cf7a8e77854`,assetId:`downtown-street-2lane`,x:32,z:104,rotation:0,scale:1,y:1.8},{id:`0da346ed-22c8-42a5-a147-829e39bf40c5`,assetId:`downtown-street-curve-2lane`,x:43.9,z:80,rotation:90,scale:1,y:1.8},{id:`677382d1-d2ad-4b04-be6e-ca067f342e85`,assetId:`downtown-street-2lane`,x:68,z:69,rotation:90,scale:1,y:1.8},{id:`34ba61e6-a6bd-44b6-ba0e-23547e21607b`,assetId:`downtown-street-2lane`,x:68,z:44.9,rotation:90,scale:1,y:2},{id:`f345ea72-23d2-414f-9069-11a00893180b`,assetId:`downtown-street-2lane`,x:68,z:21.1,rotation:90,scale:1,y:1.8},{id:`1d4eaf47-ed9b-444d-840f-6b7e5d7f57cd`,assetId:`downtown-street-2lane`,x:68,z:-2.9,rotation:90,scale:1,y:1.8},{id:`f61582e9-e70e-41d9-a7b5-94673adabe4b`,assetId:`downtown-street-2lane`,x:175,z:-62.5,rotation:0,scale:1,y:1.8},{id:`34a30853-a44b-4f34-aa0f-4f5d6ccffec0`,assetId:`downtown-street-2lane`,x:151.6,z:-62.5,rotation:0,scale:1,y:1.8},{id:`b7299753-1487-4332-9515-c5cb39f1fdbd`,assetId:`downtown-street-2lane`,x:127.9,z:-62.5,rotation:0,scale:1,y:1.8},{id:`12e196fa-05b1-4d8f-afed-60e6731aec36`,assetId:`downtown-street-2lane`,x:104,z:-62.5,rotation:0,scale:1,y:1.8},{id:`c52ea94e-1ff8-4a12-8bca-297628fa6223`,assetId:`downtown-street-2lane`,x:68,z:-27,rotation:90,scale:1,y:1.8},{id:`81b9258d-a9a1-428b-ad47-ec0e7a9efc47`,assetId:`downtown-street-curve-2lane`,x:92,z:-38.6,rotation:270,scale:1,y:1.8},{id:`manual-road-finish-001`,assetId:`downtown-street-curve-2lane`,x:187,z:-86.5,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-002`,assetId:`downtown-street-2lane`,x:211,z:-98.5,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-003`,assetId:`downtown-street-2lane`,x:211,z:-122.5,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-004`,assetId:`downtown-street-curve-2lane`,x:187,z:-134.5,rotation:180,scale:1,y:1.8},{id:`manual-road-finish-005`,assetId:`downtown-street-2lane`,x:175,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-006`,assetId:`downtown-street-2lane`,x:151,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-007`,assetId:`downtown-street-2lane`,x:127,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-008`,assetId:`downtown-street-2lane`,x:103,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-009`,assetId:`downtown-street-2lane`,x:79,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-010`,assetId:`downtown-street-2lane`,x:55,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-011`,assetId:`downtown-street-2lane`,x:31,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-012`,assetId:`downtown-street-2lane`,x:7,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-013`,assetId:`downtown-street-2lane`,x:-17,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-014`,assetId:`downtown-street-2lane`,x:-41,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-015`,assetId:`downtown-street-2lane`,x:-65,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-016`,assetId:`downtown-street-2lane`,x:-89,z:-158.5,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-017`,assetId:`downtown-street-2lane`,x:-111.8,z:-158.2,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`manual-road-finish-020`,assetId:`downtown-street-2lane`,x:-135.13,z:-158.22,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`manual-road-finish-021`,assetId:`downtown-street-curve-2lane`,x:-187,z:-134,rotation:270,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`manual-road-finish-022`,assetId:`downtown-street-2lane`,x:-211,z:-80,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-023`,assetId:`downtown-street-2lane`,x:-211,z:-56.3,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-024`,assetId:`downtown-street-2lane`,x:-211,z:-32.6,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-025`,assetId:`downtown-street-2lane`,x:-211,z:-8.8,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-026`,assetId:`downtown-street-2lane`,x:-211,z:14.9,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-027`,assetId:`downtown-street-2lane`,x:-211,z:38.6,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-028`,assetId:`downtown-street-2lane`,x:-211,z:62.4,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-029`,assetId:`downtown-street-2lane`,x:-211,z:86.1,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-030`,assetId:`downtown-street-2lane`,x:-211,z:109.8,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-031`,assetId:`downtown-street-2lane`,x:-211,z:133.6,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-032`,assetId:`downtown-street-2lane`,x:-211,z:157.3,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-033`,assetId:`downtown-street-2lane`,x:-211,z:181,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-035`,assetId:`downtown-street-curve-2lane`,x:-187,z:193,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-036`,assetId:`downtown-street-2lane`,x:-175,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-037`,assetId:`downtown-street-2lane`,x:-151.5,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-038`,assetId:`downtown-street-2lane`,x:-128,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-039`,assetId:`downtown-street-2lane`,x:-110.5,z:217,rotation:0,scale:1,y:1.8},{id:`manual-road-finish-040`,assetId:`downtown-street-curve-2lane`,x:-98.5,z:193,rotation:90,scale:1,y:1.8},{id:`manual-road-finish-041`,assetId:`downtown-street-2lane`,x:-74.5,z:181,rotation:90,scale:1,y:1.8},{id:`neighborhood-house-bottom-01`,assetId:`tripo-house-a`,x:-160,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-01-shrub-l`,assetId:`nature-bush-large`,x:-147.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-01-shrub-r`,assetId:`nature-bush-large`,x:-147.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-01-flowers`,assetId:`nature-bush-flowers`,x:-139.08,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-bottom-02`,assetId:`tripo-house-blue`,x:-55,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-02-shrub-l`,assetId:`nature-bush-large`,x:-42.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-02-shrub-r`,assetId:`nature-bush-large`,x:-42.08,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-02-flowers`,assetId:`nature-bush-flowers`,x:-34.08,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-bottom-03`,assetId:`tripo-house-a`,x:50,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-03-shrub-l`,assetId:`nature-bush-large`,x:62.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-03-shrub-r`,assetId:`nature-bush-large`,x:62.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-03-flowers`,assetId:`nature-bush-flowers`,x:70.92,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-bottom-04`,assetId:`tripo-house-a`,x:155,z:-236,rotation:0,scale:.78},{id:`neighborhood-house-bottom-04-shrub-l`,assetId:`nature-bush-large`,x:167.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-04-shrub-r`,assetId:`nature-bush-large`,x:167.92,z:-190.05,rotation:0,scale:.58},{id:`neighborhood-house-bottom-04-flowers`,assetId:`nature-bush-flowers`,x:175.92,z:-189.05,rotation:15,scale:.62},{id:`neighborhood-house-west-01`,assetId:`tripo-house-a`,x:-284,z:-92,rotation:90,scale:.68},{id:`neighborhood-house-west-01-shrub-l`,assetId:`nature-bush-large`,x:-255.54,z:-103.26,rotation:90,scale:.58},{id:`neighborhood-house-west-01-shrub-r`,assetId:`nature-bush-large`,x:-255.54,z:-103.26,rotation:90,scale:.58},{id:`neighborhood-house-west-01-flowers`,assetId:`nature-bush-flowers`,x:-254.54,z:-111.26,rotation:105,scale:.62},{id:`neighborhood-house-west-02`,assetId:`tripo-house-blue`,x:-284,z:15,rotation:90,scale:.68},{id:`neighborhood-house-west-02-shrub-l`,assetId:`nature-bush-large`,x:-255.54,z:3.74,rotation:90,scale:.58},{id:`neighborhood-house-west-02-shrub-r`,assetId:`nature-bush-large`,x:-255.54,z:3.74,rotation:90,scale:.58},{id:`neighborhood-house-west-02-flowers`,assetId:`nature-bush-flowers`,x:-254.54,z:-4.26,rotation:105,scale:.62},{id:`neighborhood-house-west-03`,assetId:`tripo-house-a`,x:-284,z:122,rotation:90,scale:.68},{id:`neighborhood-house-west-03-shrub-l`,assetId:`nature-bush-large`,x:-255.54,z:110.74,rotation:90,scale:.58},{id:`neighborhood-house-west-03-shrub-r`,assetId:`nature-bush-large`,x:-255.54,z:110.74,rotation:90,scale:.58},{id:`neighborhood-house-west-03-flowers`,assetId:`nature-bush-flowers`,x:-254.54,z:102.74,rotation:105,scale:.62},{id:`neighborhood-house-northwest-01`,assetId:`tripo-house-a`,x:-135,z:135,rotation:0,scale:.62},{id:`neighborhood-house-northwest-01-shrub-l`,assetId:`nature-bush-large`,x:-124.73,z:172.55,rotation:0,scale:.58},{id:`neighborhood-house-northwest-01-shrub-r`,assetId:`nature-bush-large`,x:-124.73,z:172.55,rotation:0,scale:.58},{id:`neighborhood-house-northwest-01-flowers`,assetId:`nature-bush-flowers`,x:-116.73,z:173.55,rotation:15,scale:.62},{id:`neighborhood-house-north-01`,assetId:`tripo-house-a`,x:0,z:178,rotation:180,scale:.72},{id:`neighborhood-house-north-01-shrub-l`,assetId:`nature-bush-large`,x:-11.92,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-01-shrub-r`,assetId:`nature-bush-large`,x:-11.92,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-01-flowers`,assetId:`nature-bush-flowers`,x:-19.92,z:134.2,rotation:195,scale:.62},{id:`neighborhood-house-north-02`,assetId:`tripo-house-a`,x:133.29,z:135.07,rotation:235,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-north-02-shrub-l`,assetId:`nature-bush-large`,x:46.08,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-02-shrub-r`,assetId:`nature-bush-large`,x:46.08,z:135.2,rotation:180,scale:.58},{id:`neighborhood-house-north-02-flowers`,assetId:`nature-bush-flowers`,x:38.08,z:134.2,rotation:195,scale:.62},{id:`neighborhood-house-east-01`,assetId:`tripo-house-a`,x:148,z:12,rotation:180,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-east-01-shrub-l`,assetId:`nature-bush-large`,x:133.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-01-shrub-r`,assetId:`nature-bush-large`,x:133.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-01-flowers`,assetId:`nature-bush-flowers`,x:125.08,z:-31.8,rotation:195,scale:.62},{id:`neighborhood-house-east-02`,assetId:`tripo-house-blue`,x:233.01,z:-8.33,rotation:210,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-east-02-shrub-l`,assetId:`nature-bush-large`,x:193.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-02-shrub-r`,assetId:`nature-bush-large`,x:193.08,z:-30.8,rotation:180,scale:.58},{id:`neighborhood-house-east-02-flowers`,assetId:`nature-bush-flowers`,x:185.08,z:-31.8,rotation:195,scale:.62},{id:`neighborhood-house-east-03`,assetId:`tripo-house-a`,x:277,z:-118,rotation:270,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-east-03-shrub-l`,assetId:`nature-bush-large`,x:255.16,z:-104.08,rotation:270,scale:.58},{id:`neighborhood-house-east-03-shrub-r`,assetId:`nature-bush-large`,x:255.16,z:-104.08,rotation:270,scale:.58},{id:`neighborhood-house-east-03-flowers`,assetId:`nature-bush-flowers`,x:254.16,z:-96.08,rotation:285,scale:.62},{id:`neighborhood-house-center-nw`,assetId:`tripo-house-b`,x:-144,z:30,rotation:270,scale:.62},{id:`neighborhood-house-center-nw-shrub-l`,assetId:`nature-bush-large`,x:-179.38,z:44.58,rotation:270,scale:.58},{id:`neighborhood-house-center-nw-shrub-r`,assetId:`nature-bush-large`,x:-179.38,z:44.58,rotation:270,scale:.58},{id:`neighborhood-house-center-nw-flowers`,assetId:`nature-bush-flowers`,x:-180.38,z:52.58,rotation:285,scale:.62},{id:`neighborhood-house-center-ne`,assetId:`tripo-house-a`,x:6,z:-29,rotation:90,scale:.62,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-center-ne-shrub-l`,assetId:`nature-bush-large`,x:-39.61,z:17.73,rotation:90,scale:.58},{id:`neighborhood-house-center-ne-shrub-r`,assetId:`nature-bush-large`,x:-39.61,z:17.73,rotation:90,scale:.58},{id:`neighborhood-house-center-ne-flowers`,assetId:`nature-bush-flowers`,x:-38.61,z:9.73,rotation:105,scale:.62},{id:`neighborhood-house-center-sw`,assetId:`tripo-house-b`,x:-70.66,z:-107.06,rotation:180,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-house-center-se`,assetId:`tripo-house-b`,x:38,z:-107,rotation:180,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-car-bottom-01`,assetId:`custom-blue-car`,x:-107,z:-211,rotation:0,scale:.88},{id:`neighborhood-car-bottom-02`,assetId:`custom-classic-car-a`,x:-2,z:-211,rotation:0,scale:.88},{id:`neighborhood-car-bottom-03`,assetId:`custom-classic-car-b`,x:103,z:-211,rotation:0,scale:.88},{id:`neighborhood-car-west-01`,assetId:`custom-classic-car-a`,x:-258,z:-39,rotation:90,scale:.88},{id:`neighborhood-car-west-02`,assetId:`custom-classic-car-b`,x:-258,z:68,rotation:90,scale:.88},{id:`neighborhood-car-east-01`,assetId:`custom-classic-car-a`,x:188,z:6,rotation:180,scale:.88,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-car-east-02`,assetId:`custom-classic-car-b`,x:251.5,z:-72.85,rotation:250,scale:.88,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-light-northwest-01`,assetId:`tripo-street-light`,x:-189,z:234,rotation:0,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-light-outer-east-01`,assetId:`tripo-street-light`,x:229,z:-116,rotation:90,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-birch-bottom-01`,assetId:`nature-tree-birch-1`,x:-205,z:-286,rotation:8,scale:.82},{id:`neighborhood-birch-bottom-02`,assetId:`nature-tree-birch-1`,x:-100,z:-310,rotation:342,scale:.78},{id:`neighborhood-birch-bottom-03`,assetId:`nature-tree-birch-1`,x:5,z:-310,rotation:18,scale:.8},{id:`neighborhood-birch-bottom-04`,assetId:`nature-tree-birch-1`,x:110,z:-310,rotation:350,scale:.8},{id:`neighborhood-birch-bottom-05`,assetId:`nature-tree-birch-1`,x:210,z:-286,rotation:12,scale:.82},{id:`neighborhood-birch-west-01`,assetId:`nature-tree-birch-1`,x:-342,z:-150,rotation:20,scale:.8},{id:`neighborhood-birch-west-02`,assetId:`nature-tree-birch-1`,x:-342,z:-35,rotation:340,scale:.82},{id:`neighborhood-birch-west-03`,assetId:`nature-tree-birch-1`,x:-342,z:78,rotation:14,scale:.78},{id:`neighborhood-birch-west-04`,assetId:`nature-tree-birch-1`,x:-342,z:176,rotation:350,scale:.8},{id:`neighborhood-birch-north-02`,assetId:`nature-tree-birch-1`,x:-50,z:230,rotation:345,scale:.78},{id:`neighborhood-birch-north-03`,assetId:`nature-tree-birch-1`,x:105,z:220,rotation:20,scale:.8},{id:`neighborhood-birch-east-01`,assetId:`nature-tree-birch-1`,x:300,z:40,rotation:338,scale:.8},{id:`neighborhood-birch-east-02`,assetId:`nature-tree-birch-1`,x:260,z:65,rotation:12,scale:.82},{id:`neighborhood-birch-east-03`,assetId:`nature-tree-birch-1`,x:326,z:-62,rotation:348,scale:.8},{id:`neighborhood-maple-center-01`,assetId:`nature-tree-maple-2`,x:-100,z:82,rotation:18,scale:.52},{id:`neighborhood-maple-east-01`,assetId:`nature-tree-maple-3`,x:238,z:92,rotation:348,scale:.46},{id:`neighborhood-path-center-nw`,assetId:`yard-stone-path`,x:-176,z:26,rotation:90,scale:.48,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`neighborhood-planter-east-01`,assetId:`yard-planter`,x:240,z:12,rotation:0,scale:.38},{id:`6b20414d-ac26-463a-9184-d6166e7250cf`,assetId:`fence-white-wood`,x:51.15,z:-271.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`6d8594de-7d7a-4e99-9391-f1607a8f57fa`,assetId:`fence-white-wood`,x:-53.85,z:-271.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`89e4b7bd-219a-4bf7-8ec0-41e51c752455`,assetId:`fence-white-wood`,x:-158.85,z:-270.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`a15829e2-00a3-4636-80e5-e41761417b81`,assetId:`fence-white-wood`,x:155.15,z:-271.18,rotation:180,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`47ae54fe-430a-4368-9b3a-1f69d39b9942`,assetId:`fence-white-wood`,x:-308.2,z:122.82,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`80e14273-7086-4e7b-a807-90c082029c93`,assetId:`fence-white-wood`,x:-309.2,z:-98.18,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`dacb208b-802e-4f8e-bb7f-1c8b152d97ba`,assetId:`fence-white-wood`,x:-309.2,z:9.82,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`f5fbf83b-7c3a-497c-9994-4b25082656fe`,assetId:`fence-white-wood`,x:229.69,z:-185.39,rotation:315,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`7cf3f086-f016-4528-b900-57ddd3f75b92`,assetId:`fence-white-wood`,x:155.75,z:53.31,rotation:15,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`ba11abaa-44c5-4ab7-8bc3-28dacd421539`,assetId:`fence-white-wood`,x:309.73,z:-60.68,rotation:70,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`83bf6b50-7565-42a1-9d18-45616d78bc72`,assetId:`fence-white-wood`,x:249.39,z:17.6,rotation:30,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`945691bd-8ddc-4067-a838-abd0565fe668`,assetId:`tripo-house-a`,x:60,z:180,rotation:180,scale:.72},{id:`859f9e0c-0e43-4c92-935d-6aef8aef0c02`,assetId:`tripo-house-b`,x:155.23,z:-109.94,rotation:0,scale:1,y:1,scaleX:.7,scaleY:.7,scaleZ:.7},{id:`57fd89de-aa12-4ebc-908c-0e4eef0f45b3`,assetId:`tripo-house-a`,x:-212.81,z:287.78,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`4f136565-70da-4926-9049-c70d3203e16a`,assetId:`tripo-house-a`,x:-92.81,z:289.78,rotation:270,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`b66ae187-96fb-4473-9b04-e5a86c40bdae`,assetId:`tripo-street-light`,x:-138,z:235,rotation:0,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`7df50282-9945-427d-bb43-214a356617bd`,assetId:`tripo-street-light`,x:-95,z:235,rotation:0,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`7395ce0a-42b7-4432-8ede-306fc6661356`,assetId:`tripo-street-light`,x:-229.91,z:176.78,rotation:270,scale:.82,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`093d89ea-e3ea-46f6-a844-cd3f9a843f1b`,assetId:`downtown-street-2lane`,x:-211,z:-104,rotation:90,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`b1b0f79d-2338-4c40-a3d6-a25036db3901`,assetId:`downtown-street-2lane`,x:-211,z:-124,rotation:90,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`4fbabcd5-50d0-4242-bc15-abd74cbeb9ab`,assetId:`downtown-street-2lane`,x:-154.13,z:-158.22,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`cf2f35a6-f03a-4139-91ae-c96ba8cb2c7c`,assetId:`downtown-street-2lane`,x:-176,z:-158.22,rotation:180,scale:1,y:1.8,scaleX:1,scaleY:1,scaleZ:1},{id:`1876069d-2539-4bef-8540-b8450941b221`,assetId:`tripo-house-b`,x:5,z:46,rotation:0,scale:.72,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`9b4830e9-c7c8-4a19-a284-a8e33e876652`,assetId:`fence-white-wood`,x:23.86,z:207.82,rotation:0,scale:1,y:1,scaleX:1.4,scaleY:1,scaleZ:1},{id:`006eda1a-919c-4ad4-b2b6-67383c0e776d`,assetId:`fence-white-wood`,x:-94.14,z:313.82,rotation:0,scale:1,y:1,scaleX:1.4,scaleY:1,scaleZ:1},{id:`91391b83-48ba-4c26-885f-9cadb690452b`,assetId:`fence-white-wood`,x:-229.14,z:313.82,rotation:0,scale:1,y:1,scaleX:1.4,scaleY:1,scaleZ:1},{id:`74cb08e4-24bb-4c7e-9115-e1ccb13d0557`,assetId:`tripo-house-b`,x:-142,z:-69,rotation:270,scale:.62,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`b782aa56-4fa0-45df-ae1a-7b6673e63132`,assetId:`nature-tree-maple-2`,x:-72.91,z:31.55,rotation:0,scale:1},{id:`5379b885-a560-4539-8380-e557fd61e66b`,assetId:`nature-tree-maple-3`,x:-152.2,z:77.43,rotation:0,scale:1},{id:`0396a4da-2841-47d9-96ac-d28e0a37d558`,assetId:`nature-tree-maple-3`,x:-91.53,z:-38.47,rotation:0,scale:1},{id:`62e3caa1-8458-42c5-9244-43d11aa10e0a`,assetId:`nature-bush`,x:-248.65,z:-216.17,rotation:0,scale:1},{id:`116e8c24-13e9-4674-91be-d91a4eccafe0`,assetId:`nature-tree-maple-2`,x:-264.19,z:-161.81,rotation:0,scale:1},{id:`a7bdca4a-f504-47e1-8539-64db97064d52`,assetId:`nature-tree-maple-2`,x:-228.47,z:-184.43,rotation:0,scale:1},{id:`8f95ace1-b6e2-4ad0-8842-f09e29523c54`,assetId:`nature-tree-maple-2`,x:-262.15,z:-201.65,rotation:0,scale:1},{id:`0e1ed0aa-fc58-4224-b046-3089eea65ac1`,assetId:`nature-bush`,x:-281.73,z:-176.49,rotation:0,scale:1},{id:`97460682-f729-494f-a486-7e322fb11e48`,assetId:`nature-bush`,x:-244.59,z:-160.5,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`14b42bf5-71c7-4bca-805c-6704ce2d0d2f`,assetId:`nature-bush`,x:-209.9,z:-191.39,rotation:0,scale:1},{id:`e9da8030-59bb-4554-bdba-bce8941acbb2`,assetId:`nature-bush`,x:-249.52,z:-165.22,rotation:0,scale:1},{id:`6fbc4bd2-e138-4f38-a25c-22fa6ff6e696`,assetId:`nature-tree-maple-2`,x:259.01,z:-240.01,rotation:0,scale:1},{id:`551ed0a3-9915-44c1-ae64-94038acb6826`,assetId:`nature-tree-maple-3`,x:285.91,z:-215.2,rotation:0,scale:1},{id:`02ca1688-50f3-4482-a10a-df178eac2602`,assetId:`nature-tree-birch-1`,x:218.45,z:-214.48,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`f25d935b-b088-4fb9-8b74-68f61c2a1f26`,assetId:`nature-tree-birch-1`,x:240.32,z:-179.51,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`3194c866-34f2-400b-8a43-98b66f05f6a6`,assetId:`nature-tree-maple-3`,x:239.14,z:-253.23,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`b4b42d35-819f-4e6c-9a54-4de764fdd4c9`,assetId:`nature-tree-maple-3`,x:285.11,z:-173.68,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`696d7c7e-2c68-4006-98ce-0fa104a5e615`,assetId:`nature-tree-maple-3`,x:280.58,z:-40.72,rotation:0,scale:1},{id:`7141d01f-3554-458b-8895-9420b40d0345`,assetId:`nature-tree-maple-3`,x:296.59,z:-76.5,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`10469327-7035-493d-982b-adb75fe2805c`,assetId:`nature-tree-maple-2`,x:181.61,z:78.92,rotation:0,scale:1},{id:`4edd054f-3b2c-4faa-ae1c-938f37ba4c33`,assetId:`nature-tree-maple-3`,x:238.76,z:55.29,rotation:0,scale:1},{id:`a5509e55-f900-4734-a882-b46f1c3af768`,assetId:`nature-tree-birch-1`,x:161.33,z:112.95,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`185ba362-a06b-4995-a5d3-c4c96067b601`,assetId:`nature-tree-maple-3`,x:126.64,z:70.84,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`03cdd96c-d396-4b44-a0a9-f39115bde01e`,assetId:`nature-tree-maple-2`,x:101.3,z:15.17,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`54527822-675c-433f-b025-ae29cb97e588`,assetId:`nature-tree-maple-2`,x:108.17,z:194.16,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`4a0902df-a72e-4585-9bfe-aedd427ba27a`,assetId:`nature-tree-maple-3`,x:168.71,z:228.31,rotation:0,scale:1},{id:`209204ff-8246-4239-b5ea-5ad3f3c4c76f`,assetId:`nature-tree-birch-1`,x:206.53,z:192.17,rotation:0,scale:1},{id:`397c300c-2718-4a92-8691-ea3eea0518a7`,assetId:`nature-bush`,x:75.83,z:287.14,rotation:0,scale:1},{id:`1fc84d13-75d3-44c0-bc2d-8920d3a5f21a`,assetId:`nature-bush`,x:82.63,z:117.7,rotation:0,scale:1},{id:`958ab228-98a4-4eb2-a23c-5706c643d70b`,assetId:`nature-bush`,x:92.5,z:137.63,rotation:0,scale:1},{id:`9b4682dd-09fa-4b39-ab72-5350c020ddc9`,assetId:`nature-tree-birch-1`,x:29.11,z:153.02,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`0d087fd8-8970-4804-b915-166ec9773006`,assetId:`nature-tree-maple-3`,x:25.06,z:253.96,rotation:0,scale:1},{id:`a118cdf3-b543-429e-8424-bb8e9e62981b`,assetId:`nature-tree-maple-2`,x:-32.54,z:241.6,rotation:0,scale:1},{id:`af48bb2c-8bb3-4c69-bc08-de41afa6fd86`,assetId:`nature-tree-maple-2`,x:-12.72,z:284.52,rotation:0,scale:1},{id:`a17e6320-d7bf-4c7c-b42b-5298eb1fbfbb`,assetId:`nature-tree-maple-2`,x:-54.58,z:336.69,rotation:0,scale:1},{id:`853a0a5a-1278-4958-81b0-257b55b9d495`,assetId:`nature-tree-maple-3`,x:-145.67,z:338.42,rotation:0,scale:1},{id:`b0f327cc-d99f-44d7-ab60-4848270aed6b`,assetId:`nature-tree-maple-3`,x:-300.2,z:338.09,rotation:0,scale:1},{id:`785d0eed-0a18-4932-bbf3-26871951ca78`,assetId:`nature-tree-maple-3`,x:-319.9,z:291.87,rotation:0,scale:1},{id:`b497d273-ddfa-4fbf-b684-06140a08057a`,assetId:`nature-tree-maple-3`,x:-151,z:394.11,rotation:0,scale:1},{id:`c0de21d5-0ca1-4462-a23b-754a9e4232a9`,assetId:`nature-tree-maple-3`,x:-231.91,z:238.57,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`9df90ff6-cbc3-44d6-99ed-4f5c5cacd333`,assetId:`nature-tree-maple-3`,x:-253.78,z:200.14,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`bc4f58fd-0e29-4815-b11b-02f53f1b81e8`,assetId:`nature-tree-maple-3`,x:-261.46,z:171.97,rotation:0,scale:1},{id:`f63ad99a-cb09-4cec-86b1-a0d7ec898695`,assetId:`nature-bush`,x:-269.36,z:236.11,rotation:0,scale:1},{id:`168c17de-6126-44d4-a530-e5760205beb3`,assetId:`nature-bush-large`,x:-295.44,z:209.82,rotation:0,scale:1},{id:`3d2648ff-2851-4653-a69a-3c57dda83a5c`,assetId:`nature-bush-flowers`,x:-301.28,z:199.42,rotation:0,scale:1},{id:`5a354a23-d3f2-4395-9dd5-416463e66929`,assetId:`nature-bush-flowers`,x:-270.21,z:225.54,rotation:0,scale:1},{id:`404c9efd-dcef-4724-a87f-3654f3f9e668`,assetId:`nature-bush-flowers`,x:-253.06,z:208.5,rotation:0,scale:1},{id:`1c0c9540-e3fa-4074-8b5b-1c9ed616148b`,assetId:`nature-tree-maple-2`,x:-333.99,z:135.71,rotation:0,scale:1},{id:`591b76f6-bdb1-47f1-ab92-9ba09fe3a42f`,assetId:`nature-tree-maple-3`,x:-332.45,z:92.3,rotation:0,scale:1},{id:`ddfd9bf1-d959-4d4d-90b9-aeffcb5c5452`,assetId:`nature-tree-maple-3`,x:-339.44,z:38.78,rotation:85,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`9dfd557d-9137-49da-a878-2134a1097b14`,assetId:`nature-tree-maple-3`,x:-335.64,z:-20.81,rotation:130,scale:1},{id:`036d9e28-363c-4b60-b5f8-a7a8d6b4fe6c`,assetId:`nature-tree-maple-3`,x:-331.7,z:-59.72,rotation:265,scale:1},{id:`ed13d1a1-57e2-4d2e-a3a9-9281d6677fa1`,assetId:`nature-tree-maple-3`,x:-319.41,z:-99.51,rotation:0,scale:1},{id:`48049312-1d32-43c3-8c58-7f651f9ea00f`,assetId:`nature-bush`,x:-296.98,z:-42.18,rotation:0,scale:1},{id:`cb8348af-2f63-488c-b6f3-40de4db4dc4b`,assetId:`nature-bush`,x:-303.16,z:-48,rotation:0,scale:1},{id:`c1f64a2d-c066-4260-922b-0b966db7108d`,assetId:`nature-bush-large`,x:-308.56,z:-44.87,rotation:85,scale:1},{id:`6d112289-fbad-4c8d-8ed7-4e325493a4ca`,assetId:`nature-bush`,x:-169.85,z:-120.4,rotation:0,scale:1},{id:`d259bfe6-51e3-4594-a0a7-2c32a2ebdd92`,assetId:`nature-tree-birch-1`,x:-167.25,z:-109.25,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`36ef72dd-e706-4de0-bf0d-ca7c00741b79`,assetId:`nature-tree-maple-2`,x:-153.93,z:-125.53,rotation:0,scale:1},{id:`d5fb20e1-806f-4d50-9721-38d1d5f533b2`,assetId:`nature-tree-maple-3`,x:-140.98,z:-23.22,rotation:0,scale:1},{id:`99e651ce-c4a2-4150-9b2f-2087622b138a`,assetId:`nature-tree-maple-3`,x:-39.8,z:176.58,rotation:65,scale:1},{id:`3f7033ec-2e93-4737-bd6d-d40d84be079b`,assetId:`nature-bush-flowers`,x:20.67,z:75.01,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`18b23ad1-ff6a-493a-817c-6f8011e26f0d`,assetId:`nature-bush-large`,x:-49.48,z:76.56,rotation:0,scale:1},{id:`e3c5dd93-b536-4d52-8a3c-241cab129023`,assetId:`nature-bush-large`,x:-82.44,z:86.92,rotation:40,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`5efc5713-c06f-42ef-9a77-82ff0bb17309`,assetId:`nature-bush-large`,x:-67.92,z:80.05,rotation:20,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`cf4e5ae5-3246-40f5-861c-ef9c66506bee`,assetId:`nature-bush-large`,x:-18.48,z:77.56,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`ff432238-242a-4d44-94ed-e8ecb8e56bc0`,assetId:`nature-bush-large`,x:-33.48,z:76.56,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`f9438b5c-4be1-4a08-872b-77000f42e6a3`,assetId:`nature-bush`,x:11.86,z:74.84,rotation:0,scale:1,y:1,scaleX:1,scaleY:1,scaleZ:1},{id:`22427270-18b0-4573-962f-2c0dd6656953`,assetId:`nature-bush-large`,x:.67,z:76.13,rotation:0,scale:1},{id:`25c5313d-2b87-4fbd-a1e8-a09afe9d4351`,assetId:`fence-white-wood`,x:-279.49,z:-217.56,rotation:50,scale:1,y:1,scaleX:1.9,scaleY:1,scaleZ:1},{id:`landscape-light-west-02`,assetId:`tripo-street-light`,x:-230,z:125,rotation:270,scale:.82,y:1},{id:`landscape-light-west-03`,assetId:`tripo-street-light`,x:-230,z:75,rotation:270,scale:.82,y:1},{id:`landscape-light-west-04`,assetId:`tripo-street-light`,x:-230,z:25,rotation:270,scale:.82,y:1},{id:`landscape-light-west-05`,assetId:`tripo-street-light`,x:-230,z:-25,rotation:270,scale:.82,y:1},{id:`landscape-light-west-06`,assetId:`tripo-street-light`,x:-230,z:-75,rotation:270,scale:.82,y:1},{id:`landscape-light-west-07`,assetId:`tripo-street-light`,x:-230,z:-125,rotation:270,scale:.82,y:1},{id:`landscape-light-bottom-01`,assetId:`tripo-street-light`,x:-145,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-light-bottom-02`,assetId:`tripo-street-light`,x:-45,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-light-bottom-03`,assetId:`tripo-street-light`,x:55,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-light-bottom-04`,assetId:`tripo-street-light`,x:155,z:-188,rotation:0,scale:.82,y:1},{id:`landscape-center-southwest-hedge-01`,assetId:`nature-bush-large`,x:-93,z:-75,rotation:4,scale:.62,y:1},{id:`landscape-center-southwest-hedge-02`,assetId:`nature-bush-large`,x:-80,z:-75,rotation:356,scale:.62,y:1},{id:`landscape-center-southwest-hedge-03`,assetId:`nature-bush-large`,x:-67,z:-75,rotation:3,scale:.62,y:1},{id:`landscape-center-southwest-hedge-04`,assetId:`nature-bush-large`,x:-54,z:-75,rotation:358,scale:.62,y:1},{id:`landscape-center-southeast-hedge-01`,assetId:`nature-bush-large`,x:15,z:-75,rotation:2,scale:.62,y:1},{id:`landscape-center-southeast-hedge-02`,assetId:`nature-bush-large`,x:28,z:-75,rotation:357,scale:.62,y:1},{id:`landscape-center-southeast-hedge-03`,assetId:`nature-bush-large`,x:41,z:-75,rotation:4,scale:.62,y:1},{id:`landscape-center-southeast-hedge-04`,assetId:`nature-bush-large`,x:54,z:-75,rotation:359,scale:.62,y:1},{id:`landscape-center-southeast-hedge-05`,assetId:`nature-bush-large`,x:67,z:-75,rotation:3,scale:.62,y:1},{id:`landscape-center-flower-southwest-01`,assetId:`nature-bush-flowers`,x:-101,z:-74,rotation:18,scale:.68,y:1},{id:`landscape-center-flower-southwest-02`,assetId:`nature-bush-flowers`,x:-46,z:-74,rotation:339,scale:.68,y:1},{id:`landscape-center-flower-southeast-01`,assetId:`nature-bush-flowers`,x:7,z:-74,rotation:24,scale:.68,y:1},{id:`landscape-center-flower-southeast-02`,assetId:`nature-bush-flowers`,x:75,z:-74,rotation:344,scale:.68,y:1},{id:`landscape-center-garden-shrub-01`,assetId:`nature-bush`,x:-118,z:88,rotation:12,scale:.66,y:1},{id:`landscape-center-garden-shrub-02`,assetId:`nature-bush-flowers`,x:-85,z:95,rotation:325,scale:.66,y:1},{id:`landscape-center-garden-shrub-03`,assetId:`nature-bush`,x:-95,z:55,rotation:42,scale:.7,y:1},{id:`landscape-center-garden-shrub-04`,assetId:`nature-bush-flowers`,x:-65,z:55,rotation:307,scale:.7,y:1},{id:`landscape-center-garden-shrub-05`,assetId:`nature-bush`,x:66,z:91,rotation:8,scale:.66,y:1},{id:`landscape-center-garden-shrub-06`,assetId:`nature-bush-flowers`,x:96,z:92,rotation:331,scale:.66,y:1},{id:`landscape-center-garden-shrub-07`,assetId:`nature-bush`,x:123,z:88,rotation:21,scale:.64,y:1},{id:`landscape-center-stones-01`,assetId:`yard-stone-path`,x:-111,z:63,rotation:18,scale:.42,y:1},{id:`landscape-center-stones-02`,assetId:`yard-stone-path`,x:-53,z:36,rotation:282,scale:.4,y:1},{id:`landscape-center-stones-03`,assetId:`yard-stone-path`,x:63,z:18,rotation:72,scale:.4,y:1},{id:`landscape-center-stones-04`,assetId:`yard-stone-path`,x:89,z:61,rotation:15,scale:.42,y:1},{id:`landscape-center-understory-west-01`,assetId:`nature-bush-flowers`,x:-100,z:44,rotation:16,scale:.58,y:1},{id:`landscape-center-understory-west-02`,assetId:`nature-bush`,x:-83,z:42,rotation:338,scale:.6,y:1},{id:`landscape-center-understory-west-03`,assetId:`nature-bush-flowers`,x:-66,z:43,rotation:29,scale:.58,y:1},{id:`landscape-center-understory-west-04`,assetId:`nature-bush`,x:-49,z:48,rotation:351,scale:.6,y:1},{id:`landscape-center-understory-east-01`,assetId:`nature-bush-flowers`,x:47,z:27,rotation:22,scale:.55,y:1},{id:`landscape-center-understory-east-02`,assetId:`nature-bush`,x:48,z:43,rotation:342,scale:.56,y:1},{id:`landscape-center-understory-east-03`,assetId:`nature-bush-flowers`,x:47,z:59,rotation:13,scale:.55,y:1},{id:`landscape-center-lawn-west-01`,assetId:`nature-bush-flowers`,x:-95,z:25,rotation:17,scale:.7,y:1},{id:`landscape-center-lawn-west-02`,assetId:`nature-bush`,x:-75,z:24,rotation:337,scale:.72,y:1},{id:`landscape-center-lawn-west-03`,assetId:`nature-bush-flowers`,x:-55,z:26,rotation:31,scale:.68,y:1},{id:`landscape-center-courtyard-01`,assetId:`nature-bush`,x:-20,z:10,rotation:11,scale:.52,y:1},{id:`landscape-center-courtyard-02`,assetId:`nature-bush-flowers`,x:0,z:10,rotation:345,scale:.54,y:1},{id:`landscape-center-courtyard-03`,assetId:`nature-bush`,x:20,z:10,rotation:22,scale:.52,y:1}],updatedAt:`2026-07-19T11:50:00.000Z`},s9=`yardline.map-editor.document.v3`;function c9(){let e=l9(U4e);if(!e)throw Error(`The bundled Construction Loop map document is invalid.`);return{...e,route:e.route.map(e=>({...e})),objects:e.objects.map(e=>({...e})),updatedAt:new Date().toISOString()}}function l9(e){if(!e||typeof e!=`object`)return null;let t=e;return t.version!==3||typeof t.name!=`string`||!Array.isArray(t.route)||!Array.isArray(t.objects)||!t.route.every(u9)||!t.objects.every(G4e)?null:{version:3,id:typeof t.id==`string`?t.id:`construction-loop-kit`,name:t.name,presetRevision:Number.isSafeInteger(t.presetRevision)?t.presetRevision:void 0,seed:f9(t.seed,20260718),roadWidth:p9(f9(t.roadWidth,24),8,60),worldSize:p9(f9(t.worldSize,440),160,800),route:t.route,routeClosed:t.routeClosed===!0,roadPaths:Array.isArray(t.roadPaths)&&t.roadPaths.every(W4e)?t.roadPaths.map(e=>({points:e.points,width:p9(f9(e.width,f9(t.roadWidth,24)),12,40),sidewalks:e.sidewalks!==!1})):void 0,objects:t.objects,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:new Date().toISOString()}}function W4e(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.points)&&t.points.length>=2&&t.points.every(u9)&&Number.isFinite(t.width)&&(t.sidewalks===void 0||typeof t.sidewalks==`boolean`)}function u9(e){if(!e||typeof e!=`object`)return!1;let t=e;return Number.isFinite(t.x)&&Number.isFinite(t.z)}function G4e(e){if(!u9(e))return!1;let t=e;return typeof t.id==`string`&&typeof t.assetId==`string`&&Number.isFinite(t.rotation)&&d9(t.rotationX)&&d9(t.rotationZ)&&Number.isFinite(t.scale)&&d9(t.y)&&d9(t.scaleX)&&d9(t.scaleY)&&d9(t.scaleZ)}function d9(e){return e===void 0||typeof e==`number`&&Number.isFinite(e)}function f9(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function p9(e,t,n){return Math.max(t,Math.min(n,e))}var m9=null,h9=null,g9=new Set;function K4e(e,t){m9=e,h9=t,_9()}function q4e(e){h9=e,_9()}function J4e(e){m9===e&&(m9=null,h9=null,_9())}function Y4e(e){return g9.add(e),e(h9??X4e(),m9),()=>{g9.delete(e)}}function _9(){let e=h9??X4e();g9.forEach(t=>t(e,m9))}function X4e(){return{mode:`move`,snapEnabled:!0,dirty:!1,canUndo:!1,objectCount:0,status:`Loading 3D editor`,selection:null}}var Z4e=`yardlineMapEditor`,Q4e=60,$4e=class{constructor(e,t){this.history=[],this.selectedId=null,this.mode=`move`,this.snapEnabled=!0,this.dirty=!1,this.status=`Click any object to edit it`,this.dragHistoryCaptured=!1,this.onKeyDown=e=>{e3e(e.target)||((e.metaKey||e.ctrlKey)&&e.code===`KeyS`&&(e.preventDefault(),this.save()),(e.metaKey||e.ctrlKey)&&e.code===`KeyZ`&&(e.preventDefault(),this.undo()),(e.metaKey||e.ctrlKey)&&e.code===`KeyD`&&(e.preventDefault(),this.duplicateSelected()),(e.code===`Delete`||e.code===`Backspace`)&&(e.preventDefault(),this.deleteSelected()),e.code===`Escape`&&this.deselect(),e.code===`KeyF`&&this.frameSelected())},this.scene=e,this.root=t.root,this.instances=t.instances,this.instantiate=t.instantiate,this.document=v9(t.document),this.highlight=new dk(`map-fly-editor-selection`,e,{blurHorizontalSize:.6,blurVerticalSize:.6}),this.highlight.innerGlow=!1,this.highlight.outerGlow=!0,this.gizmos=new lhe(e,1.35),this.gizmos.usePointerToAttachGizmos=!1,this.gizmos.clearGizmoOnEmptyPointerEvent=!1,this.gizmos.scaleRatio=.8,this.setMode(`move`),this.pointerObserver=e.onPointerObservable.add(e=>{if(e.type!==hn.POINTERDOWN||e.event.button!==0||this.gizmos.isHovered||this.gizmos.isDragging)return;let t=e.pickInfo?.pickedMesh,n=t?this.findEditableInstance(t):null;n?this.select(this.metadataFor(n)?.objectId??null):this.deselect()}),window.addEventListener(`keydown`,this.onKeyDown),K4e(this,this.getState())}dispose(){window.removeEventListener(`keydown`,this.onKeyDown),this.scene.onPointerObservable.remove(this.pointerObserver),J4e(this),this.highlight.dispose(),this.gizmos.dispose()}setMode(e){this.mode=e,this.gizmos.positionGizmoEnabled=e===`move`,this.gizmos.rotationGizmoEnabled=e===`rotate`,this.gizmos.scaleGizmoEnabled=e===`scale`,this.configureGizmoEvents(),this.applySnapSettings(),this.attachSelectedGizmo(),this.status=`${e[0].toUpperCase()}${e.slice(1)} tool active`,this.publish()}setSnapEnabled(e){this.snapEnabled=e,this.applySnapSettings(),this.status=e?`Snapping enabled`:`Free transform enabled`,this.publish()}updateSelected(e){let t=this.selectedObject(),n=this.selectedInstance(),r=t?r9(t.assetId):null;if(!t||!n||!r)return;this.captureHistory(),e.x!==void 0&&(t.x=y9(e.x,t.x)),e.y!==void 0&&(t.y=y9(e.y,t.y??0)),e.z!==void 0&&(t.z=y9(e.z,t.z)),e.rotationX!==void 0&&(t.rotationX=x9(y9(e.rotationX,t.rotationX??0))),e.rotation!==void 0&&(t.rotation=x9(y9(e.rotation,t.rotation))),e.rotationZ!==void 0&&(t.rotationZ=x9(y9(e.rotationZ,t.rotationZ??0)));let i=b9(t.scale,1);e.scaleX!==void 0&&(t.scaleX=b9(e.scaleX/i,t.scaleX??1)),e.scaleY!==void 0&&(t.scaleY=b9(e.scaleY/i,t.scaleY??1)),e.scaleZ!==void 0&&(t.scaleZ=b9(e.scaleZ/i,t.scaleZ??1)),r3e(n,t,r),this.markChanged(`Transform updated`)}deselect(){this.selectedId=null,this.gizmos.attachToNode(null),this.highlight.removeAllMeshes(),this.status=`Click any object to edit it`,this.publish()}frameSelected(){let e=this.selectedInstance(),t=this.scene.activeCamera;if(!e||!t||typeof Reflect.get(t,`setTarget`)!=`function`)return;let n=e.getHierarchyBoundingVectors(!0),r=n.min.add(n.max).scale(.5),i=Math.max(4,n.max.subtract(n.min).length()),a=t.position.subtract(r).normalize();t.position.copyFrom(r.add(a.scale(Math.max(10,i*1.35)))),t.setTarget(r),this.status=`Focused selected object`,this.publish()}save(){this.document.updatedAt=new Date().toISOString(),localStorage.setItem(s9,JSON.stringify(this.document)),this.dirty=!1,this.status=`3D draft saved locally`,this.publish()}async undo(){let e=this.history.pop();e&&(await this.restoreDocument(e),this.dirty=!0,this.status=`Undo complete`,this.publish())}async duplicateSelected(){let e=this.selectedObject();if(!e)return;this.captureHistory();let t={...e,id:o3e(),x:S9(e.x+2),z:S9(e.z+2)};this.document.objects.push(t);let n=await this.instantiate(t);n&&this.instances.set(t.id,n),this.select(t.id),this.markChanged(`Object duplicated`)}deleteSelected(){let e=this.selectedId;e&&(this.captureHistory(),this.document.objects=this.document.objects.filter(t=>t.id!==e),this.instances.get(e)?.dispose(!1,!1),this.instances.delete(e),this.selectedId=null,this.gizmos.attachToNode(null),this.highlight.removeAllMeshes(),this.markChanged(`Object deleted`))}async addObject(e){let t=r9(e),n=this.scene.activeCamera;if(!t||!n)return;let r=n.getForwardRay(),i=Math.abs(r.direction.y)>.001?(1-r.origin.y)/r.direction.y:24,a=i>2?Math.min(i,500):24,o=r.origin.add(r.direction.scale(a));await this.placeObject(t,o.x,o.z)}async addObjectAt(e,t,n){let r=r9(e),i=this.scene.activeCamera;if(!r||!i)return;let a=this.scene.createPickingRay(t,n,null,i),o=r.isRoad?i9:1,s=Math.abs(a.direction.y)>.001?(o-a.origin.y)/a.direction.y:-1;if(s<=0||s>2e3){await this.addObject(e);return}let c=a.origin.add(a.direction.scale(s));await this.placeObject(r,c.x,c.z)}async placeObject(e,t,n){this.captureHistory();let r={id:o3e(),assetId:e.id,x:S9(t),z:S9(n),rotation:0,scale:1,...e.isRoad?{y:i9}:{}};this.document.objects.push(r);let i=await this.instantiate(r);i&&this.instances.set(r.id,i),this.select(r.id),this.markChanged(`${e.label} placed — drag the gizmo to fine-tune`)}async replaceSelected(e){let t=this.selectedObject(),n=r9(e);if(!t||!n)return;this.captureHistory();let r=t.id;this.instances.get(r)?.dispose(!1,!1),this.instances.delete(r),t.assetId=e,n.isRoad&&t.y===void 0&&(t.y=i9);let i=await this.instantiate(t);i&&this.instances.set(r,i),this.select(r),this.markChanged(`Replaced with ${n.label}`)}testDrive(){this.save(),window.location.href=`./?map=construction-loop&editorDraft=1&seed=${this.document.seed}`}select(e){if(!e||!this.instances.has(e)){this.deselect();return}this.selectedId=e,this.highlight.removeAllMeshes(),this.instances.get(e).getChildMeshes().forEach(e=>{e.getTotalVertices()>0&&this.highlight.addMesh(e,P.FromHexString(`#e0a15d`))}),this.attachSelectedGizmo();let t=this.selectedAsset()?.label??`Object`;this.status=`${t} selected`,this.publish()}attachSelectedGizmo(){this.gizmos.attachToNode(this.selectedInstance())}configureGizmoEvents(){let e=this.mode===`move`?this.gizmos.gizmos.positionGizmo:this.mode===`rotate`?this.gizmos.gizmos.rotationGizmo:this.gizmos.gizmos.scaleGizmo;!e||Reflect.get(e,`__yardlineBound`)||(Reflect.set(e,`__yardlineBound`,!0),e.onDragStartObservable.add(()=>{this.dragHistoryCaptured||=(this.captureHistory(),!0)}),e.onDragEndObservable.add(()=>{this.dragHistoryCaptured=!1,this.syncSelectedFromScene(),this.markChanged(`Transform updated`)}))}applySnapSettings(){let e=this.gizmos.gizmos.positionGizmo,t=this.gizmos.gizmos.rotationGizmo,n=this.gizmos.gizmos.scaleGizmo;e&&(e.snapDistance=+!!this.snapEnabled),t&&(t.snapDistance=this.snapEnabled?Math.PI/12:0),n&&(n.snapDistance=this.snapEnabled?.05:0,n.incrementalSnap=!0)}syncSelectedFromScene(){let e=this.selectedObject(),t=this.selectedInstance(),n=e?r9(e.assetId):null;if(!e||!t||!n)return;e.x=S9(t.position.x),e.y=S9(a3e(n,t.position.y)),e.z=S9(t.position.z);let r=t.rotationQuaternion?.toEulerAngles()??t.rotation;e.rotationX=S9(x9(r.x*180/Math.PI)),e.rotation=S9(x9(r.y*180/Math.PI-(n.rotationOffset??0))),e.rotationZ=S9(x9(r.z*180/Math.PI));let i=n.defaultScale*e.scale;e.scaleX=S9(b9(t.scaling.x/i,1)),e.scaleY=S9(b9(t.scaling.y/i,1)),e.scaleZ=S9(b9(t.scaling.z/i,1))}captureHistory(){this.history.push(v9(this.document)),this.history.length>Q4e&&this.history.shift()}async restoreDocument(e){let t=new Set(e.objects.map(e=>e.id));for(let[e,n]of this.instances)t.has(e)||(n.dispose(!1,!1),this.instances.delete(e));this.document=v9(e);for(let e of this.document.objects){let t=this.instances.get(e.id),n=t?this.metadataFor(t):null;if(t&&n?.assetId===e.assetId){let n=r9(e.assetId);n&&r3e(t,e,n);continue}t?.dispose(!1,!1);let r=await this.instantiate(e);r&&this.instances.set(e.id,r)}this.selectedId&&this.instances.has(this.selectedId)?this.select(this.selectedId):this.deselect()}findEditableInstance(e){let t=e;for(;t&&t!==this.root;){if(this.metadataFor(t))return t;t=t.parent}return null}metadataFor(e){let t=e.metadata?.[Z4e];return!t||typeof t!=`object`?null:t}selectedObject(){return this.selectedId?this.document.objects.find(e=>e.id===this.selectedId)??null:null}selectedInstance(){return this.selectedId?this.instances.get(this.selectedId)??null:null}selectedAsset(){let e=this.selectedObject();return e?r9(e.assetId)??null:null}markChanged(e){this.dirty=!0,this.status=e,this.document.updatedAt=new Date().toISOString(),this.publish()}getState(){let e=this.selectedObject(),t=e?r9(e.assetId):null;return{mode:this.mode,snapEnabled:this.snapEnabled,dirty:this.dirty,canUndo:this.history.length>0,objectCount:this.document.objects.length,status:this.status,selection:e&&t?n3e(e,t):null}}publish(){q4e(this.getState())}};function e3e(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable||!!e.closest(`[contenteditable="true"]`)}function t3e(e,t){e.metadata={...e.metadata,[Z4e]:{objectId:t.id,assetId:t.assetId}},e.getChildMeshes().forEach(e=>{e.unfreezeWorldMatrix(),e.isPickable=!0})}function n3e(e,t){return{id:e.id,assetId:e.assetId,label:t.label,x:S9(e.x),y:S9(e.y??0),z:S9(e.z),rotationX:S9(e.rotationX??0),rotation:S9(e.rotation),rotationZ:S9(e.rotationZ??0),scaleX:S9(e.scale*(e.scaleX??1)),scaleY:S9(e.scale*(e.scaleY??1)),scaleZ:S9(e.scale*(e.scaleZ??1))}}function r3e(e,t,n){e.position.set(t.x,i3e(n,t),t.z),e.rotationQuaternion=A.FromEulerAngles((t.rotationX??0)*Math.PI/180,(t.rotation+(n.rotationOffset??0))*Math.PI/180,(t.rotationZ??0)*Math.PI/180);let r=n.defaultScale*t.scale;e.scaling.set(r*(t.scaleX??1),r*(t.scaleY??1),r*(t.scaleZ??1)),e.computeWorldMatrix(!0)}function i3e(e,t){let n=t.y??1;return e.category===`roads`?t.y??1.8:e.category===`markings`?t.y??1.24:e.category===`sidewalks`?(t.y??0)+1.18:e.id===`driveway`||e.id.startsWith(`downtown-floor-`)?n+.025:n+.03}function a3e(e,t){return e.category===`roads`||e.category===`markings`?t:e.category===`sidewalks`?t-1.18:e.id===`driveway`||e.id.startsWith(`downtown-floor-`)?t-.025:t-.03}function v9(e){return structuredClone(e)}function o3e(){return typeof crypto.randomUUID==`function`?crypto.randomUUID():`object-${Date.now()}-${Math.random()}`}function y9(e,t){return Number.isFinite(e)?e:t}function b9(e,t){return Number.isFinite(e)?Math.max(.05,e):t}function x9(e){return(e%360+360)%360}function S9(e){return Math.round(e*100)/100}var C9={mass:0,friction:.98,restitution:.01},w9=1,s3e=1.18,c3e=.18,l3e=1.18,u3e=1.24,d3e=[{x:-80,z:-80},{x:80,z:-80},{x:80,z:80},{x:-80,z:80}];async function f3e(e,t,n,r){let i=(t.route.length>=4?t.route:d3e).map(e=>new j(e.x,1.9,e.z)),a=t.roadPaths??(t.route.length>=2?[{points:t.route,width:t.roadWidth,sidewalks:!0}]:[]),o=new wc(`${r}-${n}`,e),s=new URLSearchParams(window.location.search).get(`fly`)===`1`;e.clearColor=fe.FromHexString(`#75b7d2ff`),e.ambientColor=P.FromHexString(`#91a99a`),e.fogMode=x.FOGMODE_LINEAR,e.fogStart=s?t.worldSize*1.05:270,e.fogEnd=s?t.worldSize*1.75:455,e.fogColor=P.FromHexString(s?`#a6c5ce`:`#82bad0`);let c=new K_(`${r}-sky`,new j(.12,1,.08),e);c.intensity=.7,c.diffuse=P.FromHexString(`#fffbed`),c.groundColor=P.FromHexString(`#43574b`);let l=new GC(`${r}-sun`,new j(-.5,-1,.36),e);l.position.set(t.worldSize*.35,160,-t.worldSize*.45),l.intensity=1.12,l.diffuse=P.FromHexString(`#fff3d6`);let u=new jT(1536,l);u.usePercentageCloserFiltering=!0,u.filteringQuality=jT.QUALITY_MEDIUM,u.bias=8e-4,u.normalBias=.025;let d=P4e(e);d.grass.diffuseColor=P.FromHexString(`#8eaa68`),d.asphalt.diffuseColor=P.FromHexString(`#697173`),d.concrete.diffuseColor=P.FromHexString(`#ddd8cc`);let f=vm.CreateBox(`${r}-ground`,{width:t.worldSize,height:.4,depth:t.worldSize},e);f.position.y=w9-.4,f.material=d.grass,f.receiveShadows=!0,f.parent=o,G7(f,`grass`);let p=[new ZO(f,YO.BOX,C9,e)],m=h3e(e,`${r}-construction-dirt`);t.id.startsWith(`construction-loop`)&&g3e(e,o,m,p);let h=new F4e(e,o,u,{maxVisibleDistance:s?void 0:470}),g=t.objects.flatMap(e=>{let t=r9(e.assetId);return t?[{object:e,asset:t}]:[]}),_=new Map;await h.preload(g.map(({asset:e})=>e));let v=async(e,t)=>{let n=await h.instantiate({rootUrl:t.rootUrl,file:t.file,name:`${r}-${e.id}`,position:new j(e.x,_3e(t,e),e.z),rotation:new j((e.rotationX??0)*Math.PI/180,(e.rotation+(t.rotationOffset??0))*Math.PI/180,(e.rotationZ??0)*Math.PI/180),scale:v3e(t,e),castShadows:!t.isRoad&&t.category!==`markings`,pbrTuning:t.pbrTuning});return s&&(t3e(n,e),_.set(e.id,n)),n};for(let{object:t,asset:n}of g){let r=await v(t,n);if(n.isRoad||n.category===`sidewalks`||n.meshCollision){r.getChildMeshes().forEach(e=>{e.getTotalVertices()>0&&G7(e,`asphalt`)}),p3e(e,r,p);continue}let i=y3e(e,o,t,n);i&&p.push(new ZO(i,YO.BOX,C9,e))}g.some(({asset:e})=>e.isRoad)||m3e(e,o,a,p,d.asphalt);let y=s?new $4e(e,{document:t,root:o,instances:_,instantiate:async e=>{let t=r9(e.assetId);return t?v(e,t):null}}):void 0,b=i[1].subtract(i[0]).normalize(),S=new j(b.z,0,-b.x),C=Math.atan2(b.x,b.z),w=i[0].add(b.scale(12));return{root:o,trackPoints:i,checkpoints:i,spawnPositions:Array.from({length:8},(e,t)=>{if(t===0)return w.add(new j(0,.34,0));let n=t-1,r=Math.floor(n/2)+1,i=n%2==0?-1:1;return w.add(S.scale(i*1.7)).add(b.scale(-r*5.6)).add(new j(0,.34,0))}),startHeading:C,collectiblePositions:i.filter((e,t)=>t%4==0).map(e=>e.add(new j(0,.65,0))),seed:n,shadowGenerator:u,dispose:()=>{y?.dispose(),p.forEach(e=>e.dispose()),h.dispose(),m.dispose(!0,!0),Object.values(d).forEach(e=>e.dispose(!0,!0)),u.dispose(),c.dispose(),l.dispose(),o.dispose(!1,!0)}}}function p3e(e,t,n){t.getChildMeshes().forEach(t=>{t.getTotalVertices()!==0&&n.push(new ZO(t,YO.MESH,C9,e))})}function m3e(e,t,n,r,i){n.forEach((n,a)=>{for(let o=0;ob3e(e,t.seed)},S3e=[E9],C3e=E9.metadata.id,w3e=S3e,T3e=new Map(S3e.map(e=>[e.metadata.id,e]));function D9(e){return e?T3e.get(e)??E9:E9}function E3e(e,t){return Number.isSafeInteger(t)?t>>>0:e.defaultSeed>>>0}async function D3e(e,t,n){let r=D9(t),i=E3e(r,n),a=await r.build(e,{seed:i});return O3e(r,a.trackPoints,a.spawnPositions,a.collectiblePositions),{definition:r,seed:i,world:a}}function O3e(e,t,n,r){let i=`Map "${e.metadata.id}"`;if(t.length<4)throw Error(`${i} needs at least four track points.`);if(n.length<8)throw Error(`${i} needs at least eight spawn positions.`);if(r.length===0)throw Error(`${i} needs at least one collectible position.`);if([...t,...n,...r].some(e=>![e.x,e.y,e.z].every(Number.isFinite)))throw Error(`${i} contains a non-finite position.`)}var O9=1/60,k9=4,k3e=1e3/15;function A3e(){let e=new URLSearchParams(window.location.search),t=Number(e.get(`seed`));return{mapId:e.get(`map`),seed:Number.isSafeInteger(t)?t:void 0}}function j3e(){return new URLSearchParams(window.location.search).get(`fly`)===`1`}var M3e=class{constructor(e,t={}){this.lastTelemetryAt=0,this.lastCheckpoint=1,this.selectedCarId=`sports-car`,this.currentMapId=C3e,this.currentMapSeed=0,this.currentSurface=`asphalt`,this.surfaceGripMultiplier=1,this.surfaceAccelerationMultiplier=1,this.turboMultiplier=1,this.utilityStunSeconds=0,this.wrongWayVisible=!1,this.disposed=!1,this.onEscape=e=>{e.code===`Escape`&&this.togglePause()},this.onVisibility=()=>{document.hidden&&this.race?.getPhase()===`racing`&&this.togglePause()},this.onResize=()=>this.engine?.resize(),this.canvas=e,this.callbacks=t}async initialize(){if(!(this.engine||this.disposed))try{let e=new Ih(this.canvas,!0,{adaptToDeviceRatio:!1,audioEngine:!0,antialias:!0,preserveDrawingBuffer:!1,stencil:!0,powerPreference:`high-performance`,deterministicLockstep:!0,lockstepMaxSteps:k9,timeStep:O9});this.engine=e;let t=Math.max(1,window.devicePixelRatio||1),n=matchMedia(`(pointer: coarse)`).matches;e.setHardwareScalingLevel(n?Math.max(1,t/1.45):Math.max(1,t/1.75));let r=new x(e);this.scene=r,r.skipPointerMovePicking=!0,r.autoClear=!0,r.getEngine().enableOfflineSupport=!0;let i=await ts();if(this.disposed)return;let a=new Uze(!1,i);r.enablePhysics(new j(0,-9.81,0),a),r.getPhysicsEngine()?.setTimeStep(O9);let o=A3e(),s=await D3e(r,o.mapId,o.seed),c=s.world;if(this.world=c,this.currentMapId=s.definition.metadata.id,this.currentMapSeed=s.seed,j3e()){c.root.setEnabled(!0),r.physicsEnabled=!1,this.flyCamera=new N2e(r,this.canvas,c.trackPoints),window.addEventListener(`resize`,this.onResize),e.runRenderLoop(()=>{this.disposed||!this.scene||this.scene.render()}),this.callbacks.onReady?.(),this.callbacks.onPhaseChange?.(`menu`);return}c.root.setEnabled(!1);let l=c.spawnPositions[0],u=v2e(r,c.shadowGenerator,l);this.car=u,u.chassis.rotationQuaternion=A.RotationAxis(j.Up(),c.startHeading),u.presentationRoot.rotationQuaternion=u.chassis.rotationQuaternion.clone(),this.presenter=new y2e(r,u.chassis,u.presentationRoot,O9,k9),this.driftVisual=new S2e(r,u.presentationRoot,u.driftRoot),this.disposeImportedCar=await _7(u,r,c.shadowGenerator,this.selectedCarId),this.controller=this.buildVehicleController(this.selectedCarId),this.input=new F2e;let d={position:l.clone(),rotation:A.RotationAxis(j.Up(),c.startHeading)};this.recovery=new x4e(r,u.aggregate.body,d),this.surfaces=new C4e(r,u.aggregate.body),this.wrongWay=new O4e(c.trackPoints),this.abilities=new g4e(r,u.aggregate.body,{getTargets:()=>[{id:`player`,body:u.aggregate.body,radius:.72},...this.opponents?.abilityTargets??[]],callbacks:{onInventoryChange:e=>{e.rolling?this.callbacks.onPowerup?.(`SELECTING…`,0,!0):this.callbacks.onPowerup?.(e.item?M4e[e.item]:null,e.charges,!1)},onTurboChanged:(e,t)=>{this.turboMultiplier=t},onTargetDisabled:(e,t)=>{e===`player`?this.utilityStunSeconds=Math.max(this.utilityStunSeconds,t):this.opponents?.disable(e,t)},onOilContact:(e,t,n)=>{e!==`player`&&this.opponents?.slow(e,t,n)},onAbilityUsed:e=>{e.type===`oil-slick`&&!e.targetId&&this.surfaces?.addOilPatch(e.position,1.85,11)}}});let f=new gh(`menu-camera`,Math.PI*1.18,Math.PI*.34,58,new j(8,0,2),r);f.lowerRadiusLimit=34,f.upperRadiusLimit=70,f.lowerBetaLimit=.35,f.upperBetaLimit=1.35,f.minZ=.08,f.maxZ=260,f.fov=.72,this.menuCamera=f;let p=new $2e(r,{initialCarId:this.selectedCarId,quality:n?`low`:`balanced`});this.frontend=p,await p.initialize(),p.setMode(`attract`,!0);let m=new E2e(r,this.canvas,u.presentationRoot,{enableMotionBlur:!n});this.followCamera=m,r.activeCamera=p.camera,this.installRaceSystems(c),r.onBeforePhysicsObservable.add(()=>this.beforePhysics()),r.onAfterPhysicsObservable.add(()=>this.afterPhysics()),window.addEventListener(`resize`,this.onResize),window.addEventListener(`keydown`,this.onEscape),document.addEventListener(`visibilitychange`,this.onVisibility),e.runRenderLoop(()=>{this.disposed||!this.scene||(this.presenter?.beginFrame(Math.min(e.getDeltaTime()/1e3,O9*k9)),this.scene.render())}),this.callbacks.onReady?.(),this.callbacks.onPhaseChange?.(`menu`)}catch(e){let t=e instanceof Error?e:Error(`Unable to initialize the game runtime.`);this.callbacks.onError?.(t)}}async startRace(e){if(e?.mapId&&await this.loadMap(e.mapId,e.seed),!this.race||!this.controller||!this.scene||!this.followCamera)return;e?.laps&&this.race.setTotalLaps(e.laps),e?.carId&&h7(e.carId)&&e.carId!==this.selectedCarId&&(this.selectedCarId=e.carId,this.disposeImportedCar?.(),this.car&&this.world&&(this.disposeImportedCar=await _7(this.car,this.scene,this.world.shadowGenerator,this.selectedCarId),this.controller=this.buildVehicleController(this.selectedCarId)));let t=this.world?.spawnPositions[0],n=this.world?.startHeading;!t||n===void 0||(this.controller.respawn({position:t.clone(),rotation:A.RotationAxis(j.Up(),n)}),this.presenter?.resetToPhysicsPose(),this.driftVisual?.reset(),this.lastCheckpoint=1,this.opponents?.reset(),this.pickups?.reset(),this.abilities?.reset(),this.surfaces?.clear(),this.recovery?.reset({position:t.clone(),rotation:A.RotationAxis(j.Up(),n)}),this.wrongWay?.reset(),this.currentSurface=`asphalt`,this.surfaceGripMultiplier=1,this.surfaceAccelerationMultiplier=1,this.turboMultiplier=1,this.utilityStunSeconds=0,this.wrongWayVisible=!1,this.callbacks.onPowerup?.(null),this.world?.root.setEnabled(!0),this.followCamera.activate(),this.frontend?.setMode(`hidden`),this.race.start())}setFrontendPreview(e,t){!this.frontend||this.race?.getPhase()!==`menu`||(this.world?.root.setEnabled(!1),t&&h7(t)&&this.frontend.selectCar(t),this.frontend.setMode(e))}togglePause(){this.race&&this.race.togglePause()}setTouchDrive(e,t){this.input?.setTouchDrive(e,t)}setTouchBrake(e){this.input?.setTouchBrake(e)}setTouchHandbrake(e){this.input?.setTouchHandbrake(e)}requestReset(){this.input?.requestReset()}usePowerup(){this.input?.requestUsePowerup()}returnToMenu(){!this.scene||!this.menuCamera||!this.race||!this.world||(this.scene.physicsEnabled=!0,this.world.root.setEnabled(!1),this.frontend?.setMode(`attract`,!0),this.scene.activeCamera=this.frontend?.camera??this.menuCamera,this.controller?.respawn({position:this.world.spawnPositions[0].clone(),rotation:A.RotationAxis(j.Up(),this.world.startHeading)}),this.presenter?.resetToPhysicsPose(),this.driftVisual?.reset(),this.race.returnToMenu())}setGraphicsQuality(e){if(!this.engine)return;let t=Math.max(1,window.devicePixelRatio||1),n=e===`performance`?1:e===`balanced`?1.45:2;this.engine.setHardwareScalingLevel(Math.max(1,t/n)),this.world&&(this.world.shadowGenerator.getShadowMap().refreshRate=e===`performance`?2:1)}dispose(){this.disposed||(this.disposed=!0,window.removeEventListener(`resize`,this.onResize),window.removeEventListener(`keydown`,this.onEscape),document.removeEventListener(`visibilitychange`,this.onVisibility),this.disposeImportedCar?.(),this.input?.dispose(),this.opponents?.dispose(),this.pickups?.dispose(),this.abilities?.dispose(),this.followCamera?.dispose(),this.presenter?.dispose(),this.driftVisual?.dispose(),this.flyCamera?.dispose(),this.frontend?.dispose(),this.car?.dispose(),this.world?.dispose(),this.scene?.dispose(),this.engine?.dispose())}beforePhysics(){if(!this.controller||!this.input||!this.race||!this.car)return;let e=this.race.getPhase(),t=this.input.sample();this.utilityStunSeconds=Math.max(0,this.utilityStunSeconds-O9);let n=e===`racing`&&this.utilityStunSeconds<=0;n&&t.usePowerup&&this.abilities?.use(),this.abilities?.update(O9);let r=this.surfaces?.sample(this.car.chassis.absolutePosition);r&&(this.currentSurface=r.type,this.surfaceGripMultiplier=r.gripMultiplier,this.surfaceAccelerationMultiplier=r.accelerationMultiplier),this.controller.setDriveMultipliers(this.surfaceAccelerationMultiplier*this.turboMultiplier,this.surfaceGripMultiplier);let i=n?{throttle:t.throttle,steer:t.steering,brake:t.brake,handbrake:t.handbrake,reset:!1}:{throttle:0,steer:0,brake:1,handbrake:!1,reset:!1};if(this.controller.update(O9,i),this.opponents?.update(O9,this.car.chassis.absolutePosition),n){let e=this.recovery?.update(O9,{upDot:this.controller.state.upDot,speed:this.controller.state.speed,throttle:t.throttle,grounded:!this.controller.state.airborne,outOfBounds:this.car.chassis.absolutePosition.y<-3,manualSelfRight:t.reset});e?.penaltyMs&&this.race.addPenalty(e.penaltyMs)}}installRaceSystems(e){if(!this.scene)return;let t=this.scene;this.race=new I2e({checkpoints:e.checkpoints,totalLaps:3,onPhaseChange:e=>{t.physicsEnabled=e!==`paused`,this.opponents?.setRacing(e===`racing`),this.callbacks.onPhaseChange?.(e)},onResult:this.callbacks.onResult}),this.opponents=new W2e(t,e.shadowGenerator,e.trackPoints,e.spawnPositions.slice(1),e.startHeading),this.opponents.load(7),this.pickups=new J2e(t,e.collectiblePositions,()=>this.abilities?.collect(void 0,1)??!1)}async loadMap(e,t){if(!this.scene||!this.car)return;let n=D9(e),r=E3e(n,t);if(n.metadata.id===this.currentMapId&&r===this.currentMapSeed)return;let i=this.scene,a=i.physicsEnabled;i.physicsEnabled=!1;try{let n=await D3e(i,e,t),r=n.world;r.root.setEnabled(!1),this.opponents?.dispose(),this.pickups?.dispose(),this.world?.dispose(),this.world=r,this.currentMapId=n.definition.metadata.id,this.currentMapSeed=n.seed;let a=r.spawnPositions[0],o={position:a.clone(),rotation:A.RotationAxis(j.Up(),r.startHeading)};this.car.chassis.position.copyFrom(a),this.car.chassis.rotationQuaternion=o.rotation.clone(),this.presenter?.resetToPhysicsPose(),this.driftVisual?.reset(),this.disposeImportedCar?.(),this.disposeImportedCar=await _7(this.car,i,r.shadowGenerator,this.selectedCarId),this.controller=this.buildVehicleController(this.selectedCarId),this.recovery=new x4e(i,this.car.aggregate.body,o),this.surfaces=new C4e(i,this.car.aggregate.body),this.wrongWay=new O4e(r.trackPoints),this.installRaceSystems(r)}finally{i.physicsEnabled=a}}buildVehicleController(e){if(!this.scene||!this.car||!this.world)throw Error(`Vehicle controller cannot be built before the world and car exist.`);let t=g7(e);this.car.aggregate.body.setMassProperties({mass:t.physics.mass}),this.car.aggregate.shape.material={friction:t.physics.friction,restitution:t.physics.restitution};let n=this.car.wheelVisuals;return new r4e(this.scene,this.car.aggregate.body,{config:f2e(t),wheelVisuals:n,spawnPose:{position:this.world.spawnPositions[0].clone(),rotation:A.RotationAxis(j.Up(),this.world.startHeading)}})}afterPhysics(){if(this.presenter?.capturePhysicsPose(),!this.controller||!this.car||!this.race)return;this.driftVisual?.setVehicleState(this.controller.state);let e=performance.now(),t=this.race.getPhase();(t===`countdown`||t===`racing`)&&this.race.update(this.car.chassis.absolutePosition,e);let n=this.race.telemetry(this.controller.speedKph,this.controller.airborne,e);n.racers=8,n.surface=this.currentSurface,n.boost=Math.min(1,(this.abilities?.state.activeTurboSeconds??0)/2.65),n.direction=N3e(this.world?.trackPoints,this.car.chassis.absolutePosition);let r=this.wrongWay?.update(O9,this.car.chassis.absolutePosition,this.car.aggregate.body.getLinearVelocity());if(this.wrongWayVisible=!!(r?.wrongWay&&r.blinkVisible),n.wrongWay=this.wrongWayVisible,n.checkpoint!==this.lastCheckpoint&&t===`racing`){this.lastCheckpoint=n.checkpoint;let e=this.world?.trackPoints;if(!e)return;let t=n.checkpoint===0?e.length-1:Math.max(0,n.checkpoint-1),r=e[t],i=e[(t+1)%e.length],a=Math.atan2(i.x-r.x,i.z-r.z);this.controller.setCheckpoint({position:r.add(new j(0,.9,0)),rotation:A.RotationAxis(j.Up(),a)}),this.recovery?.setCheckpoint({position:r.add(new j(0,.9,0)),rotation:A.RotationAxis(j.Up(),a)})}e-this.lastTelemetryAt>=k3e&&(this.lastTelemetryAt=e,this.callbacks.onTelemetry?.(n)),this.pickups?.update(O9,this.car.chassis.absolutePosition,t===`racing`)}};function N3e(e,t){if(!e||e.length<3)return`straight`;let n=0,r=1/0;for(let i=0;i0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.z-a.z)*c)/l)):0,d=t.x-(a.x+s*u),f=t.z-(a.z+c*u),p=d*d+f*f;p2.45?`u-turn`:l>0?`right`:`left`}var A9={brand:`_brand_z92v3_1`,mark:`_mark_z92v3_11`,type:`_type_z92v3_28`,compact:`_compact_z92v3_48`,inverted:`_inverted_z92v3_65`},P3e=r((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),$=r(((e,t)=>{t.exports=P3e()}))();function F3e({compact:e=!1,className:t=``,inverted:n=!1}){return(0,$.jsxs)(`div`,{className:`${A9.brand} ${e?A9.compact:``} ${n?A9.inverted:``} ${t}`,"aria-label":`Yardline RC`,children:[(0,$.jsxs)(`svg`,{className:A9.mark,viewBox:`0 0 56 56`,"aria-hidden":`true`,children:[(0,$.jsx)(`path`,{d:`M8 12h29l11 10v22H19L8 33V12Z`}),(0,$.jsx)(`path`,{d:`m16 20 10 9h15M26 29v10`}),(0,$.jsx)(`path`,{d:`M38 12v10h10`})]}),(0,$.jsxs)(`span`,{className:A9.type,children:[(0,$.jsx)(`strong`,{children:`YARDLINE`}),(0,$.jsx)(`small`,{children:`RC RACING CLUB`})]})]})}function j9(e,t,n){return Math.min(n,Math.max(t,e))}function M9(e){if(e===void 0||!Number.isFinite(e))return`--:--.---`;let t=Math.max(0,e),n=Math.floor(t/6e4),r=Math.floor(t%6e4/1e3),i=Math.floor(t%1e3);return`${n}:${r.toString().padStart(2,`0`)}.${i.toString().padStart(3,`0`)}`}function I3e(e){return e===void 0||!Number.isFinite(e)?`—`:e===0?`WINNER`:`+${(Math.max(0,e)/1e3).toFixed(3)}`}var N9={hud:`_hud_wiqib_1`,topLeft:`_topLeft_wiqib_25`,topRight:`_topRight_wiqib_26`,positionBlock:`_positionBlock_wiqib_27`,speedBlock:`_speedBlock_wiqib_28`,directionMarker:`_directionMarker_wiqib_29`,alert:`_alert_wiqib_30`,minimap:`_minimap_wiqib_31`,lapPanel:`_lapPanel_wiqib_44`,powerSlot:`_powerSlot_wiqib_45`,timePanel:`_timePanel_wiqib_46`,boostTrack:`_boostTrack_wiqib_99`,"power-slot-pulse":`_power-slot-pulse_wiqib_1`,"power-slot-roulette":`_power-slot-roulette_wiqib_1`,connection:`_connection_wiqib_195`,pauseButton:`_pauseButton_wiqib_207`,"route-cue-life":`_route-cue-life_wiqib_1`,"route-u-turn":`_route-u-turn_wiqib_1`},L3e=2e3;function R3e({phase:e=`racing`,position:t,racerCount:n,lap:r,totalLaps:i,lapProgress:a=0,speedKph:o,elapsedMs:s,bestLapMs:c,currentLapMs:l,boost:u=0,direction:d=`straight`,powerup:f,minimap:p,alert:m,connection:h=`good`,onPause:g}){let _=j9(a,0,1),v=j9(u,0,1),[y,b]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(e!==`racing`){b(null);return}b(d);let t=window.setTimeout(()=>{b(null)},L3e);return()=>window.clearTimeout(t)},[d,e]),(0,$.jsxs)(`section`,{className:N9.hud,"aria-label":`Race information`,"data-phase":e,children:[(0,$.jsxs)(`div`,{className:N9.topLeft,children:[(0,$.jsxs)(`div`,{className:N9.lapPanel,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(lo,{size:15,weight:`fill`}),` LAP`]}),(0,$.jsxs)(`strong`,{children:[Math.max(1,r),(0,$.jsxs)(`small`,{children:[`/ `,Math.max(1,i)]})]}),(0,$.jsx)(`i`,{"aria-hidden":`true`,children:(0,$.jsx)(`b`,{style:{transform:`scaleX(${_})`}})})]}),(0,$.jsxs)(`div`,{className:N9.powerSlot,"data-loaded":f?`true`:`false`,"data-rolling":f?.rolling?`true`:`false`,children:[f?.icon??(0,$.jsx)(bo,{size:25,weight:`fill`}),(0,$.jsx)(`span`,{children:f?.name??`NO ITEM`}),(f?.charges??1)>1&&(0,$.jsxs)(`b`,{children:[`×`,f?.charges]})]})]}),(0,$.jsxs)(`div`,{className:N9.topRight,children:[(0,$.jsxs)(`div`,{className:N9.timePanel,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`THIS LAP`}),(0,$.jsx)(`strong`,{children:M9(l)})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Ko,{size:14,weight:`bold`}),(0,$.jsx)(`small`,{children:`RACE`}),(0,$.jsx)(`strong`,{children:M9(s)})]}),c!==void 0&&(0,$.jsxs)(`em`,{children:[`BEST `,M9(c)]})]}),(0,$.jsx)(`span`,{className:N9.connection,"data-quality":h,"aria-label":`Connection ${h}`}),(0,$.jsx)(`button`,{type:`button`,className:N9.pauseButton,onClick:g,"aria-label":`Pause race`,children:(0,$.jsx)(Mo,{size:20,weight:`fill`})})]}),y&&(0,$.jsxs)(`div`,{className:N9.directionMarker,"data-direction":y,"aria-label":`Track direction: ${y}`,children:[y===`left`&&(0,$.jsx)(La,{size:30,weight:`bold`}),y===`right`&&(0,$.jsx)(za,{size:30,weight:`bold`}),y===`u-turn`&&(0,$.jsx)(Fa,{size:30,weight:`bold`}),y===`straight`&&(0,$.jsx)(Va,{size:30,weight:`bold`})]},y),m&&(0,$.jsx)(`div`,{className:N9.alert,role:`status`,children:m}),p&&(0,$.jsx)(`div`,{className:N9.minimap,children:p}),(0,$.jsxs)(`div`,{className:N9.positionBlock,children:[(0,$.jsx)(`small`,{children:`POSITION`}),(0,$.jsx)(`strong`,{children:Math.max(1,t)}),(0,$.jsxs)(`span`,{children:[`/ `,Math.max(1,n)]})]}),(0,$.jsxs)(`div`,{className:N9.speedBlock,children:[(0,$.jsx)(`div`,{className:N9.boostTrack,"aria-label":`Boost ${Math.round(v*100)} percent`,children:(0,$.jsx)(`span`,{style:{transform:`scaleX(${v})`}})}),(0,$.jsx)(`small`,{children:`SPEED`}),(0,$.jsx)(`strong`,{children:Math.max(0,Math.round(o))}),(0,$.jsx)(`span`,{children:`KM/H`})]})]})}var P9={countdown:`_countdown_4aya2_1`,"line-in":`_line-in_4aya2_1`,"line-in-right":`_line-in-right_4aya2_1`,countdownValue:`_countdownValue_4aya2_29`,"count-in":`_count-in_4aya2_1`,countdownGo:`_countdownGo_4aya2_66`,resultsBackdrop:`_resultsBackdrop_4aya2_80`,resultsPanel:`_resultsPanel_4aya2_103`,"panel-in":`_panel-in_4aya2_1`,resultsHeader:`_resultsHeader_4aya2_115`,resultPosition:`_resultPosition_4aya2_148`,resultsBody:`_resultsBody_4aya2_163`,resultList:`_resultList_4aya2_169`,"row-in":`_row-in_4aya2_1`,localResult:`_localResult_4aya2_188`,rank:`_rank_4aya2_201`,driver:`_driver_4aya2_208`,resultTime:`_resultTime_4aya2_209`,points:`_points_4aya2_242`,resultsActions:`_resultsActions_4aya2_248`,continueButton:`_continueButton_4aya2_273`,resultMessage:`_resultMessage_4aya2_284`,skeletonList:`_skeletonList_4aya2_298`,skeleton:`_skeleton_4aya2_298`};function z3e({value:e,visible:t=!0,subtitle:n}){if(!t)return null;let r=e===`GO`;return(0,$.jsx)(`div`,{className:P9.countdown,"aria-live":`assertive`,"aria-atomic":`true`,children:(0,$.jsxs)(`div`,{className:`${P9.countdownValue} ${r?P9.countdownGo:``}`,children:[(0,$.jsx)(`span`,{children:e}),n&&(0,$.jsx)(`small`,{children:n})]},e)})}function B3e(){return(0,$.jsx)(`div`,{className:P9.skeletonList,"aria-label":`Loading race results`,children:[0,1,2,3].map(e=>(0,$.jsx)(`span`,{style:{animationDelay:`${e*80}ms`}},e))})}function V3e({open:e,entries:t,status:n=`ready`,errorMessage:r=`The final standings could not be verified.`,trackName:i=`Workshop After Dark`,raceLabel:a=`Circuit complete`,onRematch:o,onContinue:s}){if(!e)return null;let c=t.findIndex(e=>e.isLocal),l=c>=0?c+1:void 0;return(0,$.jsx)(`div`,{className:P9.resultsBackdrop,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`race-results-title`,children:(0,$.jsxs)(`section`,{className:P9.resultsPanel,children:[(0,$.jsxs)(`header`,{className:P9.resultsHeader,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:a}),(0,$.jsx)(`h2`,{id:`race-results-title`,children:`Final standings`}),(0,$.jsx)(`p`,{children:i})]}),l&&(0,$.jsxs)(`div`,{className:P9.resultPosition,children:[(0,$.jsx)(Xo,{size:22,weight:`fill`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:l}),` / `,t.length]})]})]}),(0,$.jsxs)(`div`,{className:P9.resultsBody,children:[n===`loading`&&(0,$.jsx)(B3e,{}),n===`error`&&(0,$.jsxs)(`div`,{className:P9.resultMessage,role:`alert`,children:[(0,$.jsx)(`strong`,{children:`Results pending`}),(0,$.jsx)(`p`,{children:r})]}),n===`ready`&&t.length===0&&(0,$.jsxs)(`div`,{className:P9.resultMessage,children:[(0,$.jsx)(Eo,{size:30,weight:`duotone`}),(0,$.jsx)(`strong`,{children:`No classified racers`}),(0,$.jsx)(`p`,{children:`The session ended before a finishing time was recorded.`})]}),n===`ready`&&t.length>0&&(0,$.jsx)(`ol`,{className:P9.resultList,children:t.map((e,t)=>(0,$.jsxs)(`li`,{className:e.isLocal?P9.localResult:``,style:{animationDelay:`${t*55}ms`},children:[(0,$.jsx)(`span`,{className:P9.rank,children:String(t+1).padStart(2,`0`)}),(0,$.jsxs)(`span`,{className:P9.driver,children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsx)(`small`,{children:e.carName??`Unregistered car`})]}),(0,$.jsxs)(`span`,{className:P9.resultTime,children:[(0,$.jsx)(`strong`,{children:e.disconnected?`DNF`:M9(e.timeMs)}),(0,$.jsx)(`small`,{children:e.disconnected?`Disconnected`:I3e(t===0?0:e.gapMs)})]}),e.points!==void 0&&(0,$.jsxs)(`b`,{className:P9.points,children:[`+`,e.points,` PTS`]})]},e.id))})]}),(0,$.jsxs)(`footer`,{className:P9.resultsActions,children:[(0,$.jsxs)(`button`,{type:`button`,className:P9.rematchButton,onClick:o,children:[(0,$.jsx)(Na,{size:19,weight:`bold`}),` Rematch`]}),(0,$.jsxs)(`button`,{type:`button`,className:P9.continueButton,onClick:s,children:[`Continue `,(0,$.jsx)(Ga,{size:19,weight:`bold`})]})]})]})})}var F9={backdrop:`_backdrop_g9j2v_1`,panel:`_panel_g9j2v_22`,"pause-in":`_pause-in_g9j2v_1`,content:`_content_g9j2v_53`,resume:`_resume_g9j2v_88`,quit:`_quit_g9j2v_91`,settings:`_settings_g9j2v_93`,sliderRow:`_sliderRow_g9j2v_108`,toggleRow:`_toggleRow_g9j2v_120`,segments:`_segments_g9j2v_160`},H3e=[{value:`performance`,label:`Fast`},{value:`balanced`,label:`Balanced`},{value:`quality`,label:`Quality`}];function U3e({open:e,settings:t,canRestart:n=!0,onSettingsChange:r,onResume:i,onRestart:a,onQuit:o}){return e?(0,$.jsx)(`div`,{className:F9.backdrop,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pause-title`,children:(0,$.jsxs)(`section`,{className:F9.panel,children:[(0,$.jsxs)(`header`,{children:[(0,$.jsx)(`span`,{children:`Race interrupted`}),(0,$.jsx)(`h2`,{id:`pause-title`,children:`Paused`})]}),(0,$.jsxs)(`div`,{className:F9.content,children:[(0,$.jsxs)(`nav`,{"aria-label":`Pause actions`,children:[(0,$.jsxs)(`button`,{type:`button`,className:F9.resume,onClick:i,children:[(0,$.jsx)(Po,{size:21,weight:`fill`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Back to track`}),(0,$.jsx)(`strong`,{children:`Resume race`})]}),(0,$.jsx)(Ga,{size:18,weight:`bold`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:a,disabled:!n,children:[(0,$.jsx)(Fa,{size:21,weight:`bold`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Return to grid`}),(0,$.jsx)(`strong`,{children:`Restart race`})]}),(0,$.jsx)(Ga,{size:18,weight:`bold`})]}),(0,$.jsxs)(`button`,{type:`button`,className:F9.quit,onClick:o,children:[(0,$.jsx)(Ro,{size:21,weight:`bold`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Progress will be lost`}),(0,$.jsx)(`strong`,{children:`Leave session`})]}),(0,$.jsx)(Ga,{size:18,weight:`bold`})]})]}),(0,$.jsxs)(`div`,{className:F9.settings,children:[(0,$.jsx)(`h3`,{children:`Race settings`}),(0,$.jsxs)(`label`,{className:F9.sliderRow,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Bo,{size:18,weight:`bold`}),` Master volume`]}),(0,$.jsx)(`output`,{children:Math.round(t.masterVolume*100)}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.01`,value:t.masterVolume,onChange:e=>r({masterVolume:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:F9.sliderRow,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Bo,{size:18,weight:`duotone`}),` Music volume`]}),(0,$.jsx)(`output`,{children:Math.round(t.musicVolume*100)}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.01`,value:t.musicVolume,onChange:e=>r({musicVolume:Number(e.target.value)})})]}),(0,$.jsxs)(`fieldset`,{children:[(0,$.jsxs)(`legend`,{children:[(0,$.jsx)(Oo,{size:18,weight:`bold`}),` Graphics`]}),(0,$.jsx)(`div`,{className:F9.segments,children:H3e.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":t.graphicsQuality===e.value,onClick:()=>r({graphicsQuality:e.value}),children:e.label},e.value))})]}),(0,$.jsxs)(`label`,{className:F9.toggleRow,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Ho,{size:18,weight:`bold`}),` Steering assist`]}),(0,$.jsx)(`input`,{type:`checkbox`,checked:t.steeringAssist,onChange:e=>r({steeringAssist:e.target.checked})}),(0,$.jsx)(`i`,{"aria-hidden":`true`})]})]})]})]})}):null}var I9={controls:`_controls_qvrdm_1`,steeringZone:`_steeringZone_qvrdm_20`,actionZone:`_actionZone_qvrdm_21`,pedalZone:`_pedalZone_qvrdm_22`,controlLabel:`_controlLabel_qvrdm_33`,stickBase:`_stickBase_qvrdm_39`,stickAxis:`_stickAxis_qvrdm_71`,stickKnob:`_stickKnob_qvrdm_79`,resetButton:`_resetButton_qvrdm_134`,powerupButton:`_powerupButton_qvrdm_151`,handbrakeButton:`_handbrakeButton_qvrdm_192`,brakeButton:`_brakeButton_qvrdm_208`,throttleButton:`_throttleButton_qvrdm_209`},L9={steering:0,throttle:0,brake:0,handbrake:!1};function W3e({disabled:e=!1,alwaysVisible:t=!1,powerupLabel:n=`Use power-up`,powerupCharges:r=1,className:i=``,onControlsChange:a,onUsePowerup:o,onResetCar:s}){let c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)({...L9}),p=(0,G.useRef)(a),m=(0,G.useRef)(null);(0,G.useEffect)(()=>{p.current=a},[a]);let h=()=>{m.current===null&&(m.current=requestAnimationFrame(()=>{m.current=null,p.current({...f.current})}))},g=e=>{f.current={...f.current,...e},h()},_=()=>{u.current=null,d.current=null,l.current&&(l.current.style.transform=`translate3d(0, 0, 0)`),g({steering:0})};(0,G.useEffect)(()=>{e&&(f.current={...L9},l.current&&(l.current.style.transform=`translate3d(0, 0, 0)`),p.current({...L9}))},[e]),(0,G.useEffect)(()=>()=>{m.current!==null&&cancelAnimationFrame(m.current),p.current({...L9})},[]);let v=t=>{if(e||u.current!==t.pointerId)return;let n=d.current;if(!n)return;let r=n.left+n.width/2,i=n.top+n.height/2,a=n.width*.31,o=t.clientX-r,s=t.clientY-i,c=Math.hypot(o,s),f=c>a?a/c:1,p=o*f,m=s*f;l.current&&(l.current.style.transform=`translate3d(${p}px, ${m}px, 0)`);let h=j9(o/a,-1,1);g({steering:Math.abs(h)<.035?0:h})},y=t=>{e||u.current!==null||(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),u.current=t.pointerId,d.current=c.current?.getBoundingClientRect()??null,v(t))},b=e=>{u.current===e.pointerId&&(e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),_())},x=(t,n)=>{e||(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),g(n))},S=(e,t)=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),g(t)},C=(e,t,n)=>{e.key!==` `&&e.key!==`Enter`||(e.preventDefault(),g(t?n:{throttle:n.throttle===void 0?f.current.throttle:0,brake:n.brake===void 0?f.current.brake:0,handbrake:n.handbrake===void 0&&f.current.handbrake}))};return(0,$.jsxs)(`section`,{className:`${I9.controls} ${i}`,"data-always-visible":t?`true`:`false`,"data-disabled":e?`true`:`false`,"aria-label":`Touch driving controls`,children:[(0,$.jsxs)(`div`,{className:I9.steeringZone,children:[(0,$.jsx)(`span`,{className:I9.controlLabel,children:`STEER`}),(0,$.jsxs)(`div`,{ref:c,className:I9.stickBase,role:`slider`,"aria-label":`Steering`,"aria-valuemin":-1,"aria-valuemax":1,"aria-valuenow":Math.round(f.current.steering*100)/100,tabIndex:e?-1:0,onPointerDown:y,onPointerMove:v,onPointerUp:b,onPointerCancel:b,onLostPointerCapture:_,onContextMenu:e=>e.preventDefault(),children:[(0,$.jsx)(`span`,{className:I9.stickAxis,"aria-hidden":`true`}),(0,$.jsx)(`div`,{ref:l,className:I9.stickKnob,"aria-hidden":`true`,children:(0,$.jsx)(`span`,{})})]})]}),(0,$.jsxs)(`div`,{className:I9.actionZone,children:[(0,$.jsxs)(`button`,{type:`button`,className:I9.resetButton,disabled:e,onClick:s,"aria-label":`Reset car`,children:[(0,$.jsx)(Fa,{size:19,weight:`bold`}),(0,$.jsx)(`span`,{children:`RESET`})]}),(0,$.jsxs)(`button`,{type:`button`,className:I9.powerupButton,disabled:e||!o||r<1,onPointerDown:e=>{e.preventDefault(),o?.()},"aria-label":n,children:[(0,$.jsx)(bo,{size:27,weight:`fill`}),r>1&&(0,$.jsxs)(`b`,{children:[`×`,r]})]})]}),(0,$.jsxs)(`div`,{className:I9.pedalZone,children:[(0,$.jsxs)(`button`,{type:`button`,className:I9.handbrakeButton,disabled:e,onPointerDown:e=>x(e,{handbrake:!0}),onPointerUp:e=>S(e,{handbrake:!1}),onPointerCancel:e=>S(e,{handbrake:!1}),onKeyDown:e=>C(e,!0,{handbrake:!0}),onKeyUp:e=>C(e,!1,{handbrake:!0}),children:[(0,$.jsx)(go,{size:20,weight:`bold`}),(0,$.jsx)(`span`,{children:`SLIDE`})]}),(0,$.jsxs)(`button`,{type:`button`,className:I9.brakeButton,disabled:e,onPointerDown:e=>x(e,{brake:1,throttle:-1}),onPointerUp:e=>S(e,{brake:0,throttle:0}),onPointerCancel:e=>S(e,{brake:0,throttle:0}),onKeyDown:e=>C(e,!0,{brake:1,throttle:-1}),onKeyUp:e=>C(e,!1,{brake:1,throttle:-1}),children:[(0,$.jsx)(`small`,{children:`BRAKE`}),(0,$.jsx)(`strong`,{children:`II`})]}),(0,$.jsxs)(`button`,{type:`button`,className:I9.throttleButton,disabled:e,onPointerDown:e=>x(e,{throttle:1}),onPointerUp:e=>S(e,{throttle:0}),onPointerCancel:e=>S(e,{throttle:0}),onKeyDown:e=>C(e,!0,{throttle:1}),onKeyUp:e=>C(e,!1,{throttle:1}),children:[(0,$.jsx)(`small`,{children:`DRIVE`}),(0,$.jsx)(`strong`,{children:`III`})]})]})]})}var R9={frontend:`_frontend_1ml5a_3`,screen:`_screen_1ml5a_25`,screenTransition:`_screenTransition_1ml5a_26`,screenIn:`_screenIn_1ml5a_1`,scanlines:`_scanlines_1ml5a_28`,noise:`_noise_1ml5a_29`,eyebrow:`_eyebrow_1ml5a_39`,mainScreen:`_mainScreen_1ml5a_42`,mainBackdrop:`_mainBackdrop_1ml5a_54`,sunDisc:`_sunDisc_1ml5a_56`,cityBlocks:`_cityBlocks_1ml5a_57`,racingStripes:`_racingStripes_1ml5a_60`,mainContent:`_mainContent_1ml5a_61`,logoSuffix:`_logoSuffix_1ml5a_64`,mainMenu:`_mainMenu_1ml5a_65`,menuItem:`_menuItem_1ml5a_66`,menuPointer:`_menuPointer_1ml5a_68`,menuItemActive:`_menuItemActive_1ml5a_69`,mainHint:`_mainHint_1ml5a_71`,sceneHeader:`_sceneHeader_1ml5a_74`,headerTitle:`_headerTitle_1ml5a_75`,stepCounter:`_stepCounter_1ml5a_76`,backButton:`_backButton_1ml5a_77`,confirmButton:`_confirmButton_1ml5a_79`,garageScreen:`_garageScreen_1ml5a_83`,carRail:`_carRail_1ml5a_84`,railLabel:`_railLabel_1ml5a_85`,railCar:`_railCar_1ml5a_86`,railCarActive:`_railCarActive_1ml5a_88`,carStageLabel:`_carStageLabel_1ml5a_89`,carouselDock:`_carouselDock_1ml5a_90`,carSpecs:`_carSpecs_1ml5a_92`,specTag:`_specTag_1ml5a_93`,modelClass:`_modelClass_1ml5a_94`,carQuote:`_carQuote_1ml5a_96`,carMeta:`_carMeta_1ml5a_97`,meters:`_meters_1ml5a_98`,meter:`_meter_1ml5a_98`,meterTrack:`_meterTrack_1ml5a_98`,racePreset:`_racePreset_1ml5a_99`,trackScreen:`_trackScreen_1ml5a_102`,trackHero:`_trackHero_1ml5a_103`,trackTag:`_trackTag_1ml5a_104`,trackSwitcher:`_trackSwitcher_1ml5a_105`,trackDescription:`_trackDescription_1ml5a_106`,trackFacts:`_trackFacts_1ml5a_107`,raceSummary:`_raceSummary_1ml5a_108`,summaryKicker:`_summaryKicker_1ml5a_108`,loadingScreen:`_loadingScreen_1ml5a_111`,loadingContent:`_loadingContent_1ml5a_111`,loadingTrack:`_loadingTrack_1ml5a_111`,loadingMeta:`_loadingMeta_1ml5a_111`,loadingTip:`_loadingTip_1ml5a_111`},G3e={"sports-car":`Road Sports`,"orange-off-road":`Off-Road 4×4`,"pickup-truck":`Racing Pickup`,"modified-sports-car":`Modified Coupe`,"voltage-bandit":`Street Buggy`,"kestrel-gt":`Touring RC`,"pocket-rocket":`Mini Sprint`,"iron-howl":`Heavy Rally`,"circuit-wasp":`Pro Prototype`},z9=m7.map(e=>({id:e.id,name:e.name,className:G3e[e.id],quote:e.tagline,speed:e.displayStats.speed,acceleration:e.displayStats.acceleration,maneuver:e.displayStats.handling,weight:e.displayStats.weight,rating:e.class,engine:e.engine,drivetrain:e.drivetrain})),K3e={id:`construction-loop`,name:`Construction Loop`,location:`Neighborhood Construction Site`,length:`1183 m`,difficulty:`Easy`,surface:`Asphalt / Concrete / Grass`,description:`A toy-scale suburban neighborhood loop with finished houses, yard trees and roadside construction set dressing.`},B9=[`Start Race`,`Time Trials`,`Championship`,`Workshop`,`Options`],V9=3,H9=8;function U9(e,t){return(e+t)%t}function q3e({onClick:e,label:t=`Back`}){return(0,$.jsxs)(`button`,{className:R9.backButton,type:`button`,onClick:e,children:[(0,$.jsx)(La,{size:20,weight:`bold`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:t})]})}function W9({label:e,value:t}){let n={"--meter-value":`${t}%`};return(0,$.jsxs)(`div`,{className:R9.meter,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`div`,{className:R9.meterTrack,role:`meter`,"aria-label":e,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,children:(0,$.jsx)(`i`,{style:n})}),(0,$.jsx)(`b`,{children:t})]})}function J3e({onStartRace:e,onCancel:t,initialScreen:n=`main`,initialTrackId:r,tracks:i=[K3e],babylonPreview:a=!1,onPreviewChange:o}){let[s,c]=(0,G.useState)(n),[l,u]=(0,G.useState)(0),[d,f]=(0,G.useState)(0),[p,m]=(0,G.useState)(()=>{let e=i.findIndex(e=>e.id===r);return e>=0?e:0}),[h,g]=(0,G.useState)(0),_=z9[d],v=i[p]??K3e,y=v.name.split(/\s+/),b=y.slice(0,-1).join(` `)||y[0],x=y.length>1?y.at(-1):``,S=(0,G.useMemo)(()=>({mode:`single-race`,laps:V9,carCount:H9,carId:_.id,carName:_.name,trackId:v.id,trackName:v.name}),[_,v.id,v.name]);(0,G.useEffect)(()=>{o?.({screen:s,mode:s===`car`?`garage`:s===`track`||s===`loading`?`track`:`attract`,carId:_.id,trackId:v.id})},[_.id,o,s,v.id]);let C=(0,G.useCallback)(()=>{if(s!==`loading`){if(s===`main`){t?.();return}c(s===`track`?`car`:`main`)}},[t,s]),w=(0,G.useCallback)(e=>{f(t=>U9(t+e,z9.length))},[]),T=(0,G.useCallback)(e=>{m(t=>U9(t+e,i.length))},[i.length]);return(0,G.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),C();return}s===`main`?(e.key===`ArrowUp`&&u(e=>U9(e-1,B9.length)),e.key===`ArrowDown`&&u(e=>U9(e+1,B9.length)),e.key===`Enter`&&l===0&&c(`car`)):s===`car`?((e.key===`ArrowLeft`||e.key===`ArrowUp`)&&w(-1),(e.key===`ArrowRight`||e.key===`ArrowDown`)&&w(1),e.key===`Enter`&&c(`track`)):s===`track`&&e.key===`Enter`&&c(`loading`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,C,s,w]),(0,G.useEffect)(()=>{if(s!==`loading`)return;g(4);let t=!1,n=performance.now(),r=window.setInterval(()=>{let i=performance.now()-n,a=Math.min(1,i/1500),o=1-(1-a)**3;g(Math.round(4+o*96)),a>=1&&!t&&(t=!0,window.clearInterval(r),window.setTimeout(()=>e(S),160))},50);return()=>window.clearInterval(r)},[e,s,S]),(0,$.jsxs)(`main`,{className:R9.frontend,"data-babylon-preview":a?`true`:`false`,"aria-label":`Yardline RC racing game`,children:[(0,$.jsx)(`div`,{className:R9.scanlines,"aria-hidden":`true`}),(0,$.jsx)(`div`,{className:R9.noise,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{className:R9.screenTransition,children:[s===`main`&&(0,$.jsxs)(`section`,{className:`${R9.screen} ${R9.mainScreen}`,"aria-labelledby":`main-title`,children:[(0,$.jsxs)(`div`,{className:R9.mainBackdrop,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:R9.sunDisc}),(0,$.jsxs)(`div`,{className:R9.cityBlocks,children:[(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{}),(0,$.jsx)(`i`,{})]}),(0,$.jsx)(`div`,{className:R9.racingStripes})]}),(0,$.jsxs)(`div`,{className:R9.mainContent,children:[(0,$.jsx)(`p`,{className:R9.eyebrow,children:`Radio-controlled racing league`}),(0,$.jsxs)(`h1`,{id:`main-title`,children:[(0,$.jsx)(`span`,{children:`YARD`}),(0,$.jsx)(`span`,{children:`LINE`})]}),(0,$.jsx)(`p`,{className:R9.logoSuffix,children:`R/C RACING`}),(0,$.jsx)(`nav`,{className:R9.mainMenu,"aria-label":`Main menu`,children:B9.map((e,t)=>{let n=t!==0;return(0,$.jsxs)(`button`,{className:`${R9.menuItem} ${l===t?R9.menuItemActive:``}`,type:`button`,onMouseEnter:()=>u(t),onFocus:()=>u(t),onClick:()=>t===0&&c(`car`),"aria-disabled":n,children:[(0,$.jsx)(za,{className:R9.menuPointer,weight:`fill`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e}),n&&(0,$.jsx)(`small`,{children:`Coming soon`})]},e)})}),(0,$.jsx)(`p`,{className:R9.mainHint,children:`Arrow keys to select\xA0\xA0 / \xA0\xA0Enter to confirm`})]})]}),s===`car`&&(0,$.jsxs)(`section`,{className:`${R9.screen} ${R9.garageScreen}`,"aria-labelledby":`car-title`,children:[(0,$.jsxs)(`header`,{className:R9.sceneHeader,children:[(0,$.jsx)(q3e,{onClick:C,label:`Main menu`}),(0,$.jsxs)(`div`,{className:R9.headerTitle,children:[(0,$.jsx)(`span`,{children:`Yardline RC Works`}),(0,$.jsx)(`h2`,{id:`car-title`,children:`Select Car`})]}),(0,$.jsxs)(`span`,{className:R9.stepCounter,children:[String(d+1).padStart(2,`0`),` / `,String(z9.length).padStart(2,`0`)]})]}),(0,$.jsxs)(`aside`,{className:R9.carRail,"aria-label":`Available cars`,children:[(0,$.jsx)(`span`,{className:R9.railLabel,children:`Garage inventory`}),z9.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:`${R9.railCar} ${t===d?R9.railCarActive:``}`,onClick:()=>f(t),"aria-current":t===d?`true`:void 0,children:[(0,$.jsx)(`b`,{children:String(t+1).padStart(2,`0`)}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsx)(`small`,{children:e.className})]})]},e.id))]}),(0,$.jsxs)(`div`,{className:R9.carStageLabel,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{children:`LIVE MODEL`}),(0,$.jsx)(`b`,{children:`ROTATING DISPLAY`})]}),(0,$.jsxs)(`div`,{className:R9.carouselDock,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>w(-1),"aria-label":`Previous car: ${z9[U9(d-1,z9.length)].name}`,children:(0,$.jsx)(La,{size:24,weight:`bold`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:`Model`}),(0,$.jsxs)(`strong`,{children:[String(d+1).padStart(2,`0`),` / `,String(z9.length).padStart(2,`0`)]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>w(1),"aria-label":`Next car: ${z9[U9(d+1,z9.length)].name}`,children:(0,$.jsx)(za,{size:24,weight:`bold`})})]}),(0,$.jsxs)(`aside`,{className:R9.carSpecs,children:[(0,$.jsxs)(`span`,{className:R9.specTag,children:[(0,$.jsx)(qa,{weight:`fill`}),` Ready to race`]}),(0,$.jsx)(`p`,{className:R9.modelClass,children:_.className}),(0,$.jsx)(`h3`,{children:_.name}),(0,$.jsx)(`p`,{className:R9.carQuote,children:_.quote}),(0,$.jsxs)(`div`,{className:R9.carMeta,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Rating`}),(0,$.jsx)(`b`,{children:_.rating})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Engine`}),(0,$.jsx)(`b`,{children:_.engine})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`Drive`}),(0,$.jsx)(`b`,{children:_.drivetrain})]})]}),(0,$.jsxs)(`div`,{className:R9.meters,children:[(0,$.jsx)(W9,{label:`Speed`,value:_.speed}),(0,$.jsx)(W9,{label:`Acceleration`,value:_.acceleration}),(0,$.jsx)(W9,{label:`Maneuver`,value:_.maneuver}),(0,$.jsx)(W9,{label:`Weight`,value:_.weight})]}),(0,$.jsxs)(`div`,{className:R9.racePreset,children:[(0,$.jsx)(lo,{size:18,weight:`fill`}),(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`b`,{children:[V9,` laps`]}),(0,$.jsxs)(`small`,{children:[H9,`-car local field`]})]})]}),(0,$.jsxs)(`button`,{className:R9.confirmButton,type:`button`,onClick:()=>c(`track`),children:[(0,$.jsxs)(`span`,{children:[`Choose `,_.name]}),(0,$.jsx)(za,{size:24,weight:`bold`})]})]})]}),s===`track`&&(0,$.jsxs)(`section`,{className:`${R9.screen} ${R9.trackScreen}`,"aria-labelledby":`track-title`,children:[(0,$.jsxs)(`header`,{className:R9.sceneHeader,children:[(0,$.jsx)(q3e,{onClick:C,label:`Garage`}),(0,$.jsxs)(`div`,{className:R9.headerTitle,children:[(0,$.jsx)(`span`,{children:`Saturday feature`}),(0,$.jsx)(`h2`,{children:`Track Preview`})]}),(0,$.jsxs)(`span`,{className:R9.stepCounter,children:[String(p+1).padStart(2,`0`),` / `,String(i.length).padStart(2,`0`)]})]}),(0,$.jsxs)(`div`,{className:R9.trackHero,children:[(0,$.jsx)(`span`,{className:R9.trackTag,children:i.length>1?`Registered circuit`:`Only demo circuit`}),(0,$.jsx)(`p`,{children:v.location}),(0,$.jsxs)(`h2`,{id:`track-title`,children:[(0,$.jsx)(`span`,{children:b}),x&&(0,$.jsx)(`span`,{children:x})]}),(0,$.jsx)(`p`,{className:R9.trackDescription,children:v.description}),i.length>1&&(0,$.jsxs)(`div`,{className:R9.trackSwitcher,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Previous track: ${i[U9(p-1,i.length)].name}`,onClick:()=>T(-1),children:(0,$.jsx)(La,{size:18,weight:`bold`})}),(0,$.jsxs)(`strong`,{children:[p+1,` / `,i.length]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Next track: ${i[U9(p+1,i.length)].name}`,onClick:()=>T(1),children:(0,$.jsx)(za,{size:18,weight:`bold`})})]}),(0,$.jsxs)(`div`,{className:R9.trackFacts,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(mo,{size:22,weight:`bold`}),(0,$.jsx)(`small`,{children:`Length`}),(0,$.jsx)(`b`,{children:v.length})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Ho,{size:22,weight:`bold`}),(0,$.jsx)(`small`,{children:`Difficulty`}),(0,$.jsx)(`b`,{children:v.difficulty})]}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(bo,{size:22,weight:`fill`}),(0,$.jsx)(`small`,{children:`Surface`}),(0,$.jsx)(`b`,{children:v.surface})]})]})]}),(0,$.jsxs)(`aside`,{className:R9.raceSummary,children:[(0,$.jsx)(`span`,{className:R9.summaryKicker,children:`Race ready`}),(0,$.jsx)(`h3`,{children:_.name}),(0,$.jsxs)(`dl`,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Format`}),(0,$.jsx)(`dd`,{children:`Single race`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Laps`}),(0,$.jsx)(`dd`,{children:V9})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Grid`}),(0,$.jsxs)(`dd`,{children:[H9,` cars`]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Conditions`}),(0,$.jsx)(`dd`,{children:`Dry / Late day`})]})]}),(0,$.jsxs)(`button`,{className:R9.confirmButton,type:`button`,onClick:()=>c(`loading`),children:[(0,$.jsxs)(`span`,{children:[`Race `,v.name]}),(0,$.jsx)(lo,{size:24,weight:`fill`})]})]})]}),s===`loading`&&(0,$.jsx)(`section`,{className:`${R9.screen} ${R9.loadingScreen}`,"aria-labelledby":`loading-title`,children:(0,$.jsxs)(`div`,{className:R9.loadingContent,children:[(0,$.jsx)(`span`,{className:R9.specTag,children:`Saturday feature`}),(0,$.jsx)(`p`,{children:v.location}),(0,$.jsxs)(`h2`,{id:`loading-title`,children:[b,x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),x]})]}),(0,$.jsx)(`div`,{className:R9.loadingTrack,"aria-label":`Loading ${h}%`,children:(0,$.jsx)(`i`,{style:{transform:`scaleX(${h/100})`}})}),(0,$.jsxs)(`div`,{className:R9.loadingMeta,children:[(0,$.jsx)(`span`,{children:`Warming radio channel`}),(0,$.jsxs)(`strong`,{children:[h,`%`]})]}),(0,$.jsx)(`p`,{className:R9.loadingTip,children:`Tip: save your power-up for the narrow garden exit.`})]})})]},s)]})}var G9={editorShell:`_editorShell_xa6qr_1`,topbar:`_topbar_xa6qr_14`,brand:`_brand_xa6qr_23`,brandGlyph:`_brandGlyph_xa6qr_34`,projectTitle:`_projectTitle_xa6qr_50`,toolbarActions:`_toolbarActions_xa6qr_54`,modeBar:`_modeBar_xa6qr_56`,panelTabs:`_panelTabs_xa6qr_57`,categoryStrip:`_categoryStrip_xa6qr_58`,wideButton:`_wideButton_xa6qr_59`,resetButton:`_resetButton_xa6qr_60`,dangerButton:`_dangerButton_xa6qr_61`,secondaryButton:`_secondaryButton_xa6qr_68`,testButton:`_testButton_xa6qr_69`,iconButton:`_iconButton_xa6qr_70`,hiddenInput:`_hiddenInput_xa6qr_73`,workspace:`_workspace_xa6qr_75`,libraryPanel:`_libraryPanel_xa6qr_76`,inspectorPanel:`_inspectorPanel_xa6qr_77`,searchField:`_searchField_xa6qr_85`,selectedPreviewHeader:`_selectedPreviewHeader_xa6qr_94`,assetList:`_assetList_xa6qr_97`,assetRow:`_assetRow_xa6qr_98`,assetThumbnail:`_assetThumbnail_xa6qr_101`,thumbnailSkeleton:`_thumbnailSkeleton_xa6qr_103`,"thumbnail-shimmer":`_thumbnail-shimmer_xa6qr_1`,thumbnailError:`_thumbnailError_xa6qr_104`,emptyState:`_emptyState_xa6qr_109`,preview:`_preview_xa6qr_111`,previewStatus:`_previewStatus_xa6qr_113`,previewHint:`_previewHint_xa6qr_114`,previewError:`_previewError_xa6qr_115`,textureGrid:`_textureGrid_xa6qr_122`,canvasPanel:`_canvasPanel_xa6qr_127`,canvasReadout:`_canvasReadout_xa6qr_132`,zoomControls:`_zoomControls_xa6qr_133`,mapStage:`_mapStage_xa6qr_138`,canvasGround:`_canvasGround_xa6qr_142`,gridFill:`_gridFill_xa6qr_143`,minorGrid:`_minorGrid_xa6qr_144`,majorGrid:`_majorGrid_xa6qr_145`,routeCenter:`_routeCenter_xa6qr_146`,routeNode:`_routeNode_xa6qr_148`,mapObject:`_mapObject_xa6qr_150`,scaleLegend:`_scaleLegend_xa6qr_155`,modeHint:`_modeHint_xa6qr_156`,statusbar:`_statusbar_xa6qr_161`,statusDot:`_statusDot_xa6qr_163`,inspectorHeader:`_inspectorHeader_xa6qr_165`,sectionLabel:`_sectionLabel_xa6qr_167`,inspectorBody:`_inspectorBody_xa6qr_169`,fieldPair:`_fieldPair_xa6qr_171`,fieldTriple:`_fieldTriple_xa6qr_172`,textField:`_textField_xa6qr_177`,nudgeRow:`_nudgeRow_xa6qr_185`,formField:`_formField_xa6qr_188`,toggleField:`_toggleField_xa6qr_191`,helpText:`_helpText_xa6qr_198`};function Y3e({asset:e}){let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(`loading`);return(0,G.useEffect)(()=>{let n=t.current;if(!n)return;let i=!1,a=new Ih(n,!0,{preserveDrawingBuffer:!1,stencil:!0}),o=new x(a);o.clearColor=new fe(.075,.08,.085,1);let s=new gh(`asset-camera`,Math.PI*.72,Math.PI*.34,5.6,j.Zero(),o);s.lowerRadiusLimit=2.8,s.upperRadiusLimit=11,s.wheelPrecision=45,s.panningSensibility=0,s.attachControl(n,!0);let c=new K_(`asset-fill`,new j(.2,1,.1),o);c.intensity=1.5,c.groundColor=new P(.18,.19,.2);let l=new GC(`asset-key`,new j(-.6,-1,.5),o);l.intensity=1.8,r(`loading`),xD.ImportMeshAsync(``,e.rootUrl,e.file,o).then(({meshes:e})=>{if(i)return;let t=new wc(`asset-pivot`,o);for(let n of e)n.parent||=t,n.useVertexColors=!1,n.hasVertexAlpha=!1,n.computeWorldMatrix(!0);let n=new j(1/0,1/0,1/0),a=new j(-1/0,-1/0,-1/0);for(let t of e){let e=t.getBoundingInfo?.().boundingBox;e&&(n=j.Minimize(n,e.minimumWorld),a=j.Maximize(a,e.maximumWorld))}let s=a.subtract(n),c=Math.max(s.x,s.y,s.z,.001);t.scaling.setAll(3.2/c),t.position=n.add(a).scale(.5).scale(-3.2/c),t.rotation.y=-.35,r(`ready`)}).catch(()=>{i||r(`error`)}),a.runRenderLoop(()=>{i||o.render()});let u=new ResizeObserver(()=>a.resize());return u.observe(n),()=>{i=!0,u.disconnect(),a.stopRenderLoop(),o.dispose(),a.dispose()}},[e]),(0,$.jsxs)(`div`,{className:G9.preview,children:[(0,$.jsx)(`canvas`,{ref:t,"aria-label":`3D preview of ${e.label}`}),n===`loading`&&(0,$.jsx)(`span`,{className:G9.previewStatus,children:`Loading model…`}),n===`error`&&(0,$.jsx)(`span`,{className:`${G9.previewStatus} ${G9.previewError}`,children:`Preview unavailable`}),n===`ready`&&(0,$.jsx)(`span`,{className:G9.previewHint,children:`Drag to orbit · Scroll to zoom`})]})}var K9=new Map;function X3e({asset:e}){let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(()=>K9.get(e.id)),[o,s]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{a(K9.get(e.id)),s(!1)},[e.id]),(0,G.useEffect)(()=>{let e=t.current;if(!e)return;let n=new IntersectionObserver(([e])=>r(e?.isIntersecting??!1),{rootMargin:`80px`,threshold:.01});return n.observe(e),()=>n.disconnect()},[]),(0,G.useEffect)(()=>{if(!n||i||o)return;let t=!1,r=!1,c=window.document.createElement(`canvas`);c.width=160,c.height=112;let l=new Ih(c,!1,{preserveDrawingBuffer:!0,stencil:!1}),u=new x(l);u.clearColor=new fe(.075,.085,.09,1);let d=new gh(`thumbnail-camera`,Math.PI*.72,Math.PI*.34,5.6,j.Zero(),u);d.fov=.72;let f=new K_(`thumbnail-fill`,new j(.2,1,.1),u);f.intensity=1.5,f.groundColor=new P(.18,.19,.2);let p=new GC(`thumbnail-key`,new j(-.6,-1,.5),u);p.intensity=1.7;let m=()=>{r||(r=!0,u.dispose(),l.dispose())};return xD.ImportMeshAsync(``,e.rootUrl,e.file,u).then(async({meshes:n})=>{if(t)return;let r=new wc(`thumbnail-pivot`,u);for(let e of n)e.parent||=r,e.useVertexColors=!1,e.hasVertexAlpha=!1,e.computeWorldMatrix(!0);let i=new j(1/0,1/0,1/0),o=new j(-1/0,-1/0,-1/0);for(let e of n){if(e.getTotalVertices()===0)continue;let t=e.getBoundingInfo().boundingBox;i=j.Minimize(i,t.minimumWorld),o=j.Maximize(o,t.maximumWorld)}let s=o.subtract(i),l=Math.max(s.x,s.y,s.z,.001);if(r.scaling.setAll(3.25/l),r.position=i.add(o).scale(-.5*3.25/l),r.rotation.y=-.35,await u.whenReadyAsync(),u.render(),t)return;let d=c.toDataURL(`image/webp`,.82);K9.set(e.id,d),a(d)}).catch(()=>{t||s(!0)}).finally(m),()=>{t=!0,m()}},[e,o,i,n]),(0,$.jsxs)(`span`,{ref:t,className:G9.assetThumbnail,"aria-hidden":`true`,children:[i&&(0,$.jsx)(`img`,{src:i,alt:``}),!i&&!o&&(0,$.jsx)(`span`,{className:G9.thumbnailSkeleton}),o&&(0,$.jsx)(`span`,{className:G9.thumbnailError,children:`No preview`})]})}var Z3e=.35,Q3e=5,$3e=[{id:`all`,label:`All`},{id:`roads`,label:`Roads`},{id:`sidewalks`,label:`Sidewalks`},{id:`markings`,label:`Markings`},{id:`buildings`,label:`Buildings`},{id:`facades`,label:`Facades`},{id:`roofs`,label:`Roofs`},{id:`structures`,label:`Structure`},{id:`props`,label:`Props`},{id:`houses`,label:`Houses`},{id:`nature`,label:`Nature`},{id:`vehicles`,label:`Vehicles`},{id:`street`,label:`Street`}];function e6e(){let e=c9();try{let t=localStorage.getItem(s9);if(!t)return e;let n=l9(JSON.parse(t));return n?t6e(n,e)?(localStorage.setItem(s9,JSON.stringify(e)),e):o9(a9({...n,presetRevision:e.presetRevision})):e}catch{return e}}function t6e(e,t){return e.id===t.id&&(e.presetRevision??0)<(t.presetRevision??0)}function q9(e){return a9({...e,presetRevision:c9().presetRevision})}function J9(e){return-e}function n6e(){return typeof crypto.randomUUID==`function`?crypto.randomUUID():`object-${Date.now()}-${Math.random()}`}function r6e(){let[e,t]=(0,G.useState)(e6e),[n,r]=(0,G.useState)(`select`),[i,a]=(0,G.useState)(`assets`),[o,s]=(0,G.useState)(`roads`),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`downtown-street-2lane`),[f,p]=(0,G.useState)([]),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(null),[b,x]=(0,G.useState)(1),[S,C]=(0,G.useState)({x:0,z:0}),[w,T]=(0,G.useState)(`Ready`),E=(0,G.useRef)(null),ee=(0,G.useRef)(null),D=(0,G.useRef)([]),te=r9(u)??n9[0],O=f.map(t=>e.objects.find(e=>e.id===t)).filter(e=>!!e),ne=O[0]??null,re=e.objects.some(e=>e.id.startsWith(`auto-route-road-`)||e.id.startsWith(`completed-route-road-`)),k=(0,G.useMemo)(()=>{let e=c.trim().toLowerCase();return n9.filter(t=>(o===`all`||t.category===o)&&(!e||t.label.toLowerCase().includes(e)))},[o,c]),ie=(0,G.useCallback)((e,n=!0)=>{t(t=>(n&&(D.current=[...D.current.slice(-79),t]),{...e(t),updatedAt:new Date().toISOString()}))},[]),A=(0,G.useCallback)(()=>{let e=D.current.at(-1);if(!e){T(`Nothing to undo`);return}D.current=D.current.slice(0,-1),t(e),p(t=>t.filter(t=>e.objects.some(e=>e.id===t))),h(null),T(`Undo`)},[]),j=(e,t)=>{x(n=>{let r=a6e(e,Z3e,Q3e);if(t){let e=n/r;C(n=>({x:Y9(t.x-(t.x-n.x)*e),z:Y9(t.z-(t.z-n.z)*e)}))}return r})},ae=(e,t)=>{let n=E.current;if(!n)return null;let r=n.getScreenCTM();if(!r)return null;let i=n.createSVGPoint();i.x=e,i.y=t;let a=i.matrixTransform(r.inverse());return{x:Math.round(a.x*10)/10,z:Math.round(-a.y*10)/10}},oe=t=>{if(t.target!==t.currentTarget&&t.target.closest(`[data-map-object]`))return;let r=ae(t.clientX,t.clientY);if(r){if(t.button===1||n===`select`){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),y({pointerId:t.pointerId,startClientX:t.clientX,startClientY:t.clientY,startCenter:S,viewSize:e.worldSize/b}),!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&p([]),T(`Panning canvas`);return}if(n===`route`){ie(e=>({...e,route:[...e.route,r]})),T(`Route point ${e.route.length+1} added`);return}if(n===`place`){let e=te.isRoad||te.category===`sidewalks`||te.category===`markings`?12:1,t={id:n6e(),assetId:te.id,x:Math.round(r.x/e)*e,z:Math.round(r.z/e)*e,rotation:0,scale:1,...te.isRoad?{y:i9}:{}};ie(e=>({...e,objects:[...e.objects,t]})),p([t.id]),T(`${te.label} placed`);return}!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&p([])}},se=(t,r)=>{if(n!==`select`)return;t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId);let i=t.shiftKey||t.metaKey||t.ctrlKey,a=f.includes(r),o=i?a?f.filter(e=>e!==r):[...f,r]:a?f:[r];if(p(o),i&&a)return;let s=ae(t.clientX,t.clientY);s&&(D.current=[...D.current.slice(-79),e],h({ids:o,startPoint:s,starts:Object.fromEntries(e.objects.filter(e=>o.includes(e.id)).map(e=>[e.id,{x:e.x,z:e.z}]))}))},M=(t,n)=>{t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId);let r=ae(t.clientX,t.clientY);r&&(D.current=[...D.current.slice(-79),e],_({index:n,startPoint:r,startRoute:e.route.map(e=>({...e}))}),T(`Moving route node ${n+1}`))},ce=e=>{if(v&&v.pointerId===e.pointerId){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-v.startClientX)/t.width*v.viewSize,r=(e.clientY-v.startClientY)/t.height*v.viewSize;C({x:Y9(v.startCenter.x-n),z:Y9(v.startCenter.z+r)});return}if(g){let t=ae(e.clientX,e.clientY);if(!t)return;let n=t.x-g.startPoint.x,r=t.z-g.startPoint.z;ie(e=>({...e,route:e.route.map((e,t)=>{let i=g.startRoute[t];return t===g.index&&i?{x:Y9(i.x+n),z:Y9(i.z+r)}:e})}),!1);return}if(!m)return;let t=ae(e.clientX,e.clientY);if(!t)return;let n=t.x-m.startPoint.x,r=t.z-m.startPoint.z;ie(e=>({...e,objects:e.objects.map(e=>{let t=m.starts[e.id];return t?{...e,x:Y9(t.x+n),z:Y9(t.z+r)}:e})}),!1)},le=e=>{f.length!==0&&ie(t=>({...t,objects:t.objects.map(t=>f.includes(t.id)?{...t,...e}:t)}))},N=(0,G.useCallback)(()=>{f.length!==0&&(ie(e=>({...e,objects:e.objects.filter(e=>!f.includes(e.id))})),p([]),T(`${f.length} object${f.length===1?``:`s`} removed`))},[f,ie]),ue=e=>{e.preventDefault();let t=ae(e.clientX,e.clientY),n=e.deltaY>0?.88:1.14;j(b*n,t??void 0)};(0,G.useEffect)(()=>{re&&(t(e=>{let t={...o9(a9(e)),updatedAt:new Date().toISOString()};return localStorage.setItem(s9,JSON.stringify(q9(t))),t}),p(e=>e.filter(e=>!e.startsWith(`auto-route-road-`)&&!e.startsWith(`completed-route-road-`))),T(`Removed auto road pieces`))},[re]),(0,G.useEffect)(()=>{let e=e=>{let t=i6e(e.target);if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){e.preventDefault(),A();return}if(!t){if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),N();return}if(e.key===`+`||e.key===`=`){e.preventDefault(),j(b*1.18);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),j(b/1.18);return}e.key.toLowerCase()===`v`&&r(`select`),e.key.toLowerCase()===`b`&&r(`place`),e.key.toLowerCase()===`p`&&r(`route`)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,A,b]);let de=()=>{let n=o9(q9(e));t(n),localStorage.setItem(s9,JSON.stringify(n)),T(`Saved locally`)},fe=()=>{let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=window.document.createElement(`a`);r.href=n,r.download=`${e.id||`yardline-map`}.json`,r.click(),URL.revokeObjectURL(n),T(`Map exported`)},pe=async e=>{let n=e.target.files?.[0];if(e.target.value=``,n)try{let e=l9(JSON.parse(await n.text()));if(!e)throw Error(`Invalid map file`);t(o9(a9(e))),p([]),T(`Imported ${e.name}`)}catch{T(`Import failed — choose a Yardline map JSON file`)}},P=()=>{let e=c9();t(e),p([]),T(`Starter map restored`)},F=()=>{let n=o9(q9(e));t(n),localStorage.setItem(s9,JSON.stringify(n)),window.location.href=`./?map=construction-loop&editorDraft=1&seed=${n.seed}`},me=()=>{let e=!!v,t=!!g;h(null),_(null),y(null),(e||t)&&T(`Ready`)},he=()=>{let n=o9(q9(e));t(n),localStorage.setItem(s9,JSON.stringify(n)),window.location.href=`./?map=construction-loop&editorDraft=1&seed=${n.seed}&fly=1`},ge=()=>{ie(o9),p(e=>e.filter(e=>!e.startsWith(`auto-route-road-`)&&!e.startsWith(`completed-route-road-`))),T(`Auto road pieces removed`)},_e=e.worldSize/2,ve=e.worldSize/b,ye=ve/2,be=(e.routeClosed&&e.route.length>2?[...e.route,e.route[0]]:e.route).map(e=>`${e.x},${J9(e.z)}`).join(` `);return(0,$.jsxs)(`main`,{className:G9.editorShell,children:[(0,$.jsxs)(`header`,{className:G9.topbar,children:[(0,$.jsxs)(`a`,{className:G9.brand,href:`./`,"aria-label":`Back to Yardline Racing`,children:[(0,$.jsx)(`span`,{className:G9.brandGlyph,children:`YL`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:`MAP WORKBENCH`}),(0,$.jsx)(`small`,{children:`RC WORLD BUILDER · ALPHA`})]})]}),(0,$.jsxs)(`div`,{className:G9.projectTitle,children:[(0,$.jsx)(`span`,{children:`ACTIVE MAP`}),(0,$.jsx)(`input`,{value:e.name,"aria-label":`Map name`,onChange:e=>ie(t=>({...t,name:e.target.value}))})]}),(0,$.jsxs)(`div`,{className:G9.toolbarActions,children:[(0,$.jsxs)(`button`,{type:`button`,className:G9.secondaryButton,onClick:de,children:[(0,$.jsx)(fo,{size:18}),`Save`]}),(0,$.jsx)(`button`,{type:`button`,className:G9.iconButton,title:`Import JSON`,onClick:()=>ee.current?.click(),children:(0,$.jsx)(Qo,{size:19})}),(0,$.jsx)(`button`,{type:`button`,className:G9.iconButton,title:`Export JSON`,onClick:fe,children:(0,$.jsx)(ao,{size:19})}),(0,$.jsx)(`input`,{ref:ee,className:G9.hiddenInput,type:`file`,accept:`application/json,.json`,onChange:pe}),(0,$.jsxs)(`button`,{type:`button`,className:G9.secondaryButton,onClick:he,children:[(0,$.jsx)(so,{size:18}),`Fly review`]}),(0,$.jsxs)(`button`,{type:`button`,className:G9.testButton,onClick:F,children:[(0,$.jsx)(Po,{size:18,weight:`fill`}),`Test drive`]})]})]}),(0,$.jsxs)(`section`,{className:G9.workspace,children:[(0,$.jsxs)(`aside`,{className:G9.libraryPanel,"aria-label":`Map asset library`,children:[(0,$.jsxs)(`div`,{className:G9.panelTabs,children:[(0,$.jsxs)(`button`,{type:`button`,"data-active":i===`assets`,onClick:()=>a(`assets`),children:[(0,$.jsx)(to,{size:17}),`Models`]}),(0,$.jsxs)(`button`,{type:`button`,"data-active":i===`textures`,onClick:()=>a(`textures`),children:[(0,$.jsx)(vo,{size:17}),`Textures`]})]}),i===`assets`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:G9.searchField,children:[(0,$.jsx)(wo,{size:17}),(0,$.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Search ${n9.length} models`})]}),(0,$.jsx)(`div`,{className:G9.categoryStrip,children:$3e.map(e=>(0,$.jsx)(`button`,{type:`button`,"data-active":o===e.id,onClick:()=>s(e.id),children:e.label},e.id))}),(0,$.jsxs)(`div`,{className:G9.selectedPreviewHeader,children:[(0,$.jsx)(`span`,{children:`SELECTED MODEL`}),(0,$.jsx)(`strong`,{children:te.label})]}),(0,$.jsx)(Y3e,{asset:te}),(0,$.jsxs)(`div`,{className:G9.assetList,children:[k.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:G9.assetRow,"data-active":e.id===te.id,onClick:()=>{d(e.id),r(`place`)},children:[(0,$.jsx)(X3e,{asset:e}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.label}),(0,$.jsxs)(`small`,{children:[e.category,` · `,e.footprint[0],` × `,e.footprint[1],` units`]})]})]},e.id)),k.length===0&&(0,$.jsx)(`p`,{className:G9.emptyState,children:`No models match this filter.`})]})]}):(0,$.jsx)(`div`,{className:G9.textureGrid,children:R4e.map(e=>(0,$.jsxs)(`figure`,{children:[(0,$.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`}),(0,$.jsx)(`figcaption`,{children:e.name})]},e.url))})]}),(0,$.jsxs)(`section`,{className:G9.canvasPanel,"aria-label":`Map canvas`,children:[(0,$.jsxs)(`div`,{className:G9.modeBar,children:[(0,$.jsxs)(`button`,{type:`button`,"data-active":n===`select`,onClick:()=>r(`select`),children:[(0,$.jsx)(ro,{size:18}),`Select `,(0,$.jsx)(`kbd`,{children:`V`})]}),(0,$.jsxs)(`button`,{type:`button`,"data-active":n===`place`,onClick:()=>r(`place`),children:[(0,$.jsx)(to,{size:18}),`Place `,(0,$.jsx)(`kbd`,{children:`B`})]}),(0,$.jsxs)(`button`,{type:`button`,"data-active":n===`route`,onClick:()=>r(`route`),children:[(0,$.jsx)(Ao,{size:18}),`Route `,(0,$.jsx)(`kbd`,{children:`P`})]}),(0,$.jsxs)(`div`,{className:G9.zoomControls,"aria-label":`Canvas zoom controls`,children:[(0,$.jsx)(`button`,{type:`button`,title:`Zoom out`,onClick:()=>j(b/1.2),children:`−`}),(0,$.jsxs)(`span`,{children:[Math.round(b*100),`%`]}),(0,$.jsx)(`button`,{type:`button`,title:`Zoom in`,onClick:()=>j(b*1.2),children:`+`})]}),(0,$.jsxs)(`span`,{className:G9.canvasReadout,children:[e.objects.length,` OBJECTS · `,e.route.length,` ROUTE NODES`]})]}),(0,$.jsxs)(`div`,{className:G9.mapStage,"data-mode":n,children:[(0,$.jsxs)(`svg`,{ref:E,viewBox:`${S.x-ye} ${J9(S.z)-ye} ${ve} ${ve}`,onPointerDown:oe,onPointerMove:ce,onPointerUp:me,onPointerLeave:me,onWheel:ue,role:`img`,"aria-label":`Top-down map editing canvas`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(`pattern`,{id:`minor-grid`,width:`10`,height:`10`,patternUnits:`userSpaceOnUse`,children:(0,$.jsx)(`path`,{d:`M 10 0 L 0 0 0 10`,className:G9.minorGrid})}),(0,$.jsxs)(`pattern`,{id:`major-grid`,width:`50`,height:`50`,patternUnits:`userSpaceOnUse`,children:[(0,$.jsx)(`rect`,{width:`50`,height:`50`,fill:`url(#minor-grid)`}),(0,$.jsx)(`path`,{d:`M 50 0 L 0 0 0 50`,className:G9.majorGrid})]})]}),(0,$.jsx)(`rect`,{className:G9.canvasGround,x:-_e,y:-_e,width:e.worldSize,height:e.worldSize}),(0,$.jsx)(`rect`,{className:G9.gridFill,x:-_e,y:-_e,width:e.worldSize,height:e.worldSize}),e.route.length>1&&(0,$.jsx)(`polyline`,{className:G9.routeCenter,points:be}),e.route.map((e,t)=>(0,$.jsxs)(`g`,{className:G9.routeNode,"data-route-node":!0,transform:`translate(${e.x} ${J9(e.z)})`,onPointerDown:e=>M(e,t),children:[(0,$.jsx)(`circle`,{r:`5.5`}),(0,$.jsx)(`text`,{y:`1.7`,children:t+1})]},`${e.x}-${e.z}-${t}`)),e.objects.map(e=>{let t=r9(e.assetId);if(!t)return null;let n=t.footprint[0]*e.scale*(e.scaleX??1),r=t.footprint[1]*e.scale*(e.scaleZ??1);return(0,$.jsxs)(`g`,{"data-map-object":!0,className:G9.mapObject,"data-selected":f.includes(e.id),transform:`translate(${e.x} ${J9(e.z)}) rotate(${e.rotation})`,onPointerDown:t=>se(t,e.id),children:[(0,$.jsx)(`rect`,{x:-n/2,y:-r/2,width:n,height:r,rx:`2`,style:{"--asset-color":t.swatch}}),(0,$.jsx)(`path`,{d:`M 0 ${-r/2+2} L 3 ${-r/2+7} L -3 ${-r/2+7} Z`})]},e.id)})]}),(0,$.jsxs)(`div`,{className:G9.scaleLegend,children:[(0,$.jsx)(`span`,{}),`50 world units`]}),(0,$.jsx)(`div`,{className:G9.modeHint,children:n===`place`?`Click to place ${te.label}`:n===`route`?`Click to append route nodes`:`Click and drag an object to move it`})]}),(0,$.jsxs)(`footer`,{className:G9.statusbar,children:[(0,$.jsx)(`span`,{className:G9.statusDot}),w,(0,$.jsxs)(`span`,{children:[`WORLD `,e.worldSize,` × `,e.worldSize]}),(0,$.jsx)(`span`,{children:`TOY SCALE ≈ 1:18`})]})]}),(0,$.jsxs)(`aside`,{className:G9.inspectorPanel,"aria-label":`Map inspector`,children:[(0,$.jsxs)(`div`,{className:G9.inspectorHeader,children:[(0,$.jsx)(`span`,{children:`INSPECTOR`}),(0,$.jsx)(`strong`,{children:O.length>1?`${O.length} objects selected`:ne?r9(ne.assetId)?.label:`Map settings`})]}),ne?(0,$.jsxs)(`div`,{className:G9.inspectorBody,children:[(0,$.jsx)(`p`,{className:G9.sectionLabel,children:`TRANSFORM`}),(0,$.jsxs)(`div`,{className:G9.fieldTriple,children:[(0,$.jsxs)(`label`,{children:[`X`,(0,$.jsx)(`input`,{type:`number`,step:`1`,value:ne.x,onChange:e=>le({x:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{children:[`Y`,(0,$.jsx)(`input`,{type:`number`,step:`0.25`,value:ne.y??0,onChange:e=>le({y:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{children:[`Z`,(0,$.jsx)(`input`,{type:`number`,step:`1`,value:ne.z,onChange:e=>le({z:Number(e.target.value)})})]})]}),(0,$.jsxs)(`div`,{className:G9.nudgeRow,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>le({y:Y9((ne.y??0)-.25)}),children:`Y −0.25`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>le({y:0}),children:`Y 0`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>le({y:Y9((ne.y??0)+.25)}),children:`Y +0.25`})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Elevation `,(0,$.jsxs)(`span`,{children:[(ne.y??0).toFixed(2),`u`]}),(0,$.jsx)(`input`,{type:`range`,min:`-20`,max:`40`,step:`0.25`,value:ne.y??0,onChange:e=>le({y:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Rotation X `,(0,$.jsxs)(`span`,{children:[ne.rotationX??0,`°`]}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`359`,value:ne.rotationX??0,onChange:e=>le({rotationX:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Rotation Y `,(0,$.jsxs)(`span`,{children:[ne.rotation,`°`]}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`359`,value:ne.rotation,onChange:e=>le({rotation:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Rotation Z `,(0,$.jsxs)(`span`,{children:[ne.rotationZ??0,`°`]}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`359`,value:ne.rotationZ??0,onChange:e=>le({rotationZ:Number(e.target.value)})})]}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`Scale `,(0,$.jsxs)(`span`,{children:[ne.scale.toFixed(2),`×`]}),(0,$.jsx)(`input`,{type:`range`,min:`0.25`,max:`3`,step:`0.05`,value:ne.scale,onChange:e=>le({scale:Number(e.target.value)})})]}),(0,$.jsxs)(`button`,{type:`button`,className:G9.dangerButton,onClick:()=>{N()},children:[(0,$.jsx)(Jo,{size:17}),`Delete selected`]})]}):(0,$.jsxs)(`div`,{className:G9.inspectorBody,children:[(0,$.jsx)(`p`,{className:G9.sectionLabel,children:`WORLD`}),(0,$.jsxs)(`label`,{className:G9.formField,children:[`World size `,(0,$.jsxs)(`span`,{children:[e.worldSize,` units`]}),(0,$.jsx)(`input`,{type:`range`,min:`160`,max:`800`,step:`20`,value:e.worldSize,onChange:e=>ie(t=>({...t,worldSize:Number(e.target.value)}))})]}),(0,$.jsxs)(`label`,{className:G9.textField,children:[`Map ID`,(0,$.jsx)(`input`,{value:e.id,onChange:e=>ie(t=>({...t,id:e.target.value.replace(/[^a-z0-9-]/g,`-`)}))})]}),(0,$.jsxs)(`label`,{className:G9.textField,children:[`Generation seed`,(0,$.jsx)(`input`,{type:`number`,value:e.seed,onChange:e=>ie(t=>({...t,seed:Number(e.target.value)}))})]}),(0,$.jsx)(`p`,{className:G9.sectionLabel,children:`ROUTE`}),(0,$.jsx)(`p`,{className:G9.helpText,children:`Roads are kit models. The route is only the racing line used by checkpoints and AI drivers.`}),(0,$.jsxs)(`label`,{className:G9.toggleField,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.routeClosed===!0,disabled:e.route.length<3,onChange:e=>ie(t=>({...t,routeClosed:e.target.checked}))}),`Connect last node to first`]}),(0,$.jsx)(`button`,{type:`button`,className:G9.wideButton,disabled:!re,onClick:ge,children:`Remove auto roads`}),(0,$.jsx)(`button`,{type:`button`,className:G9.wideButton,disabled:e.route.length===0,onClick:()=>ie(e=>({...e,route:e.route.slice(0,-1)})),children:`Remove last route node`}),(0,$.jsx)(`p`,{className:G9.helpText,children:`Route nodes are optional while editing. Add them when you are ready to test checkpoints and AI.`}),(0,$.jsxs)(`button`,{type:`button`,className:G9.resetButton,onClick:P,children:[(0,$.jsx)(Fa,{size:17}),`Restore starter map`]})]})]})]})]})}function i6e(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function a6e(e,t,n){return Math.max(t,Math.min(n,e))}function Y9(e){return Math.round(e*100)/100}var X9={shell:`_shell_1s4wv_1`,dropSurface:`_dropSurface_1s4wv_14`,toolbar:`_toolbar_1s4wv_59`,identity:`_identity_1s4wv_78`,toolGroup:`_toolGroup_1s4wv_118`,toolbarActions:`_toolbarActions_1s4wv_119`,assetActions:`_assetActions_1s4wv_162`,inspectorActions:`_inspectorActions_1s4wv_163`,saveButton:`_saveButton_1s4wv_173`,driveButton:`_driveButton_1s4wv_174`,navigationHelp:`_navigationHelp_1s4wv_185`,assetDock:`_assetDock_1s4wv_186`,inspector:`_inspector_1s4wv_163`,emptyInspector:`_emptyInspector_1s4wv_188`,panelHeader:`_panelHeader_1s4wv_207`,sectionTitle:`_sectionTitle_1s4wv_208`,searchField:`_searchField_1s4wv_269`,dragHint:`_dragHint_1s4wv_281`,assetResults:`_assetResults_1s4wv_297`,noAssets:`_noAssets_1s4wv_370`,objectId:`_objectId_1s4wv_422`,fieldGrid:`_fieldGrid_1s4wv_463`,wideField:`_wideField_1s4wv_470`,deleteButton:`_deleteButton_1s4wv_505`,statusBar:`_statusBar_1s4wv_539`},o6e={mode:`move`,snapEnabled:!0,dirty:!1,canUndo:!1,objectCount:0,status:`Loading 3D editor`,selection:null},s6e=[{id:`move`,label:`Move`,icon:Ua},{id:`rotate`,label:`Rotate`,icon:Na},{id:`scale`,label:`Scale`,icon:Za}];function c6e(){let[e,t]=(0,G.useState)(o6e),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(`street`),[o,s]=(0,G.useState)(`downtown-street-2lane`),[c,l]=(0,G.useState)(null);(0,G.useEffect)(()=>Y4e((e,n)=>{t(e),r(n)}),[]),(0,G.useEffect)(()=>{if(!c)return;let e=()=>l(null),t=t=>{t.code===`Escape`&&e()},r=e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},i=t=>{t.preventDefault();let r=t.dataTransfer?.getData(`application/x-yardline-map-asset`)||c;e(),r&&n?.addObjectAt(r,t.clientX,t.clientY)};return window.addEventListener(`dragover`,r),window.addEventListener(`drop`,i),window.addEventListener(`dragend`,e),window.addEventListener(`blur`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`dragover`,r),window.removeEventListener(`drop`,i),window.removeEventListener(`dragend`,e),window.removeEventListener(`blur`,e),window.removeEventListener(`keydown`,t)}},[n,c]);let u=(0,G.useMemo)(()=>{let e=i.trim().toLowerCase();return n9.filter(t=>!e||t.label.toLowerCase().includes(e)||t.category.toLowerCase().includes(e)).slice(0,8)},[i]);return(0,$.jsxs)(`div`,{className:X9.shell,"aria-label":`3D map editor`,children:[(0,$.jsxs)(`div`,{className:X9.dropSurface,"data-active":!!c,children:[(0,$.jsx)(`span`,{children:`DROP TO PLACE`}),(0,$.jsx)(`small`,{children:`The model will land at this map position`})]}),(0,$.jsxs)(`header`,{className:X9.toolbar,children:[(0,$.jsxs)(`div`,{className:X9.identity,children:[(0,$.jsx)(`span`,{children:`YL`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{children:`3D MAP EDITOR`}),(0,$.jsxs)(`small`,{children:[`CONSTRUCTION LOOP · `,e.objectCount,` OBJECTS`]})]})]}),(0,$.jsxs)(`div`,{className:X9.toolGroup,"aria-label":`Transform tools`,children:[s6e.map(({id:t,label:r,icon:i})=>(0,$.jsxs)(`button`,{type:`button`,"data-active":e.mode===t,disabled:!n,onClick:()=>n?.setMode(t),title:`${r} selected object`,children:[(0,$.jsx)(i,{size:18,weight:`bold`}),(0,$.jsx)(`span`,{children:r})]},t)),(0,$.jsxs)(`button`,{type:`button`,"data-active":e.snapEnabled,disabled:!n,onClick:()=>n?.setSnapEnabled(!e.snapEnabled),title:`Toggle transform snapping`,children:[(0,$.jsx)(So,{size:18,weight:`bold`}),(0,$.jsx)(`span`,{children:`Snap`})]})]}),(0,$.jsxs)(`div`,{className:X9.toolbarActions,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!e.canUndo||!n,onClick:()=>void n?.undo(),title:`Undo`,children:(0,$.jsx)(Fa,{size:18,weight:`bold`})}),(0,$.jsx)(`button`,{type:`button`,disabled:!e.selection||!n,onClick:()=>void n?.duplicateSelected(),title:`Duplicate selected`,children:(0,$.jsx)(Ya,{size:18,weight:`bold`})}),(0,$.jsxs)(`button`,{type:`button`,className:X9.saveButton,disabled:!n,onClick:()=>n?.save(),children:[(0,$.jsx)(fo,{size:18,weight:`bold`}),(0,$.jsx)(`span`,{children:e.dirty?`Save changes`:`Saved`})]}),(0,$.jsxs)(`button`,{type:`button`,className:X9.driveButton,disabled:!n,onClick:()=>n?.testDrive(),children:[(0,$.jsx)(Po,{size:17,weight:`fill`}),(0,$.jsx)(`span`,{children:`Test drive`})]})]})]}),(0,$.jsxs)(`aside`,{className:X9.navigationHelp,children:[(0,$.jsx)(`span`,{children:`FLY + EDIT`}),(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`kbd`,{children:`WASD`}),` move · `,(0,$.jsx)(`kbd`,{children:`Q`}),(0,$.jsx)(`kbd`,{children:`E`}),` descend / rise · right-drag look`]}),(0,$.jsxs)(`p`,{children:[`Left-click object · `,(0,$.jsx)(`kbd`,{children:`F`}),` focus · `,(0,$.jsx)(`kbd`,{children:`Esc`}),` clear`]}),(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`kbd`,{children:`⌘S`}),` save · `,(0,$.jsx)(`kbd`,{children:`⌘Z`}),` undo · `,(0,$.jsx)(`kbd`,{children:`⌘D`}),` duplicate · `,(0,$.jsx)(`kbd`,{children:`Del`}),` remove`]}),(0,$.jsx)(`a`,{href:`./?tool=map-editor`,onClick:()=>n?.save(),children:`Open 2D editor`})]}),(0,$.jsx)(l6e,{query:i,chosenAssetId:o,visibleAssets:u,selection:e.selection,disabled:!n,onQueryChange:a,onChoose:s,onDragStart:(e,t)=>{n&&(s(e),l(e),t.dataTransfer.effectAllowed=`copy`,t.dataTransfer.setData(`application/x-yardline-map-asset`,e),t.dataTransfer.setData(`text/plain`,e))},onDragEnd:()=>l(null),onAdd:()=>void n?.addObject(o),onReplace:()=>void n?.replaceSelected(o)}),e.selection?(0,$.jsx)(u6e,{selection:e.selection,actions:n}):(0,$.jsxs)(`aside`,{className:X9.emptyInspector,children:[(0,$.jsx)($a,{size:25,weight:`duotone`}),(0,$.jsx)(`span`,{children:`NO OBJECT SELECTED`}),(0,$.jsx)(`strong`,{children:`Click a model in the world`}),(0,$.jsx)(`p`,{children:`Roads, houses, props, trees, and sidewalks can all be edited directly.`})]}),(0,$.jsxs)(`div`,{className:X9.statusBar,"data-dirty":e.dirty,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(`strong`,{children:e.dirty?`UNSAVED`:`DRAFT CURRENT`}),(0,$.jsx)(`p`,{children:e.status})]})]})}function l6e({query:e,chosenAssetId:t,visibleAssets:n,selection:r,disabled:i,onQueryChange:a,onChoose:o,onDragStart:s,onDragEnd:c,onAdd:l,onReplace:u}){return(0,$.jsxs)(`aside`,{className:X9.assetDock,children:[(0,$.jsxs)(`div`,{className:X9.panelHeader,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:`MODEL LIBRARY`}),(0,$.jsx)(`strong`,{children:`Place or replace`})]}),(0,$.jsx)(to,{size:20,weight:`duotone`})]}),(0,$.jsx)(`p`,{className:X9.dragHint,children:`Drag any model card directly onto the map.`}),(0,$.jsxs)(`label`,{className:X9.searchField,children:[(0,$.jsx)(wo,{size:16}),(0,$.jsx)(`input`,{value:e,onChange:e=>a(e.target.value),placeholder:`Search ${n9.length} models`})]}),(0,$.jsxs)(`div`,{className:X9.assetResults,children:[n.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:i,draggable:!i,"data-active":t===e.id,onClick:()=>o(e.id),onDragStart:t=>s(e.id,t),onDragEnd:c,title:`Drag onto the map to place`,children:[(0,$.jsx)(`i`,{style:{background:e.swatch}}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:e.label}),(0,$.jsxs)(`small`,{children:[e.category,` · `,e.footprint[0],` × `,e.footprint[1]]})]})]},e.id)),n.length===0&&(0,$.jsx)(`p`,{className:X9.noAssets,children:`No models match this search.`})]}),(0,$.jsxs)(`div`,{className:X9.assetActions,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:l,children:[(0,$.jsx)(Io,{size:16,weight:`bold`}),`Place new`]}),(0,$.jsxs)(`button`,{type:`button`,disabled:i||!r,onClick:u,children:[(0,$.jsx)(Wo,{size:16,weight:`bold`}),`Replace`]})]})]})}function u6e({selection:e,actions:t}){return(0,$.jsxs)(`aside`,{className:X9.inspector,children:[(0,$.jsxs)(`div`,{className:X9.panelHeader,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{children:`SELECTED OBJECT`}),(0,$.jsx)(`strong`,{children:e.label})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t?.deselect(),"aria-label":`Clear selection`,children:`×`})]}),(0,$.jsx)(`p`,{className:X9.objectId,children:e.id}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:X9.sectionTitle,children:[(0,$.jsx)(`span`,{children:`POSITION`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>t?.frameSelected(),children:[(0,$.jsx)($a,{size:15}),`Focus`]})]}),(0,$.jsxs)(`div`,{className:X9.fieldGrid,children:[(0,$.jsx)(Z9,{label:`X`,value:e.x,onChange:e=>t?.updateSelected({x:e})}),(0,$.jsx)(Z9,{label:`Y`,value:e.y,onChange:e=>t?.updateSelected({y:e})}),(0,$.jsx)(Z9,{label:`Z`,value:e.z,onChange:e=>t?.updateSelected({z:e})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:X9.sectionTitle,children:[(0,$.jsx)(`span`,{children:`ROTATION`}),(0,$.jsx)(`small`,{children:`LOCAL AXES`})]}),(0,$.jsxs)(`div`,{className:X9.fieldGrid,children:[(0,$.jsx)(Z9,{label:`X`,value:e.rotationX,step:5,onChange:e=>t?.updateSelected({rotationX:e})}),(0,$.jsx)(Z9,{label:`Y`,value:e.rotation,step:5,onChange:e=>t?.updateSelected({rotation:e})}),(0,$.jsx)(Z9,{label:`Z`,value:e.rotationZ,step:5,onChange:e=>t?.updateSelected({rotationZ:e})})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:X9.sectionTitle,children:[(0,$.jsx)(`span`,{children:`SCALE`}),(0,$.jsx)(`small`,{children:`LOCAL AXES`})]}),(0,$.jsxs)(`div`,{className:X9.fieldGrid,children:[(0,$.jsx)(Z9,{label:`X`,value:e.scaleX,step:.05,onChange:e=>t?.updateSelected({scaleX:e})}),(0,$.jsx)(Z9,{label:`Y`,value:e.scaleY,step:.05,onChange:e=>t?.updateSelected({scaleY:e})}),(0,$.jsx)(Z9,{label:`Z`,value:e.scaleZ,step:.05,onChange:e=>t?.updateSelected({scaleZ:e})})]})]}),(0,$.jsxs)(`div`,{className:X9.inspectorActions,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void t?.duplicateSelected(),children:[(0,$.jsx)(Ya,{size:16}),`Duplicate`]}),(0,$.jsxs)(`button`,{type:`button`,className:X9.deleteButton,onClick:()=>t?.deleteSelected(),children:[(0,$.jsx)(Jo,{size:16}),`Delete`]})]})]})}function Z9({label:e,value:t,step:n=.5,wide:r=!1,onChange:i}){return(0,$.jsxs)(`label`,{className:r?X9.wideField:void 0,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`input`,{type:`number`,value:t,step:n,onChange:e=>i(Number(e.target.value))})]})}var d6e={masterVolume:.84,musicVolume:.62,graphicsQuality:`balanced`,steeringAssist:!0},f6e=new URLSearchParams(window.location.search).get(`map`),Q9=new URLSearchParams(window.location.search).get(`fly`)===`1`,$9=D9(f6e).metadata,p6e=w3e.map(({metadata:e})=>({id:e.id,name:e.name,location:e.location,length:`${e.lengthMeters} m`,difficulty:e.difficulty[0].toUpperCase()+e.difficulty.slice(1),surface:e.surfaces.map(e=>e[0].toUpperCase()+e.slice(1)).join(` / `),description:e.description})),m6e={phase:`booting`,speedKph:0,lap:1,totalLaps:3,position:1,racers:8,elapsedMs:0,bestLapMs:null,currentLapMs:0,countdown:null,checkpoint:1,checkpointCount:11,airborne:!1,wrongWay:!1,surface:`asphalt`,boost:0,direction:`straight`},h6e=e=>e===`countdown`?`countdown`:e===`finished`?`finished`:e===`menu`||e===`booting`?`grid`:`racing`;function g6e(){let e=(0,G.useRef)(null),t=(0,G.useRef)(null),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(`booting`),[o,s]=(0,G.useState)(m6e),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(d6e),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)({mode:`single-race`,laps:3,carCount:8,carId:`sports-car`,carName:`Sports Car`,trackId:$9.id,trackName:$9.name}),[v]=(0,G.useState)(()=>matchMedia(`(max-width: 900px)`).matches);(0,G.useEffect)(()=>{if(!e.current)return;let n=new M3e(e.current,{onReady:()=>r(!0),onPhaseChange:e=>a(e),onTelemetry:s,onResult:l,onPowerup:(e,t=0,n=!1)=>p(e?{name:e,charges:t,rolling:n}:null),onError:e=>h(e.message)});return t.current=n,n.initialize(),()=>{n.dispose(),t.current=null}},[]);let y=(0,G.useCallback)((e=g)=>{_(e),l(null),t.current?.startRace({laps:e.laps,carId:e.carId,mapId:e.trackId})},[g]),b=(0,G.useCallback)(()=>{l(null),t.current?.returnToMenu()},[]),x=(0,G.useCallback)(e=>{let n=t.current;n?.setTouchDrive(e.throttle,e.steering),n?.setTouchBrake(e.brake),n?.setTouchHandbrake(e.handbrake)},[]),S=(0,G.useCallback)(e=>{d(n=>{let r={...n,...e};return e.graphicsQuality&&t.current?.setGraphicsQuality(e.graphicsQuality),r})},[]),C=[`countdown`,`racing`,`paused`,`finished`].includes(i),w=o.checkpointCount>0?o.checkpoint===0?1:o.checkpoint/o.checkpointCount:0;return(0,$.jsxs)(`main`,{className:`game-shell`,"data-phase":i,"data-review-mode":Q9||void 0,children:[(0,$.jsx)(`canvas`,{ref:e,className:`game-canvas`,"aria-label":Q9?`Construction Loop fly review`:`Yardline RC racing game`,tabIndex:Q9?0:-1}),!n&&!m&&(0,$.jsxs)(`section`,{className:`loading-screen`,"aria-live":`polite`,children:[(0,$.jsx)(F3e,{}),(0,$.jsx)(`div`,{className:`loading-track`,children:(0,$.jsx)(`span`,{})}),(0,$.jsx)(`p`,{children:`Preparing ${$9.name}`})]}),m&&(0,$.jsxs)(`section`,{className:`error-screen`,role:`alert`,children:[(0,$.jsx)(es,{size:34,weight:`duotone`}),(0,$.jsx)(`span`,{children:`Runtime unavailable`}),(0,$.jsx)(`h1`,{children:`The workshop could not open.`}),(0,$.jsx)(`p`,{children:m}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:`Try again`})]}),n&&i===`menu`&&!Q9&&(0,$.jsx)(J3e,{babylonPreview:!0,initialTrackId:$9.id,tracks:p6e,onStartRace:y,onPreviewChange:({mode:e,carId:n})=>t.current?.setFrontendPreview(e,n)}),n&&Q9&&(0,$.jsx)(c6e,{}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R3e,{phase:h6e(i),position:o.position,racerCount:o.racers,lap:o.lap,totalLaps:o.totalLaps,lapProgress:w,speedKph:o.speedKph,elapsedMs:o.elapsedMs,bestLapMs:o.bestLapMs??void 0,currentLapMs:o.currentLapMs,boost:o.boost,direction:o.direction,powerup:f??void 0,alert:o.wrongWay?`WRONG WAY`:o.airborne?`AIR CONTROL`:o.surface===`grass`?`LOW GRIP`:void 0,connection:`good`,onPause:()=>t.current?.togglePause()}),(0,$.jsx)(z3e,{visible:i===`countdown`,value:o.countdown===null?`READY`:o.countdown||`GO`,subtitle:g.trackName}),(0,$.jsx)(W3e,{disabled:i!==`racing`,alwaysVisible:v,onControlsChange:x,powerupLabel:f?.name??`No power-up`,powerupCharges:f?.charges??0,onUsePowerup:()=>t.current?.usePowerup(),onResetCar:()=>t.current?.requestReset()}),(0,$.jsx)(U3e,{open:i===`paused`,settings:u,onSettingsChange:S,onResume:()=>t.current?.togglePause(),onRestart:()=>y(),onQuit:b}),(0,$.jsx)(V3e,{open:i===`finished`,entries:c?[{id:`local-player`,name:`Rookie 17`,carName:g.carName,timeMs:c.totalTimeMs,points:240,isLocal:!0}]:[],status:c?`ready`:`loading`,onRematch:()=>y(),onContinue:b})]})]})}function _6e(){return window.location.pathname===`/map-editor`||new URLSearchParams(window.location.search).get(`tool`)===`map-editor`?(0,$.jsx)(r6e,{}):(0,$.jsx)(g6e,{})}(0,Gi.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(G.StrictMode,{children:(0,$.jsx)(_6e,{})}));export{cie as $,Kj as A,Qk as B,SM as C,Hu as Ct,sM as D,lM as E,$ye as F,jk as G,Wk as H,tbe as I,yk as J,Ek as K,zve as L,Lj as M,Fj as N,nM as O,jj as P,vv as Q,KA as R,EM as S,Wu as St,mM as T,Su as Tt,Bk as U,qk as V,Pk as W,Hae as X,Ev as Y,Wae as Z,fP as _,$g as _t,aK as a,j_ as at,YM as b,Wg as bt,YG as c,T_ as ct,NH as d,__ as dt,V_ as et,DH as f,m_ as ft,dL as g,n_ as gt,yB as h,a_ as ht,oAe as i,N_ as it,Vj as j,eM as k,GG as l,C_ as lt,EH as m,c_ as mt,wK as n,L_ as nt,nK as o,k_ as ot,OH as p,d_ as pt,Ck as q,cAe as r,F_ as rt,$G as s,D_ as st,w2 as t,z_ as tt,FH as u,x_ as ut,_Se as v,Xg as vt,bM as w,Au as wt,WM as x,Bg as xt,ZM as y,qg as yt,tA as z}; \ No newline at end of file