@babylonjs/lite 1.39.0 → 1.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var NoA=Object.defineProperty,b=(A,e,t)=>()=>{if(t)throw t[0];try{return A&&(e=A(A=0)),e}catch(g){throw t=[g],g}},H=(A,e)=>{let t={};for(var g in A)NoA(t,g,{get:A[g],enumerable:!0});return e||NoA(t,Symbol.toStringTag,{value:"Module"}),t};function LPA(A){const e="ownerDocument"in A?A.ownerDocument:A.document,t=e.defaultView;if(!t)throw new Error("Keyboard input requires a document with a window.");const g=new Set,I={keys:g},o=()=>g.clear(),C=s=>{const B=s.code;B&&g.add(B)},r=s=>{g.delete(s.code)},n=()=>{e.hidden&&o()};return A.addEventListener("keydown",C,!0),A.addEventListener("blur",o,!0),t.addEventListener("keyup",r,!0),t.addEventListener("blur",o),e.addEventListener("visibilitychange",n),I._dispose=()=>{A.removeEventListener("keydown",C,{capture:!0}),A.removeEventListener("blur",o,{capture:!0}),t.removeEventListener("keyup",r,{capture:!0}),t.removeEventListener("blur",o),e.removeEventListener("visibilitychange",n),o()},I}function YPA(A,e){return A.keys.has(e)}function xPA(A){const e=A._dispose;A._dispose=void 0,e?.()}function GoA(A){A.deltaX=A.deltaY=A.wheelX=A.wheelY=A.wheelZ=A.wheelDeltaMode=0}function JPA(A){const e=A.ownerDocument,t=e.defaultView;if(!t)throw new Error("Pointer input requires a document with a window.");const g={x:0,y:0,deltaX:0,deltaY:0,wheelX:0,wheelY:0,wheelZ:0,wheelDeltaMode:0,buttons:0,pointerId:null,pointerType:""};let I=null,o=null,C="",r=0,n=0;const s=()=>{I=o=g.pointerId=null,C=g.pointerType="",g.buttons=0,GoA(g)},B=D=>D.composedPath().includes(A),Q=(D,_)=>{const y=A.getBoundingClientRect();g.x=D.clientX-y.left,g.y=D.clientY-y.top,_&&(e.pointerLockElement===A?(g.deltaX+=D.movementX,g.deltaY+=D.movementY):o===D.pointerId&&C===D.pointerType&&(g.deltaX+=D.clientX-r,g.deltaY+=D.clientY-n)),o=g.pointerId=D.pointerId,C=g.pointerType=D.pointerType,g.buttons=D.buttons,r=D.clientX,n=D.clientY},E=D=>{D.isPrimary&&B(D)&&(I===null||I===D.pointerId)&&(I=D.pointerId,Q(D,!1))},c=D=>{D.isPrimary&&(I===null?B(D)||e.pointerLockElement===A:I===D.pointerId)&&(Q(D,!0),I=D.buttons===0?null:D.pointerId)},l=D=>{I===D.pointerId&&(Q(D,!0),I=null)},u=D=>{I===D.pointerId&&s()},p=D=>{g.wheelDeltaMode!==D.deltaMode&&(g.wheelX=g.wheelY=g.wheelZ=0),g.wheelDeltaMode=D.deltaMode,g.wheelX+=D.deltaX,g.wheelY+=D.deltaY,g.wheelZ+=D.deltaZ},d=()=>{e.hidden&&s()},f=[["pointerdown",E],["pointermove",c],["pointerup",l],["pointercancel",u],["lostpointercapture",u]];for(const[D,_]of f)t.addEventListener(D,_,{capture:!0,passive:!0});return A.addEventListener("wheel",p,{passive:!0,capture:!0}),A.addEventListener("blur",s),t.addEventListener("blur",s),e.addEventListener("visibilitychange",d),e.addEventListener("pointerlockchange",s),g._dispose=()=>{for(const[D,_]of f)t.removeEventListener(D,_,{capture:!0});A.removeEventListener("wheel",p,{capture:!0}),A.removeEventListener("blur",s),t.removeEventListener("blur",s),e.removeEventListener("visibilitychange",d),e.removeEventListener("pointerlockchange",s),s()},g}function HPA(A){const e=A._dispose;A._dispose=void 0,e?.()}function TPA(A=0){if(!Number.isInteger(A)||A<0)throw new RangeError("Gamepad index must be a nonnegative integer.");if(typeof navigator>"u"||typeof navigator.getGamepads!="function")return null;let e;try{e=navigator.getGamepads()}catch{return null}const t=e[A];return t?.connected?{id:t.id,index:t.index,mapping:t.mapping,timestamp:t.timestamp,axes:Array.from(t.axes),buttons:Array.from(t.buttons,({value:g,pressed:I,touched:o})=>({value:g,pressed:I,touched:o}))}:null}function qPA(A){FH=A}function m(A,...e){const t=new Error(FH?.(A,e)??`#${A}`);throw t.lite=e,t}var FH,rA=b((()=>{FH=null})),CA,Zo,gt,Ho,l1,Tv,Te,qv,Cr,To,VA=b((()=>{CA=Float32Array,Zo=Float64Array,gt=Uint32Array,Ho=Int32Array,l1=Uint16Array,Tv=Int16Array,Te=Uint8Array,qv=Int8Array,Cr=Uint8ClampedArray,To=DataView}));function PPA(){return new CA(16)}function bg(){return(boA??PPA)()}function kH(){return bg()}function OPA(A){boA=A}var boA,Ii=b((()=>{VA()})),_A,iA,DA,RC,ZA=b((()=>{_A=globalThis.GPUTextureUsage,iA=globalThis.GPUBufferUsage,DA=globalThis.GPUShaderStage,RC=globalThis.GPUColorWrite}));function FoA(A){const e=A.size;return"canvas"in e?e.canvas:e}function Pv(A){return{_descriptor:A,_resolveSize:FoA,_colorTexture:null,_colorView:null,_depthTexture:null,_depthView:null,_width:0,_height:0}}function yI(A){const e=Pv(A);return"surface"in A.size&&(u1(A),e._resolveSize=u1),e}function sI(A,e){if(A._eager){A._syncEager?.(e);return}Bg(A);const t=A._descriptor,g=(A._resolveSize??FoA)(t);A._width=g.width,A._height=g.height;const I=e._device;t.format&&(A._colorTexture=I.createTexture(KH(t,g,t.format,_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING|_A.COPY_SRC|_A.COPY_DST)),A._colorView=A._colorTexture.createView()),t.dFormat&&(A._depthTexture=I.createTexture(KH(t,g,t.dFormat,_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING)),A._depthView=A._depthTexture.createView())}function KH(A,e,t,g){return{label:A.lbl,size:e,format:t,sampleCount:A.samples,usage:g}}function Bg(A){if(!A||A._eager&&!A._disposeAttachments)return;const e=A._colorTexture,t=A._depthTexture;if(A._colorTexture=A._depthTexture=null,A._colorView=A._depthView=null,A._width=A._height=0,A._disposeAttachments)A._disposeAttachments(e,t);else try{e?.destroy()}finally{A._ownsDepthTexture!==!1&&t?.destroy()}}function u1(A){const e=A.size;if("surface"in e){const t=e.scale;(!Number.isFinite(t)||t<=0)&&m(61,t);const g=e.surface.canvas;return{width:Math.floor(g.width*t)||1,height:Math.floor(g.height*t)||1}}return"canvas"in e?e.canvas:e}var Fg=b((()=>{rA(),ZA()})),vH,UH,LH=b((()=>{vH="1.39.0",UH=`Babylon Lite v${vH}`}));function XF(A){return"clientWidth"in A}function VPA(A){return A.endsWith("-srgb")?A:`${A}-srgb`}function jPA(A,e,t){const g=koA(A,e,t);return A._surfaces.push(g),Vv(g),Ov(g),g}function koA(A,e,t){const g=e.getContext("webgpu");g||m(62),XF(e)&&e.setAttribute("data-engine",UH);const I=t?.format??navigator.gpu.getPreferredCanvasFormat(),o=t?.srgb?VPA(I):I,C=t?.alphaMode??"opaque";g.configure({device:A._device,format:I,alphaMode:C,viewFormats:[o]});const r=t?.msaaSamples===1?1:4,n=Pv({lbl:"swapchain",format:o,samples:1,size:{width:0,height:0}});return n._eager=!0,{engine:A,canvas:e,format:o,msaaSamples:r,scRT:n,maxDevicePixelRatio:t?.maxDevicePixelRatio??1/0,_uniqueId:KoA++,_context:g,_configureFormat:I,_alphaMode:C,_renderingContexts:[]}}function Ov(A){const e=A._context.getCurrentTexture(),t=A.scRT;t._colorTexture=e,t._colorView=e.createView({format:A.format}),t._width=e.width,t._height=e.height}function Vv(A){const e=A.canvas;if(!XF(e))return;const t=A._w??e.clientWidth,g=A._h??e.clientHeight;if(!(t>0&&g>0))return;const I=Math.min(globalThis.devicePixelRatio||1,A.maxDevicePixelRatio);YH(A,t*I|0,g*I|0)}function YH(A,e,t){const g=A.canvas,I=e|0,o=t|0;if(I>0&&o>0&&!(I===g.width&&o===g.height)){g.width=I,g.height=o,A.scRT._width=I,A.scRT._height=o;for(const C of A._renderingContexts)C._resize?.()}}function WPA(A){A===A.engine&&m(63),A._renderingContexts.length=0,A._ro?.disconnect(),A._context.unconfigure();const e=A.engine._surfaces,t=e.indexOf(A);t!==-1&&e.splice(t,1)}var KoA,$a=b((()=>{rA(),Fg(),LH(),KoA=1})),zPA=H({MAT4_STORAGE_F64_BUILD_TAG:()=>xH,allocateF64Mat4:()=>voA});function voA(){return new Zo(16)}var xH,ZPA=b((()=>{VA(),xH="@@MAT4_STORAGE_F64@@",voA[xH]=!0}));function UoA(A){if(!Number.isFinite(A)||A<1)throw new Error(`setMaxLights: expected positive integer, got ${A}`);Ht=A|0}var Ht,EI=b((()=>{Ht=16})),XPA=H({applyLightFoOffset:()=>AOA,getFloatingOriginOffset:()=>LoA,lightFoVersion:()=>$PA,wrapRenderableForFO:()=>eOA});function LoA(A){const e=A.camera;if(!e)return{x:0,y:0,z:0};const t=e.worldMatrix;return{x:t[12],y:t[13],z:t[14]}}function $PA(A){const e=A.camera,t=e?e.worldMatrixVersion:-1,g=YoA??=new WeakMap;let I=g.get(A);return I?(I[0]!==e||I[1]!==t)&&(I[0]=e,I[1]=t,I[2]++):g.set(A,I=[e,t,0]),I[2]}function AOA(A,e){const t=e.camera?.worldMatrix;if(!t)return;const g=t[12],I=t[13],o=t[14];let C=0;for(const r of e.lights){if(C>=Ht)break;if(!r._writeLightUbo)continue;const n=4+C*16,s=A[n+3];if(s!==1&&s!==3){const B=r.worldMatrix;A[n]=B[12]-g,A[n+1]=B[13]-I,A[n+2]=B[14]-o}C++}}function eOA(A,e,t){let g=-1,I;return()=>{const o=e.camera,C=o?o.worldMatrixVersion:-1;(C!==g||o!==I)&&(t(),g=C,I=o),A()}}var YoA,xoA=b((()=>{EI(),YoA=null})),tOA=H({makePackMeshWorld:()=>gOA,packMat4IntoF32WithOffset:()=>JH});function JH(A,e,t,g,I,o,C){const r=e,n=g,s=t;A[s+0]=r[n+0],A[s+1]=r[n+1],A[s+2]=r[n+2],A[s+3]=r[n+3],A[s+4]=r[n+4],A[s+5]=r[n+5],A[s+6]=r[n+6],A[s+7]=r[n+7],A[s+8]=r[n+8],A[s+9]=r[n+9],A[s+10]=r[n+10],A[s+11]=r[n+11],A[s+12]=r[n+12]-I,A[s+13]=r[n+13]-o,A[s+14]=r[n+14]-C,A[s+15]=r[n+15]}function gOA(A){return(e,t,g,I)=>{const o=A.camera;if(!o){JH(e,t,g,I,0,0,0);return}const C=o.worldMatrix;JH(e,t,g,I,C[12],C[13],C[14])}}var IOA=b((()=>{})),iOA=H({createGpuFrameTimer:()=>oOA,destroyGpuFrameTimer:()=>sOA,gpuFrameTimerBegin:()=>COA,gpuFrameTimerEnd:()=>rOA,gpuFrameTimerResolve:()=>nOA,gpuTimingSupportedFor:()=>JoA});function JoA(A){return A.features.has("timestamp-query")}function oOA(A){return JoA(A)?{device:A,markerPipeline:A.createComputePipeline({layout:"auto",compute:{module:A.createShaderModule({code:"@compute @workgroup_size(1) fn main() {}"}),entryPoint:"main"}}),querySet:A.createQuerySet({type:"timestamp",count:2}),resolveBuf:A.createBuffer({size:16,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),pool:[],lastMs:0,inFlight:0}:null}function COA(A,e){const t=e.beginComputePass({timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:0}});t.setPipeline(A.markerPipeline),t.dispatchWorkgroups(1),t.end()}function rOA(A,e){const t=e.beginComputePass({timestampWrites:{querySet:A.querySet,endOfPassWriteIndex:1}});t.setPipeline(A.markerPipeline),t.dispatchWorkgroups(1),t.end()}function nOA(A){if(A.inFlight>3)return;const e=A.device,t=A.pool.pop()??e.createBuffer({size:16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),g=e.createCommandEncoder();g.resolveQuerySet(A.querySet,0,2,A.resolveBuf,0),g.copyBufferToBuffer(A.resolveBuf,0,t,0,16),e.queue.submit([g.finish()]),A.inFlight++,t.mapAsync(GPUMapMode.READ).then(()=>{const I=new BigInt64Array(t.getMappedRange()),o=Number(I[1]-I[0])/1e6;o>=0&&o<5e3&&(A.lastMs=A.lastMs>0?A.lastMs*.8+o*.2:o),t.unmap(),A.pool.push(t),A.inFlight--},()=>{A.inFlight--})}function sOA(A){A.querySet.destroy(),A.resolveBuf.destroy();for(const e of A.pool)e.destroy();A.pool.length=0}var BOA=b((()=>{}));function q1(){_Q=_Q+1|0}function QOA(A){return A._renderingContexts}function aOA(A){if(!A||typeof A._kind!="string")throw new TypeError("Invalid RenderingContext: missing internal kind discriminator");return A._kind}function $F(A,e){return A._renderingContexts.indexOf(e)!==-1}function DQ(A,e){return A._renderingContexts.indexOf(e)!==-1?!1:(A._renderingContexts.push(e),!0)}function AE(A,e){const t=A._renderingContexts,g=t.indexOf(e);return g===-1?!1:(t.splice(g,1),!0)}function EOA(A){const e=mC?.deviceFeatures;mC=A,mC.deviceFeatures=e}function HoA(){return mC?mC():{}}function ToA(A){return VoA.filter(e=>A.features.has(e))}function cOA(A){const e=mC??(()=>({}));e.deviceFeatures=A,mC=e}async function qoA(A,e){const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance",...mC?mC():{}});t||m(50);const g=mC?.deviceFeatures?.(t,e)??ToA(t),I=await t.requestDevice({requiredFeatures:g,requiredLimits:e?.requiredLimits});console.log(`${UH} - WebGPU engine`);const o=!!e?.useHighPrecisionMatrix,C=!!e?.useFloatingOrigin;if(C&&!o&&m(51),o){const{allocateF64Mat4:c}=await Promise.resolve().then(()=>(ZPA(),zPA));OPA(c)}let r,n,s,B;if(C){const[{wrapRenderableForFO:c,lightFoVersion:l,applyLightFoOffset:u},{makePackMeshWorld:p}]=await Promise.all([Promise.resolve().then(()=>(xoA(),XPA)),Promise.resolve().then(()=>(IOA(),tOA))]);r=c,n=p,s=l,B=u}const Q={_device:I},E=[Q];return Object.assign(Q,{engine:Q,surfaces:E,_surfaces:E,_device:I,_options:e,drawCallCount:0,gpuFrameTimeMs:0,useHighPrecisionMatrix:o,useFloatingOrigin:C,_animFrameId:0,_renderFn:null,_currentEncoder:void 0,_currentDelta:0,_cbs:[],_wrapRenderableForFO:r,_makePackMeshWorld:n,_lightFoVersion:s,_applyLightFoOffset:B},koA(Q,A,e)),Vv(Q),Ov(Q),Q}function HH(A){for(const e of A.surfaces)Vv(e)}function lOA(A,e,t){YH(A,e,t)}function jv(A){const e=A.canvas;return{width:e.width,height:e.height}}function A3(A){return new Promise(e=>{let t=!0,g=0;A._renderFn=I=>{const o=t?0:g>0?I-g:16.667;g=I,HH(A),PoA(A,o),t&&(t=!1,e()),A._renderFn&&(A._animFrameId=requestAnimationFrame(A._renderFn))},A._animFrameId=requestAnimationFrame(A._renderFn)})}function uOA(A){return A._device.queue.onSubmittedWorkDone()}function Wv(A){A._animFrameId&&cancelAnimationFrame(A._animFrameId),A._animFrameId=0,A._renderFn=null,A._flushGpuRetirements?.(A)}function pOA(A,e,t=A.surfaces){if(t!==A.surfaces)for(let g=t.length;g--;)t[g].engine!==A&&m(52);PoA(A,e,t)}function PoA(A,e,t=A._surfaces){let g=0;for(let C=t.length;C--;)g+=t[C]._renderingContexts.length;if(!g)return A.drawCallCount=0,A._flushGpuRetirements?.(A);const I=A._device.createCommandEncoder({label:"frame"});A._currentEncoder=I,A._currentDelta=e;let o=!1;try{A._gpuTimerBegin?.(I),g=0;for(let r=0;r<t.length;r++){const n=t[r];n._capturePreFrame?.(n),Ov(n);const s=n._renderingContexts;for(let B=0;B<s.length;B++){const Q=s[B];Q._update(),g+=Q._drawCallsPre+Q._record()}}const C=A._currentEncoder;for(let r=0;r<t.length;r++){const n=t[r];n._captureService?.(n,C)}A._gpuTimerEnd?.(C),A._cbs[0]=C.finish(),A._device.queue.submit(A._cbs),o=!0,A._flushGpuRetirements?.(A),A.drawCallCount=g,A._gpuTimerResolve?.()}finally{A._currentEncoder=void 0,A._finishOptionalFrame?.(o)}}function OoA(A){return A._device.features.has("timestamp-query")}function dOA(A,e){if(!e){A._gpuTimerWanted=!1,A.gpuFrameTimeMs=0,A._gpuTimerBegin=void 0,A._gpuTimerEnd=void 0,A._gpuTimerResolve=A._gpuTaskTimerResolve;return}OoA(A)&&(A._gpuTimerWanted=!0,Promise.resolve().then(()=>(BOA(),iOA)).then(({createGpuFrameTimer:t,gpuFrameTimerBegin:g,gpuFrameTimerEnd:I,gpuFrameTimerResolve:o})=>{A._gpuTimer===void 0&&(A._gpuTimer=t(A._device));const C=A._gpuTimer;C&&A._gpuTimerWanted&&(A._gpuTimerBegin=r=>g(C,r),A._gpuTimerEnd=r=>I(C,r),A._gpuTimerResolve=()=>{o(C),A.gpuFrameTimeMs=C.lastMs,A._gpuTaskTimerResolve?.()})}))}var _Q,mC,VoA,hI=b((()=>{rA(),Ii(),$a(),LH(),_Q=0,mC=null,VoA=["float32-filterable","texture-compression-astc","texture-compression-bc","texture-compression-etc2","texture-compression-unaligned","timestamp-query","primitive-index"]}));hI();function TH(A,e,t){if(!Number.isInteger(t))throw new RangeError("Rendering context index must be an integer.");const g=A._renderingContexts,I=g.indexOf(e);return I===-1?!1:(g.splice(I,1),g.splice(Math.max(0,Math.min(t,g.length)),0,e),!0)}rA();var joA=!1;function fOA(){joA||(joA=!0,cOA((A,e)=>{const t=ToA(A);for(const g of e?.requiredFeatures??[])A.features.has(g)||m(1012,g),t.includes(g)||t.push(g);return t}))}function DOA(A,e){return fOA(),qoA(A,e)}function WoA(A){const e=A._gpuEvents,t=A._device;e._device!==t&&(e._device?.removeEventListener("uncapturederror",e._onError),e._device=t,t.addEventListener("uncapturederror",e._onError),t.lost.then(g=>{if(e._device===t)for(const I of e._lost)I(g)}))}function zoA(A){let e=A._gpuEvents;if(!e){const t=new Set;e=A._gpuEvents={_errors:t,_lost:new Set,_device:null,_onError:g=>{const I=g.error;for(const o of t)o(I)}},A._attachGpuEvents=WoA}return WoA(A),e}function _OA(A,e){const t=zoA(A);return t._errors.add(e),()=>{t._errors.delete(e)}}function yOA(A,e){const t=zoA(A);return t._lost.add(e),()=>{t._lost.delete(e)}}function ZoA(A){return A._device.limits}function hOA(A,e){return A._device.features.has(e)}function zv(A){oC(A.splice(0))}function oC(A){for(const e of A)try{e()}catch(t){console.error("GPU resource retirement failed.",t)}}function ag(A,e){A._flushGpuRetirements??=Zv,(A._retirements??=[]).push(e)}function XoA(A,e){if(!e.length)return;const t=e.slice();ag(A,()=>oC(t))}function Zv(A){const e=A._retirements;if(!e)return;A._retirements=null;const t=A._retiring??=new Set;t.add(e),queueMicrotask(()=>{A._device.queue.onSubmittedWorkDone().then(()=>{t.delete(e),zv(e)}).catch(()=>{})})}async function wOA(A){await Promise.resolve();do{Zv(A);const e=A._retiring,t=e?[...e]:[];await A._device.queue.onSubmittedWorkDone();for(const g of t)e.delete(g),zv(g)}while(A._retirements?.length||A._retiring?.size)}function $oA(A){const e=A._retirements,t=A._retiring;A._retirements=null,A._retiring=null,e&&zv(e),t?.forEach(zv)}var kg=b((()=>{}));hI(),kg();function SOA(A){$oA(A),Wv(A);const e=A._surfaces;for(const t of e)t._renderingContexts.length=0,t._ro?.disconnect(),t._context.unconfigure();e.length=0;try{A._disposeManagedResources?.(),A._disposeStorageBuffers?.()}finally{A._device.destroy()}}function MOA(A){const e={useHighPrecisionMatrix:!1,useFloatingOrigin:!1,drawCallCount:0,gpuFrameTimeMs:0,_animFrameId:0,_renderFn:null,_currentDelta:0,_cbs:[],_renderingContexts:[]};e.engine=e;const t=[e];return e.surfaces=t,e._surfaces=t,e}function A1A(A,e,t){A._currentDelta=t,e._update()}function ROA(A,e,t,g=1e3/60){for(let I=0;I<t;I++)A1A(A,e,g)}function Xv(A,e){e.hooks.size===0&&(A._gpuTaskTimerResolve===e.dispatch&&(A._gpuTaskTimerResolve=void 0),A._gpuTimerResolve===e.dispatch&&(A._gpuTimerResolve=void 0),$v?.get(A)===e&&$v.delete(A))}function e3(A,e,t,g){const I=e==="frame"?A._currentEncoder:null;e==="frame"&&!I&&m(53);const o=$v??=new WeakMap;let C=o.get(A);if(!C){const n=new Set,s=(Q=A._currentEncoder,E=!0)=>{if(!(!Q||C.lastDispatchedEncoder===Q)){if(!E){for(const c of n)c.encoder===Q&&(n.delete(c),c.cancel?.());Xv(A,C);return}C.lastDispatchedEncoder=Q;for(const c of n){if(c.encoder&&c.encoder!==Q){n.delete(c),c.cancel?.();continue}c.encoder&&n.delete(c),c.run(Q)}Xv(A,C)}};C={hooks:n,dispatch:s,lastDispatchedEncoder:null},o.set(A,C);const B=A._gpuTaskTimerResolve;A._gpuTaskTimerResolve=s,(!A._gpuTimerResolve||A._gpuTimerResolve===B)&&(A._gpuTimerResolve=s)}const r={run:t,cancel:g,encoder:I};return C.hooks.add(r),I&&queueMicrotask(()=>{C.hooks.has(r)&&A._currentEncoder!==I&&(C.hooks.delete(r),g?.(),Xv(A,C))}),()=>{C.hooks.delete(r)&&Xv(A,C)}}var $v,A9=b((()=>{rA(),$v=null})),mOA=H({createGpuTaskTimer:()=>NOA,installGpuTaskTimer:()=>GOA});function NOA(A){return A.features.has("timestamp-query")?{device:A,querySet:A.createQuerySet({type:"timestamp",count:128}),resolveBuffer:A.createBuffer({size:1024,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),readbackPool:[],pendingReadbacks:new Set,records:[],wrappedGraphs:[],patchedContextLists:[],patchedSurfaceLists:[],taskCapacity:o1A,currentEncoder:null,patchedEncoderMethods:null,activeTaskTiming:null,nextQueryIndex:0,nextTaskIndex:0,frameIndex:0,lastPublishedFrameIndex:0,droppedTaskCount:0,inFlight:0,skipFrame:!1,disposed:!1}:null}function GOA(A,e,t){bOA(A,e._surfaces);for(const o of e.surfaces)e1A(A,o);const I=e3(e,"persistent",o=>{A.currentEncoder===o&&xOA(A,t)});return()=>{kOA(A,I),TOA(A)}}function bOA(A,e){for(const g of A.patchedSurfaceLists)if(g.list===e)return;const t=e.push;e.push=(...g)=>{const I=t.apply(e,g);for(const o of g)e1A(A,o);return I},A.patchedSurfaceLists.push({list:e,push:t})}function e1A(A,e){const t=e._renderingContexts;FOA(A,t);for(const g of t){const I=g1A(g);I&&t1A(A,I)}}function FOA(A,e){for(const g of A.patchedContextLists)if(g.list===e)return;const t=e.push;e.push=(...g)=>{const I=t.apply(e,g);for(const o of g){const C=g1A(o);C&&t1A(A,C)}return I},A.patchedContextLists.push({list:e,push:t})}function t1A(A,e){for(const I of A.wrappedGraphs)if(I.graph===e)return;const t=e.execute,g=()=>vOA(A,e);e.execute=g,A.wrappedGraphs.push({graph:e,execute:t})}function kOA(A,e){for(const t of A.patchedSurfaceLists)t.list.push=t.push;A.patchedSurfaceLists.length=0;for(const t of A.patchedContextLists)t.list.push=t.push;A.patchedContextLists.length=0;for(const t of A.wrappedGraphs)t.graph.execute=t.execute;A.wrappedGraphs.length=0,qH(A),e()}function g1A(A){const e=A,t=e._frameGraph??e.frameGraph;return KOA(t)?t:null}function KOA(A){return typeof A=="object"&&A!==null&&"_tasks"in A&&"execute"in A}function vOA(A,e){let t=0;for(const g of e._tasks)g.executionEnabled!==!1&&(t+=UOA(A,g));return t}function UOA(A,e){const t=e.engine._currentEncoder;A.currentEncoder!==t&&LOA(A,t);const g=A.nextTaskIndex++;if(A.skipFrame)return I1A(e);const I={beginQueryIndex:-1,endQueryIndex:-1,passCount:0,conflicted:!1,dropped:!1};A.activeTaskTiming=I;try{const o=I1A(e);return I.passCount>0&&!I.conflicted&&!I.dropped&&A.records.push({index:g,name:e.name,beginQueryIndex:I.beginQueryIndex,endQueryIndex:I.endQueryIndex}),o}finally{A.activeTaskTiming=null}}function I1A(A){if(A.execute)return A.execute();let e=0;for(const t of A._passes)e+=t._execute();return e}function LOA(A,e){qH(A),A.currentEncoder=e,A.patchedEncoderMethods=YOA(A,e),A.records.length=0,A.nextQueryIndex=0,A.nextTaskIndex=0,A.droppedTaskCount=0,A.skipFrame=A.inFlight>VH}function YOA(A,e){const t=e.beginRenderPass.bind(e),g=e.beginComputePass.bind(e),I=Object.getOwnPropertyDescriptor(e,"beginRenderPass"),o=Object.getOwnPropertyDescriptor(e,"beginComputePass");return Reflect.set(e,"beginRenderPass",C=>t(i1A(A,C)),e)||m(54),Reflect.set(e,"beginComputePass",C=>g(i1A(A,C)),e)||(PH(e,"beginRenderPass",I),m(55)),{encoder:e,beginRenderPass:I,beginComputePass:o}}function i1A(A,e){const t=A.activeTaskTiming;if(!t||t.conflicted||t.dropped)return e;if(e?.timestampWrites!==void 0)return t.conflicted=!0,e;const g=A.taskCapacity*2;if(t.passCount===0)return A.nextQueryIndex+2>g?(t.dropped=!0,A.droppedTaskCount++,e):(t.beginQueryIndex=A.nextQueryIndex++,t.endQueryIndex=A.nextQueryIndex++,t.passCount++,{...e,timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:t.beginQueryIndex,endOfPassWriteIndex:t.endQueryIndex}});if(A.nextQueryIndex>=g)return t.dropped=!0,A.droppedTaskCount++,e;t.endQueryIndex=A.nextQueryIndex++,t.passCount++;const I={querySet:A.querySet,endOfPassWriteIndex:t.endQueryIndex};return{...e,timestampWrites:I}}function qH(A){const e=A.patchedEncoderMethods;e&&(PH(e.encoder,"beginRenderPass",e.beginRenderPass),PH(e.encoder,"beginComputePass",e.beginComputePass)),A.currentEncoder=null,A.patchedEncoderMethods=null,A.activeTaskTiming=null}function PH(A,e,t){t?Object.defineProperty(A,e,t):Reflect.deleteProperty(A,e)}function xOA(A,e){if(A.disposed)return;A.frameIndex++;const t=A.records.slice(),g=t.length,I=A.nextQueryIndex,o=A.droppedTaskCount;if(A.records.length=0,A.nextQueryIndex=0,A.droppedTaskCount=0,qH(A),A.skipFrame||A.inFlight>VH)return;if(g===0){o>0&&OH(A,e,nr("available",!0,!0,A.frameIndex,[],o,0));return}const C=I*8,r=A.readbackPool.pop()??JOA(A),n=A.device.createCommandEncoder({label:"gpu-task-timing-resolve"});n.resolveQuerySet(A.querySet,0,I,A.resolveBuffer,0),n.copyBufferToBuffer(A.resolveBuffer,0,r,0,C),A.device.queue.submit([n.finish()]),A.inFlight++,A.pendingReadbacks.add(r),HOA(A,{buffer:r,byteLength:C,frameIndex:A.frameIndex,records:t,droppedTaskCount:o,publish:e})}function JOA(A){return A.device.createBuffer({size:A.taskCapacity*16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}async function HOA(A,e){const t=e.buffer;try{if(await Promise.resolve(),await t.mapAsync(GPUMapMode.READ,0,e.byteLength),A.disposed)return;const g=new BigUint64Array(t.getMappedRange(0,e.byteLength)),I=[];let o=null,C=null;for(const n of e.records){const s=g[n.beginQueryIndex],B=g[n.endQueryIndex];B>=s&&(I.push({index:n.index,name:n.name,durationMs:Number(B-s)/1e6}),o=o===null||s<o?s:o,C=C===null||B>C?B:C)}const r=o===null||C===null?0:Number(C-o)/1e6;t.unmap(),A.pendingReadbacks.delete(t),A.readbackPool.push(t),A.inFlight--,OH(A,e.publish,nr("available",!0,!0,e.frameIndex,I,e.droppedTaskCount,r))}catch(g){if(A.disposed)return;A.pendingReadbacks.delete(t),A.inFlight--,t.destroy(),OH(A,e.publish,nr("error",!0,!0,e.frameIndex,[],e.droppedTaskCount,0,qOA(g)))}}function OH(A,e,t){t.frameIndex>A.lastPublishedFrameIndex&&(A.lastPublishedFrameIndex=t.frameIndex,e(t))}function TOA(A){if(!A.disposed){A.disposed=!0,A.querySet.destroy(),A.resolveBuffer.destroy();for(const e of A.readbackPool)e.destroy();for(const e of A.pendingReadbacks)e.destroy();A.readbackPool.length=0,A.pendingReadbacks.clear(),A.inFlight=0}}function qOA(A){return A instanceof Error?A.message:String(A)}var o1A,VH,POA=b((()=>{rA(),A9(),s1A(),o1A=64,VH=3}));function $g(A,e,t,g,I,o){const C=t[g],r=t[g+1],n=t[g+2],s=t[g+3],B=t[g+4],Q=t[g+5],E=t[g+6],c=t[g+7],l=t[g+8],u=t[g+9],p=t[g+10],d=t[g+11],f=t[g+12],D=t[g+13],_=t[g+14],y=t[g+15];let w=I[o],S=I[o+1],R=I[o+2],M=I[o+3];A[e]=C*w+B*S+l*R+f*M,A[e+1]=r*w+Q*S+u*R+D*M,A[e+2]=n*w+E*S+p*R+_*M,A[e+3]=s*w+c*S+d*R+y*M,w=I[o+4],S=I[o+5],R=I[o+6],M=I[o+7],A[e+4]=C*w+B*S+l*R+f*M,A[e+5]=r*w+Q*S+u*R+D*M,A[e+6]=n*w+E*S+p*R+_*M,A[e+7]=s*w+c*S+d*R+y*M,w=I[o+8],S=I[o+9],R=I[o+10],M=I[o+11],A[e+8]=C*w+B*S+l*R+f*M,A[e+9]=r*w+Q*S+u*R+D*M,A[e+10]=n*w+E*S+p*R+_*M,A[e+11]=s*w+c*S+d*R+y*M,w=I[o+12],S=I[o+13],R=I[o+14],M=I[o+15],A[e+12]=C*w+B*S+l*R+f*M,A[e+13]=r*w+Q*S+u*R+D*M,A[e+14]=n*w+E*S+p*R+_*M,A[e+15]=s*w+c*S+d*R+y*M}var go=b((()=>{}));function C1A(A,e,t,g,I){const o=1/Math.tan(e*.5),C=I-g;A[0]=o/t,A[5]=o,A[10]=-g/C,A[11]=1,A[14]=I*g/C}var r1A=b((()=>{})),it=b((()=>{}));function Io(A){const e=A.worldMatrixVersion;if(A._viewVer===e)return A._viewCache;const t=A._viewCache,g=A.worldMatrix,I=A._useFloatingOrigin,o=I?0:g[12],C=I?0:g[13],r=I?0:g[14];return t[0]=g[0],t[1]=g[4],t[2]=g[8],t[3]=0,t[4]=g[1],t[5]=g[5],t[6]=g[9],t[7]=0,t[8]=g[2],t[9]=g[6],t[10]=g[10],t[11]=0,t[12]=-(g[0]*o+g[1]*C+g[2]*r),t[13]=-(g[4]*o+g[5]*C+g[6]*r),t[14]=-(g[8]*o+g[9]*C+g[10]*r),t[15]=1,A._viewVer=e,t}function OOA(A){e9=A}function p1(A){return(A._projFov!==A.fov||A._projNear!==A.nearPlane||A._projFar!==A.farPlane)&&(A._projFov=A.fov,A._projNear=A.nearPlane,A._projFar=A.farPlane,A._projRev=(A._projRev??0)+1),A.worldMatrixVersion+(A._projRev??0)}function Xo(A,e){const t=p1(A);if(A._projVer===t&&A._projAspect===e)return A._projCache;const g=A._projCache;return e9!==null&&A.ortho?e9(A,e,g):C1A(g,A.fov,e,A.nearPlane,A.farPlane),A._projVer=t,A._projAspect=e,g}function io(A,e){const t=p1(A);if(A._vpVer===t&&A._vpAspect===e)return A._vpCache;const g=A._vpCache;return $g(g,0,Xo(A,e),0,Io(A),0),A._vpVer=t,A._vpAspect=e,g}function rr(A){const e=A.worldMatrix;return{x:e[12],y:e[13],z:e[14]}}function ii(A,e,t){const g=A?.viewport;return e/t*(g?g.width/g.height:1)}function n1A(A,e,t,g){const I=e?.viewport;if(!I)return;const o=Math.floor(I.x*t),C=Math.floor((1-I.y-I.height)*g),r=Math.ceil((I.x+I.width)*t)-o,n=Math.ceil((1-I.y)*g)-C;A.setViewport(o,C,r,n,0,1),A.setScissorRect(o,C,r,n)}var e9,Mg=b((()=>{go(),r1A(),it(),e9=null})),VOA=H({_measureRenderTaskOverdrawCost:()=>jOA});async function jOA(A,e,t){const g=A._device;g.features.has("timestamp-query")||m(141);const I=t?.repeats??9;if(!Number.isInteger(I)||I<1)throw new RangeError("overdraw probe: repeats must be a positive integer");const o=e._config.rt,C=e._config.depth??o;(e._config.depth?e._config.depth._eager===!0:e._config.depthClear===!1)&&m(142);const r=o._width,n=o._height;(!r||!n)&&m(143);const s=o._descriptor.format??e._targetSignature._colorFormat,B=e._targetSignature._depthStencilFormat,Q=o._descriptor.samples??e._targetSignature._sampleCount??1;(!s||!B?.startsWith("depth"))&&m(144);const E=[],c={index:0};for(const M of[e._opaqueBindings,e._directBindings,e._transparentBindings]){for(const N of M){const G=N.renderable.mesh;G&&G.visible===!1||E.push(N)}M!==e._transparentBindings&&(c.index=E.length)}E.length===0&&m(145);const l=e._sceneBG;l||m(146);const u=e._config.cam??e.scene.camera??null,p=(()=>{const M=E.slice(0,c.index);if(!u||M.length<=1)return E;const N=Io(u),G=F=>{const v=F.renderable._worldCenter??(()=>{const U=F.renderable.mesh?.worldMatrix;return U?[U[12],U[13],U[14]]:null})();return v?v[0]*N[2]+v[1]*N[6]+v[2]*N[10]+N[14]:0},K=M.map(F=>({b:F,z:G(F)}));return K.sort((F,v)=>F.z-v.z),[...K.map(F=>F.b),...E.slice(c.index)]})(),d=g.createTexture({label:"overdraw-probe-color",size:{width:r,height:n},format:s,sampleCount:Q,usage:GPUTextureUsage.RENDER_ATTACHMENT}),f=g.createTexture({label:"overdraw-probe-depth",size:{width:r,height:n},format:B,sampleCount:Q,usage:GPUTextureUsage.RENDER_ATTACHMENT}),D=B==="depth24plus-stencil8"||B==="depth32float-stencil8",_=C._descriptor.depthClearValue??0,y=g.createQuerySet({type:"timestamp",count:I*6}),w=g.createBuffer({label:"overdraw-probe-resolve",size:I*6*8,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),S=g.createBuffer({label:"overdraw-probe-read",size:I*6*8,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),R=(M,N)=>{const G=u?.viewport;if(G){const F=Math.floor(G.x*r),v=Math.floor((1-G.y-G.height)*n),U=Math.ceil((G.x+G.width)*r)-F,L=Math.ceil((1-G.y)*n)-v;M.setViewport(F,v,U,L,0,1),M.setScissorRect(F,v,U,L)}M.setBindGroup(0,l);let K=null;for(const F of N)F.pipeline!==K&&(M.setPipeline(F.pipeline),K=F.pipeline),F.draw(M,A)};try{const M=d.createView(),N=f.createView();for(let j=0;j<I;j++){const O=g.createCommandEncoder({label:"overdraw-probe"}),z={view:N,depthClearValue:_,depthLoadOp:"clear",depthStoreOp:"store",...D?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}},Z={view:M,loadOp:"clear",storeOp:"discard",clearValue:{r:0,g:0,b:0,a:0}},AA=O.beginRenderPass({label:"overdraw-probe-a",colorAttachments:[Z],depthStencilAttachment:z,timestampWrites:{querySet:y,beginningOfPassWriteIndex:j*6,endOfPassWriteIndex:j*6+1}});R(AA,E),AA.end();const BA=O.beginRenderPass({label:"overdraw-probe-b",colorAttachments:[Z],depthStencilAttachment:{view:N,depthLoadOp:"load",depthStoreOp:"discard",...D?{stencilLoadOp:"load",stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:y,beginningOfPassWriteIndex:j*6+2,endOfPassWriteIndex:j*6+3}});R(BA,E),BA.end();const QA=O.beginRenderPass({label:"overdraw-probe-c",colorAttachments:[Z],depthStencilAttachment:{...z,depthStoreOp:"discard",...D?{stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:y,beginningOfPassWriteIndex:j*6+4,endOfPassWriteIndex:j*6+5}});R(QA,p),QA.end(),j===I-1&&(O.resolveQuerySet(y,0,I*6,w,0),O.copyBufferToBuffer(w,0,S,0,I*6*8)),g.queue.submit([O.finish()])}await S.mapAsync(GPUMapMode.READ);const G=new BigUint64Array(S.getMappedRange()),K=[],F=[],v=[];for(let j=0;j<I;j++){const O=Number(G[j*6+1]-G[j*6])/1e6,z=Number(G[j*6+3]-G[j*6+2])/1e6,Z=Number(G[j*6+5]-G[j*6+4])/1e6;O>0&&O<1e3&&K.push(O),z>0&&z<1e3&&F.push(z),Z>0&&Z<1e3&&v.push(Z)}S.unmap(),(!K.length||!F.length||!v.length)&&m(147);const U=j=>{const O=j.slice().sort((z,Z)=>z-Z);return O[O.length>>1]},L=+U(K).toFixed(3),x=+U(F).toFixed(3),P=+U(v).toFixed(3);return{width:r,height:n,sampleCount:Q,bindings:E.length,msAsIs:L,msVisibleOnly:x,overdrawMs:+(L-x).toFixed(3),ratio:x>0?+(L/x).toFixed(3):0,msFrontToBack:P,sortGainMs:+(L-P).toFixed(3),repeats:I}}finally{y.destroy(),w.destroy(),S.destroy(),d.destroy(),f.destroy()}}var WOA=b((()=>{rA(),Mg()}));function t9(A){return A._device.features.has("timestamp-query")}function g9(A){if(!t9(A))return nr("unsupported",!1,!1,0,[],0,0);const e=A._gpuTaskTimingResult;return e||(A._gpuTaskTimerWanted?nr("pending",!0,!0,0,[],0,0):nr("disabled",!0,!1,0,[],0,0))}async function zOA(A,e){if(!e){A._gpuTaskTimerEpoch=(A._gpuTaskTimerEpoch??0)+1,A._gpuTaskTimerWanted=!1,A._gpuTaskTimerDisable?.(),A._gpuTaskTimerDisable=void 0,A._gpuTaskTimer=void 0;const C=t9(A);return A._gpuTaskTimingResult=nr(C?"disabled":"unsupported",C,!1,0,[],0,0),A._gpuTaskTimingResult}if(!t9(A))return A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=nr("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult;if(A._gpuTaskTimerWanted)return g9(A);const t=(A._gpuTaskTimerEpoch??0)+1;A._gpuTaskTimerEpoch=t,A._gpuTaskTimerWanted=!0,A._gpuTaskTimingResult=nr("pending",!0,!0,0,[],0,0);const{createGpuTaskTimer:g,installGpuTaskTimer:I}=await Promise.resolve().then(()=>(POA(),mOA));if(!A._gpuTaskTimerWanted||A._gpuTaskTimerEpoch!==t)return g9(A);A._gpuTaskTimer===void 0&&(A._gpuTaskTimer=g(A._device));const o=A._gpuTaskTimer;return o?(A._gpuTaskTimerDisable=I(o,A,C=>{A._gpuTaskTimerWanted&&A._gpuTaskTimerEpoch===t&&(A._gpuTaskTimingResult=C)}),g9(A)):(A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=nr("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult)}async function ZOA(A,e,t){const{_measureRenderTaskOverdrawCost:g}=await Promise.resolve().then(()=>(WOA(),VOA));return g(A,e,t)}function nr(A,e,t,g,I,o,C,r){return{status:A,supported:e,enabled:t,frameIndex:g,tasks:I,totalDurationMs:C,droppedTaskCount:o,error:r}}var s1A=b((()=>{}));$a();function XOA(A){if(!XF(A.canvas)||typeof ResizeObserver>"u")return()=>{};A._ro?.disconnect();const e=A._ro=new ResizeObserver(([t])=>{A._w=Math.round(t.contentRect.width),A._h=Math.round(t.contentRect.height)});return e.observe(A.canvas),()=>{e.disconnect(),A._ro===e&&(A._ro=void 0,A._w=A._h=void 0)}}var $OA=H({createCapturePreFrame:()=>iVA,createCaptureService:()=>IVA});function AVA(A){return Math.ceil(A*4/256)*256}function eVA(A){const e=A._captureQueue;!e||e.length===0||A._swapchainCopySrc||(A._swapchainCopySrc=!0,A._context.configure({device:A.engine._device,format:A._configureFormat,alphaMode:A._alphaMode,usage:_A.RENDER_ATTACHMENT|_A.COPY_SRC,viewFormats:[A.format]}))}function tVA(A,e){const t=A._captureQueue;if(!t||t.length===0||!A._swapchainCopySrc)return;A._captureQueue=void 0;const g=A.scRT._colorTexture;if(!g){const n=new Error("captureScreenshot: no swapchain texture available");for(const s of t)s.reject(n);return}const I=A.scRT._width,o=A.scRT._height,C=AVA(I),r=A.engine._device.createBuffer({label:"screenshot-readback",size:C*o,usage:iA.COPY_DST|iA.MAP_READ});e.copyTextureToBuffer({texture:g},{buffer:r,bytesPerRow:C,rowsPerImage:o},{width:I,height:o,depthOrArrayLayers:1}),gVA({buffer:r,width:I,height:o,bytesPerRow:C,bgra:A.format.startsWith("bgra"),reqs:t})}async function gVA(A){const{buffer:e,width:t,height:g,bytesPerRow:I,bgra:o,reqs:C}=A;try{await Promise.resolve(),await e.mapAsync(GPUMapMode.READ);const r=new Uint8Array(e.getMappedRange()),n=new Uint8ClampedArray(t*g*4);for(let B=0;B<g;B++){const Q=B*I,E=B*t*4;for(let c=0;c<t;c++){const l=Q+c*4,u=E+c*4;o?(n[u]=r[l+2],n[u+1]=r[l+1],n[u+2]=r[l]):(n[u]=r[l],n[u+1]=r[l+1],n[u+2]=r[l+2]),n[u+3]=255}}e.unmap(),e.destroy();const s={width:t,height:g,data:n};for(const B of C)B.resolve(s)}catch(r){try{e.destroy()}catch{}for(const n of C)n.reject(r)}}function IVA(){return tVA}function iVA(){return eVA}var oVA=b((()=>{ZA()}));function CVA(A){const e=new Promise((t,g)=>{(A._captureQueue??=[]).push({resolve:t,reject:g})});return A._captureService||Promise.resolve().then(()=>(oVA(),$OA)).then(({createCaptureService:t,createCapturePreFrame:g})=>{A._captureService??=t(),A._capturePreFrame??=g()}),e}function t3(A,e){return Math.ceil(A/e)*e}var g3=b((()=>{}));function Ft(A,e,t,g){const I=A._device.createBuffer({label:g,size:t3(Math.max(e.byteLength,4),4),usage:t|iA.COPY_DST,mappedAtCreation:!0});return new Te(I.getMappedRange()).set(new Te(e.buffer,e.byteOffset,e.byteLength)),I.unmap(),I}var qI=b((()=>{VA(),ZA(),g3()})),rVA=H({getCpuStorageRecoveryLimits:()=>nVA,rebuildCpuStorageBuffers:()=>sVA});function nVA(A){for(const e of A._storageBuffers??[])if(e._data){const t=A._device.limits;return{maxBufferSize:t.maxBufferSize,maxStorageBufferBindingSize:t.maxStorageBufferBindingSize,maxStorageBuffersPerShaderStage:t.maxStorageBuffersPerShaderStage}}}function sVA(A){for(const e of A._storageBuffers??[])e._destroyed||(e._buffer=e._data?Ft(A,e._data,iA.STORAGE,e._label):null)}var BVA=b((()=>{ZA(),qI()}));function LI(A,e={},t=""){const g=A._device,I=I9??=new WeakMap;let o=I.get(g);o||I.set(g,o=new Map);let C=t;for(const n in I3){const s=n;C+=`:${e[s]??I3[s]}`}let r=o.get(C);return r||o.set(C,r=g.createSampler(e)),r}function QVA(A){I9?.delete(A._device)}function aVA(A,e){const t=I9?.get(A._device);if(t){const g=Object.keys(I3);for(const[I,o]of t)if(o===e){const C=I.split(":").slice(-g.length);return Object.fromEntries(g.map((r,n)=>[r,typeof I3[r]=="number"?Number(C[n]):C[n]]))}}}var I9,i9,o9,I3,ki=b((()=>{I9=null,i9="nearest",o9="clamp-to-edge",I3={minFilter:i9,magFilter:i9,mipmapFilter:i9,addressModeU:o9,addressModeV:o9,addressModeW:o9,maxAnisotropy:1}}));function sr(A,e={}){const t=e.compare,g=e.lodMinClamp??0,I=e.lodMaxClamp??32;return LI(A,e,t!==void 0||g!==0||I!==32?`${t??""}:${g}:${I}`:"")}var i3=b((()=>{ki()}));function C9(){return B1A??=new WeakMap}var B1A,jH=b((()=>{B1A=null}));function qo(A){const e=C9();e.set(A,(e.get(A)??0)+1)}var Br=b((()=>{jH()}));function Kg(A){qo(A.texture)}var cI=b((()=>{Br()}));function r9(A){return C9().get(A.texture)===0}function n9(A){return C9().get(A.texture)??0}var o3=b((()=>{jH()}));function s9(A){return LI(A,Q1A)}function $o(A){return LI(A,a1A)}function B9(A){return LI(A,E1A)}var Q1A,a1A,E1A,oo=b((()=>{ki(),Q1A={magFilter:"nearest",minFilter:"nearest"},a1A={magFilter:"linear",minFilter:"linear"},E1A={magFilter:"linear",minFilter:"linear",mipmapFilter:"linear"}})),Cs=H({generateMipmaps:()=>yQ,recordMipmaps:()=>Q9});function EVA(){eE?.clear(),eE=null,C3=null,a9=null,r3=null,E9=null}function cVA(A){const e=A._device;e!==E9&&(EVA(),E9=e),C3??=e.createShaderModule({code:c1A}),a9??=$o(A),r3??=e.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:DA.FRAGMENT,sampler:{}}]})}function lVA(A,e){const t=A._device;cVA(A),eE??=new Map;let g=eE.get(e);return g||(g=t.createRenderPipeline({layout:t.createPipelineLayout({bindGroupLayouts:[r3]}),vertex:{module:C3,entryPoint:"vs"},fragment:{module:C3,entryPoint:"fs",targets:[{format:e}]},primitive:{topology:"triangle-list"}}),eE.set(e,g)),g}function yQ(A,e,t){const g=A._device,I=g.createCommandEncoder();Q9(A,e,I,t),g.queue.submit([I.finish()])}function Q9(A,e,t,g){if(e.mipLevelCount<=1)return;const I=A._device,o=lVA(A,e.format),C=g!=null?{dimension:"2d",baseArrayLayer:g,arrayLayerCount:1}:{};for(let r=1;r<e.mipLevelCount;r++){const n=e.createView({baseMipLevel:r-1,mipLevelCount:1,...C}),s=e.createView({baseMipLevel:r,mipLevelCount:1,...C}),B=I.createBindGroup({layout:r3,entries:[{binding:0,resource:n},{binding:1,resource:a9}]}),Q=t.beginRenderPass({colorAttachments:[{view:s,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});Q.setPipeline(o),Q.setBindGroup(0,B),Q.draw(3),Q.end()}}var c1A,eE,C3,a9,r3,E9,A1=b((()=>{ZA(),oo(),c1A="@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1),p*vec2f(.5,-.5)+.5);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}",eE=null,C3=null,a9=null,r3=null,E9=null})),uVA=H({rebuildDynamicTexture2D:()=>pVA});async function pVA(A,e){const t=e._recoverySource;if(!t||t.kind!=="dynamic")return;const{width:g,height:I,format:o,levels:C,samplerDesc:r}=t,n=A._device.createTexture({size:{width:g,height:I},format:o,mipLevelCount:C,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(t.source)try{A._device.queue.copyExternalImageToTexture({source:t.source,flipY:t.flipY},{texture:n,premultipliedAlpha:t.premultipliedAlpha},[g,I]),C>1&&yQ(A,n)}catch{t.source=null}e.texture=n,e.view=n.createView(),e.sampler=sr(A,r),e.width=g,e.height=I,Kg(e)}var dVA=b((()=>{ZA(),cI(),i3(),A1()})),WH=H({rebuildTexture2D:()=>fVA,settleRebuiltTextureOwnership:()=>DVA});async function fVA(A,e){const t=e._recoverySource;if(!t||r9(e))return;c9??=new WeakMap;const g=c9.get(t);if(g?.device===A._device){g.tex!==e&&(await g.done,_VA(A,e,g.tex));return}const I=n9(e),o=yVA(A,e,t);if(c9.set(t,{device:A._device,tex:e,done:o}),await o,I>0){const C=A._deviceLostRecovery;C&&(C._pendingOwnership??=[]).push([e,I])}}function DVA(A){const e=A._pendingOwnership;if(A._pendingOwnership=void 0,!!e)for(const[t,g]of e)for(let I=n9(t);I<g;I++)Kg(t)}function _VA(A,e,t){const g=l1A(A,e)??t.sampler;e.texture=t.texture,e.view=t.view,e.width=t.width,e.height=t.height,e.sampler=g}function l1A(A,e){const t=A._deviceLostRecovery?._samplerDescriptors,g=t?.get(e.sampler);if(!g)return;const I=sr(A,g);return t.set(I,g),I}async function yVA(A,e,t){if(t.kind==="url"){const n=await hVA(A,t.url,t.opts);e.texture=n.texture,e.view=n.view,e.sampler=n.sampler,e.width=n.width,e.height=n.height,e._recoverySource=t;return}if(t.kind==="solid"){const n=A._device.createTexture({size:{width:1,height:1},format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST}),s=new Te(t.rgba.map(B=>Math.round(B*255)));A._device.queue.writeTexture({texture:n},s,{bytesPerRow:4,rowsPerImage:1},{width:1,height:1}),e.texture=n,e.view=n.createView(),e.sampler=$o(A),e.width=1,e.height=1;return}if(t.kind==="dynamic"){const{rebuildDynamicTexture2D:n}=await Promise.resolve().then(()=>(dVA(),uVA));await n(A,e);return}if(t.kind==="pixels"){const n=t.options,s=A._device.createTexture({size:{width:t.width,height:t.height},format:n.srgb?"rgba8unorm-srgb":"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST});A._device.queue.writeTexture({texture:s},t.data,{bytesPerRow:t.width*4,rowsPerImage:t.height},{width:t.width,height:t.height}),e.texture=s,e.view=s.createView(),e.sampler=sr(A,{addressModeU:n.addressModeU??"clamp-to-edge",addressModeV:n.addressModeV??"clamp-to-edge",minFilter:n.minFilter??"nearest",magFilter:n.magFilter??"nearest"}),e.width=t.width,e.height=t.height;return}if(t.kind==="render"){const n=A._device.createTexture({size:{width:t.width,height:t.height},format:t.format,usage:_A.TEXTURE_BINDING|_A.RENDER_ATTACHMENT|_A.COPY_DST});e.texture=n,e.view=n.createView(),e.sampler=sr(A,t.samplerDesc),e.width=t.width,e.height=t.height;return}if(t.kind==="external"){if(!t.bitmap)throw new Error("Cannot recover a released external-image texture");const n=A._device.createTexture({size:{width:t.width,height:t.height},format:t.format,mipLevelCount:t.levels,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:t.bitmap,flipY:t.flipY},{texture:n,premultipliedAlpha:t.premultipliedAlpha},{width:t.width,height:t.height}),t.levels>1){const{generateMipmaps:s}=await Promise.resolve().then(()=>(A1(),Cs));s(A,n)}e.texture=n,e.view=n.createView(),e.sampler=sr(A,t.samplerDesc),e.width=t.width,e.height=t.height;return}const g=t.bitmap?.width??1,I=t.bitmap?.height??1,o=t.srgb?"rgba8unorm-srgb":"rgba8unorm",C=t.mipMaps?Math.floor(Math.log2(Math.max(g,I)))+1:1,r=A._device.createTexture({size:{width:g,height:I},format:o,mipLevelCount:C,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.COPY_SRC|_A.RENDER_ATTACHMENT});if(t.bitmap){if(A._device.queue.copyExternalImageToTexture({source:t.bitmap},{texture:r,premultipliedAlpha:!1},{width:g,height:I}),t.mipMaps&&C>1){const{generateMipmaps:n}=await Promise.resolve().then(()=>(A1(),Cs));n(A,r)}}else A._device.queue.writeTexture({texture:r},t.fallback??new Te([255,255,255,255]),{bytesPerRow:4},{width:1,height:1});e.texture=r,e.view=r.createView(),e.sampler=l1A(A,e)??sr(A,{addressModeU:"repeat",addressModeV:"repeat",minFilter:"linear",magFilter:"linear",mipmapFilter:"linear",maxAnisotropy:4}),e.width=g,e.height=I}async function hVA(A,e,t){const g=t.mipMaps??!0,I=t.addressModeU??"repeat",o=t.addressModeV??"repeat",C=t.invertY??!0,r=t.srgb??!1,n=t.premultiplyAlpha??!1,s=r?"rgba8unorm-srgb":"rgba8unorm",B=await(await fetch(e)).blob(),Q=await createImageBitmap(B,{premultiplyAlpha:n?"premultiply":"none",colorSpaceConversion:"none"}),E=Q.width,c=Q.height,l=g?Math.floor(Math.log2(Math.max(E,c)))+1:1,u=A._device.createTexture({size:{width:E,height:c},format:s,mipLevelCount:l,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:Q,flipY:C},{texture:u,premultipliedAlpha:n},{width:E,height:c}),Q.close(),g&&l>1){const{generateMipmaps:_}=await Promise.resolve().then(()=>(A1(),Cs));_(A,u)}const p=t.minFilter??"linear",d=t.magFilter??"linear",f=g?"linear":"nearest",D=sr(A,{addressModeU:I,addressModeV:o,minFilter:p,magFilter:d,mipmapFilter:f,maxAnisotropy:p==="linear"&&d==="linear"&&f==="linear"?4:1});return{texture:u,view:u.createView(),sampler:D,width:E,height:c}}var c9,zH=b((()=>{VA(),ZA(),i3(),cI(),o3(),oo(),c9=null})),wVA=H({runDeviceLostRecovery:()=>SVA});function u1A(){return Promise.resolve().then(()=>(BVA(),rVA))}async function SVA(A,e,t){const g=new Map;for(const B of t)g.set(B._kind,B);const I=A._renderFn!==null;Wv(A),RVA(A,g),$oA(A);const o=await rs("requesting a replacement adapter",()=>navigator.gpu.requestAdapter({powerPreference:"high-performance",...HoA()}));o||m(47);const C=e._requiredFeatures.filter(B=>!o.features.has(B));C.length&&m(48,C.join(", "));const r=A._storageBuffers?.size?await u1A():void 0;A._device=await rs("requesting a replacement device",()=>o.requestDevice({requiredFeatures:e._requiredFeatures,requiredLimits:{...A._options?.requiredLimits,...r?.getCpuStorageRecoveryLimits(A)}})),A._attachGpuEvents?.(A),await rs("rebuilding engine storage buffers",async()=>{(r??(A._storageBuffers?.size?await u1A():void 0))?.rebuildCpuStorageBuffers(A)}),await rs("reconfiguring rendering surfaces",()=>{for(const B of A.surfaces){const Q=B._swapchainCopySrc?_A.RENDER_ATTACHMENT|_A.COPY_SRC:_A.RENDER_ATTACHMENT;B._context.configure({device:A._device,format:B._configureFormat,alphaMode:B._alphaMode,usage:Q,viewFormats:[B.format]}),Ov(B)}}),await rs("resizing rendering surfaces",()=>HH(A));const n=await MVA(A,e),s=Array.from(g.values()).sort((B,Q)=>(B._recoverOrder??0)-(Q._recoverOrder??0));try{for(const B of s)await rs(`running "${B._kind}" recovery`,()=>B._recover(A))}finally{n?.()}I&&await rs("restarting rendering",()=>A3(A))}async function MVA(A,e){const t=e._textures,g=[];for(const C of t){const r=C.deref();r?g.push(r):t.delete(C)}if(g.length===0)return;const{rebuildTexture2D:I,settleRebuiltTextureOwnership:o}=await Promise.resolve().then(()=>(zH(),WH));try{await rs("rebuilding recoverable textures",async()=>{const C=(await Promise.allSettled(g.map(r=>I(A,r)))).find(r=>r.status==="rejected");if(C)throw C.reason})}catch(C){throw o(e),C}return()=>o(e)}function RVA(A,e){const t=new Set;for(const g of A.surfaces)for(const I of g._renderingContexts)e.has(I._kind)||t.add(I._kind);if(t.size)throw new Error(`Device-lost recovery cannot rebuild registered rendering contexts of kind: ${Array.from(t).sort().join(", ")}. Recovering around them would leave them bound to the lost device and crash the browser's renderer process on the next frame. Enable that kind's device-lost recovery before the device is lost, or unregister the context.`)}async function rs(A,e){try{return await e()}catch(t){const g=t instanceof Error?t.message:String(t);throw new Error(`Device-lost recovery failed while ${A}: ${g}`,{cause:t})}}var mVA=b((()=>{rA(),hI(),kg(),ZA(),$a()}));function NVA(A){return A._deviceLostRecovery??={_forceNextLoss:!1,_requiredFeatures:[],_armedDevice:null,_registrations:[],_samplerDescriptors:new WeakMap,_captureRefs:0,_meshCaptureRefs:0,_textures:new Set,_texturesPruneAt:64}}function l9(A,e){const t=NVA(A),g=t._registrations;g.length===0&&(t._requiredFeatures=Array.from(A._device.features)),g.some(o=>o._kind===e._kind)||e._enable?.(A),g.push(e),p1A(A,t);let I=!1;return{disable(){if(I)return;I=!0;const o=g.indexOf(e);o>=0&&g.splice(o,1),g.some(C=>C._kind===e._kind)||e._disable?.(A)}}}function GVA(A){const e=A._deviceLostRecovery;return!!e?._registrations.length&&(e._forceNextLoss=!0)}function p1A(A,e){const t=A._device;e._armedDevice===t||e._recovering||(e._armedDevice=t,t.lost.then(g=>{if(e._registrations.length===0||e._armedDevice!==t||g.reason==="destroyed"&&!e._forceNextLoss)return;e._forceNextLoss=!1,e._recovering=!0;const I=[...e._registrations];for(const o of I)o._onLost?.(g);Promise.resolve().then(()=>(mVA(),wVA)).then(({runDeviceLostRecovery:o})=>o(A,e,I)).then(()=>{e._recovering=!1,p1A(A,e);for(const o of I)o._onRecovered?.()},o=>{e._recovering=!1;for(const C of I)C._onRecoveryFailed?.(o)})}))}rA();function bVA(A){GVA(A)||m(49),A._device.destroy()}function u9(A,e){const t={...A,...e};return ZH?.(A,t),XH?.(A,t),t}function FVA(A){ZH=A}function kVA(A){XH=A}function tE(A,e,t={}){const g=A._device;n3||(n3=new WeakMap);let I=n3.get(g);I||(I=new Map,n3.set(g,I));const o=`${e}\0${t.mipMaps??!0}\0${t.addressModeU??"repeat"}\0${t.addressModeV??"repeat"}\0${t.minFilter??"linear"}\0${t.magFilter??"linear"}\0${t.invertY??!0}\0${t.srgb??!1}\0${t.premultiplyAlpha??!1}`,C=I.get(o);if(C)return C;const r=I,n=KVA(A,e,t);return r.set(o,n),n.catch(()=>r.delete(o)),n}async function KVA(A,e,t){const g=A._device,I=t.mipMaps??!0,o=t.addressModeU??"repeat",C=t.addressModeV??"repeat",r=t.invertY??!0,n=t.srgb??!1,s=t.premultiplyAlpha??!1,B=n?"rgba8unorm-srgb":"rgba8unorm",Q=await(await fetch(e)).blob(),E=await createImageBitmap(Q,{premultiplyAlpha:s?"premultiply":"none",colorSpaceConversion:"none"}),c=E.width,l=E.height,u=I?Math.floor(Math.log2(Math.max(c,l)))+1:1,p=g.createTexture({size:{width:c,height:l},format:B,mipLevelCount:u,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(g.queue.copyExternalImageToTexture({source:E,flipY:r},{texture:p,premultipliedAlpha:s},{width:c,height:l}),E.close(),I&&u>1){const{generateMipmaps:w}=await Promise.resolve().then(()=>(A1(),Cs));w(A,p)}const d=t.minFilter??"linear",f=t.magFilter??"linear",D=I?"linear":"nearest",_=LI(A,{addressModeU:o,addressModeV:C,minFilter:d,magFilter:f,mipmapFilter:D,maxAnisotropy:d==="linear"&&f==="linear"&&D==="linear"?4:1}),y={texture:p,view:p.createView(),sampler:_,width:c,height:l};return A._dlr?.u(y,e,t),Kg(y),y}var ZH,XH,n3,NC=b((()=>{ZA(),cI(),ki(),ZH=null,XH=null,n3=null}));function vVA(A){AT=A}function $H(A,e){const t=C9(),g=(t.get(A)??1)-1;return g<=0?(A.destroy(),e&&AT?.(e),t.set(A,0),!0):(t.set(A,g),!1)}var AT,s3=b((()=>{jH(),AT=null}));rA(),NC(),s3();var UVA=64,d1A=null;function f1A(A,e,t){e._recoverySource=t;const g=A._textures;if(g.size>=A._texturesPruneAt){for(const I of g)I.deref()||g.delete(I);A._texturesPruneAt=Math.max(UVA,g.size*2)}g.add(new WeakRef(e))}function D1A(A,e){const t=A._recoverySource;if(!t)return;const g=d1A?.get(t)?.deref();g&&f1A(g,e,t)}function LVA(A){const e=A._recoverySource;e?.kind==="external"&&(e.bitmap?.close(),e.bitmap=null)}function YVA(A,e,t,g){const I=A._recoverySource;I?.kind==="dynamic"&&(I.source=e,I.flipY=t,I.premultipliedAlpha=g)}function xVA(A){const e=A._deviceLostRecovery,t=new WeakRef(e),g=(I,o)=>{(d1A??=new WeakMap).set(o,t),f1A(e,I,o)};kVA(D1A),vVA(LVA),A._updateCapturedDynamicTexture=YVA,A._dlr={t:g,dt(I,o,C,r,n,s){g(I,{kind:"dynamic",width:o,height:C,format:r,levels:n,samplerDesc:s,source:null,flipY:!0,premultipliedAlpha:!1})},c(I,o,...C){e._meshCaptureRefs&&(I._rebuild=()=>o(...C))},async x(I,o,C,r,n,s,B,Q,E){const c=await createImageBitmap(I,{premultiplyAlpha:Q?"premultiply":"none",colorSpaceConversion:"none"});try{const l=await E(c);return g(l,{kind:"external",bitmap:c,width:o,height:C,format:r,levels:n,samplerDesc:s,flipY:B,premultipliedAlpha:Q}),l}catch(l){throw c.close(),l}},d:D1A,u(I,o,C){g(I,{kind:"url",url:o,opts:{...C}})},s(I,o,C,r,n){g(I,{kind:"solid",rgba:[o,C,r,n]})},b(I,o,C,r,n){g(I,{kind:"bitmap",bitmap:o,srgb:C,mipMaps:r,fallback:n})},p(I,o,C){g(I,{kind:"pixels",data:o.slice(0,I.width*I.height*4),width:I.width,height:I.height,options:{...C}})},r(I,o,C,r,n){g(I,{kind:"render",width:o,height:C,format:r,samplerDesc:n})},w(I,o,C,r,n,s,B=0,Q=n*4){const E=I._recoverySource;if(E?.kind!=="pixels")return;const c=new Uint8Array(o.buffer,o.byteOffset,o.byteLength),l=n*4;for(let u=0;u<s;u++){const p=B+u*Q,d=((r+u)*E.width+C)*4;E.data.set(c.subarray(p,p+l),d)}},m(I,o,C,r,n,s){A._deviceLostRecovery?._meshCaptureRefs&&(I._cpuUv2s=o??null,I._cpuTangents=C??null,I._cpuColors=r??null,I._cpuGpuIndices=n,I._cpuIndexFormat=s)},e(I,o,C){e._meshCaptureRefs&&(I._envRecoverySource={kind:"env",url:o,brdfUrl:C})},h(I,o,C){e._meshCaptureRefs&&(I._envRecoverySource={kind:"hdr",url:o,faceSize:C})}}}function _1A(A,e=!1){const t=A._deviceLostRecovery;t||m(46),t._captureRefs++,e&&t._meshCaptureRefs++,t._captureRefs===1&&xVA(A)}function y1A(A,e=!1){const t=A._deviceLostRecovery;!t||t._captureRefs===0||(t._captureRefs--,e&&t._meshCaptureRefs>0&&t._meshCaptureRefs--,t._captureRefs===0&&(A._dlr=void 0))}var e1,ns=b((()=>{e1=class{_x;_y;_z;_onDirty;constructor(A,e,t,g){this._x=A,this._y=e,this._z=t,this._onDirty=g}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._onDirty())}set(A,e,t){this._x=A,this._y=e,this._z=t,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z}}})),B3,p9=b((()=>{B3=class{_x;_y;_z;_w;_onDirty;_version=0;constructor(A,e,t,g,I){this._x=A,this._y=e,this._z=t,this._w=g,this._onDirty=I}get version(){return this._version}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._version++,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._version++,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._version++,this._onDirty())}get w(){return this._w}set w(A){this._w!==A&&(this._w=A,this._version++,this._onDirty())}set(A,e,t,g){this._x=A,this._y=e,this._z=t,this._w=g,this._version++,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z,A.w)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z,A[e+3]=this._w}}}));function P1(A,e,t,g,I,o,C,r,n,s,B,Q){const E=o*o,c=C*C,l=r*r,u=o*C,p=o*r,d=C*r,f=n*o,D=n*C,_=n*r;A[e]=(1-2*(c+l))*s,A[e+1]=2*(u+_)*s,A[e+2]=2*(p-D)*s,A[e+3]=0,A[e+4]=2*(u-_)*B,A[e+5]=(1-2*(E+l))*B,A[e+6]=2*(d+f)*B,A[e+7]=0,A[e+8]=2*(p+D)*Q,A[e+9]=2*(d-f)*Q,A[e+10]=(1-2*(E+c))*Q,A[e+11]=0,A[e+12]=t,A[e+13]=g,A[e+14]=I,A[e+15]=1}var GC=b((()=>{}));function Q3(A,e){A[tT]=e}function eT(A){return A===null?null:A[tT]??null}function hQ(A){eT(A)?._invalidate()}function JVA(A){eT(A)?.markLocalDirty()}function h1A(A,e,t){const g=bg();return w1A(g,A,e,t),g}function w1A(A,e,t,g){e.x===0&&e.y===0&&e.z===0&&t.x===0&&t.y===0&&t.z===0&&t.w===1&&g.x===1&&g.y===1&&g.z===1?(A.fill(0),A[0]=A[5]=A[10]=A[15]=1):P1(A,0,e.x,e.y,e.z,t.x,t.y,t.z,t.w,g.x,g.y,g.z)}function gE(A){let e=0,t=-1,g=null,I=null;const o=bg();let C=null,r=null;const n=[];function s(){I=null,e++;for(const E of n)E._invalidate()}function B(){const E=C.worldMatrixVersion;E!==t&&(t=E,s())}const Q={get parent(){return C},set parent(E){E!==C&&(r!==null&&r._removeChild(Q),C=E,r=eT(E),r!==null&&r._addChild(Q),t=-1,s())},markLocalDirty(){g=null,s()},getWorldMatrix(){if(r===null&&C!==null&&B(),I!==null)return I;const E=g??=A();if(C!==null){const c=C.worldMatrix;$g(o,0,c,0,E,0),I=o}else I=E;return I},getWorldMatrixVersion(){return r===null&&C!==null&&B(),e},_invalidate:s,_addChild(E){n.push(E)},_removeChild(E){const c=n.indexOf(E);c>=0&&n.splice(c,1)}};return Q}var tT,tn=b((()=>{go(),Ii(),GC(),tT=Symbol("wmState")}));function d9(A,e,t){const g=Math.cos(A*.5),I=Math.sin(A*.5),o=Math.cos(e*.5),C=Math.sin(e*.5),r=Math.cos(t*.5),n=Math.sin(t*.5);return[I*o*r+g*C*n,g*C*r-I*o*n,g*o*n+I*C*r,g*o*r-I*C*n]}function S1A(A,e,t,g){const I=2*(A*t+g*e),o=Math.asin(Math.max(-1,Math.min(1,I)));return[Math.atan2(-(2*(e*t-g*A)),1-2*(A*A+e*e)),o,Math.atan2(-(2*(A*e-g*t)),1-2*(e*e+t*t))]}var f9=b((()=>{}));function gT(A){let e=0,t=0,g=0,I=-1;const o=()=>{if(A.version!==I){const r=S1A(A.x,A.y,A.z,A.w);e=r[0],t=r[1],g=r[2],I=A.version}},C=(r,n,s)=>{e=r,t=n,g=s;const[B,Q,E,c]=d9(r,n,s);A.set(B,Q,E,c),I=A.version};return{get x(){return o(),e},set x(r){o(),C(r,t,g)},get y(){return o(),t},set y(r){o(),C(e,r,g)},get z(){return o(),g},set z(r){o(),C(e,t,r)},set:C}}function HVA(A,e,t,g,I,o,C,r,n,s,B){return M1A(A,null,e,t,g,I,o,C,r,n,s,B)}function wQ(A,e,t,g,I){const o=M1A(A,e,t?.x,t?.y,t?.z,g?.x,g?.y,g?.z,g?.w,I?.x,I?.y,I?.z);return o._localMatrixLocked=t?void 0:!0,o}function M1A(A,e,t,g,I,o,C,r,n,s,B,Q){const E=a3({name:A,children:[]},t,g,I,o,C,r,n,s,B,Q);return e&&(E._localMatrix=e),E}function a3(A,e=0,t=0,g=0,I=0,o=0,C=0,r=1,n=1,s=1,B=1){let Q;const E=gE(()=>f._localMatrix?f._localMatrix:(Q??=bg(),w1A(Q,l,u,d),Q)),c=()=>{f._localMatrixLocked||(f._localMatrix=void 0,E.markLocalDirty())},l=new e1(e,t,g,c),u=new B3(I,o,C,r,c),p=gT(u),d=new e1(n,s,B,c),f={...A,position:l,rotationQuaternion:u,rotation:p,scaling:d,get parent(){return E.parent},set parent(D){E.parent=D},get worldMatrix(){return E.getWorldMatrix()},get worldMatrixVersion(){return E.getWorldMatrixVersion()}};return Q3(f,E),f}var CC=b((()=>{ns(),p9(),tn(),f9(),Ii()}));function SQ(A,e=0,t=0,g=0,I=0,o=0,C=0,r=1,n=1,s=1){const[B,Q,E,c]=d9(I,o,C),l=a3({children:[],...A},e,t,g,B,Q,E,c,r,n,s);return Object.defineProperties(l,{worldMatrix:{enumerable:!1},worldMatrixVersion:{enumerable:!1}}),l}function D9(A,e,t,g,I,o,C,r){const n=A._device,s=Ft(A,e,iA.VERTEX),B=Ft(A,t,iA.VERTEX),Q=Ft(A,g,iA.INDEX);let E;I&&I.length>0?E=Ft(A,I,iA.VERTEX):(E=n.createBuffer({size:e.length/3*8,usage:iA.VERTEX,mappedAtCreation:!0}),E.unmap());let c=null;o&&o.length>0&&(c=Ft(A,o,iA.VERTEX));const l=C&&C.length>0?Ft(A,C,iA.VERTEX):null,u=r&&r.length>0?Ft(A,r,iA.VERTEX):null;return{positionBuffer:s,normalBuffer:B,uvBuffer:E,uv2Buffer:c,tangentBuffer:l,colorBuffer:u,hasUv:!!I&&I.length>0,hasUv2:!!o&&o.length>0,hasTangent:!!C&&C.length>0,hasColor:!!r&&r.length>0,indexBuffer:Q,indexCount:g.length,indexFormat:"uint32"}}var ss=b((()=>{ZA(),qI(),CC(),f9()}));function R1A(A,e){const t=A.indexCount;A._drawRangeSource=e,Object.defineProperty(A,"indexCount",{enumerable:!0,configurable:!0,get:()=>A._drawRangeSource?.indexCount??t})}var m1A=b((()=>{}));function XI(A,e,t){return A._device.createBuffer({label:t,size:t3(e,16),usage:iA.UNIFORM|iA.COPY_DST})}var co=b((()=>{ZA(),g3()}));function oi(A){const e=A._device,t=N1A??=new WeakMap;let g=t.get(e);return g||(g=e.createBindGroupLayout({label:"scene",entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,buffer:{type:"uniform"}}]}),t.set(e,g)),g}function IT(A){const e=A._blend?{format:A._format,blend:A._blend}:{format:A._format};return{label:A._label,layout:A._engine._device.createPipelineLayout({bindGroupLayouts:A._bgls}),vertex:{module:A._vertModule,entryPoint:"main",buffers:A._vertexBuffers},fragment:{module:A._fragModule,entryPoint:"main",targets:[e]},depthStencil:{format:A._depthStencilFormat??"depth24plus-stencil8",depthCompare:A._depthCompare??"greater-equal",depthWriteEnabled:A._depthWriteEnabled??!0},multisample:{count:A._msaaSamples},primitive:{topology:"triangle-list",cullMode:A._cullMode??"back",frontFace:"ccw"}}}var N1A,Ci=b((()=>{ZA(),Fg(),it(),N1A=null}));function Rg(A,e,t){const g=A._device,I=XI(A,e.byteLength,t);try{g.queue.writeBuffer(I,0,e.buffer,e.byteOffset,e.byteLength)}catch(o){throw I.destroy(),o}return I}var gI=b((()=>{co()}));function iT(){return 16+Ht*16*4}function G1A(A){let e=0;for(const t of A)e+=t._lightVersion??0;return e}function oT(A,e){A.fill(0);let t=0;const g=4;for(const I of e){if(t>=Ht)break;I._writeLightUbo&&(I._writeLightUbo(A,g+t*16),t++)}CT[0]=t,A[0]=b1A[0]}function _9(A,e){let t=e._lightGpuState;const g=iT();if(t&&t._byteSize===g)return t;const I=!t;t?._buffer.destroy();const o=new CA(g/4);return oT(o,e.lights),A._applyLightFoOffset?.(o,e),t={_buffer:Rg(A,o),_scratch:o,_version:G1A(e.lights)+(A._lightFoVersion?.(e)??0),_listVersion:e._lightListVersion??0,_lightCount:e.lights.length,_byteSize:g},e._lightGpuState=t,I&&e._disposables.push(()=>{e._lightGpuState?._buffer.destroy(),e._lightGpuState=void 0}),t}function TVA(A,e){const t=_9(A,e),g=G1A(e.lights)+(A._lightFoVersion?.(e)??0),I=e._lightListVersion??0;return(g!==t._version||I!==t._listVersion||e.lights.length!==t._lightCount)&&(t._version=g,t._listVersion=I,t._lightCount=e.lights.length,oT(t._scratch,e.lights),A._applyLightFoOffset?.(t._scratch,e),A._device.queue.writeBuffer(t._buffer,0,t._scratch)),t._buffer}function qVA(A,e,t){oT(e,t.lights),A._applyLightFoOffset?.(e,t)}var CT,b1A,rT=b((()=>{VA(),EI(),gI(),CT=new gt(1),b1A=new CA(CT.buffer)})),y9=b((()=>{}));function t1(A){return $H(A)}var Bs=b((()=>{s3()}));function gn(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}function PVA(A,e,t){return Math.max(1,Math.floor(Math.log2(Math.max(A,e))-t)+1)}var Qr=b((()=>{}));function F1A(A){const e=new Te(A);for(let l=0;l<8;l++)if(e[l]!==k1A[l])throw new Error("Invalid .env file: bad magic");let t=8;for(;t<e.length&&e[t]!==0;)t++;const g=new TextDecoder().decode(e.subarray(8,t));t++;const I=t,o=JSON.parse(g),C=o.width,r=gn(C,C),n=o.irradiance,s=new CA(27),B=["x","y","z","xx","yy","zz","yz","zx","xy"];for(let l=0;l<9;l++){const u=n[B[l]];s[l*3]=u[0],s[l*3+1]=u[1],s[l*3+2]=u[2]}const Q=o.specular.mipmaps,E=o.imageType||"image/png",c=[];for(const l of Q){const u=I+l.position,p=A.slice(u,u+l.length);c.push(new Blob([p],{type:E}))}return{faceBlobs:c,irradianceSH:s,width:C,mipCount:r}}var k1A,K1A=b((()=>{VA(),Qr(),k1A=new Te([134,22,135,150,246,214,150,54])}));function v1A(){return{minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}}function OVA(A,e,t,g){const I=t-g,o=t+g,C=e===0?"minX":e===1?"minY":"minZ",r=e===0?"maxX":e===1?"maxY":"maxZ";I<A[C]&&(A[C]=I),o>A[r]&&(A[r]=o)}function U1A(A,e){const t=e.boundMin,g=e.boundMax;if(!t||!g)return;if(e._expandWorldBounds!==void 0){e._expandWorldBounds(A,e);return}const I=e.worldMatrix,o=[(t[0]+g[0])*.5,(t[1]+g[1])*.5,(t[2]+g[2])*.5],C=[(g[0]-t[0])*.5,(g[1]-t[1])*.5,(g[2]-t[2])*.5];for(let r=0;r<3;r++){let n=I[12+r],s=0;for(let B=0;B<3;B++){const Q=I[B*4+r];n+=Q*o[B],s+=Math.abs(Q)*C[B]}OVA(A,r,n,s)}}var L1A=b((()=>{})),Y1A=H({computeSceneSize:()=>x1A});function x1A(A,e){const t=v1A();for(const d of A.meshes)U1A(t,d);const g=t.minX,I=t.minY,o=t.minZ,C=t.maxX,r=t.maxY,n=t.maxZ;if(!isFinite(g))return{groundSize:15,skyboxSize:e??20,rootPosition:[0,0,0]};const s=C-g,B=r-I,Q=n-o,E=Math.sqrt(s*s+B*B+Q*Q);let c=15,l=e??20;const u=A.camera;u&&"upperRadiusLimit"in u&&u.upperRadiusLimit&&(c=u.upperRadiusLimit*2,l=c),E>c&&(c=E*2,l=c),c*=1.1,l*=1.5;const p=[g+s*.5,I-1e-5,o+Q*.5];return{groundSize:c,skyboxSize:l,rootPosition:p}}var nT=b((()=>{L1A()}));function VVA(A,e){const t=e.fog;t&&(A[80]=t.mode,A[81]=t.start,A[82]=t.end,A[83]=t.density,A[84]=t.color[0],A[85]=t.color[1],A[86]=t.color[2])}function jVA(A,e){const t=e.clipPlane;t&&(A[88]=t[0],A[89]=t[1],A[90]=t[2],A[91]=t[3])}function WVA(A,e){A[36]=e._environmentRotation??0;const t=e._envTextures?.sphericalHarmonics;t&&A.set(t,40)}function h9(A,e){const t=A._sceneUboContributors??=[];t.includes(e)||t.push(e)}function w9(A){for(const e of A._frameGraph._tasks)e._sceneUboCacheKey&&(e._sceneUboCacheKey.length=0)}function zVA(A,e){A.fog=e,h9(A,VVA)}function ZVA(A,e){A.clipPlane=e,h9(A,jVA)}function IE(A){h9(A,WVA)}var MQ=b((()=>{})),S9=H({decodeBrdfPng:()=>XVA,uploadCubemapRGBD:()=>$VA});function J1A(A,e){A!==BT&&(BT=A,QT=A.createShaderModule({code:q1A}),M9=null,R9=null);const t=e?R9:M9;if(t)return t;const g=A.createComputePipeline({layout:"auto",compute:{module:QT,entryPoint:"main",constants:{[sT]:e?1:0}}});return e?R9=g:M9=g,g}function H1A(A,e,t,g){return A.createBindGroup({layout:e.getBindGroupLayout(0),entries:[{binding:0,resource:t},{binding:1,resource:g}]})}function T1A(A,e,t,g,I){const o=A.beginComputePass();o.setPipeline(e),o.setBindGroup(0,t),o.dispatchWorkgroups(Math.ceil(g/8),Math.ceil(I/8)),o.end()}function XVA(A,e){const t=A._device,g=J1A(t,!1),I=e.width,o=e.height,C=t.createTexture({size:{width:I,height:o},format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});t.queue.copyExternalImageToTexture({source:e,flipY:!1},{texture:C,premultipliedAlpha:!1},{width:I,height:o});const r=t.createTexture({size:{width:I,height:o},format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING}),n=H1A(t,g,C.createView(),r.createView()),s=t.createCommandEncoder();return T1A(s,g,n,I,o),t.queue.submit([s.finish()]),C.destroy(),r}function $VA(A,e,t,g){const I=A._device,o=J1A(I,!0),C=I.createTexture({size:{width:t,height:t,depthOrArrayLayers:6},format:"rgba16float",mipLevelCount:g,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.COPY_SRC|_A.RENDER_ATTACHMENT,dimension:"2d"});for(let r=0;r<g;r++){const n=Math.max(1,t>>r),s=I.createTexture({size:{width:n,height:n},format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT}),B=I.createTexture({size:{width:n,height:n},format:"rgba16float",usage:_A.STORAGE_BINDING|_A.COPY_SRC}),Q=H1A(I,o,s.createView(),B.createView());for(let E=0;E<6;E++){const c=r*6+E;if(c>=e.length)break;I.queue.copyExternalImageToTexture({source:e[c],flipY:!1},{texture:s,premultipliedAlpha:!1},{width:n,height:n});const l=I.createCommandEncoder();T1A(l,o,Q,n,n),l.copyTextureToTexture({texture:B},{texture:C,origin:{x:0,y:0,z:E},mipLevel:r},{width:n,height:n}),I.queue.submit([l.finish()])}s.destroy(),B.destroy()}return C}var sT,q1A,BT,QT,M9,R9,m9=b((()=>{ZA(),sT=0,q1A=`@id(${sT})override f:bool=false;@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var o:texture_storage_2d<rgba16float,write>;@compute@workgroup_size(8,8)fn main(@builtin(global_invocation_id)g:vec3u){let d=textureDimensions(t);if(any(g.xy>=d)){return;}let c=textureLoad(t,vec2u(g.x,select(g.y,d.y-1u-g.y,f)),0);textureStore(o,g.xy,vec4f(pow(c.rgb,vec3f(2.2))/max(c.a,1.0/255.0),1));}`,BT=null,QT=null,M9=null,R9=null})),aT,P1A=b((()=>{aT="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,0.0)).xyz+scene.vEyePosition.xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),O1A,AjA=b((()=>{O1A="struct c{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32}@group(1) @binding(0) var<uniform> mesh:c;struct d{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:d)->@location(0) vec4<f32>{var a=vec4<f32>(mesh.skyOutputColor,1.0);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.positionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"}));function ri(A){return`${A._colorFormat??"-"}|${A._depthStencilFormat??"-"}|${A._depthCompare??""}|${A._sampleCount}`}var ni=b((()=>{})),V1A,N9,ET,G9=b((()=>{V1A="fn perturbNormal(vNormalW:vec3<f32>,positionW:vec3<f32>,uv:vec2<f32>,bumpScale:f32)->vec3<f32>{let normalSample=textureSample(bT,bS,uv).rgb*2.0-1.0;let N=normalize(vNormalW)*bumpScale;let dp1=dpdx(positionW);let dp2=-dpdy(positionW);let duv1=dpdx(uv);let duv2=-dpdy(uv);let dp2perp=cross(dp2,N);let dp1perp=cross(N,dp1);var tangent=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent=dp2perp*duv1.y+dp1perp*duv2.y;let det=max(dot(tangent,tangent),dot(bitangent,bitangent));let invmax=select(inverseSqrt(det),0.0,det==0.0);let cotangentFrame=mat3x3<f32>(tangent*invmax,bitangent*invmax,N);return normalize(cotangentFrame*normalSample);}",N9="fn dither(seed:vec2<f32>,varianceAmount:f32)->f32{let rand=fract(sin(dot(seed,vec2<f32>(12.9898,78.233)))*43758.5453);let normVariance=varianceAmount/255.0;return mix(-normVariance,normVariance,rand);}",ET="fn dither(a:vec2<f32>,b:f32)->f32{return 0.0;}"})),j1A,ejA=b((()=>{j1A="struct a{viewProjection:mat4x4<f32>,view:mat4x4<f32>,vEyePosition:vec4<f32>,envRotationY:f32,_envPad0:f32,_envPad1:f32,_envPad2:f32,vSphericalL00:vec4<f32>,vSphericalL1_1:vec4<f32>,vSphericalL10:vec4<f32>,vSphericalL11:vec4<f32>,vSphericalL2_2:vec4<f32>,vSphericalL2_1:vec4<f32>,vSphericalL20:vec4<f32>,vSphericalL21:vec4<f32>,vSphericalL22:vec4<f32>,vImageInfos:vec4<f32>,vFogInfos:vec4<f32>,vFogColor:vec4<f32>,clipPlane:vec4<f32>}@group(0) @binding(0) var<uniform> scene:a;"})),lo,O1=b((()=>{ejA(),y9(),lo=j1A}));function E3(A,e,t){return A._device.createBindGroupLayout({label:e,entries:[{binding:0,visibility:t,buffer:{type:"uniform"}}]})}var c3=b((()=>{})),W1A=H({buildSolidSkyboxRenderable:()=>z1A});function tjA(A,e){const t=new CA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),g=new l1([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return{posBuffer:Ft(A,t,iA.VERTEX),idxBuffer:Ft(A,g,iA.INDEX)}}function gjA(){function A(e){const t=e._device;return iE&&F9===t||(iE=E3(e,"skybox-material",DA.VERTEX|DA.FRAGMENT)),iE}return{getPipeline(e,t){const g=e._device;F9!==g&&(b9.clear(),iE=null,F9=g);const I=ri(t),o=b9.get(I);if(o)return o;const C=g.createShaderModule({code:lo+aT,label:"skybox-vert"}),r=g.createShaderModule({code:N9+O1A,label:"skybox-frag"}),n=g.createRenderPipeline(IT({_label:"skybox-pipeline",_engine:e,_bgls:[oi(e),A(e)],_vertModule:C,_fragModule:r,_vertexBuffers:X1A,_format:t._colorFormat,_depthStencilFormat:t._depthStencilFormat,_depthCompare:t._depthCompare,_msaaSamples:t._sampleCount,_depthWriteEnabled:!1}));return b9.set(I,n),n},createBindGroup(e,t,g){return e._device.createBindGroup({layout:A(e),entries:[{binding:0,resource:{buffer:t}}]})}}}function z1A(A,e,t,g,I){const o=A.surface.engine,C=A.clearColor,r=tjA(o,t),n=gjA(),s=IjA(o,g,I,[C.r,C.g,C.b]),B=n.createBindGroup(o,s,e),Q={order:0,isTransparent:!1,bind(E,c){return{renderable:Q,pipeline:n.getPipeline(E,c),draw(l){return l.setBindGroup(1,B),l.setVertexBuffer(0,r.posBuffer),l.setIndexBuffer(r.idxBuffer,"uint16"),l.drawIndexed(36),1}}}};return o._dlr?.c(Q,z1A,A,e,t,g,I),Q}function IjA(A,e,t,g){const I=new CA(Z1A/4);return I[0]=I[5]=I[10]=I[15]=1,I[12]=e[0],I[13]=e[1],I[14]=e[2],I[16]=t[0],I[17]=t[1],I[18]=t[2],I[20]=g[0],I[21]=g[1],I[22]=g[2],Rg(A,I)}var Z1A,X1A,b9,iE,F9,$1A=b((()=>{VA(),ZA(),P1A(),AjA(),Ci(),ni(),G9(),O1(),qI(),gI(),c3(),Z1A=96,X1A=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],b9=new Map,iE=null,F9=null})),ACA,ijA=b((()=>{ACA="struct g{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:g;struct h{@location(0) position:vec3<f32>,@location(1) normal:vec3<f32>,@location(2) uv:vec2<f32>}struct e{@builtin(position) clipPos:vec4<f32>,@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@vertex fn main(c:h)->e{var a:e;let b=mesh.world;let d=b*vec4<f32>(c.position,1.0);a.vPositionW=d.xyz;a.clipPos=scene.viewProjection*d;let f=mat3x3<f32>(b[0].xyz,b[1].xyz,b[2].xyz);a.vNormalW=normalize(f*c.normal);a.vUV=c.uv;return a;}"})),eCA,ojA=b((()=>{eCA="struct o{world:mat4x4<f32>,primaryColor:vec3<f32>,alpha:f32,backgroundCenter:vec3<f32>,_pad:f32}@group(1) @binding(0) var<uniform> mesh:o;@group(1) @binding(1) var n:texture_2d<f32>;@group(1) @binding(2) var m:sampler;struct p{@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@fragment fn main(b:p)->@location(0) vec4<f32>{let g=normalize(b.vNormalW);let c=textureSample(n,m,b.vUV);let h=c.rgb;let f=max(h,vec3<f32>(0.0));let i=mesh.primaryColor;let j=f*i;var e=mesh.alpha*c.a;let k=dot(g,normalize(scene.vEyePosition.xyz-mesh.backgroundCenter));const l:f32=0.1;let d=clamp(k/l,0.0,1.0);e*=d*d;var a=vec4<f32>(j,e);if (scene.vImageInfos.w>=0.0){a=applyImageProcessing(a);}a=vec4<f32>(a.rgb*a.a,a.a);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.vPositionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"})),tCA=H({buildGroundRenderable:()=>gCA});async function gCA(A,e,t,g,I,o,C=!0){const r=CjA(C,lo+ICA+(C?N9:ET)+eCA),n=rjA(A,e),s=njA(A,t,g),B=(await sjA(A,I,o)).createView(),Q=$o(A),E=r.createBindGroup(A,s,B,Q),c={order:200,isTransparent:!0,bind(l,u){return{renderable:c,pipeline:r.getPipeline(l,u),draw(p){return p.setBindGroup(1,E),p.setVertexBuffer(0,n.posBuffer),p.setVertexBuffer(1,n.normBuffer),p.setVertexBuffer(2,n.uvBuffer),p.setIndexBuffer(n.idxBuffer,"uint16"),p.drawIndexed(6),1}}}};return A._dlr?.c(c,gCA,A,e,t,g,I,void 0,C),c}function CjA(A,e){function t(g){const I=g._device;return oE&&l3===I||(oE=I.createBindGroupLayout({label:"ground-material",entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}]}),l3=I),oE}return{getPipeline(g,I){const o=g._device;l3!==o&&(k9.clear(),oE=null,l3=o);const C=`${+A}|${ri(I)}`,r=k9.get(C);if(r)return r;const n=o.createShaderModule({code:lo+ACA,label:"ground-vert"}),s=o.createShaderModule({code:e,label:"ground-frag"}),B=o.createRenderPipeline({label:"ground-pipeline",layout:o.createPipelineLayout({bindGroupLayouts:[oi(g),t(g)]}),vertex:{module:n,entryPoint:"main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:12,attributes:[{shaderLocation:1,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:2,offset:0,format:"float32x2"}]}]},fragment:{module:s,entryPoint:"main",targets:[{format:I._colorFormat,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},depthStencil:{format:I._depthStencilFormat??"depth24plus-stencil8",depthCompare:I._depthCompare??"greater-equal",depthWriteEnabled:!1},multisample:{count:I._sampleCount},primitive:{topology:"triangle-list",cullMode:"back",frontFace:"ccw"}});return k9.set(C,B),B},createBindGroup(g,I,o,C){return g._device.createBindGroup({layout:t(g),entries:[{binding:0,resource:{buffer:I}},{binding:1,resource:o},{binding:2,resource:C}]})}}}function rjA(A,e){const t=e/2,g=new CA([-t,-t,0,t,-t,0,t,t,0,-t,t,0]),I=new CA([0,0,1,0,0,1,0,0,1,0,0,1]),o=new CA([0,0,1,0,1,1,0,1]),C=new l1([0,2,1,0,3,2]);return{posBuffer:Ft(A,g,iA.VERTEX),normBuffer:Ft(A,I,iA.VERTEX),uvBuffer:Ft(A,o,iA.VERTEX),idxBuffer:Ft(A,C,iA.INDEX)}}function njA(A,e,t){const g=new CA(iCA/4),I=2220446049250313e-31;return g[0]=g[15]=1,g[5]=g[10]=I,g[6]=-1,g[9]=1,g[12]=e[0],g[13]=e[1],g[14]=e[2],g[16]=t[0],g[17]=t[1],g[18]=t[2],g[19]=.9,g[20]=0,g[21]=0,g[22]=0,Rg(A,g)}async function sjA(A,e,t){const g=A._device;if(!e){const C=g.createTexture({size:[1,1],format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST});return g.queue.writeTexture({texture:C},new Te([255,255,255,255]),{bytesPerRow:4},[1,1]),C}const I=t?await t:await fetch(e).then(C=>C.blob()).then(C=>createImageBitmap(C,{premultiplyAlpha:"none"})),o=g.createTexture({size:[I.width,I.height],format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});return g.queue.copyExternalImageToTexture({source:I},{texture:o},[I.width,I.height]),I.close(),o}var ICA,iCA,k9,oE,l3,oCA=b((()=>{VA(),ZA(),oo(),gI(),Ci(),ni(),ijA(),ojA(),qI(),O1(),G9(),it(),ICA="fn applyImageProcessing(result:vec4<f32>)->vec4<f32>{var rgb=result.rgb;rgb*=scene.vImageInfos.x;const tonemappingCalibration:f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb);rgb=pow(rgb,vec3<f32>(1.0/2.2));rgb=clamp(rgb,vec3<f32>(0.0),vec3<f32>(1.0));let highContrast=rgb*rgb*(3.0-2.0*rgb);if(scene.vImageInfos.y<1.0){rgb=mix(vec3<f32>(0.5),rgb,scene.vImageInfos.y);}else{rgb=mix(rgb,highContrast,scene.vImageInfos.y-1.0);}rgb=max(rgb,vec3<f32>(0.0));return vec4<f32>(rgb,result.a);}",iCA=96,k9=new Map,oE=null,l3=null}));function CCA(A,e){const t=new CA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),g=new l1([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return[Ft(A,t,iA.VERTEX),Ft(A,g,iA.INDEX)]}async function rCA(A,e,t){return await A._environmentSkyboxShaderComposer?.(e,t)??e}function nCA(A,e,t,g){const I={order:0,isTransparent:!1,bind(o,C){return{renderable:I,pipeline:A.getPipeline(o,C),draw(r){return r.setBindGroup(1,e),r.setVertexBuffer(0,t),r.setIndexBuffer(g,"uint16"),r.drawIndexed(36),1}}}};return I}function sCA(A,e,t){function g(I){const o=I._device;d3!==o&&(u3.clear(),p3.clear(),d3=o);const C=p3.get(A);if(C)return C;const r=o.createBindGroupLayout({label:`${A}-material`,entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}]});return p3.set(A,r),r}return{getPipeline(I,o){const C=I._device;d3!==C&&(u3.clear(),p3.clear(),d3=C);const r=`${t}|${ri(o)}`,n=u3.get(r);if(n)return n;const s=C.createShaderModule({code:e,label:`${A}-vert`}),B=C.createShaderModule({code:t,label:`${A}-frag`}),Q=C.createRenderPipeline(IT({_label:`${A}-pipeline`,_engine:I,_bgls:[oi(I),g(I)],_vertModule:s,_fragModule:B,_vertexBuffers:BCA,_format:o._colorFormat,_depthStencilFormat:o._depthStencilFormat,_depthCompare:o._depthCompare,_msaaSamples:o._sampleCount,_depthWriteEnabled:!1}));return u3.set(r,Q),Q},createBindGroup(I,o,C,r){return I._device.createBindGroup({layout:g(I),entries:[{binding:0,resource:{buffer:o}},{binding:1,resource:C},{binding:2,resource:r}]})}}}var BCA,u3,p3,d3,QCA=b((()=>{VA(),ZA(),Ci(),ni(),qI(),it(),BCA=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],u3=new Map,p3=new Map,d3=null})),aCA,BjA=b((()=>{aCA="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,1.0)).xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),ECA,QjA=b((()=>{ECA="struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,exposureLinear:f32,contrast:f32,_pad1:f32,_pad2:f32,_pad3:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var c:texture_cube<f32>;@group(1) @binding(2) var d:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:h)->@location(0) vec4<f32>{var e=normalize(b.positionUVW);var a=textureSampleLevel(c,d,e,0.0).rgb;a*=mesh.primaryColor;if (scene.vImageInfos.w>=0.0){a*=mesh.exposureLinear;a=1.0-exp2(-1.590579*a);a=pow(a,vec3<f32>(1.0/2.2));a=saturate(a);let f=a*a*(3.0-2.0*a);a=mix(a,f,mesh.contrast-1.0);a=a+vec3<f32>(dither(b.positionW.xy,0.5));a=max(a,vec3<f32>(0.0));}return vec4<f32>(a,1.0);}"})),ajA=H({buildDdsSkyboxRenderable:()=>cT});async function cT(A,e,t,g,I,o=!0){const C=A.surface.engine,[r,n]=CCA(C,e),{cubeView:s,sampler:B}=await cjA(C,I??lCA),Q=await rCA(A,ECA,"dds"),E=lo+(o?N9:ET)+Q,c=sCA(o?"skybox-dds":"skybox-dds0",lo+aCA,E),l=EjA(C,t,g,A.imageProcessing.exposure,A.imageProcessing.contrast),u=nCA(c,c.createBindGroup(C,l,s,B),r,n);return C._dlr?.c(u,cT,A,e,t,g,I,o),u}function EjA(A,e,t,g,I){const o=new CA(cCA/4);return o[0]=o[5]=o[10]=o[15]=1,o[12]=e[0],o[13]=e[1],o[14]=e[2],o[16]=t[0],o[17]=t[1],o[18]=t[2],o[19]=g,o[20]=I,Rg(A,o)}async function cjA(A,e){const t=A._device,g=await(await fetch(e)).arrayBuffer(),I=new Ho(g,0,32),o=I[3],C=Math.max(I[7],1),r=I[21]===808540228?148:128,n=new Te(g,r),s=t.createTexture({size:[o,o,6],format:"rgba16float",mipLevelCount:C,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});let B=0;for(let Q=0;Q<6;Q++)for(let E=0;E<C;E++){const c=Math.max(o>>E,1);t.queue.writeTexture({texture:s,origin:{x:0,y:0,z:Q},mipLevel:E},n.buffer,{offset:n.byteOffset+B,bytesPerRow:c*8},{width:c,height:c}),B+=c*c*8}return{cubeView:s.createView({dimension:"cube"}),sampler:LI(A,{magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",maxAnisotropy:4})}}var cCA,lCA,uCA=b((()=>{VA(),ZA(),ki(),gI(),G9(),O1(),QCA(),BjA(),QjA(),cCA=96,lCA="https://assets.babylonjs.com/core/environments/backgroundSkybox.dds"})),pCA,ljA=b((()=>{pCA="struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32,exposureLinear:f32,contrast:f32,_pad3:f32,_pad4:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var b:texture_cube<f32>;@group(1) @binding(2) var c:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(d:h)->@location(0) vec4<f32>{var e=normalize(d.positionUVW);var a=textureSampleLevel(b,c,e,0.0).rgb;a*=mesh.exposureLinear;a=pow(a,vec3<f32>(1.0/2.2));a=clamp(a,vec3<f32>(0.0),vec3<f32>(1.0));let f=a*a*(3.0-2.0*a);if (mesh.contrast<1.0){a=mix(vec3<f32>(0.5),a,mesh.contrast);} else{a=mix(a,f,mesh.contrast-1.0);}a=max(a,vec3<f32>(0.0));return vec4<f32>(a,1.0);}"})),dCA=H({buildHdrSkyboxRenderable:()=>fCA});async function fCA(A,e,t,g,I){const o=A.surface.engine,[C,r]=CCA(o,t),n=await rCA(A,pCA,"hdr"),s=sCA("skybox-hdr",lo+aT,n),B=ujA(o,g,I,A.clearColor,A.imageProcessing.exposure,A.imageProcessing.contrast),Q=nCA(s,s.createBindGroup(o,B,e.specularCubeView,e.cubeSampler),C,r);return o._dlr?.c(Q,fCA,A,e,t,g,I),Q}function ujA(A,e,t,g,I,o){const C=new CA(DCA/4);return C[0]=C[5]=C[10]=C[15]=1,C[12]=e[0],C[13]=e[1],C[14]=e[2],C[16]=t[0],C[17]=t[1],C[18]=t[2],C[20]=g.r,C[21]=g.g,C[22]=g.b,C[24]=I,C[25]=o,Rg(A,C)}var DCA,_CA=b((()=>{VA(),QCA(),P1A(),ljA(),O1(),gI(),DCA=112}));async function pjA(A,e,t){const g=A.surface.engine,I=fetch(e).then(w=>w.arrayBuffer()),o=K9(t.brdfUrl),{faceBlobs:C,irradianceSH:r,width:n,mipCount:s}=F1A(await I),B=await Promise.all(C.map(w=>createImageBitmap(w,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),Q=await Promise.resolve().then(()=>(m9(),S9)),E=Q.uploadCubemapRGBD(g,B,n,s);for(const w of B)w.close();const c=await o,l=Q.decodeBrdfPng(g,c);c.close();const u=CE(E,l,r,.8,g);A._envTextures=u,IE(A),qo(E),qo(l),A._disposables.push(()=>{t1(E),t1(l)}),A.imageProcessing.toneMappingEnabled=!0,A.imageProcessing.exposure=.8,A.imageProcessing.contrast=1.2;const p=t?.groundTextureUrl,d=p?fetch(p).then(w=>w.blob()).then(w=>createImageBitmap(w,{premultiplyAlpha:"none"})):void 0,f=t?.skyboxUrl,D=f!=null&&f.toLowerCase().endsWith(".dds"),_=f!=null&&(f===e||f.toLowerCase().endsWith(".env")),y={skipSkybox:D||_||t?.skipSkybox,skipGround:t?.skipGround};return g._dlr?.e(A,e,t.brdfUrl),A._deferredBuilders.push(async()=>{const w=A.environmentPrimaryColor??[.08697355964132344,.08697355964132344,.2122208331110881],{groundSize:S,skyboxSize:R,rootPosition:M}=x1A(A,t?.skyboxSize),N=R/2;if(!y.skipSkybox){const G=await Promise.resolve().then(()=>($1A(),W1A));A._renderables.push(G.buildSolidSkyboxRenderable(A,u,N,M,w))}if(!y.skipGround){const G=await Promise.resolve().then(()=>(oCA(),tCA));A._renderables.push(await G.buildGroundRenderable(g,S,M,w,p,d))}if(D){const G=await Promise.resolve().then(()=>(uCA(),ajA));A._renderables.push(await G.buildDdsSkyboxRenderable(A,N,M,w,f))}if(_){const G=await Promise.resolve().then(()=>(_CA(),dCA));A._renderables.push(await G.buildHdrSkyboxRenderable(A,u,N,M,w))}}),u}function yCA(A){const e=.3333338747897695,t=.33333298856284405,g=1.4999984284682104,I=3.999982863580422,o=1.3333326611423701,C=.6666653397393608,r=1.999991431790211,n=new CA(36);for(let s=0;s<3;s++){const B=A[s],Q=A[3+s],E=A[6+s],c=A[9+s],l=A[12+s],u=A[15+s],p=A[18+s],d=A[21+s],f=A[24+s];n[s]=(c+l)*e+u*t,n[4+s]=Q*g,n[8+s]=E*g,n[12+s]=B*g,n[16+s]=f*I,n[20+s]=p*I,n[24+s]=u*o-(c+l)*C,n[28+s]=d*I,n[32+s]=(c-l)*r}return n}var lT=b((()=>{VA(),Br(),Bs(),f3(),K1A(),nT(),MQ()}));async function K9(A){const e=await fetch(A);if(e.ok)try{return await createImageBitmap(await e.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"})}catch{}throw new Error(`BRDF LUT '${A}' is not an image (${e.status} ${e.headers.get("content-type")??""}).`)}function CE(A,e,t,g,I,o){return{specularCube:A,specularCubeView:A.createView({dimension:"cube"}),brdfLut:e,brdfLutView:e.createView(),cubeSampler:B9(I),brdfSampler:$o(I),irradianceSH:t,sphericalHarmonics:o??yCA(t),lodGenerationScale:g}}var f3=b((()=>{lT(),oo()}));function hCA(A){const e=1/Math.PI,t=new CA(27);for(let g=0;g<3;g++){const I=g*9,o=A[I],C=A[I+1],r=A[I+2],n=A[I+3],s=A[I+4],B=A[I+5],Q=A[I+6],E=A[I+7],c=A[I+8];t[0+g]=n*1.02333*e,t[3+g]=C*1.02333*e,t[6+g]=r*1.02333*e,t[9+g]=(o*.886227-Q*.247708+c*.429043)*e,t[12+g]=(o*.886227-Q*.247708-c*.429043)*e,t[15+g]=(o*.886227+Q*.495417)*e,t[18+g]=B*.858086*e,t[21+g]=E*.858086*e,t[24+g]=s*.858086*e}return t}var wCA=b((()=>{VA()})),djA=H({computeSHFromEquirect:()=>RCA,parseRGBE:()=>SCA});function SCA(A){const e=new Te(A);let t=0;function g(){let Q="";for(;t<e.length;){const E=e[t++];if(E===10)break;E!==13&&(Q+=String.fromCharCode(E))}return Q}g().startsWith("#?")||m(235);let I="";for(;t<e.length;){const Q=g();if(Q==="")break;Q.startsWith("FORMAT=")&&(I=Q.slice(7))}I&&I!=="32-bit_rle_rgbe"&&m(236,I);const o=g(),C=o.match(/-Y\s+(\d+)\s+\+X\s+(\d+)/);C||m(237,o);const r=parseInt(C[1],10),n=parseInt(C[2],10),s=new CA(n*r*3),B=new Te(n*4);for(let Q=0;Q<r;Q++)t=fjA(e,t,n,s,Q*n*3,B);return{width:n,height:r,data:s}}function fjA(A,e,t,g,I,o){if(t>=8&&t<=32767&&A[e]===2&&A[e+1]===2&&(A[e+2]&128)===0){(A[e+2]<<8)+A[e+3]!==t&&m(238),e+=4;for(let C=0;C<4;C++){let r=C,n=0;for(;n<t;){e>=A.length&&m(239);const s=A[e++];if(s===0&&m(240),s>128){const B=s-128;(B>t-n||e>=A.length)&&m(241);const Q=A[e++];for(let E=0;E<B;E++)o[r]=Q,r+=4;n+=B}else{(s>t-n||e+s>A.length)&&m(242);for(let B=0;B<s;B++)o[r]=A[e++],r+=4;n+=s}}}for(let C=0;C<t;C++)MCA(o[C*4],o[C*4+1],o[C*4+2],o[C*4+3],g,I+C*3)}else{e+t*4>A.length&&m(243);for(let C=0;C<t;C++)MCA(A[e],A[e+1],A[e+2],A[e+3],g,I+C*3),e+=4}return e}function MCA(A,e,t,g,I,o){if(g===0)I[o]=I[o+1]=I[o+2]=0;else{const C=Math.pow(2,g-136);I[o]=A*C,I[o+1]=e*C,I[o+2]=t*C}}function RCA(A,e,t){const g=.282094791773878,I=.48860251190292,o=1.092548430592079,C=.31539156525252,r=.54627421529604,n=new Zo(27);let s=0;for(let E=0;E<t;E++){const c=(E+.5)/t*Math.PI,l=Math.sin(c),u=Math.cos(c),p=l*(Math.PI/t)*(2*Math.PI/e);for(let d=0;d<e;d++){const f=(2*(d+.5)/e-1)*Math.PI,D=l*Math.sin(f),_=u,y=l*Math.cos(f),w=(E*e+d)*3;let S=A[w],R=A[w+1],M=A[w+2];const N=Math.max(S,R,M);if(N>4096){const F=4096/N;S*=F,R*=F,M*=F}const G=p;s+=G;const K=[g,I*_,I*y,I*D,o*D*_,o*_*y,C*(3*y*y-1),o*D*y,r*(D*D-_*_)];for(let F=0;F<9;F++){const v=K[F]*G;n[F]=n[F]+S*v,n[9+F]=n[9+F]+R*v,n[18+F]=n[18+F]+M*v}}}const B=4*Math.PI/s;for(let E=0;E<27;E++)n[E]=n[E]*B;const Q=[1,2/3,2/3,2/3,.25,.25,.25,.25,.25];for(let E=0;E<3;E++)for(let c=0;c<9;c++)n[E*9+c]=n[E*9+c]*Q[c];return hCA(n)}var mCA=b((()=>{rA(),VA(),wCA()})),NCA,DjA=b((()=>{NCA="struct t{faceSize:u32,equirectWidth:u32,equirectHeight:u32,_pad:u32}@group(0) @binding(0) var p:texture_2d<f32>;@group(0) @binding(1) var k:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(2) var<uniform> params:t;const i=3.14159265359;const d=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) a:vec3u){let h=a.z;let c=params.faceSize;if (a.x>=c||a.y>=c||h>=6u){return;}let f=f32(a.x)/f32(c);let e=f32(a.y)/f32(c);let b=h*4u;let g=normalize(d[b]*(1.0-f)*(1.0-e)+d[b+1u]*f*(1.0-e)+d[b+2u]*(1.0-f)*e+d[b+3u]*f*e);let l=atan2(g.z,g.x);let m=acos(clamp(g.y,-1.0,1.0));let n=l/i*0.5+0.5;let o=m/i;let j=clamp(i32(round(n*f32(params.equirectWidth))),0,i32(params.equirectWidth)-1);let q=clamp(i32(round(o*f32(params.equirectHeight))),0,i32(params.equirectHeight)-1);let r=i32(params.equirectHeight)-q-1;let s=textureLoad(p,vec2<i32>(j,r),0);textureStore(k,vec2<i32>(a.xy),i32(h),vec4<f32>(s.rgb,1.0));}"})),GCA,_jA=b((()=>{GCA="struct ha{faceSize:u32,mipLevel:u32,totalMips:u32,srcSize:u32}@group(0) @binding(0) var x:texture_cube<f32>;@group(0) @binding(1) var F:sampler;@group(0) @binding(2) var z:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(3) var<uniform> params:ha;const k=3.14159265359;const n=1024u;const g=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));fn I(ca:u32,j:f32,d:f32)->vec3<f32>{let i=ca*4u;return normalize(g[i]*(1.0-j)*(1.0-d)+g[i+1u]*j*(1.0-d)+g[i+2u]*(1.0-j)*d+g[i+3u]*j*d);}fn J(ba:u32)->f32{var a=ba;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn K(aa:f32,C:f32,s:f32)->vec3<f32>{let Z=s*s;let u=2.0*k*aa;let o=sqrt((1.0-C)/(1.0+(Z-1.0)*C));let w=sqrt(1.0-o*o);return vec3<f32>(cos(u)*w,sin(u)*w,o);}fn L(y:f32,t:f32)->f32{let A=y*y*(t-1.0)+1.0;return t/(k*A*A);}fn H(Y:u32,M:f32,S:f32)->vec3<f32>{return I(Y,M,S);}@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) c:vec3u){let f=c.z;let h=params.faceSize>>params.mipLevel;if (c.x>=h||c.y>=h||f>=6u){return;}let R=f32(c.x)/f32(h);let Q=f32(c.y)/f32(h);let b=normalize(H(f,R,Q));let q=pow(2.0,f32(params.mipLevel)/0.8)/f32(params.srcSize);if (params.mipLevel==0u){let O=textureSampleLevel(x,F,b,0.0);textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(O.rgb,1.0));return;}var X=select(vec3<f32>(1.0,0.0,0.0),vec3<f32>(0.0,0.0,1.0),abs(b.z)<0.999);let v=normalize(cross(X,b));let P=cross(b,v);var p=vec3<f32>(0.0);var m=0.0;let E=f32(params.srcSize);let T=4.0*k/(6.0*E*E);let U=f32(params.totalMips)-1.0;for(var e=0u;e<n;e++){let W=f32(e)/f32(n);let N=J(e);let r=K(W,N,q);let B=v*r.x+P*r.y+b*r.z;let D=max(dot(b,B),0.0);let G=2.0*D*B-b;let l=dot(b,G);if (l>0.0){let da=q*q;let ea=L(D,da)/4.0;let fa=1.0/(f32(n)*max(ea,0.0001));let ga=clamp(0.5*log2(fa/T)+1.0,0.0,U);let V=textureSampleLevel(x,F,G,ga);p+=V.rgb*l;m+=l;}}if (m>0.0){p/=m;}textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(p,1.0));}"})),uT,bCA=b((()=>{uT="@group(0) @binding(0) var z:texture_storage_2d<rgba16float,write>;fn x(G:u32)->f32{var a=G;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn w(B:f32,u:f32,J:f32)->vec3f{let t=2.0*3.14159265359*B;let k=sqrt((1.0-u)/(1.0+(J-1.0)*u));let q=sqrt(1.0-k*k);return vec3f(cos(t)*q,sin(t)*q,k);}fn y(b:f32,n:f32)->vec2f{let o=vec3f(sqrt(1.0-b*b),0.0,b);let p=n*n;let e=p*p;var r=0.0;var l=0.0;let g=1024u;for(var f=0u;f<g;f++){let F=f32(f)/f32(g);let E=x(f);let j=w(F,E,e);let i=max(dot(o,j),0.0);let A=2.0*i*j-o;let d=max(A.z,0.0);let s=max(j.z,0.0);if (d>0.0&&s>0.0){let C=d*sqrt(b*b*(1.0-e)+e);let D=b*sqrt(d*d*(1.0-e)+e);let v=(0.5/max(C+D,1e-6))*d*(4.0*i/s);let m=pow(1.0-i,5.0);r+=(1.0-m)*v;l+=m*v;}}return vec2f(r/f32(g),l/f32(g));}@compute @workgroup_size(8,8) fn main(@builtin(global_invocation_id) c:vec3u){if (c.x>=256u||c.y>=256u){return;}let H=max((f32(c.x)+0.5)/256.0,0.001);let I=max((f32(c.y)+0.5)/256.0,0.04);let h=y(H,I);textureStore(z,vec2u(c.x,c.y),vec4f(h.y,h.x+h.y,0.0,1.0));}"})),yjA=H({HDR_LOD_GENERATION_SCALE:()=>pT,_enableHdrEnvironmentCopySource:()=>FCA,equirectToCubemapGPU:()=>kCA,generateBrdfLut:()=>vCA,prefilterCubemapGPU:()=>KCA});function FCA(){dT=_A.COPY_SRC}function kCA(A,e,t){const g=A._device,I=g.createTexture({size:[e.width,e.height],format:"rgba32float",usage:_A.TEXTURE_BINDING|_A.COPY_DST});{const E=new CA(e.width*e.height*4);for(let c=0;c<e.width*e.height;c++)E[c*4]=e.data[c*3],E[c*4+1]=e.data[c*3+1],E[c*4+2]=e.data[c*3+2],E[c*4+3]=1;g.queue.writeTexture({texture:I},E.buffer,{bytesPerRow:e.width*16},{width:e.width,height:e.height})}const o=g.createTexture({size:[t,t,6],format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING|_A.COPY_SRC,dimension:"2d"}),C=g.createShaderModule({code:NCA}),r=g.createComputePipeline({layout:"auto",compute:{module:C,entryPoint:"main"}}),n=Rg(A,new gt([t,e.width,e.height,0])),s=g.createBindGroup({layout:r.getBindGroupLayout(0),entries:[{binding:0,resource:I.createView()},{binding:1,resource:o.createView()},{binding:2,resource:{buffer:n}}]}),B=g.createCommandEncoder(),Q=B.beginComputePass();return Q.setPipeline(r),Q.setBindGroup(0,s),Q.dispatchWorkgroups(Math.ceil(t/8),Math.ceil(t/8),6),Q.end(),g.queue.submit([B.finish()]),I.destroy(),n.destroy(),o}function KCA(A,e,t,g){const I=A._device,o=I.createTexture({size:{width:t,height:t,depthOrArrayLayers:6},mipLevelCount:g,format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING|_A.COPY_DST|dT}),C=e.createView({dimension:"cube"}),r=$o(A),n=I.createComputePipeline({layout:"auto",compute:{module:I.createShaderModule({code:GCA}),entryPoint:"main"}}),s=XI(A,16);{const B=I.createCommandEncoder();B.copyTextureToTexture({texture:e},{texture:o,mipLevel:0},{width:t,height:t,depthOrArrayLayers:6}),I.queue.submit([B.finish()])}for(let B=1;B<g;B++){const Q=t>>B;if(Q<1)break;I.queue.writeBuffer(s,0,new gt([t,B,g,t]));const E=o.createView({baseMipLevel:B,mipLevelCount:1}),c=I.createBindGroup({layout:n.getBindGroupLayout(0),entries:[{binding:0,resource:C},{binding:1,resource:r},{binding:2,resource:E},{binding:3,resource:{buffer:s}}]}),l=I.createCommandEncoder(),u=l.beginComputePass();u.setPipeline(n),u.setBindGroup(0,c),u.dispatchWorkgroups(Math.ceil(Q/8),Math.ceil(Q/8),6),u.end(),I.queue.submit([l.finish()])}return e.destroy(),s.destroy(),o}function vCA(A){const e=A._device;(!D3||fT!==e)&&(D3=e.createComputePipeline({layout:"auto",compute:{module:e.createShaderModule({code:uT}),entryPoint:"main"}}),fT=e);const t=256,g=e.createTexture({size:{width:t,height:t},format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING}),I=e.createBindGroup({layout:D3.getBindGroupLayout(0),entries:[{binding:0,resource:g.createView()}]}),o=e.createCommandEncoder(),C=o.beginComputePass();return C.setPipeline(D3),C.setBindGroup(0,I),C.dispatchWorkgroups(Math.ceil(t/8),Math.ceil(t/8)),C.end(),e.queue.submit([o.finish()]),g}var pT,dT,D3,fT,DT=b((()=>{VA(),ZA(),oo(),gI(),co(),DjA(),_jA(),bCA(),pT=.8,dT=0,D3=null,fT=null})),hjA=H({rebuildSceneEnvironment:()=>wjA});async function wjA(A,e){const t=e._envTextures;if(!t)return;const g=e._envRecoverySource;g||m(198);const I=t.sphericalHarmonics;e._envTextures=void 0;let o;if(g.kind==="env")o=await SjA(A,g,I);else{const n=await Promise.resolve().then(()=>(mCA(),djA)),s=await Promise.resolve().then(()=>(DT(),yjA)),B=await UCA(g.url),Q=n.parseRGBE(B),E=n.computeSHFromEquirect(Q.data,Q.width,Q.height),c=s.equirectToCubemapGPU(A,Q,g.faceSize);o=CE(s.prefilterCubemapGPU(A,c,g.faceSize,Math.floor(Math.log2(g.faceSize))+1),s.generateBrdfLut(A),E,s.HDR_LOD_GENERATION_SCALE,A,I)}Object.assign(t,o);const{specularCube:C,brdfLut:r}=t;qo(C),qo(r),e._disposables.push(()=>{t1(C),t1(r)}),e._envTextures=t,e._envRecoverySource=g}async function SjA(A,e,t){const g=K9(e.brdfUrl);g.catch(()=>{});const{faceBlobs:I,irradianceSH:o,width:C,mipCount:r}=F1A(await UCA(e.url)),n=await Promise.all(I.map(c=>createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),s=await Promise.resolve().then(()=>(m9(),S9)),B=s.uploadCubemapRGBD(A,n,C,r);for(const c of n)c.close();const Q=await g,E=s.decodeBrdfPng(A,Q);return Q.close(),CE(B,E,o,.8,A,t)}async function UCA(A){const e=await fetch(A);return e.ok||m(199,A,e.status,e.statusText),e.arrayBuffer()}var MjA=b((()=>{rA(),Br(),Bs(),f3(),K1A()}));function Cg(A,e,t=0,g=0){const I=e;if(g===0&&I.length===16){A.set(I,t);return}const o=g,C=t;A[C+0]=I[o+0],A[C+1]=I[o+1],A[C+2]=I[o+2],A[C+3]=I[o+3],A[C+4]=I[o+4],A[C+5]=I[o+5],A[C+6]=I[o+6],A[C+7]=I[o+7],A[C+8]=I[o+8],A[C+9]=I[o+9],A[C+10]=I[o+10],A[C+11]=I[o+11],A[C+12]=I[o+12],A[C+13]=I[o+13],A[C+14]=I[o+14],A[C+15]=I[o+15]}var Hi=b((()=>{}));function _T(A,e){Cg(A,e._lightMatrix,0),A[16]=e._depthValues[0],A[17]=e._depthValues[1],A[18]=0,A[19]=0,A[20]=e._shadowsInfo[0],A[21]=e._shadowsInfo[1],A[22]=e._shadowsInfo[2],A[23]=e._shadowsInfo[3]}function LCA(A,e,t,g,I,o){const C=Math.sqrt(A*A+e*e+t*t)||1,r=A/C,n=e/C,s=t/C;let B=0,Q=1,E=0;Math.abs(n)>.99&&(B=0,Q=0,E=1);let c=Q*s-E*n,l=E*r-B*s,u=B*n-Q*r;const p=Math.sqrt(c*c+l*l+u*u)||1;c/=p,l/=p,u/=p;const d=n*u-s*l,f=s*c-r*u,D=r*l-n*c;return new CA([c,d,r,0,l,f,n,0,u,D,s,0,-(c*g+l*I+u*o),-(d*g+f*I+D*o),-(r*g+n*I+s*o),1])}function YCA(A,e){const t=new CA(16);for(let g=0;g<4;g++)for(let I=0;I<4;I++){let o=0;for(let C=0;C<4;C++)o+=A[g+C*4]*e[C+I*4];t[g+I*4]=o}return t}function xCA(A,e,t,g,I=0,o=0,C=0){const r=A.worldMatrix,n=A.direction,s=LCA(r[0]*n.x+r[4]*n.y+r[8]*n.z,r[1]*n.x+r[5]*n.y+r[9]*n.z,r[2]*n.x+r[6]*n.y+r[10]*n.z,r[12]-I,r[13]-o,r[14]-C);let B=1/0,Q=-1/0,E=1/0,c=-1/0;for(const d of e){const f=d.worldMatrix,D=d.boundMin??[-.5,-.5,-.5],_=d.boundMax??[.5,.5,.5];for(let y=0;y<8;y++){const w=y&1?_[0]:D[0],S=y&2?_[1]:D[1],R=y&4?_[2]:D[2],M=f[0]*w+f[4]*S+f[8]*R+f[12]-I,N=f[1]*w+f[5]*S+f[9]*R+f[13]-o,G=f[2]*w+f[6]*S+f[10]*R+f[14]-C,K=s[0]*M+s[4]*N+s[8]*G+s[12],F=s[1]*M+s[5]*N+s[9]*G+s[13];B=Math.min(B,K),Q=Math.max(Q,K),E=Math.min(E,F),c=Math.max(c,F)}}Number.isFinite(B)||(B=-1,Q=1,E=-1,c=1);const l=(Q-B)*.1,u=(c-E)*.1;B-=l,Q+=l,E-=u,c+=u;const p=new CA(16);return p[0]=2/(Q-B),p[5]=2/(c-E),p[10]=1/(g-t),p[12]=-(Q+B)/(Q-B),p[13]=-(c+E)/(c-E),p[14]=-t/(g-t),p[15]=1,{_view:s,_viewProj:YCA(p,s),_near:t,_far:g}}function _3(A,e,t){const g=new CA(8);return g[0]=e,g[2]=t,g[4]=0,g[5]=1,Rg(A,g)}function JCA(A,e=null,t=A._depthTexture){const g=A._config._mapSize;return{_descriptor:{size:{width:g,height:g},format:e?"rgba16float":void 0,dFormat:"depth32float",depthClearValue:1,depthCompare:"less-equal",samples:1},_colorTexture:e,_colorView:e?.createView()??null,_depthTexture:t,_depthView:t.createView(),_width:g,_height:g,_eager:!0,_ownsDepthTexture:!1}}function yT(A,e,t,g){const I=new CA(24);return _T(I,{_lightMatrix:e,_depthValues:t,_shadowsInfo:g}),{ubo:Rg(A,I),data:I}}function hT(A){let e=0;for(const t of A)e+=t.worldMatrixVersion+~~t.thinInstances?._version;return e}function v9(A){return{fov:1,nearPlane:1,farPlane:1,children:[],_viewCache:bg(),_projCache:bg(),_vpCache:bg(),get worldMatrix(){return A._light.worldMatrix},get worldMatrixVersion(){return this._shadowCameraVersion??A._light._lightVersion}}}function U9(A,e,t,g,I,o){A.nearPlane=t,A.farPlane=g,A._shadowCameraVersion=e,A._viewCache=I,A._viewVer=e,A._vpCache=o,A._vpVer=p1(A),A._vpAspect=1}var Qs=b((()=>{VA(),it(),Mg(),gI(),Hi(),Ii()}));function HCA(A,e,t,g,I){A.fill(0);const o=io(g,I),C=Io(g),r=g.worldMatrix;Cg(A,o,0),Cg(A,C,16),e.useFloatingOrigin?(A[32]=0,A[33]=0,A[34]=0):(A[32]=r[12],A[33]=r[13],A[34]=r[14]),A[87]=e.canvas.width;const n=t.imageProcessing;A[76]=n.exposure,A[77]=n.contrast,A[78]=t._envTextures?.lodGenerationScale??.8,A[79]=+n.toneMappingEnabled,A[37]=e.canvas.height}var TCA=b((()=>{Mg(),Hi()}));function RjA(A){d1=A}var d1,wT=b((()=>{d1=null}));function qCA(A,e){return{_renderables:A,_opaqueBindings:[],_directBindings:[],_transparentBindings:[],_ob:[],_lastVersion:e}}function ST(A,e,t){A.clr??=!0;const g=A.rt._descriptor,I=A.depth?._descriptor,o={_colorFormat:g.format,_depthStencilFormat:I?.dFormat??g.dFormat,_depthCompare:g.depthCompare??I?.depthCompare,_sampleCount:g.samples},C={loadOp:"clear",storeOp:"store"},r={targetWidth:0,targetHeight:0},n={...qCA([],-1),name:A.name,_config:A,_ownsTargets:!A.sharedRt,engine:e,scene:t,_passes:[],_renderPassDescriptor:{colorAttachments:[C]},_colorAttachment:C,_sceneUBO:XI(e,368),_suData:new CA(92),_sceneUboCacheKey:[],_targetSignature:o,_updateContext:r,record(){if(n._disposed)throw new Error("RenderTask has been disposed.");n._recordExplicit?n._recordExplicit(n,!0):L9(n,A.autoMirror!==!1?t._renderables.slice():n._renderables,!0)},execute(){return FjA(n,e,o)},dispose(){if(n._disposed)return;n._disposed=!0,d1&&d1._retire([n._opaqueBindings,n._directBindings,n._transparentBindings]);const s=n._pendingMeshes;s&&(s.length=0);for(const Q of n._renderables)n._retireRenderable?.(n.engine,Q);n._passes.length=n._opaqueBindings.length=n._directBindings.length=0,n._transparentBindings.length=n._renderables.length=n._ob.length=0,n._ownsTargets&&(Bg(A.rt),Bg(A.rst)),A.depth?._eager||Bg(A.depth);const B=n._sceneUBO;ag(n.engine,()=>B.destroy()),n._batchState?._release(n.engine),n._batchState=void 0}};return n}function PCA(A,e){if(!A._renderables)return;A._removeMesh?.(e);let t=!1;for(let g=A._renderables.length-1;g>=0;g--)A._renderables[g].mesh===e&&(A._retireRenderable?.(A.engine,A._renderables[g]),A._renderables.splice(g,1),t=!0);for(const g of[A._opaqueBindings,A._directBindings,A._transparentBindings])for(let I=g.length-1;I>=0;I--)g[I].renderable.mesh===e&&(d1&&d1._retire([[g[I]]]),g.splice(I,1),t=!0);if(t){const g=A._batchState;A._batchState=g?._select([A._opaqueBindings,A._directBindings,A._transparentBindings]),g?._release(A.engine,[A._batchState]),A._ob.length=0,A._lastVersion=-1}}function mjA(A,e){return e._sortDistance-A._sortDistance||A.renderable.order-e.renderable.order}function OCA(A,e){return A.renderable.order-e.renderable.order}function NjA(A,e){const t=A._transparentBindings;if(t.length<=1||!e)return;const g=Io(e);for(const I of t){const o=I.renderable._worldCenter;I._sortDistance=o?o[0]*g[2]+o[1]*g[6]+o[2]*g[10]+g[14]:0}t.sort(mjA)}function L9(A,e=A._renderables,t=!1,g=!0,I){const o=A._config,C=o.rt,r=A._batchState,n=qCA(e,A.scene._renderableVersion);if(t){const E=(c,l)=>{c&&(l||A._ownsTargets||c._eager)&&sI(c,A.engine)};E(C),C._descriptor.samples>1&&E(o.rst),E(o.depth,!0)}const{_opaqueBindings:s,_directBindings:B,_transparentBindings:Q}=n;try{for(const E of e){const c=E.bind(A.engine,A._targetSignature);n._batchState=A._targetSignature._collectBatches?.(n._batchState,c),E.isTransparent||E._transmissive?Q.push(c):E._direct?B.push(c):s.push(c)}s.sort(OCA),B.sort(OCA),t&&VCA(A,A.engine,!1)}catch(E){throw d1&&d1._retire([n._opaqueBindings,n._directBindings,n._transparentBindings],[A._opaqueBindings,A._directBindings,A._transparentBindings]),n._batchState?._release(void 0,I??[r]),E}return t&&(GjA(A,C),A._updateContext.targetWidth=C._width,A._updateContext.targetHeight=C._height),g&&(d1&&d1._retire([A._opaqueBindings,A._directBindings,A._transparentBindings],[s,B,Q]),Object.assign(A,n),r?._release(A.engine,[n._batchState])),n}function GjA(A,e){const t=A._config,g=A._colorAttachment;g.view=e._colorView,A._renderPassDescriptor.colorAttachments=e._colorView?[g]:[];const I=t.depth??e,o=I._depthView;let C;if(o){const r=I._descriptor,n=(t.depth?I._eager:t.depthClear===!1)?"load":"clear";C={view:o,depthClearValue:r.depthClearValue??0,depthLoadOp:n,depthStoreOp:"store"},r.dFormat?.includes("stencil")&&(C.stencilClearValue=0,C.stencilLoadOp=n,C.stencilStoreOp="store")}A._renderPassDescriptor.depthStencilAttachment=C}function bjA(A,e,t){const g=A.scene;A._config.autoMirror!==!1&&A._lastVersion!==g._renderableVersion&&L9(A,g._renderables.slice()),VCA(A,e);const I=A._updateContext,o=A._config.cam??g.camera;t._colorFormat&&(A._config._skipClusteredLights||g._clusteredLightUpdater?.(o,I.targetWidth,I.targetHeight),TVA(e,g)),KjA(A,e,g,o),I._camera=o,A._batchState?._reset(),MT(A._opaqueBindings,I),MT(A._directBindings,I),MT(A._transparentBindings,I),A._batchState?._flush(e),NjA(A,o)}function FjA(A,e,t){if(A.enabled===!1)return 0;const g=A.scene;bjA(A,e,t);const I=A._colorAttachment,o=A._config;if(o.rt._colorView&&(o.rt===g.surface.scRT&&(I.view=o.rt._colorView),I.resolveTarget=o.rst?._colorView??void 0,I.clearValue=o.clrColor??g.clearColor,I.loadOp=o.clr?"clear":"load"),A._executeWithTransmission)return A._executeWithTransmission(t._sampleCount);const C=e._currentEncoder.beginRenderPass(A._renderPassDescriptor),r=kjA(A,C);return C.end(),r}function kjA(A,e){const t=A.engine,g=A._config,I=g.rt,o=A.scene,C=A._opaqueBindings,r=A._ob,n=A._sceneBG;if(n1A(e,g.cam??o.camera,I._width,I._height),e.setBindGroup(0,n),A._lastVis!==_Q||!r.length){const B=I._descriptor,Q=t._device.createRenderBundleEncoder({colorFormats:B.format?[B.format]:[],depthStencilFormat:A._targetSignature._depthStencilFormat,sampleCount:B.samples});Q.setBindGroup(0,n),rE(Q,C,t),r[0]=Q.finish(),A._lastVis=_Q}let s=C.length;return e.executeBundles(r),e.setBindGroup(0,n),s+=rE(e,A._directBindings,t),s+=rE(e,A._transparentBindings,t,!0),s}function VCA(A,e,t=!0){const g=_9(e,A.scene)._buffer;if(g===A._lightsUBO)return;const I=e._device.createBindGroup({layout:oi(e),entries:[{binding:0,resource:{buffer:A._sceneUBO}},{binding:1,resource:{buffer:g}}]});A._lightsUBO=g,A._sceneBG=I,t&&(A._ob=[])}function KjA(A,e,t,g){if(!g)return;const I=g.viewport,o=A._config.rt,C=(A._config.cs?e.canvas.width/e.canvas.height:o._width/o._height)*(I?I.width/I.height:1);d1&&d1._setProjectionAspect(A._updateContext,C);const r=t.fog,n=t.imageProcessing,s=p1(g),B=t._envTextures,Q=A._sceneUboCacheKey;if(Q[0]===g&&Q[1]===r&&Q[2]===s&&Q[3]===C&&Q[4]===n.exposure&&Q[5]===n.contrast&&Q[6]===B)return;Q[0]=g,Q[1]=r,Q[2]=s,Q[3]=C,Q[4]=n.exposure,Q[5]=n.contrast,Q[6]=B;const E=A._suData;HCA(E,e,t,g,C);const c=t._sceneUboContributors;if(c)for(const l of c)l(E,t);e._device.queue.writeBuffer(A._sceneUBO,0,E)}function MT(A,e){for(const t of A)t.update?.(e)}function rE(A,e,t,g){let I=null,o=0;for(const C of e){const r=C.renderable.mesh;r&&(r.visible===!1||g&&r._skipColorDraw)||(C.pipeline!==I&&(A.setPipeline(C.pipeline),I=C.pipeline),o+=C.draw(A,t))}return o}var nE=b((()=>{VA(),hI(),kg(),Fg(),Mg(),Ci(),TCA(),co(),y9(),rT(),wT()}));function RT(A,e){const t=A._groups.get(e);return t?t.r:e._sceneIndependentRebuild?e._rebuildSingle:void 0}var mT=b((()=>{}));function NT(A,e=[]){for(const{mesh:t,material:g}of A._pendingMeshes){if(!g)continue;const I={_lifetimeDisposers:[]},o=RT(A.scene,g._buildGroup);o||m(156),e.push(I);const C=o(A.scene,t,g,I);C._lifetimeDisposers=I._lifetimeDisposers,A._renderables.push(C)}return A._pendingMeshes.length=0,e}function vjA(A){const e=[],t={scene:A.scene,_renderables:A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()},g=()=>{for(const I of e)oC(I._lifetimeDisposers);e.length=0};try{A._prepareTaskMeshes?.(t),NT(t,e)}catch(I){throw g(),I}return{renderables:t._renderables,dispose:g}}function jCA(A,e=!1){A._disposed&&m(157);const t=A._batchState,g=[],I=A._pendingMeshes.length>0,o=A._config.autoMirror!==!1,C={scene:A.scene,_renderables:o?I?[]:A.scene._renderables.slice():A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()};let r;try{A._prepareTaskMeshes?.(C,!0),NT(C,g),r=L9(A,C._renderables,e,!1)}catch(n){for(const s of g)oC(s._lifetimeDisposers);throw n}I&&(A._config.autoMirror=!1),A._pendingMeshes=C._pendingMeshes,d1&&d1._retire([A._opaqueBindings,A._directBindings,A._transparentBindings],[r._opaqueBindings,r._directBindings,r._transparentBindings]),Object.assign(A,r),t?._release(A.engine,[r._batchState])}var WCA=b((()=>{rA(),kg(),mT(),nE(),wT()}));function sE(A,e,t){return ST(A,e,t)}function y3(A,e,t){h3(A),A._addMesh(e,t)}function h3(A){A._addMesh||(A._pendingMeshes??=[],A._addMesh=LjA,A._recordExplicit=jCA,A._retireRenderable=UjA)}function UjA(A,e){e._lifetimeDisposers&&XoA(A,e._lifetimeDisposers)}function LjA(A,e){if(this._disposed)throw new Error("RenderTask has been disposed.");const t=e?.material??A.material;t&&(this._pendingMeshes.push({mesh:A,material:t}),this._sceneBG&&GT(this))}function YjA(A,e){const t=A._pendingMeshes;if(t)for(let g=t.length-1;g>=0;g--)t[g].mesh===e&&t.splice(g,1);PCA(A,e)}function GT(A){jCA(A)}var BE=b((()=>{kg(),nE(),WCA()})),zCA,xjA=b((()=>{zCA="struct c{@builtin(position) clipPos:vec4<f32>,@location(0) sampleCenter:vec2<f32>}@vertex fn main(@builtin(vertex_index) d:u32)->c{var e=array<vec2<f32>,3>(vec2<f32>(-1.0,-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));var a:c;let b=e[d];a.clipPos=vec4<f32>(b,0.0,1.0);a.sampleCenter=b*vec2<f32>(0.5,-0.5)+0.5;return a;}"}));function rC(A,e){const t=si(A);return Object.create(t,{source:{value:t,enumerable:!0},_renderFeatures:{value:{features:e.features,features2:e.features2},writable:!0,enumerable:!0,configurable:!0}})}function Y9(A){const e=A;return!!e.source&&!!e._renderFeatures}function si(A){return Y9(A)?A.source:A}var wI=b((()=>{}));function JjA(){JT=A=>A}function HjA(A){S3=A}function Po(A){(T9??=new Map).set(A._id,A),M3=null}function ZCA(){return T9??=new Map}function w3(){if(!M3){const A=T9;M3=A?Array.from(A.values()).sort((e,t)=>e._id.localeCompare(t._id)):[]}return M3}var x9,J9,bT,FT,kT,as,KT,QE,vT,RQ,XCA,UT,LT,H9,YT,xT,JT,S3,T9,M3,q9,mg=b((()=>{x9=1024,J9=2048,bT=4096,FT=8192,kT=16384,as=65536,KT=1<<17,QE=1<<18,vT=1<<19,RQ=1<<20,XCA=1<<21,UT=32768,LT=1<<22,H9=1<<24,YT=1<<26,xT=1<<27,JT=null,S3=null,T9=null,M3=null,q9=3456})),TjA=H({createStandardEsmShadowMaterialView:()=>qjA});function qjA(A,e){const t=rC(A,{features:(A._renderFeatures??{features:0}).features&~as|RQ});return Object.defineProperty(t,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(t,"_esmShadowDepthCode",{value:$CA,enumerable:!1}),t}var $CA,PjA=b((()=>{wI(),mg(),$CA="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),R3,m3,P9,HT,O9,V9,TT,j9,W9,qT,aE,PT,z9,Z9,X9,EE,mQ,Ti=b((()=>{R3=1024,m3=2048,P9=4096,HT=32768,O9=1<<17,V9=1<<21,TT=1<<22,j9=1<<25,W9=1<<26,qT=1<<27,aE=1<<28,PT=1<<29,z9=1024,Z9=2048,X9=4096,EE=32768,mQ=65536})),OjA=H({PBR2_ESM_SHADOW_OUTPUT:()=>mQ,PBR2_HAS_BASE_COLOR_FACTOR:()=>X9,PBR2_HAS_REFLECTANCE_FACTORS:()=>z9,PBR2_HAS_REFRACTION:()=>16,PBR2_HAS_UV2:()=>Z9,PBR2_HAS_UV_TRANSFORM:()=>512,PBR2_NO_COLOR_OUTPUT:()=>EE,PBR_HAS_ALPHA_BLEND:()=>64,PBR_HAS_ALPHA_TEST:()=>8,PBR_HAS_ANISOTROPY:()=>W9,PBR_HAS_COTANGENT_NORMAL:()=>512,PBR_HAS_DOUBLE_SIDED:()=>256,PBR_HAS_EMISSIVE:()=>2,PBR_HAS_EMISSIVE_COLOR:()=>V9,PBR_HAS_ENV:()=>4,PBR_HAS_FOG:()=>32,PBR_HAS_GAMMA_ALBEDO:()=>j9,PBR_HAS_METALLIC_REFLECTANCE_MAP:()=>R3,PBR_HAS_NORMAL_MAP:()=>1,PBR_HAS_OCCLUSION:()=>HT,PBR_HAS_REFLECTANCE_MAP:()=>m3,PBR_HAS_SHEEN:()=>TT,PBR_HAS_SKYBOX:()=>PT,PBR_HAS_SPECULAR_AA:()=>O9,PBR_HAS_SPEC_GLOSS:()=>128,PBR_HAS_SUBSURFACE:()=>qT,PBR_HAS_THICKNESS_MAP:()=>aE,PBR_HAS_TONEMAP:()=>16,PBR_HAS_USE_ALPHA_ONLY_MR:()=>P9,_getPbrExts:()=>Es,_getPbrExtsSorted:()=>ArA,_getPbrSceneHooks:()=>erA,_registerPbrExt:()=>AI,_registerPbrSceneHook:()=>$9});function AI(A){(AU??=new Map).set(A.id,A),N3=null}function Es(){return AU??=new Map}function ArA(){if(!N3){const A=AU;N3=A?Array.from(A.values()).sort((e,t)=>e.id.localeCompare(t.id)):[]}return N3}function $9(A){(OT??=new Set).add(A)}function erA(){return OT??[]}var AU,N3,OT,Eg=b((()=>{Ti(),AU=null,N3=null,OT=null})),VjA=H({createPbrEsmShadowMaterialView:()=>jjA});function jjA(A,e){const t=A._renderFeatures??{features:0,features2:0},g=rC(A,{features:t.features&-194,features2:(t.features2??0)&-17|mQ});return Object.defineProperty(g,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(g,"_esmShadowDepthCode",{value:trA,enumerable:!1}),g}var trA,WjA=b((()=>{wI(),Eg(),trA="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),eU=b((()=>{})),zjA=H({createNodeEsmShadowMaterialView:()=>ZjA});function ZjA(A,e){const t=rC(A,{features:(A._renderFeatures??{features:0}).features|2});return Object.defineProperty(t,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(t,"_esmShadowDepthCode",{value:grA,enumerable:!1}),t}var grA,XjA=b((()=>{wI(),eU(),grA="let depthMetricSM=(in.position.z+nmeShadowParams.depthValues.x)/nmeShadowParams.depthValues.y+nmeShadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,nmeShadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),$jA=H({createEsmDirectionalShadowGenerator:()=>rrA,ensureEsmShadowTaskState:()=>orA,getEsmShadowTaskResources:()=>VT,setEsmShadowTaskResources:()=>IrA});function IrA(A,e){A._esmResources=e}function VT(A){return A._esmResources??null}async function AWA(A){const e=[];let t=!1,g=!1,I=!1;for(const o of A){const C=o.material?._buildGroup._materialFamily;t||=C==="standard",g||=C==="pbr",I||=C==="node"}t&&!jT&&e.push(Promise.resolve().then(()=>(PjA(),TjA)).then(o=>{jT=o.createStandardEsmShadowMaterialView})),g&&!WT&&e.push(Promise.resolve().then(()=>(WjA(),VjA)).then(o=>{WT=o.createPbrEsmShadowMaterialView})),I&&!zT&&e.push(Promise.resolve().then(()=>(XjA(),zjA)).then(o=>{zT=o.createNodeEsmShadowMaterialView})),await Promise.all(e)}function eWA(A){const e=Math.round(Math.max(A,1));for(const t of[e,e-1,e+1,e-2,e+2])if(t%2!==0&&Math.floor(t/2)%2===0&&t>0)return Math.max(t,3);return Math.max(e,3)}function tWA(A){const e=.3333333333333333;return Math.exp(-(A*A/(2*e*e)))/(Math.sqrt(2*Math.PI)*e)}function gWA(A){const e=eWA(A),t=(e-1)/2,g=[],I=[];let o=0;for(let n=0;n<e;n++){const s=tWA(n/(e-1)*2-1);g[n]=n-t,I[n]=s,o+=s}for(let n=0;n<I.length;n++)I[n]=I[n]/o;const C=[],r=[];for(let n=0;n<=t;n+=2){const s=Math.min(n+1,Math.floor(t));if(n===s){C.push(g[n]),r.push(I[n]);continue}const B=s===t,Q=I[n]+I[s]*(B?.5:1),E=g[n]+1/(1+I[n]/I[s]);E===0?(C.push(g[n],g[n+1]),r.push(I[n],I[n+1])):(C.push(E,-E),r.push(Q,Q))}return{offsets:C,weights:r}}function irA(A){let e=(Object.is(A,-0)?0:A).toPrecision(10);return/[.eE]/.test(e)||(e+=".0"),e}function IWA(A){const{offsets:e,weights:t}=gWA(A),g=e.length;return`struct BlurParams{delta:vec2<f32>,_pad:vec2<f32>,};@group(0)@binding(0)var<uniform>params:BlurParams;@group(0)@binding(1)var srcTex:texture_2d<f32>;@group(0)@binding(2)var srcSampler:sampler;const OFFSETS=array<f32,${g}>(${e.map(irA).join(",")});const WEIGHTS=array<f32,${g}>(${t.map(irA).join(",")});@fragment fn main(@location(0)sampleCenter:vec2<f32>)->@location(0)vec4<f32>{var blend=vec4<f32>(0.0);for(var i=0u;i<${g}u;i=i+1u){blend+=textureSample(srcTex,srcSampler,sampleCenter+params.delta*OFFSETS[i])*WEIGHTS[i];}return blend;}`}function orA(A,e,t,g,I){const o=I;if(o){if(o._casterMeshes===g)return o;ag(A,o._task.dispose)}const C=VT(t);if(!C)throw new Error("ShadowTask: missing ESM metadata.");const r=new Map,n=v9(t),s={_task:sE({name:"esm",rt:JCA(t,C._esmTexture,C._depthBuffer),clr:!0,clrColor:{r:0,g:0,b:0,a:0},cam:n,autoMirror:!1,_skipClusteredLights:!0},A,e),_camera:n,_lastCasterVersion:-1,_lastLightVersion:-1,_lastFoVersion:-1,_casterMeshes:g,_scene:e};for(const B of g){const Q=B.material;Q&&y3(s._task,B,{material:CWA(Q,r,t._shadowParamsUBO)})}return s}function iWA(A,e,t){const g=VT(e);if(!g)return 0;const I=t._casterMeshes,o=hT(I),C=e._light._lightVersion,r=A.useFloatingOrigin?t._scene.camera:null,n=r?r.worldMatrixVersion:0,s=r?r.worldMatrix[12]:0,B=r?r.worldMatrix[13]:0,Q=r?r.worldMatrix[14]:0;if(!e._config._forceRefreshEveryFrame&&o===t._lastCasterVersion&&C===t._lastLightVersion&&n===t._lastFoVersion&&r===t._lastFoCamera)return 0;const E=xCA(e._light,I,e._config._orthoMinZ,e._config._orthoMaxZ,s,B,Q);rWA(e._lightMatrix,E._viewProj)&&(Cg(e._lightMatrix,E._viewProj,0),e._version++,_T(g._shadowUboData,e),A._device.queue.writeBuffer(e._shadowUBO,0,g._shadowUboData)),oWA(t,E),t._lastCasterVersion=o,t._lastLightVersion=C,t._lastFoVersion=n,t._lastFoCamera=r;const c=t._task.execute?.()??0,l=A._currentEncoder;return CrA(l,g._blurPipeline,g._blurTexH,g._blurHBG),CrA(l,g._blurPipeline,e._depthTexture,g._blurVBG),c+2}function CrA(A,e,t,g){const I=A.beginRenderPass({colorAttachments:[{view:t.createView(),loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});I.setPipeline(e),I.setBindGroup(0,g),I.draw(3),I.end()}function oWA(A,e){const t=A._camera;U9(t,t.worldMatrixVersion+1,e._near,e._far,e._view,e._viewProj)}function CWA(A,e,t){const g=e.get(A);if(g)return g;const I=A._buildGroup._materialFamily;let o;return I==="standard"?o=jT(A,t):I==="pbr"?o=WT(A,t):I==="node"&&(o=zT(A,t)),e.set(A,o),o}function rWA(A,e){for(let t=0;t<16;t++)if(A[t]!==e[t])return!0;return!1}function rrA(A,e,t={}){const g=A._device,I=t.mapSize??1024,o=t.depthScale??50,C=t.bias??5e-5,r=t.blurKernel??1,n=t.blurScale??2,s=t.darkness??0,B=t.frustumEdgeFalloff??0,Q=t.orthoMinZ??1,E=t.orthoMaxZ??1e4,c=t.forceRefreshEveryFrame??!1,l=I/n,u={_mapSize:I,_bias:C,_orthoMinZ:Q,_orthoMaxZ:E,_forceRefreshEveryFrame:c},p=_3(A,C,o),d=g.createTexture({size:{width:I,height:I},format:"rgba16float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING}),f=g.createTexture({size:{width:I,height:I},format:"depth32float",usage:_A.RENDER_ATTACHMENT}),D=g.createTexture({size:{width:l,height:l},format:"rgba16float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING}),_=g.createTexture({size:{width:l,height:l},format:"rgba16float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING}),y=g.createShaderModule({code:zCA}),w=g.createShaderModule({code:IWA(r)}),S=g.createBindGroupLayout({entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}]}),R=g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[S]}),vertex:{module:y,entryPoint:"main"},fragment:{module:w,entryPoint:"main",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list",cullMode:"none"}}),M=$o(A),N=Rg(A,new CA([1/l,0,0,0])),G=g.createBindGroup({layout:S,entries:[{binding:0,resource:{buffer:N}},{binding:1,resource:d.createView()},{binding:2,resource:M}]}),K=Rg(A,new CA([0,1/l,0,0])),F=g.createBindGroup({layout:S,entries:[{binding:0,resource:{buffer:K}},{binding:1,resource:D.createView()},{binding:2,resource:M}]}),v=new CA(16),U=new CA([s,0,o,B]),L=new CA([0,1]),{ubo:x,data:P}=yT(A,v,L,U),j={_shadowType:"esm",_light:e,_depthTexture:_,_depthSampler:M,_lightMatrix:v,_shadowsInfo:U,_depthValues:L,_shadowParamsUBO:p,_shadowUBO:x,_config:u,_version:0};return j._preloadShadowTask=AWA,j._ensureShadowTaskState=(O,z,Z)=>{const AA=orA(O,z,j,Z,j._shadowTaskState??null);return j._shadowTaskState=AA,AA},j._renderShadowMap=(O,z)=>iWA(O,j,z),IrA(j,{_esmTexture:d,_depthBuffer:f,_blurTexH:D,_blurPipeline:R,_blurHBG:G,_blurVBG:F,_shadowUboData:P,_blurKernel:r,_blurScale:n}),j}var jT,WT,zT,nrA=b((()=>{VA(),kg(),ZA(),gI(),oo(),BE(),Qs(),xjA(),Hi()})),nWA=H({rebuildSceneShadowGenerators:()=>sWA});async function sWA(A,e){const t=new Set(e.shadowGenerators);for(const g of e.lights)g.shadowGenerator&&t.add(g.shadowGenerator);for(const g of t){if(g._shadowType!=="esm"&&g._shadowType!=="csm"&&m(798,g._shadowType),g._shadowTaskState?._task.dispose(),g._shadowTaskState=void 0,g._preloadPending=void 0,g._shadowType==="csm"){const n=A._device,s=g._config._mapSize;g._depthTexture=n.createTexture({size:{width:s,height:s,depthOrArrayLayers:g._csmCascadeCount},format:"depth32float",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|(g._csmCache?GPUTextureUsage.COPY_DST:0)}),g._depthSampler=n.createSampler({compare:"less",magFilter:"linear",minFilter:"linear"}),g._shadowParamsUBO=_3(A,g._config._bias,1/s),g._shadowUBO=Rg(A,new Float32Array(80));const B=g._csmReceiverTexture;B&&(B.texture=g._depthTexture,B.view=g._depthTexture.createView({dimension:"2d-array"}),B.sampler=g._depthSampler,B.width=s,B.height=s,Kg(B)),g._version++;continue}const I=await Promise.resolve().then(()=>(nrA(),$jA)),o=I.getEsmShadowTaskResources(g);o||m(799);const C=I.createEsmDirectionalShadowGenerator(A,g._light,{mapSize:g._config._mapSize,depthScale:g._shadowsInfo[2],bias:g._config._bias,blurKernel:o._blurKernel,blurScale:o._blurScale,darkness:g._shadowsInfo[0],frustumEdgeFalloff:g._shadowsInfo[3],orthoMinZ:g._config._orthoMinZ,orthoMaxZ:g._config._orthoMaxZ,forceRefreshEveryFrame:g._config._forceRefreshEveryFrame}),r=I.getEsmShadowTaskResources(C);r||m(800),g._depthTexture=C._depthTexture,g._depthSampler=C._depthSampler,g._lightMatrix=C._lightMatrix,g._shadowsInfo=C._shadowsInfo,g._depthValues=C._depthValues,g._shadowParamsUBO=C._shadowParamsUBO,g._shadowUBO=C._shadowUBO,g._version++,I.setEsmShadowTaskResources(g,r)}}var BWA=b((()=>{rA(),cI(),gI(),Qs()})),ZT=H({createSkeleton:()=>QWA});function QWA(A,e,t,g,I,o,C){const r=A._device,n=g*4,s=r.createTexture({size:[n,1],format:"rgba32float",usage:_A.TEXTURE_BINDING|_A.COPY_DST});r.queue.writeTexture({texture:s},I.buffer,{bytesPerRow:n*16},{width:n,height:1});const B=new gt(e.length);for(let u=0;u<e.length;u++)B[u]=e[u];const Q=Ft(A,B,iA.VERTEX),E=Ft(A,t,iA.VERTEX);let c=null,l=null;if(o&&C){const u=new gt(o.length);for(let p=0;p<o.length;p++)u[p]=o[p];c=Ft(A,u,iA.VERTEX),l=Ft(A,C,iA.VERTEX)}return{boneTexture:s,boneCount:g,jointsBuffer:Q,weightsBuffer:E,joints:e,weights:t,boneMatrices:I,joints1Buffer:c,weights1Buffer:l,joints1:o??null,weights1:C??null,_skinBuffers:{jointsBuffer:Q,weightsBuffer:E,joints1Buffer:c,weights1Buffer:l}}}var XT=b((()=>{VA(),ZA(),qI()})),$T=H({MORPH_WEIGHTS_HEADER_BYTES:()=>16,createMorphTargets:()=>srA,setMorphTargetWeights:()=>BrA});function srA(A,e,t,g,I){const o=e.length,C=new CA(o*t*tU);for(let c=0;c<o;c++){const l=e[c],u=c*t*tU;for(let p=0;p<t;p++){const d=u+p*tU;C[d]=l.positions[p*3],C[d+1]=l.positions[p*3+1],C[d+2]=l.positions[p*3+2],l.normals&&(C[d+3]=l.normals[p*3],C[d+4]=l.normals[p*3+1],C[d+5]=l.normals[p*3+2])}}const r=Ft(A,C,iA.STORAGE),n=new ArrayBuffer(16+o*4),s=new gt(n,0,2);s[0]=o,s[1]=t;const B=new CA(n,16,o);for(let c=0;c<o;c++)B[c]=g?.[c]??0;const Q=Ft(A,new Te(n),iA.STORAGE),E=new CA(o);return E.set(B),{deltasBuffer:r,count:o,weightsBuffer:Q,targets:e,weights:E,...I?{names:I}:{}}}function BrA(A,e,t){if(e._disposed)throw new Error("Cannot update disposed morph targets");const g=Math.min(e.count,t.length);e.weights.fill(0);for(let I=0;I<g;I++)e.weights[I]=t[I]??0;A._device.queue.writeBuffer(e.weightsBuffer,16,e.weights)}var tU,G3=b((()=>{VA(),ZA(),qI(),tU=6})),aWA=H({_rebuildMeshes:()=>arA,rebuildRegisteredScenes:()=>EWA,rebuildRenderables:()=>QrA});async function EWA(A){A._pbrFallbackTex=void 0;for(const e of A.surfaces)for(const t of e._renderingContexts){if(t._kind!=="scene")continue;const g=t;!$F(e,g)||g._z||await cWA(A,g)}}async function cWA(A,e){if(e._envTextures){const{rebuildSceneEnvironment:g}=await Promise.resolve().then(()=>(MjA(),hjA));await cE("rebuilding environment textures",()=>g(A,e))}if(await cE("rebuilding material textures",()=>uWA(A,e)),await cE("rebuilding meshes",()=>arA(A,e)),e._z)return;if(e.shadowGenerators.length>0||e.lights.some(g=>g.shadowGenerator)){const{rebuildSceneShadowGenerators:g}=await Promise.resolve().then(()=>(BWA(),nWA));await cE("rebuilding shadows",()=>g(A,e))}if(e._z)return;const t=e._renderables.filter(g=>!!g._rebuild).map(g=>g._rebuild);e._renderables.length=e._uniformUpdaters.length=0,e._meshDisposables.clear(),e._lightGpuState&&(e._lightGpuState=void 0);for(const[g,I]of e._groups){const o=await cE("rebuilding material groups",()=>g(e,I));if(e._z)return;I.r=e._runtimeBuilds?.base(g,o.rebuildSingle)??o.rebuildSingle,o._w!==void 0&&(I._w=o._w),I.o=o.renderables,e._renderables.push(...o.renderables),o.updater&&e._uniformUpdaters.push(o.updater)}t.length>0&&e._renderables.push(...await cE("rebuilding renderables",()=>QrA(t))),e._renderables.sort((g,I)=>g.order-I.order),e._renderableVersion++,lWA(A,e),e._frameGraph.build()}async function QrA(A){const e=[];for(const t of A){const g=await t();g&&e.push(g)}return e}async function cE(A,e){try{return await e()}catch(t){const g=t instanceof Error?t.message:String(t);throw new Error(`Device-lost Scene recovery failed while ${A}: ${g}`,{cause:t})}}function lWA(A,e){for(const t of e._frameGraph._tasks){if(!("_sceneUBO"in t&&"_targetSignature"in t&&"_opaqueBindings"in t))continue;const g=t;g._sceneUBO=XI(A,368),g._lightsUBO=_9(A,e)._buffer,g._sceneBG=A._device.createBindGroup({layout:oi(A),entries:[{binding:0,resource:{buffer:g._sceneUBO}},{binding:1,resource:{buffer:g._lightsUBO}}]}),g._opaqueBindings.length=0,g._directBindings.length=0,g._transparentBindings.length=0,g._ob.length=0,g._lastVersion=-1,g._sceneUboCacheKey.length=0}}async function arA(A,e){let t=null,g=null;for(const I of e.meshes){if(I._cpuPositions&&I._cpuNormals&&I._cpuIndices){const o=I._gpu._recoverShared;I._gpu=o?o(A,I,ErA):ErA(A,I)}if(I.skeleton){t??=(await Promise.resolve().then(()=>(XT(),ZT))).createSkeleton;const o=I.skeleton,C=t(A,o.joints,o.weights,o.boneCount,o.boneMatrices,o.joints1,o.weights1);Object.assign(o,C)}if(I.morphTargets){g??=(await Promise.resolve().then(()=>(G3(),$T))).createMorphTargets;const o=I.morphTargets,C=g(A,o.targets.map(r=>({positions:r.positions,normals:r.normals})),I._cpuPositions?I._cpuPositions.length/3:0,Array.from(o.weights));Object.assign(o,C)}}}function ErA(A,e){const t=e._gpu,g=t._drawRangeSource;if(g){const B=D9(A,g.positions,g.normals,g.indices,g.uvs,g.uvs2,g.tangents,g.colors);return R1A(B,{...g}),B._firstIndex=t._firstIndex,B._baseVertex=t._baseVertex,B._vertexCapacity=g.positions.length/3,B._indexCapacity=g.indices.length,B}const I=e._cpuPositions,o=e._cpuNormals,C=e._cpuUvs,r=e._cpuGpuIndices??e._cpuIndices,n=A._device;let s;return C&&C.length>0?s=Ft(A,C,iA.VERTEX):(s=n.createBuffer({size:I.length/3*8,usage:iA.VERTEX,mappedAtCreation:!0}),s.unmap()),{positionBuffer:Ft(A,I,iA.VERTEX),normalBuffer:Ft(A,o,iA.VERTEX),tangentBuffer:e._cpuTangents?.length?Ft(A,e._cpuTangents,iA.VERTEX):null,uvBuffer:s,uv2Buffer:e._cpuUv2s?Ft(A,e._cpuUv2s,iA.VERTEX):null,colorBuffer:e._cpuColors?Ft(A,e._cpuColors,iA.VERTEX):null,hasUv:!!C&&C.length>0,hasUv2:!!e._cpuUv2s&&e._cpuUv2s.length>0,hasTangent:!!e._cpuTangents&&e._cpuTangents.length>0,hasColor:!!e._cpuColors&&e._cpuColors.length>0,indexBuffer:Ft(A,r,iA.INDEX),indexCount:r.length,indexFormat:e._cpuIndexFormat??e._gpu.indexFormat}}async function uWA(A,e){const t=new Set,g=new WeakSet,I=[],o=r=>{if(!r||typeof r!="object")return;const n=r;if(n.texture&&n.view&&n.sampler&&typeof n.width=="number"&&typeof n.height=="number"){const s=n;t.has(s)||(t.add(s),I.push(s));return}if(!g.has(r)){g.add(r);for(const s of Object.values(n))o(s)}};for(const r of e.meshes)o(r.material);if(I.length===0)return;const{rebuildTexture2D:C}=await Promise.resolve().then(()=>(zH(),WH));await Promise.all(I.map(r=>C(A,r)))}var pWA=b((()=>{ZA(),hI(),ss(),m1A(),co(),qI(),Ci(),rT(),y9()}));function dWA(A,e={}){return l9(A,{_kind:"scene",_recoverOrder:100,_enable(t){_1A(t,!0)},_disable(t){y1A(t,!0)},async _recover(t){const{rebuildRegisteredScenes:g}=await Promise.resolve().then(()=>(pWA(),aWA));await g(t)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function fWA(A){A7=A}function V1(){return A7}function crA(A){e7=A}function cs(){return e7}var A7,e7,bC=b((()=>{A7=null,e7=null}));function gU(A,e){const t=e.cellWidthPx,g=e.cellHeightPx,I=e.marginPx??0,o=e.spacingPx??0,C=e.columns??Math.max(1,Math.floor((A.width-I*2+o)/(t+o))),r=e.rows??Math.max(1,Math.floor((A.height-I*2+o)/(g+o))),n=e.pivot??[.5,.5],s=A.width,B=A.height,Q=[];for(let E=0;E<r;E++)for(let c=0;c<C;c++){const l=I+c*(t+o),u=I+E*(g+o);Q.push({uvMin:[l/s,u/B],uvMax:[(l+t)/s,(u+g)/B],sourceSizePx:[t,g],pivot:[n[0],n[1]]})}return{texture:A,textureSizePx:[s,B],frames:Q,premultipliedAlpha:e.premultipliedAlpha??!1}}async function DWA(A,e,t={}){return t.metadataUrl!==void 0&&m(827),t.gridSize||m(828),gU(await tE(A,e,{invertY:!1,addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",mipMaps:!1,minFilter:t.sampling==="nearest"?"nearest":"linear",magFilter:t.sampling==="nearest"?"nearest":"linear",premultiplyAlpha:t.premultiplyOnLoad??!1,...t.textureOptions}),{cellWidthPx:t.gridSize[0],cellHeightPx:t.gridSize[1],premultipliedAlpha:t.premultipliedAlpha??!1})}function b3(A,e){return(e<0||e>=A.frames.length)&&m(829,e,A.frames.length),e}function _WA(A){A.texture.texture.destroy()}var F3=b((()=>{rA(),NC()})),t7,g7,lrA=b((()=>{t7={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},g7={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}})),urA,IU,prA,I7,i7,drA,o7=b((()=>{lrA(),urA={_key:"opaque"},IU={_key:"alpha",_descriptor:t7},prA={_key:"premultiplied",_descriptor:g7,_premultipliedOpacity:!0},I7={_key:"additive",_descriptor:{color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},i7={_key:"oneone",_descriptor:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},drA={_key:"multiply",_descriptor:{color:{srcFactor:"dst",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"dst-alpha",dstFactor:"zero",operation:"add"}}}}));function yWA(A){s7=A}function lE(){return s7}function C7(A,e={}){const t=e.depth??"none",g=e.blendMode??IU,I=Math.max(1,e.capacity??yrA),o={positionPx:[e.view?.positionPx?.[0]??0,e.view?.positionPx?.[1]??0],zoom:e.view?.zoom??1,rotation:e.view?.rotation??0},C=t==="none"?13:14,r=C*4,n=new CA(I*C),s={_entityType:"sprite-2d-layer",atlas:A,depth:t,blendMode:g,opacity:e.opacity??1,visible:e.visible??!0,order:e.order??0,view:o,pivot:[e.pivot?.[0]??.5,e.pivot?.[1]??.5],layerZ:e.layerZ??.5,count:0,_capacity:I,_instanceFloatsPerSprite:C,_instanceStrideBytes:r,_instanceData:n,_savedSize:new CA(I*2),_version:0,_dirtyMin:0,_dirtyMax:0};return V1()?.initLayer(s,e),s}function hWA(A,e){const t=A.shaderParams??=[0,0,0,0];t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3]}function wWA(A,e){let t=A._capacity;for(;t<e;)t*=2;const g=new CA(t*A._instanceFloatsPerSprite);g.set(A._instanceData),A._instanceData=g;const I=new CA(t*2);I.set(A._savedSize),A._savedSize=I,A._capacity=t}function iU(A,e){A.count=e}function frA(A,e,t,g){const I=A._instanceData,o=e*A._instanceFloatsPerSprite,C=e*2,r=g===null,n=t.frame!==void 0?A.atlas.frames[b3(A.atlas,t.frame)]:null,s=t.positionPx?t.positionPx[0]:g[0],B=t.positionPx?t.positionPx[1]:g[1];let Q,E;t.sizePx?(Q=t.sizePx[0],E=t.sizePx[1]):n?(Q=n.sourceSizePx[0],E=n.sourceSizePx[1]):r?(Q=0,E=0):(Q=A._savedSize[C],E=A._savedSize[C+1]),A._savedSize[C]=Q,A._savedSize[C+1]=E;let c;t.visible!==void 0?c=t.visible:r?c=!0:c=g[2]!==0||g[3]!==0;let l,u,p,d;n?(l=n.uvMin[0],u=n.uvMin[1],p=n.uvMax[0],d=n.uvMax[1]):r?(l=0,u=0,p=1,d=1):(l=g[4],u=g[5],p=g[6],d=g[7]);const f=l>p,D=u>d,_=!r&&g[4]>g[6],y=!r&&g[5]>g[7],w=t.flipX!==void 0?t.flipX===!0:_,S=t.flipY!==void 0?t.flipY===!0:y;if(f!==w){const G=l;l=p,p=G}if(D!==S){const G=u;u=d,d=G}const R=t.rotation??(g?g[8]:0),M=A.depth!=="none",N=M?t.z??(g?g[13]:A.layerZ):0;I[o+0]=s,I[o+1]=B,I[o+2]=c?Q:0,I[o+3]=c?E:0,I[o+4]=l,I[o+5]=u,I[o+6]=p,I[o+7]=d,I[o+8]=R,t.color?(I[o+9]=t.color[0],I[o+10]=t.color[1],I[o+11]=t.color[2],I[o+12]=t.color[3]):r&&(I[o+9]=1,I[o+10]=1,I[o+11]=1,I[o+12]=1),M&&(I[o+13]=N)}function k3(A,e,t){A._dirtyMin>=A._dirtyMax?(A._dirtyMin=e,A._dirtyMax=t):(e<A._dirtyMin&&(A._dirtyMin=e),t>A._dirtyMax&&(A._dirtyMax=t)),A._version=A._version+1|0,lE()?.dirty(A,e,t)}function NQ(A,e,t){k3(A,e,t)}function DrA(A,e){e.positionPx===void 0&&m(843);const t=A.count;return t>=A._capacity&&wWA(A,t+1),frA(A,t,e,null),A._vertexExtension?._initInstance(A._instanceData,t*A._instanceFloatsPerSprite),iU(A,A.count+1),lE()?.add(A,t),k3(A,t,t+1),t}function _rA(A,e,t){(e<0||e>=A.count)&&m(844,e,A.count);const g=e*A._instanceFloatsPerSprite;frA(A,e,t,A._instanceData.subarray(g,g+A._instanceFloatsPerSprite)),k3(A,e,e+1)}function r7(A,e){(e<0||e>=A.count)&&m(845,e,A.count);const t=A.count-1;A._handleHooks?.removeIndex(e,t),e!==t&&(A._instanceData.copyWithin(e*A._instanceFloatsPerSprite,t*A._instanceFloatsPerSprite,(t+1)*A._instanceFloatsPerSprite),A._savedSize.copyWithin(e*2,t*2,(t+1)*2)),A._savedSize[t*2]=0,A._savedSize[t*2+1]=0,iU(A,t),lE()?.remove(A,e,t),k3(A,e,e+1)}function SWA(A){const e=A.count;A._dirtyMin=0,A._dirtyMax=0,A._handleHooks?.clear(),e!==0&&(A._savedSize.fill(0,0,e*2),iU(A,0),lE()?.clear(A,e),A._version=A._version+1|0)}function n7(A,e,t){(e<0||e>=A.count)&&m(846,e,A.count);const g=b3(A.atlas,t),I=A.atlas.frames[g],o=e*A._instanceFloatsPerSprite,C=A._instanceData[o+4]>A._instanceData[o+6],r=A._instanceData[o+5]>A._instanceData[o+7];A._instanceData[o+4]=C?I.uvMax[0]:I.uvMin[0],A._instanceData[o+5]=r?I.uvMax[1]:I.uvMin[1],A._instanceData[o+6]=C?I.uvMin[0]:I.uvMax[0],A._instanceData[o+7]=r?I.uvMin[1]:I.uvMax[1],k3(A,e,e+1)}var s7,yrA,FC=b((()=>{rA(),VA(),F3(),bC(),o7(),s7=null,yrA=16}));function MWA(A){Q7=A}function B7(){return Q7}var Q7,hrA=b((()=>{Q7=null}));function RWA(A){a7=A}function GQ(){return a7}var a7,bQ=b((()=>{a7=null}));function mWA(A,e,t){return`${E7(A,e,t)} @fragment fn fs(in:O)->@location(0)vec4f{let s=textureSample(atlasTex,atlasSamp,in.uv);return s*in.tint*L.opacityMul;}`}function E7(A,e,t=!1,g){const I=`@group(${e})`,o=A?",@location(6)z:f32":"",C=t?",@location(7)o:vec2f":"",r=A?"1 - in.z":"0";return`struct Lr{viewPos:vec2f,viewScale:f32,viewRot:f32,screenSize:vec2f,pivot:vec2f,opacityMul:vec4f,aa:vec4f,};${I} @binding(0)var<uniform>L:Lr;${I} @binding(1)var atlasTex:texture_2d<f32>;${I} @binding(2)var atlasSamp:sampler;struct I{@builtin(vertex_index)vid:u32,@location(0)p:vec2f,@location(1)s:vec2f,@location(2)a:vec2f,@location(3)b:vec2f,@location(4)r:f32,@location(5)c:vec4f${o}${C}${g?._input??""}};struct O{@builtin(position)p:vec4f,@location(0)uv:vec2f,@location(1)tint:vec4f,${g?._output??""}};@vertex fn vs(in:I)->O{var q=array<vec2f,4>(vec2f(0,0),vec2f(1,0),vec2f(1,1),vec2f(0,1));let c=q[in.vid];let l=(c-L.pivot)*in.s;let cr=cos(in.r);let sr=sin(in.r);let r=vec2f(l.x*cr-l.y*sr,l.x*sr+l.y*cr);let p=in.p+r-L.viewPos;let lc=cos(L.viewRot);let ls=sin(L.viewRot);let v=vec2f(p.x*lc-p.y*ls,p.x*ls+p.y*lc)*L.viewScale;let n=vec2f(v.x/L.screenSize.x*2-1,1-v.y/L.screenSize.y*2);let uv=mix(in.a,in.b,c)${t?" + in.o":""};var out:O;out.p=vec4f(n,${r},1);out.uv=uv;out.tint=in.c;${g?._assignment??""} return out;}`}function wrA(){return{_devices:new WeakMap}}function SrA(A){A._devices=new WeakMap}function NWA(){return uE??=wrA(),CU++,uE}function MrA(){CU>0&&--CU===0&&uE&&(SrA(uE),uE=null)}function K3(A,e,t,g,I,o,C=!1,r,n,s,B="greater-equal"){const Q=GWA(A,e),E=bWA(o,r),c=GQ(),l=o&&C&&g>1&&!!s&&!!c?.(s),u=FWA(t,g,I,o,C,E,l,s,B),p=Q._pipelines.get(u);if(p)return p;const d=KWA(A,Q,t,g,I,o,C,E,l,n,s,B);return Q._pipelines.set(u,d),d}function RrA(A,e,t,g,I,o){const C=g.atlas.texture,r=[{binding:0,resource:{buffer:I}},{binding:1,resource:C.view},{binding:2,resource:C.sampler}];if(o)for(const n of V1().bindEntries(o,3))r.push(n);return A._device.createBindGroup({layout:e.getBindGroupLayout(t),entries:r})}function GWA(A,e){let t=e._devices.get(A._device);return t||(t={_shaderModules:new Map,_pipelines:new Map},e._devices.set(A._device,t)),t}function bWA(A,e){return A?(e||m(858),e):null}function FWA(A,e,t,g,I,o,C,r,n="greater-equal"){const s=r?V1()?.pipelineKeyPart(r)??"":"",B=r?._uvScrollAttr?"1":"0",Q=r?B7()?.pipelineKeyPart(r)??"0":"0";return`${A}:${e}:${t._key}:${g?1:0}:${I?1:0}:${o??"-"}:${g?n:"-"}:${C?"a":"n"}:cs${s}:uv${B}:cg${Q}`}function kWA(A,e,t,g){const I=g?V1()?.shaderModule(A,t,g):null;if(I)return I;const o=g?B7()?.shaderModule(A,t,g):null;if(o)return o;const C=g?._uvScrollAttr!=null,r=`${t?1:0}:${C?1:0}`;let n=e._shaderModules.get(r);return n||(n=A._device.createShaderModule({code:mWA(t,t?1:0,C)}),e._shaderModules.set(r,n)),n}function KWA(A,e,t,g,I,o,C,r,n,s,B,Q="greater-equal"){const E=A._device,c=[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}],l=B?V1()?.layoutEntries(B,3):null;if(l)for(const w of l)c.push(w);const u=E.createBindGroupLayout({entries:c}),p=kWA(A,e,o,B);o&&!s&&m(859);const d=o?[s,u]:[u],f=[{shaderLocation:0,offset:FrA,format:"float32x2"},{shaderLocation:1,offset:krA,format:"float32x2"},{shaderLocation:2,offset:KrA,format:"float32x2"},{shaderLocation:3,offset:vrA,format:"float32x2"},{shaderLocation:4,offset:UrA,format:"float32"},{shaderLocation:5,offset:LrA,format:"float32x4"}];o&&f.push({shaderLocation:6,offset:YrA,format:"float32"}),B?._uvScrollAttr&&f.push(B._uvScrollAttr);const D=B?V1()?.vertexAttribute(B):null;D&&f.push(D);const _=B?._instanceStrideBytes??(o?56:52),y={layout:E.createPipelineLayout({bindGroupLayouts:d}),vertex:{module:p,entryPoint:"vs",buffers:[{arrayStride:_,stepMode:"instance",attributes:f}]},fragment:{module:p,entryPoint:"fs",targets:[{format:t,blend:I._descriptor,writeMask:RC.ALL}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:n?{count:g,alphaToCoverageEnabled:!0}:{count:g}};return o&&(y.depthStencil={format:r,depthCompare:Q,depthWriteEnabled:C}),E.createRenderPipeline(y)}function oU(A,e,t){return A.createBuffer({size:e._capacity*e._instanceStrideBytes,usage:iA.VERTEX|iA.COPY_DST,label:t})}function mrA(A,e,t,g,I){const o=e._capacity*e._instanceStrideBytes;return t.size>=o?{buffer:t,capacity:g,reallocated:!1}:(t.destroy(),{buffer:oU(A,e,I),capacity:e._capacity,reallocated:!0})}function NrA(A,e,t,g){const I=lE()?.upload(A,e,t,g);if(I!==void 0)return I;if(g===e._version)return g;if(e.count===0)return e._dirtyMin=0,e._dirtyMax=0,e._version;let o,C;if(g===-1?(o=0,C=e.count):(o=e._dirtyMin,C=Math.min(e._dirtyMax,e.count)),C>o){const r=o*e._instanceStrideBytes,n=(C-o)*e._instanceStrideBytes;A.queue.writeBuffer(t,r,e._instanceData.buffer,e._instanceData.byteOffset+r,n)}return e._dirtyMin=0,e._dirtyMax=0,e._version}function GrA(A,e,t,g){g[0]=A.view.positionPx[0],g[1]=A.view.positionPx[1],g[2]=A.view.zoom,g[3]=A.view.rotation,g[4]=e,g[5]=t,g[6]=A.pivot[0],g[7]=A.pivot[1];const I=A.opacity;A.blendMode._premultipliedOpacity?(g[8]=I,g[9]=I,g[10]=I,g[11]=I):(g[8]=1,g[9]=1,g[10]=1,g[11]=I),B7()?.writeUbo(A,g)}function brA(A,e,t,g,I){let o=!I;if(!o){for(let C=0;C<16;C++)if(g[C]!==t[C]){o=!0;break}}return o&&(A.queue.writeBuffer(e,0,t.buffer,t.byteOffset,64),g.set(t)),!0}var FrA,krA,KrA,vrA,UrA,LrA,YrA,uE,CU,rU,v3=b((()=>{rA(),VA(),ZA(),FC(),bC(),hrA(),bQ(),FrA=0,krA=8,KrA=16,vrA=24,UrA=32,LrA=36,YrA=52,uE=null,CU=0,rU=new l1([0,1,2,0,2,3])})),vWA=H({rebuildRegisteredSpriteRenderers:()=>UWA});async function UWA(A){const e=[],t=new Set;for(const g of A.surfaces)for(const I of g._renderingContexts){if(I._kind!=="sprite-renderer")continue;const o=I;e.push(o),o._target&&t.add(o._target);for(const C of o.layers){t.add(C.atlas.texture);for(const r of C.customShader?._extraTextures??[])t.add(r.texture)}}if(t.size>0){const{rebuildTexture2D:g}=await Promise.resolve().then(()=>(zH(),WH));await Promise.all(Array.from(t,I=>g(A,I)))}for(const g of e)LWA(g)}function LWA(A){const e=A._surface.engine,t=V1();A._indexBuffer=Ft(e,rU,iA.INDEX),A._targetView=A._target?.view??null,A._visibleBundles.length=0;for(const g of A._layerGpu.values())g.instanceBuffer=oU(e._device,g.layer),g.instanceBufferCapacity=g.layer._capacity,g.uniformBuffer=XI(e,64),g.bindGroup=null,g.uploadedVersion=-1,g.fx&&(t.disposeFx(g.fx),g.fx=t.createLayerFx(e,"sprite-layer-fx-ubo",g.layer)),g.pipeline=null,g.lastUbo.fill(0),g.uboUploaded=!1,g.renderBundle=null,g.bundleCount=-1;for(const g of A.layers)K3(e,A._pipelineCache,A._surface.format,1,g.blendMode,!1,!1,void 0,void 0,g)}var YWA=b((()=>{ZA(),co(),qI(),bC(),v3()}));function xWA(A,e={}){return l9(A,{_kind:"sprite-renderer",_enable:_1A,_disable:y1A,async _recover(t){const{rebuildRegisteredSpriteRenderers:g}=await Promise.resolve().then(()=>(YWA(),vWA));await g(t)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function JWA(A){BU=A}function c7(A){return BU?._key(A)??A.curveSet}function HWA(A,e,t,g,I,o,C,r){const n=g._atlas._glyphSlots.get(I);if(!n)return!1;const s=n._index;if(s>d7||r>d7)return!1;const B=t*3;return A[B]=o,A[B+1]=C,e[B+2]=s|r<<16,!0}function xrA(A,e,t){const g=t*3;A[g]=0,A[g+1]=0,e[g+2]=tnA}function JrA(A,e){e>pE&&m(864,pE);const t=e*8;if(A._styles.length>=t)return;let g=Math.max(A._styles.length*2,8);for(;g<t;)g*=2;g=Math.min(g,pE*8);const I=new Float32Array(g);I.set(A._styles),A._styles=I}function U3(A){const e=A.glyphs;let t=1;for(let g=0;g<e.length;g++)e[g].color!==void 0&&t++;return t}function HrA(A,e){for(let t=0;t<e.length;t++)A._freeStyleSlots.push(e[t])}function TrA(A,e,t){if(t?.length===e)return t;const g=A._freeStyleSlots,I=Math.max(0,e-g.length-(t?.length??0));JrA(A,A._styleCount+I),t&&HrA(A,t);const o=A._styleCount,C=new Array(e);for(let r=0;r<e;r++)C[r]=g.pop()??A._styleCount++;return A._styleCount!==o&&A._styleVersion++,C}function qrA(A,e,t,g,I){const o=e*8,C=A._styles,r=Math.fround(t[0]),n=Math.fround(t[1]),s=Math.fround(t[2]),B=Math.fround(t[3]),Q=Math.fround(g),E=Math.fround(I);C[o]===r&&C[o+1]===n&&C[o+2]===s&&C[o+3]===B&&C[o+4]===Q&&C[o+5]===E||(C[o]=r,C[o+1]=n,C[o+2]=s,C[o+3]=B,C[o+4]=Q,C[o+5]=E,A._styleVersion++)}function TWA(A,e){const t=e*3;if(A._instances.length>=t)return;let g=Math.max(A._instances.length*2,3);for(;g<t;)g*=2;const I=new Float32Array(g);I.set(A._instances.subarray(0,A._instanceCount*3)),A._instances=I,A._instancesU32=new Uint32Array(I.buffer),A._dirtyStart=0,A._dirtyEnd=A._instanceCount}function nU(A,e,t){t<=e||(A._dirtyStart===A._dirtyEnd?(A._dirtyStart=e,A._dirtyEnd=t):(e<A._dirtyStart&&(A._dirtyStart=e),t>A._dirtyEnd&&(A._dirtyEnd=t)),A._version++)}function qWA(A){return A._freeSlots.length>0?A._freeSlots.pop():-1}function PrA(A,e,t,g){for(const I of A._groups)if(I!==g&&I._slotStart>=e){I._slotStart+=t;for(let o=0;o<I._freeSlots.length;o++)I._freeSlots[o]=I._freeSlots[o]+t}for(const I of A._runRecords.values()){const o=I._slots;for(let C=0;C<o.length;C++)o[C]>=e&&(o[C]=o[C]+t)}A._layoutVersion++}function PWA(A,e,t){const g=e._slotStart+e._slotCount;if(t<=0)return g;TWA(A,A._instanceCount+t);const I=t*3,o=g*3,C=A._instanceCount*3;return C>o&&A._instances.copyWithin(o+I,o,C),PrA(A,g,t,e),A._instanceCount+=t,e._slotCount+=t,nU(A,g,A._instanceCount),g}function OrA(A,e,t){const g=new Array(t).fill(-1);let I=!0,o=-1,C=t;for(let r=0;r<t;r++){const n=qWA(e);if(n===-1){C=r;break}g[r]=n,I&&=n>=o,o=n}if(C<t){const r=PWA(A,e,t-C);I&&=r>=o;for(let n=C,s=r;n<t;n++)g[n]=s++}return I||g.sort(OWA),g}function OWA(A,e){return A-e}function VrA(A,e,t){let g=Number.POSITIVE_INFINITY,I=-1;for(const o of t)xrA(A._instances,A._instancesU32,o),e._freeSlots.push(o),o<g&&(g=o),o>I&&(I=o);I>=0&&nU(A,g,I+1)}function VWA(A,e){for(const t of A._groups)if(t._groupKey===e)return t}function sU(A,e,t){const g=A._curveSets.get(e);return g||m(865,t,e),g}function jrA(A,e,t,g){return{_curveSetId:A,_curveSet:e,_slotStart:t,_slotCount:0,_liveCount:0,_freeSlots:[],_bindGroup:null,_bindGroupVersion:-1,_groupKey:g}}function jWA(A,e,t){const g=VWA(A,t);if(g)return g;const I=jrA(e,sU(A._storage,e,"addRun"),A._instanceCount,t);return A._groups.push(I),I}function l7(A,e,t,g,I){const o=t.pixelsPerFontUnit,C=o!==0?1/o:0,r=BU?._param(t)??0,n=I[0];qrA(A,n,t.defaultColor??gnA,C,r);let s=0,B=null,Q=Number.POSITIVE_INFINITY,E=-1;for(let c=0;c<t.glyphs.length;c++){const l=t.glyphs[c],u=g[c];let p=n;const d=l.color;d!==void 0&&(p=I[++s],qrA(A,p,d,C,r)),HWA(A._instances,A._instancesU32,u,e._curveSet,l.glyphId,l.x,l.y,p)?B!==null&&B.push(u):(B===null&&(B=g.slice(0,c)),xrA(A._instances,A._instancesU32,u),e._freeSlots.push(u)),u<Q&&(Q=u),u>E&&(E=u)}return E>=0&&nU(A,Q,E+1),B??g}function WrA(A,e,t){let g=0,I=0;for(const Q of e)g+=Q.glyphs.length,I+=U3(Q);JrA(A,I);const o=g*3;if(A._instances.length<o){let Q=Math.max(A._instances.length*2,3);for(;Q<o;)Q*=2;A._instances=new Float32Array(Q),A._instancesU32=new Uint32Array(A._instances.buffer)}const C=new Map;for(const Q of A._groups)C.set(Q._groupKey,Q);A._storage=t;const r=new Map;for(const Q of e){const E=c7(Q);let c=r.get(E);c||(c=[],r.set(E,c)),c.push(Q)}const n=[],s=new Map;let B=0;A._styleCount=0,A._freeStyleSlots.length=0,A._styleVersion++;for(const[Q,E]of r){const c=E[0].curveSet,l=sU(t,c,"reset"),u=C.get(Q)??jrA(c,l,B,Q);u._curveSet!==l&&(u._curveSet=l,u._bindGroup=null,u._bindGroupVersion=-1),u._slotStart=B,u._freeSlots=[];const p=n.length;let d=0;for(const f of E){const D=new Array(f.glyphs.length).fill(-1);for(let S=0;S<f.glyphs.length;S++)D[S]=B++;const _=U3(f),y=new Array(_);for(let S=0;S<_;S++)y[S]=A._styleCount++;const w=l7(A,u,f,D,y);d+=w.length,s.set(f,{_run:f,_groupIdx:p,_slots:w,_styleSlots:y})}u._slotCount=B-u._slotStart,u._liveCount=d,n.push(u)}A._instanceCount=B,A._groups=n,A._runs.length=0;for(const Q of e)A._runs.push(Q);A._runRecords=s,A._dirtyStart=0,A._dirtyEnd=B,A._version++,A._layoutVersion++}function zrA(A,e){return typeof e=="number"?ZrA(A,e,"updateTextData"):e}function ZrA(A,e,t){if(typeof e=="number"){const g=A._runs[e];return g||m(866,t,e,A._runs.length-1),g}return A._runRecords.has(e)||m(867,t),e}function u7(A,e){return typeof e=="number"?e:A._runs.indexOf(e)}function XrA(A,e,t){A._runRecords.has(e)&&m(868);const g=t??A._runs.length;sU(A._storage,e.curveSet,"addRun");const I=TrA(A,U3(e)),o=jWA(A,e.curveSet,c7(e)),C=A._groups.indexOf(o),r=l7(A,o,e,OrA(A,o,e.glyphs.length),I);o._liveCount+=r.length,A._runRecords.set(e,{_run:e,_groupIdx:C,_slots:r,_styleSlots:I}),A._runs.splice(g,0,e)}function $rA(A,e){const t=zrA(A,e),g=A._runRecords.get(t);g||m(869);const I=A._groups[g._groupIdx];VrA(A,I,g._slots),I._liveCount-=g._slots.length,HrA(A,g._styleSlots),A._runRecords.delete(t);const o=u7(A,e);o>=0&&A._runs.splice(o,1),I._liveCount===0&&WWA(A,I)}function WWA(A,e){const t=A._groups.indexOf(e);if(t<0)return;const g=e._slotStart,I=e._slotCount;A._groups.splice(t,1);for(const o of A._runRecords.values())o._groupIdx>t&&o._groupIdx--;if(I>0){const o=I*3,C=(g+I)*3,r=A._instanceCount*3;r>C&&A._instances.copyWithin(C-o,C,r),PrA(A,g,-I),A._instanceCount-=I,nU(A,g,A._instanceCount)}}function zWA(A,e,t){const g=zrA(A,e),I=A._runRecords.get(g);I||m(870),g!==t&&A._runRecords.has(t)&&m(871);const o=A._groups[I._groupIdx];if(c7(t)===o._groupKey&&t.glyphs.length>0){const r=TrA(A,U3(t),I._styleSlots),n=I._slots.length;let s=I._slots;t.glyphs.length!==n&&(VrA(A,o,s),s=OrA(A,o,t.glyphs.length));const B=l7(A,o,t,s,r);if(o._liveCount+=B.length-n,g===t)I._slots=B,I._styleSlots=r;else{A._runRecords.delete(g),A._runRecords.set(t,{_run:t,_groupIdx:I._groupIdx,_slots:B,_styleSlots:r});const Q=u7(A,e);Q>=0&&(A._runs[Q]=t)}return}const C=u7(A,e);sU(A._storage,t.curveSet,"replaceRun"),U3(t)>A._freeStyleSlots.length+I._styleSlots.length+pE-A._styleCount&&m(872,pE),$rA(A,C>=0?C:g),XrA(A,t,C>=0?C:void 0)}function AnA(A,e){const t=[],g=new Float32Array(3),I={runs:t,_runs:t,_groups:[],_runRecords:new Map,_instances:g,_instancesU32:new Uint32Array(g.buffer),_instanceCount:0,_styles:new Float32Array(8),_styleCount:0,_freeStyleSlots:[],_styleVersion:1,_storage:A,_version:1,_layoutVersion:0,_dirtyStart:0,_dirtyEnd:0};return e&&e.length>0&&WrA(I,e,A),I}function p7(A,e){switch(e.update){case"reset":WrA(A,e.runs??A._runs.slice(),e.storage??A._storage);return;case"addRun":XrA(A,e.run,e.insertBefore);return;case"removeRun":$rA(A,e.run);return;case"replaceRun":zWA(A,e.previous,e.run);return}}function enA(A){for(const e of A._groups)e._bindGroup=null;A._groups=[],A._instanceCount=0,A._styleCount=0,A._freeStyleSlots.length=0,A._runs.length=0,A._runRecords.clear()}var tnA,d7,pE,gnA,BU,ls=b((()=>{rA(),tnA=4294967295,d7=65534,pE=65535,gnA=[1,1,1,1],BU=null}));function QU(A,e){return A.createBuffer({label:"text-styles",size:e*32,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function InA(A,e,t){const g=Math.max(1,e._styleCount);let I=!1;if(g*32>t._styleBuf.size&&(t._styleBuf.destroy(),t._styleBuf=QU(A,e._styles.byteLength/32),t._uploadedStyleVersion=-1,I=!0),t._uploadedStyleVersion!==e._styleVersion){if(e._styleCount>0){const o=e._styles;A.queue.writeBuffer(t._styleBuf,0,o.buffer,o.byteOffset,e._styleCount*32)}t._uploadedStyleVersion=e._styleVersion}return I}var f7=b((()=>{ls()}));function inA(A){const e=new Map;if(A)for(const[t,g]of A)e.set(t,rnA(g));return{_curveSets:e}}function onA(A,e,t){let g=A._curveSets.get(e);g||(g=rnA(new Map),A._curveSets.set(e,g));for(const[I,o]of t)g._curves.has(I)||(g._curves.set(I,o),g._atlas._glyphSlots.set(I,snA(g._atlas,o)))}function CnA(A){for(const e of A._curveSets.values()){const t=e._atlas._gpu;t&&(t._curveTex.destroy(),t._bandTex.destroy(),t._metaBuf.destroy(),e._atlas._gpu=null)}A._curveSets.clear()}function ZWA(){return{_curveTexData:new Float32Array(BnA),_curveTexelsUsed:0,_bandTexData:new Uint32Array(j1*2),_bandTexelsUsed:0,_glyphSlots:new Map,_metaData:new Float32Array(192),_slotCount:0,_version:0,_gpu:null}}function rnA(A){const e=ZWA();for(const[t,g]of A)e._glyphSlots.set(t,snA(e,g));return{_curves:A,_atlas:e}}function nnA(A,e,t,g=4){const I=e*g,o=j1*g;if(A.length>=I)return A;let C=Math.max(A.length*2,o);for(;C<I;)C*=2;C=Math.ceil(C/o)*o;const r=new t(C);return r.set(A),r}function snA(A,e){const t=$WA(e),g=e.curves;let I=A._curveTexelsUsed;const o=new Array(g.length);for(let F=0;F<g.length;F++){const v=I/j1|0,U=(I+1)/j1|0;v!==U&&(I=U*j1),o[F]=I,I+=2}const C=I;A._curveTexData=nnA(A._curveTexData,C,Float32Array);const r=A._curveTexData;for(let F=0;F<g.length;F++){const v=g[F],U=o[F],L=U*4;r[L]=v.p0x,r[L+1]=v.p0y,r[L+2]=v.p1x,r[L+3]=v.p1y;const x=(U+1)*4;r[x]=v.p2x,r[x+1]=v.p2y}A._curveTexelsUsed=C;const n=t._hBandCount+t._vBandCount;let s=A._bandTexelsUsed;s%4096+n>4096&&(s=((s/j1|0)+1)*j1);const B=s%j1,Q=s/j1|0,E=[...t._hBands,...t._vBands];let c=n;const l=new Array(E.length);for(let F=0;F<E.length;F++)l[F]=c,c+=E[F]._curveIndices.length;const u=s+c;A._bandTexData=nnA(A._bandTexData,u,Uint32Array,2);const p=A._bandTexData;for(let F=0;F<E.length;F++){const v=(s+F)*2;p[v]=E[F]._curveIndices.length,p[v+1]=l[F]}for(let F=0;F<E.length;F++){const v=E[F],U=s+l[F];for(let L=0;L<v._curveIndices.length;L++){const x=o[v._curveIndices[L]],P=x%j1,j=x/j1|0,O=(U+L)*2;p[O]=P,p[O+1]=j}}A._bandTexelsUsed=u,A._version++;const{xMin:d,yMin:f,xMax:D,yMax:_}=e.bounds,y=D-d,w=_-f,S=y>0?t._vBandCount/y:0,R=w>0?t._hBandCount/w:0,M=A._slotCount++,N=A._slotCount*12;if(A._metaData.length<N){const F=new Float32Array(Math.max(A._metaData.length*2,N));F.set(A._metaData),A._metaData=F}const G=M*12,K=A._metaData;return K[G]=d,K[G+1]=f,K[G+2]=D,K[G+3]=_,K[G+4]=B,K[G+5]=Q,K[G+6]=t._vBandCount-1,K[G+7]=t._hBandCount-1,K[G+8]=S,K[G+9]=R,K[G+10]=-d*S,K[G+11]=-f*R,{_index:M}}function L3(A,e){const t=A[e];if(!t)throw new Error("buildGlyphBands: invalid curve index");return t}function XWA(A){const{curves:e,bounds:t}=A,g=Math.max(1,Math.min(8,Math.floor(e.length/2))),{xMin:I,yMin:o,xMax:C,yMax:r}=t,n=C-I,s=r-o,B=s/g,Q=n/g,E=[],c=[];for(let l=0;l<g;l++)E.push({_curveIndices:[]}),c.push({_curveIndices:[]});for(let l=0;l<e.length;l++){const u=L3(e,l),p=Math.min(u.p0y,u.p1y,u.p2y),d=Math.max(u.p0y,u.p1y,u.p2y),f=Math.min(u.p0x,u.p1x,u.p2x),D=Math.max(u.p0x,u.p1x,u.p2x);if(s>0)for(let _=0;_<g;_++){const y=o+_*B,w=o+(_+1)*B;d>=y&&p<=w&&E[_]._curveIndices.push(l)}if(n>0)for(let _=0;_<g;_++){const y=I+_*Q,w=I+(_+1)*Q;D>=y&&f<=w&&c[_]._curveIndices.push(l)}}for(const l of E)l._curveIndices.sort((u,p)=>{const d=L3(e,u),f=L3(e,p);return Math.max(f.p0x,f.p1x,f.p2x)-Math.max(d.p0x,d.p1x,d.p2x)});for(const l of c)l._curveIndices.sort((u,p)=>{const d=L3(e,u),f=L3(e,p);return Math.max(f.p0y,f.p1y,f.p2y)-Math.max(d.p0y,d.p1y,d.p2y)});return{_hBands:E,_vBands:c,_hBandCount:g,_vBandCount:g}}function $WA(A){return A._bands??=XWA(A)}var j1,BnA,D7=b((()=>{j1=4096,BnA=j1*4}));function dE(A){let e=1;for(;e<A;)e<<=1;return e}function QnA(A,e){return A.createBuffer({label:"text-glyph-metadata",size:e*h7,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function _7(A){return A<=0?1:Math.ceil(A/Y3)}function aU(A,e,t,g){return A.createTexture({label:t,format:g,size:{width:Y3,height:e,depthOrArrayLayers:1},usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC})}function anA(A,e,t,g,I){if(g===0)return;const o=_7(g);A.queue.writeTexture({texture:e},t.buffer,{offset:t.byteOffset,bytesPerRow:Y3*I*4,rowsPerImage:o},{width:Y3,height:o,depthOrArrayLayers:1})}function y7(A,e){let t=e._gpu;const g=_7(e._curveTexelsUsed),I=_7(e._bandTexelsUsed),o=Math.max(1,e._slotCount);t&&t._device!==A&&(t._curveTex.destroy(),t._bandTex.destroy(),t._metaBuf.destroy(),t=null);let C=!1;if(t)g>t._curveTexRows&&(t._curveTex.destroy(),t._curveTexRows=dE(g),t._curveTex=aU(A,t._curveTexRows,"text-slug-curves","rgba32float"),t._uploadedVersion=-1,C=!0),I>t._bandTexRows&&(t._bandTex.destroy(),t._bandTexRows=dE(I),t._bandTex=aU(A,t._bandTexRows,"text-slug-bands","rg32uint"),t._uploadedVersion=-1,C=!0),o>t._metaCap&&(t._metaBuf.destroy(),t._metaCap=dE(o),t._metaBuf=QnA(A,t._metaCap),t._uploadedVersion=-1,C=!0);else{const r=dE(Math.max(1,g)),n=dE(Math.max(1,I)),s=dE(o);t={_device:A,_curveTex:aU(A,r,"text-slug-curves","rgba32float"),_bandTex:aU(A,n,"text-slug-bands","rg32uint"),_curveTexRows:r,_bandTexRows:n,_metaBuf:QnA(A,s),_metaCap:s,_uploadedVersion:-1},e._gpu=t,C=!0}if(t._uploadedVersion!==e._version){if(anA(A,t._curveTex,e._curveTexData,e._curveTexelsUsed,4),anA(A,t._bandTex,e._bandTexData,e._bandTexelsUsed,2),e._slotCount>0){const r=e._metaData;A.queue.writeBuffer(t._metaBuf,0,r.buffer,r.byteOffset,e._slotCount*h7)}t._uploadedVersion=e._version}return{_rebuilt:C,_gpu:t}}var Y3,h7,w7=b((()=>{D7(),Y3=4096,h7=48})),AzA=H({rebuildRegisteredTextRenderers:()=>ezA});function ezA(A){for(const e of A.surfaces)for(const t of e._renderingContexts)t._kind==="text-renderer"&&tzA(t)}function tzA(A){const e=A._surface.engine,t=e._device;A._visibleBundles.length=0;for(const g of A._layerGpu.values())g._textU=XI(e,EnA,"text-layer-ubo"),g._instanceBuf=t.createBuffer({label:"text-layer-instances",size:g._instanceCap*12,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),g._styleBuf=QU(t,g._styleBuf.size/32),g._uploadedStyleVersion=-1,g._pipeline=null,g._bindGroupCache.length=0,g._uploadedDataVersion=-1,g._uploadedViewportW=0,g._uploadedViewportH=0,g._lastMvpInputs.fill(0),g._mvpUploaded=!1,g._renderBundle=null,g._bundleLayoutVersion=-1,g._bundleDrawCalls=0;for(const g of A.layers)for(const I of g.data._groups)y7(t,I._curveSet._atlas);A._update()}var EnA,gzA=b((()=>{co(),f7(),w7(),ls(),EnA=96}));function IzA(A,e={}){return l9(A,{_kind:"text-renderer",async _recover(t){const{rebuildRegisteredTextRenderers:g}=await Promise.resolve().then(()=>(gzA(),AzA));g(t)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function nC(A){A._refCount=(A._refCount??1)+1}function W1(A){const e=A._refCount;return e===void 0||e<=1?!0:(A._refCount=e-1,!1)}var us=b((()=>{})),cnA=H({rebuildScenePbrPipelines:()=>S7,rebuildSceneRenderables:()=>M7});async function S7(A,e=!1){await lnA(A,"pbr",e)}async function M7(A){await lnA(A,void 0,!1)}async function lnA(A,e,t){const g=A;if(!g._built&&!t)return;const I=g._lightListVersion??0,o=g.surface.engine,C=p=>{g._z?p.forEach(d=>d()):ag(o,()=>p.forEach(d=>d()))};let r=!1,n=!1,s=!1,B=!1;try{for(let p=1;;p++){if(e!==void 0){await Q();break}if(c(g),await Q(),!E(g))break;if(p>=pnA){g._rebuildHook=EU,B=!0,n=!0;break}}s=!0}finally{if(r&&(g._renderables.sort(unA),g._renderableVersion++,g._materialEpoch++,g._built&&g._frameGraph.build()),e===void 0&&s&&!n&&(g._lightListVersion??0)===I){const p=g._pendingTopologyRetirements?.splice(0);p?.length&&C(p),B||(g._rebuildHook=void 0)}}async function Q(){for(const[p,d]of g._groups){if(e!==void 0&&p._materialFamily!==e)continue;if(d.length===0){(d.o||d.r)&&(l(p,d),r=!0);continue}const f=g._runtimeBuilds;await f?.wait(d);let D=!1;const _=async()=>{const S=g._runtimeBuilds,R=[...d].filter(z=>g.meshes.includes(z)&&z.material?._buildGroup===p);if(R.length===0){l(p,d);return}const M=!!d.r,N=g._disposables.length,G=new Map,K=new Map(R.map(z=>[z,z.material]));for(const z of R){const Z=g._meshDisposables.get(z);Z&&(G.set(z,Z),g._meshDisposables.delete(z),S?.holdPendingDisposers(z,Z))}let F,v;g._p=z=>(v=z,!0);try{F=await p(g,R)}catch(z){v?.[1]();for(const Z of R){const AA=G.get(Z),BA=g._meshDisposables.get(Z);if(BA&&BA!==AA)for(const sA of BA)sA();const QA=g.meshes.includes(Z)&&Z.material===K.get(Z)&&Z.material?._buildGroup===p&&d.includes(Z);AA&&QA?g._meshDisposables.set(Z,AA):(g._meshDisposables.delete(Z),AA&&C(AA)),AA&&S?.releasePendingDisposers(Z,AA)}throw z}finally{delete g._p}if(g._z||f?._d()){v?.[1]();for(const Z of R){const AA=g._meshDisposables.get(Z),BA=G.get(Z);if(AA&&AA!==BA)for(const QA of AA)QA();g._meshDisposables.delete(Z)}for(const Z of g._disposables.splice(0))Z();const z=[...G.values()].flat();C(z);for(const[Z,AA]of G)S?.releasePendingDisposers(Z,AA);return}v?.[0](),p._rebuildSingle=F.rebuildSingle,d.r=g._runtimeBuilds?.base(p,F.rebuildSingle)??F.rebuildSingle,F._w!==void 0&&(d._w=F._w),M&&u(g,N);const U=new Set(R.filter(z=>g.meshes.includes(z)&&z.material===K.get(z)&&z.material?._buildGroup===p&&d.includes(z)));if(U.size!==R.length&&F.renderables.some(z=>!z.mesh)){for(const z of R){const Z=g._meshDisposables.get(z),AA=G.get(z);if(Z&&Z!==AA)for(const BA of Z)BA();AA&&g.meshes.includes(z)?g._meshDisposables.set(z,AA):(g._meshDisposables.delete(z),AA&&C(AA)),AA&&S?.releasePendingDisposers(z,AA)}D=!0;return}const L=new Set;for(const z of R){if(!U.has(z)){const Z=G.get(z),AA=g._meshDisposables.get(z);if(AA&&AA!==Z)for(const BA of AA)BA();Z&&g.meshes.includes(z)?(g._meshDisposables.set(z,Z),G.delete(z),S?.releasePendingDisposers(z,Z)):g._meshDisposables.delete(z);continue}L.add(z.material),z._renderableGen=-~z._renderableGen,g._runtimeBuilds?.reset(z)}for(const z of L)z._csmGen=(z._csmGen??0)+1;const x=d.o,P=x?.length?new Set(x):null;for(let z=g._renderables.length-1;z>=0;z--){const Z=g._renderables[z];(U.has(Z.mesh)||P?.has(Z))&&g._renderables.splice(z,1)}const j=F.renderables.filter(z=>!z.mesh||U.has(z.mesh));g._renderables.push(...j),d.o=j;const O=[...G.values()].flat();C(O);for(const[z,Z]of G)S?.releasePendingDisposers(z,Z)},{X:y}=await Promise.resolve().then(()=>(pU(),lU)),w=3;for(let S=1;;S++){if(D=!1,await y(g,p,_),g._z||f?._d()){n=!0;return}if(!D)break;if(S>=w){l(p,d),g._rebuildHook=EU,B=!0,n=!0;break}}if(D){r=!0;continue}r=!0}}function E(p){for(const d of p.meshes){const f=d.material?._buildGroup;if(f&&!p._groups.get(f)?.includes(d))return!0}return!1}function c(p){const d=new Map;for(const f of p.meshes){const D=f.material?._buildGroup;if(!D)continue;const _=d.get(D);_?_.push(f):d.set(D,[f])}for(const[f,D]of p._groups){const _=d.get(f)??[];(D.length!==_.length||_.some((y,w)=>D[w]!==y))&&(D.length=0,D.push(..._)),d.delete(f)}for(const[f,D]of d){const _=D;p._groups.set(f,_)}}function l(p,d){const f=d.o;if(f?.length){const D=new Set(f);for(let _=g._renderables.length-1;_>=0;_--)D.has(g._renderables[_])&&g._renderables.splice(_,1)}d.o=void 0,d.r=void 0,g._runtimeBuilds?.dropBase(p),g._rebuildHook=EU,B=!0}function u(p,d){const f=new Set(p._disposables.slice(0,d));for(let D=p._disposables.length-1;D>=d;D--)f.has(p._disposables[D])&&p._disposables.splice(D,1)}}var unA,pnA,EU,cU=b((()=>{kg(),unA=(A,e)=>A.order-e.order,pnA=8,EU=A=>M7(A)})),lU=H({A:()=>fnA,B:()=>DnA,C:()=>izA,X:()=>ozA});function dnA(A,e,t){A.pendingDisposers.set(e,t)}function R7(A,e,t){t&&A.pendingDisposers.get(e)===t&&A.pendingDisposers.delete(e)}function fnA(A,e,t,g){if(!e||t.material!==e)return g??Promise.resolve();const I=DnA(A,e._buildGroup,t);return g?Promise.all([g,I]).then(()=>{}):I}function izA(A,e,t){let g=t;for(const I of e){const o=Array.isArray(I),C=o?I[0]:I;g=fnA(A,o?I[1]:C.material,C,g)}return(g??Promise.resolve()).catch(I=>{A._runtimeBuilds?._x(I)})}function DnA(A,e,t){if(A._z||!A.meshes.includes(t))return A._runtimeBuilds?.all().catch(()=>{})??Promise.resolve();CzA(A,e,t);const g=A._runtimeBuilds??_nA(A);return e._materialFamily==="pbr"&&(A._built||A._groups.get(e)?.r)?(g._n||(g._l=Promise.resolve(g._l).then(()=>Promise.resolve().then(()=>(cU(),cnA))).finally(()=>{g._n=void 0}).then(({rebuildScenePbrPipelines:I})=>A._z?void 0:I(A,!0)).catch(I=>{A._runtimeBuilds?._x(I)}),g._n=g.track(g._l)),g._n):g.queue(e,t).catch(()=>{})}function ozA(A,e,t){return A._z?Promise.resolve(void 0):(A._runtimeBuilds??_nA(A)).exclusive(e,t)}function _nA(A){const e={disposed:!1,error:null,active:new Set,chains:new WeakMap,generations:new WeakMap,installed:new WeakMap,installedMeshes:new Set,pendingDisposers:new WeakMap,tail:null},t=A,g={queue:(I,o)=>{const C=(e.generations.get(o)??0)+1,r=o.material;e.generations.set(o,C);const n=e.chains.get(o),s=[e.tail,In?.get(I)].filter(c=>!!c);let B=()=>{};const Q=new Promise(c=>{B=c});e.tail=Q,(In??=new WeakMap).set(I,Q);const E=(n?n.catch(()=>{}):Promise.resolve()).then(()=>Promise.all(s)).then(()=>rzA(A,e,I,o,r,C)).catch(c=>{throw uU(A,e,I,o,r,C)&&(e.error=c instanceof Error?c:new Error("Runtime mesh build failed",{cause:c})),c}).finally(()=>{B(),e.tail===Q&&(e.tail=null),In?.get(I)===Q&&In.delete(I)}).finally(()=>{e.chains.get(o)===E&&e.chains.delete(o)});return e.chains.set(o,E),g.track(E)},all:()=>Promise.all(e.active).then(()=>{}),track:I=>{const o=I.finally(()=>e.active.delete(o));return e.active.add(o),Promise.all(e.active).then(()=>{})},base:(I,o)=>{const C=ps?.get(I);return C&&C.bases.set(A,o),C?.dispatch??o},get w(){return!!e.tail},pendingDisposers:I=>e.pendingDisposers.get(I),holdPendingDisposers:(I,o)=>dnA(e,I,o),releasePendingDisposers:(I,o)=>R7(e,I,o),reset:I=>{hnA(A,e,I),t._pbrMeshGeomContexts?.delete(I)},remove:I=>{e.generations.set(I,(e.generations.get(I)??0)+1),e.chains.delete(I),ynA(A,e,I),t._pbrMeshGeomContexts?.delete(I)},dropBase:I=>{const o=ps?.get(I);o&&(o.bases.delete(A),o.scenes.delete(A))},wait:async I=>{const o=new Set;for(const C of I){const r=e.chains.get(C);r&&o.add(r)}await Promise.all(o)},_e:(I=!0)=>{if(e.error){const o=e.error;throw I&&(e.error=null),o}},_x:I=>{e.error=I instanceof Error?I:new Error("Runtime mesh build failed",{cause:I})},_d:()=>e.disposed,exclusive:(I,o)=>{const C=[];e.tail&&C.push(e.tail);const r=In?.get(I);r&&C.push(r);const n=Promise.all(C).then(o),s=n.then(()=>{},()=>{});return e.tail=s,(In??=new WeakMap).set(I,s),s.then(()=>{e.tail===s&&(e.tail=null),In?.get(I)===s&&In.delete(I)}),n}};return A._runtimeBuilds=g,(A._beforeRender??=[]).push(()=>{g._e()}),A._disposables.push(()=>{e.disposed=!0,e.active.clear();for(const I of e.installedMeshes)hnA(A,e,I);for(const I of A._groups.keys())ps?.get(I)?.bases.delete(A);A._runtimeBuilds=void 0,t._pbrMeshGeomContexts=void 0}),g}function CzA(A,e,t){for(const[I,o]of A._groups)if(I!==e){const C=o.indexOf(t);C>=0&&o.splice(C,1)}let g=A._groups.get(e);g||(g=[],A._groups.set(e,g)),g.includes(t)||g.push(t)}async function rzA(A,e,t,g,I,o){if(!uU(A,e,t,g,I,o))return;const C=A._meshDisposables.get(g);C&&(A._meshDisposables.delete(g),dnA(e,g,C));const r=t._rebuildSingle,n=ps?.get(t)?.bases.get(A)??A._groups.get(t)?.r,s=!!A._groups.get(t)?.r,B=A._disposables.length,Q=A,E=Q._pbrGeomContext;let c,l;try{l=await t(A,[g]),c=Q._pbrGeomContext}catch(d){if(wnA(A,e,g,C),SnA(A,e),!uU(A,e,t,g,I,o))return;throw d}finally{t._rebuildSingle=r,t._materialFamily==="pbr"&&s&&(Q._pbrGeomContext=E)}if(!uU(A,e,t,g,I,o)){wnA(A,e,g,C),SnA(A,e);return}for(let d=A._renderables.length-1;d>=0;d--)A._renderables[d].mesh===g&&A._renderables.splice(d,1);if(C){for(const d of C){const f=A._disposables.indexOf(d);f>=0&&A._disposables.splice(f,1);const D=d.p;if(D){D._disposed=!0;const _=D._owner;if(_){const y=_.indexOf(D);y>=0&&_.splice(y,1),D._owner=void 0,_.length===0&&D._onOwnerEmpty?.()}else D._onOwnerEmpty?.();D._onOwnerEmpty&&(D._onOwnerEmpty=void 0)}}ag(A.surface.engine,()=>{for(const d of C)d()})}R7(e,g,C),A._renderables.push(...l.renderables);const u=A._groups.get(t);u&&(u.o=[...(u.o??[]).filter(d=>d.mesh!==g),...l.renderables]),l.updater&&A._uniformUpdaters.push(l.updater),s&&szA(A,B),t._materialFamily==="pbr"&&s&&c&&(Q._pbrMeshGeomContexts??=new WeakMap).set(g,c),nzA(A,e,t,g,l.rebuildSingle,s?n:l.rebuildSingle),g._renderableGen=-~g._renderableGen;const p=A._groups.get(t);p&&!s&&(p.r=l.rebuildSingle),A._renderables.sort(MnA),A._renderableVersion++,A._materialEpoch++}function nzA(A,e,t,g,I,o){let C=ps?.get(t);if(!C){const B=new WeakMap,Q=new WeakMap;C={bases:Q,dispatch:(c,l,u,p)=>{const d=B.get(c)?.get(l);if(d)return d(c,l,u,p);const f=Q.get(c)??c._groups.get(t)?.r;if(f)return f(c,l,u,p);throw new Error("Material group has not completed its initial build")},scenes:B},(ps??=new WeakMap).set(t,C)}let r=C.scenes.get(A);r||(r=new WeakMap,C.scenes.set(A,r)),r.set(g,I),C.bases.has(A)||C.bases.set(A,o??I);const n=A._groups.get(t);n&&(n.r=C.dispatch);let s=e.installed.get(g);s||(s=new Set,e.installed.set(g,s)),s.add(t),e.installedMeshes.add(g)}function ynA(A,e,t){const g=e.installed.get(t);if(g){for(const I of g)ps?.get(I)?.scenes.get(A)?.delete(t);e.installed.delete(t),e.installedMeshes.delete(t)}}function hnA(A,e,t){ynA(A,e,t)}function uU(A,e,t,g,I,o){return!e.disposed&&e.generations.get(g)===o&&A.meshes.includes(g)&&g.material===I&&I._buildGroup===t}function wnA(A,e,t,g){const I=A._meshDisposables.get(t);if(I&&I!==g){A._meshDisposables.delete(t);for(const o of I)o()}if(g)if(A.meshes.includes(t))A._meshDisposables.set(t,g);else if(e.disposed)for(const o of g)o();else ag(A.surface.engine,()=>{for(const o of g)o()});R7(e,t,g)}function SnA(A,e){if(!e.disposed)return;const t=A._disposables.splice(0);for(const g of t)g()}function szA(A,e){const t=new Set(A._disposables.slice(0,e));for(let g=A._disposables.length-1;g>=e;g--)t.has(A._disposables[g])&&A._disposables.splice(g,1)}var MnA,In,ps,pU=b((()=>{kg(),MnA=(A,e)=>A.order-e.order,In=null,ps=null}));function RnA(A,e,t,g=e.material){return Promise.resolve().then(()=>(pU(),lU)).then(I=>I.A(A,g,e,t)).catch(I=>console.error(I))}function dU(A,e,t){A._runtimeThinBuild=RnA,A.thinInstances?(A.thinInstances.matrices=e,A.thinInstances.count=t,A.thinInstances._capacity=t,A.thinInstances._version++,A.thinInstances._dirtyMin=0,A.thinInstances._dirtyMax=t):A.thinInstances={matrices:e,count:t,_capacity:t,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:t,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1}}function m7(A,e){const t=A.thinInstances;t&&(t.count=e,t._version++,t._dirtyMin=0,t._dirtyMax=e)}function BzA(A,e){const t=A.thinInstances;if(t){if(!Number.isInteger(e)||e<0||e>t._capacity)throw new RangeError(`Thin instance draw count ${e} must be an integer between 0 and capacity ${t._capacity}`);t.count!==e&&((!t._gpuBuffer||t._gpuVersion!==t._version||t.colors&&(!t._colorGpuBuffer||t._colorGpuVersion!==t._colorVersion))&&m(645),t.count=e,t._gpuVersion=++t._version)}}function QzA(A){const e=A.thinInstances;e||m(646),e._drawArgsBuffer||(e._drawArgsInstanceCount=-1)}function azA(A,e){A._runtimeThinBuild=RnA;const t=A.thinInstances;if(!t){const o=new CA(256);return o.set(e,0),A.thinInstances={matrices:o,count:1,_capacity:16,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:1,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1},0}const g=t.count;if(g>=t._capacity){const I=t._capacity*2,o=new CA(I*16);o.set(t.matrices),t.matrices=o,t._capacity=I}return t.matrices.set(e,g*16),t.count++,t._version++,t._dirtyMin=0,t._dirtyMax=t.count,g}function EzA(A,e,t){const g=A.thinInstances;g.matrices.set(t,e*16),g._version++,g._dirtyMin=Math.min(g._dirtyMin,e),g._dirtyMax=Math.max(g._dirtyMax,e+1)}function czA(A,e){const t=A.thinInstances,g=t.count-1;e!==g&&t.matrices.copyWithin(e*16,g*16,g*16+16),t.count--,t._version++,t._dirtyMin=0,t._dirtyMax=t.count}function N7(A){const e=A.thinInstances;e._version++,e._dirtyMin=0,e._dirtyMax=e.count}function lzA(A,e){const t=A.thinInstances;t.colors=e,t._version++,t._colorVersion++,t._colorDirtyMin=0,t._colorDirtyMax=t.count}function uzA(A,e,t,g,I,o){const C=A.thinInstances,r=C.colors,n=e*4;r[n]=t,r[n+1]=g,r[n+2]=I,r[n+3]=o,C._version++,C._colorVersion++,C._colorDirtyMin=Math.min(C._colorDirtyMin,e),C._colorDirtyMax=Math.max(C._colorDirtyMax,e+1)}function pzA(A,e=!0){const t=A.thinInstances;t||m(647),t._gpuCullingEnabled!==e&&(t._gpuCullingEnabled=e,t._gpuVersion=-1,t._colorGpuVersion=-1)}function dzA(A,e){const t=A.thinInstances;t||m(648),t._cullBoundsPad=e}function fzA(A,e,t){const g=A.thinInstances,I=e.thinInstances;if((!g||!I)&&m(649),A===e&&m(650),((g._refCount??1)>1||(I._refCount??1)>1)&&m(651),!Number.isFinite(t.distance)||t.distance<0)throw new RangeError("setThinInstanceLodPartner distance must be a finite non-negative number");const o=t.band??0;if(!Number.isFinite(o)||o<0)throw new RangeError("setThinInstanceLodPartner band must be a finite non-negative number");g._lodSource&&m(652),I._lodPartner&&m(653),I._lodSource&&I._lodSource!==A&&m(654),I.colors&&!g.colors&&m(655);const C=g._lodPartner;if(C&&C!==e){const n=C.thinInstances;n&&n._lodSource===A&&fU(n),C._clone=void 0,g._lodBuckets=null}g._lodPartner=e,g._lodDistance=t.distance,g._lodBand=o,I._lodSource=A,A._clone=e._clone="Cannot clone LOD-paired mesh";const r=g._lodBuckets??new WeakMap;g._lodBuckets=r,I._lodBuckets=r,I._gpuCullingEnabled||(I._lodAutoCull=!0,I._gpuCullingEnabled=!0,I._gpuVersion=-1,I._colorGpuVersion=-1)}function DzA(A){const e=A.thinInstances;if(!e?._lodPartner)return;const t=e._lodPartner,g=t.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,t._clone=void 0,g&&g._lodSource===A&&fU(g)}function _zA(A){const e=A.thinInstances;if(!e)return;const t=e._lodSource,g=t?.thinInstances;t&&g?._lodPartner===A&&(g._lodPartner=null,g._lodDistance=void 0,g._lodBand=void 0,g._lodBuckets=null,t._clone=void 0),e._lodSource&&fU(e);const I=e._lodPartner,o=I?.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,I&&o?._lodSource===A&&(I._clone=void 0,fU(o))}function fU(A){A._lodSource=null,A._lodBuckets=null,A._lodAutoCull&&(A._lodAutoCull=!1,A._gpuCullingEnabled=!1,A._gpuVersion=-1,A._colorGpuVersion=-1)}var fE=b((()=>{rA(),VA()}));function yzA(A){G7=A}function hzA(A){DU=A}function mnA(A){A.positionBuffer.destroy(),A.normalBuffer.destroy(),A.uvBuffer.destroy(),A.tangentBuffer?.destroy(),A.uv2Buffer?.destroy(),A.colorBuffer?.destroy()}function z1(A){if(A._disposed)return;A._disposed=!0,G7?.(A);const e=A._gpu;W1(e)&&(DU?DU(e,mnA):(mnA(e),e.indexBuffer.destroy()),e._shaderColorFallback?.destroy());const t=A.thinInstances;t&&W1(t)&&(_zA(A),t._gpuBuffer?.destroy(),t._colorGpuBuffer?.destroy(),t._drawArgsBuffer?.destroy());const g=A.skeleton;g&&W1(g)&&(g._disposed=!0,g.boneTexture.destroy(),W1(g._skinBuffers)&&(g.jointsBuffer.destroy(),g.weightsBuffer.destroy(),g.joints1Buffer?.destroy(),g.weights1Buffer?.destroy()));const I=A.vat;I&&W1(I)&&(I.settingsBuffer.destroy(),I.instanceTexture?.destroy(),W1(I._textureResource)&&I._textureResource.texture.destroy(),W1(I._skinBuffers)&&(I.jointsBuffer.destroy(),I.weightsBuffer.destroy(),I.joints1Buffer?.destroy(),I.weights1Buffer?.destroy()));const o=A.morphTargets;o&&W1(o)&&(o._disposed=!0,o.deltasBuffer.destroy(),o.weightsBuffer.destroy())}var DU,G7,ar=b((()=>{us(),fE(),DU=null,G7=null}));function NnA(A){const e=x3;x3=e?(t,g)=>{e(t,g),A(t,g)}:A}function DE(A,e){A._materialSwapQueue.includes(e)||A._materialSwapQueue.push(e)}function b7(A){const e=_E?.get(A);if(e)for(const t of e)DE(t,A)}function wzA(A){return _E?.get(A)}function SzA(A){let e=A.material;Object.defineProperty(A,"material",{get(){return e},set(t){if(t!==e){x3?.(A,t),e=t;const g=_E?.get(A);if(g)for(const I of g)DE(I,A),I._meshMaterialChange?.(A,t)}},configurable:!0,enumerable:!0})}function MzA(A,e){e._disposed&&m(792,e.name),x3?.(e,e.material);const t=_E??=new WeakMap;let g=t.get(e);g||(t.set(e,g=new Set),SzA(e)),g.add(A)}function GnA(A,e){const t=_E?.get(e);return t?(t.delete(A),t.size===0):!0}var _E,x3,ds=b((()=>{rA(),_E=null,x3=null}));function _U(A){const e=A._materialSwapQueue;if(!e[0]||A._runtimeBuilds?.w)return;let t,g,I;const o=A._renderables;for(const r of e){const n=r.material;if(!n)continue;const s=r._runtimeThinBuild;if(s){g=s(A,r,g);continue}const B=A._groups.get(n._buildGroup),Q=B?.r;if(!Q){(I??=[]).push(r);continue}if(B._w?.(r)){(I??=[]).push([r,n]);continue}const E=A._meshDisposables.get(r);E&&(A._meshDisposables.delete(r),ag(A.surface.engine,()=>E.forEach(p=>p())));const c=B.o;let l;for(let p=o.length;p--;)o[p].mesh===r&&(l=o.splice(p,1)[0]);r._renderableGen=-~r._renderableGen;const u=Q(A,r);if(c){const p=c.indexOf(l);p<0?c.push(u):c[p]=u}t=o.push(u)}if(t&&(o.sort((r,n)=>r.order-n.order),A._renderableVersion++,A._materialEpoch++),e.length=0,!I)return g;const C=I;return Promise.resolve().then(()=>(pU(),lU)).then(({C:r})=>r(A,C,g),r=>{const n=A._runtimeBuilds;n?n._x(r):console.error(r)})}var F7=b((()=>{kg()}));function RzA(A){k7=A}function mzA(A,e,t){k7?.(A,e,t)}var k7,bnA=b((()=>{k7=null}));function FnA(A){const e={_tasks:[],_currentProcessedTask:null,build(){for(let t=0;t<e._tasks.length;t++)knA(e,e._tasks[t]);for(const t of e._tasks)for(const g of t._passes)g._initialize()},execute(){let t=0;for(const g of e._tasks)if(g.executionEnabled!==!1)if(g.execute)t+=g.execute();else for(const I of g._passes)t+=I._execute();return t},dispose(){for(const t of e._tasks)t.dispose();e._tasks.length=0,e._currentProcessedTask=null}};return e}function NzA(A){return A._tasks}function GzA(A,e){A._tasks.includes(e)||m(121,e.name),knA(A,e);for(const t of e._passes)t._initialize()}function knA(A,e){e._passes.length=0,A._currentProcessedTask=e;try{e.record()}finally{A._currentProcessedTask=null}}function KnA(A,e){A._tasks.push(e)}var yU=b((()=>{rA()}));function bzA(){return hU??=new WeakMap,hU}function vnA(A,e){bzA().set(A,e),wU&&wU(A,e).catch(t=>console.error(t))}function J3(A){return hU?.get(A)}function FzA(A,e){if(e!==1/0&&(!Number.isInteger(e)||e<0))throw new RangeError("setShadowCasterMaxCascade requires a non-negative integer or Infinity");A._shadowMaxCascade=e===1/0?void 0:e}function kzA(A){wU=A}var hU,wU,SU=b((()=>{hU=null,wU=null})),KzA=H({createShadowTask:()=>vzA});function vzA(A,e){const t=new Set;kzA(UnA);const g={name:"shadow",engine:A,scene:e,_passes:[],async _preload(){const I=[];for(const o of e.lights){const C=o.shadowGenerator,r=C?J3(C):null;C?._preloadShadowTask&&r&&I.push(UnA(C,r))}await Promise.all(I)},record(){g._passes.length=0;for(const I of e.lights){const o=I.shadowGenerator,C=o?J3(o):null;if(o?._ensureShadowTaskState&&C&&!o._preloadPending){t.add(o);const r=o._ensureShadowTaskState(A,e,C),n=e._renderableVersion;r._task.record(),r._recordedVersion=n}}},execute(){let I=0;for(const o of e.lights){const C=o.shadowGenerator,r=C?J3(C):null;if(C?._ensureShadowTaskState&&C._renderShadowMap&&r&&!C._preloadPending){t.add(C);const n=C._shadowTaskState??null,s=C._ensureShadowTaskState(A,e,r);if(s!==n||s._recordedVersion!==e._renderableVersion){const B=e._renderableVersion;s._task.record(),s._recordedVersion=B}I+=C._renderShadowMap(A,s)}}return I},dispose(){g._passes.length=0;for(const I of t){const o=I._shadowTaskState;o&&(o._task.dispose(),I._shadowTaskState=void 0)}t.clear()}};return g}async function UnA(A,e){A._preloadPending=e,await A._preloadShadowTask?.(e),A._preloadPending===e&&(A._preloadPending=void 0)}var UzA=b((()=>{SU()}));function LzA(A){FQ=A}function YzA(A){K7=A}function LnA(A,e){const t=A.camera;t&&!t._useFloatingOrigin!=!e&&(t._useFloatingOrigin=e,t._viewVer=-1,t._projFov=void 0)}function YnA(A,e){const t=A.engine,g={_kind:"scene",surface:A,clearColor:{r:.2,g:.2,b:.3,a:1},camera:null,lights:[],meshes:[],animationGroups:[],fog:null,clipPlane:null,shadowGenerators:[],imageProcessing:{exposure:1,contrast:1,toneMappingEnabled:!1},_renderables:[],_prePasses:[],_pickSources:[],_uniformUpdaters:[],fixedDeltaMs:0,_beforeRender:[],_deferredBuilders:[],_groups:new Map,_disposables:[],_meshDisposables:new Map,_materialSwapQueue:[],_renderableVersion:0,_materialEpoch:0,_built:!1,_drawCallsPre:0,_update(){const o=g.fixedDeltaMs>0?g.fixedDeltaMs:t._currentDelta,C=t._currentEncoder;let r=0;LnA(g,t.useFloatingOrigin);for(const n of g._beforeRender)n(o);LnA(g,t.useFloatingOrigin),g._materialSwapQueue.length&&_U(g);for(const n of g._prePasses)r+=n.execute(C,t);for(const n of g._uniformUpdaters)n.update(t);g._drawCallsPre=r},_record(){return g._frameGraph.execute()},_resize(){g._frameGraph.build()}},I=FnA(t);if(g._frameGraph=I,e?.defaultRenderTask!==!1){const o=A.msaaSamples>1,C=o?Pv({lbl:"scene-color",format:A.format,dFormat:"depth24plus-stencil8",samples:A.msaaSamples,size:A}):A.scRT,r=o?void 0:Pv({lbl:"scene-depth",dFormat:"depth24plus-stencil8",samples:1,size:A});KnA(I,ST({name:"scene",rt:C,rst:o?A.scRT:void 0,depth:r},t,g))}return g._disposables.push(()=>I.dispose()),g}function yE(A,e){A._beforeRender.unshift(e)}function xnA(){return FQ!==void 0}function JnA(A,e){FQ?.run(A,e)}function H3(A,e,t){FQ?.record(A,e,t)}function xzA(A){return A._frameGraph}function hE(A,e){const t=A;t._deferredBuilders.push(async()=>{const g=await e(t.surface.engine,t);t._renderables.push(...g.renderables),g.dispose&&t._disposables.push(g.dispose)})}function tg(A,e){if(FQ&&A._sceneChanges&&A._sceneChanges.depth===0){FQ.run(A,()=>tg(A,e));return}const t=A;if("entities"in e){const I=e;for(const o of I.entities)tg(A,o);if(I.clearColor&&(t.clearColor=I.clearColor),I.camera&&!t.camera&&(t.camera=I.camera),I.animationGroups?.length){const o=t.surface.engine,C=I.animationGroups;t.animationGroups.push(...C);const r=n=>{for(const s of C)mzA(s,n,o)};I._beforeRenderHook=r,t._beforeRender.push(r)}I._sceneSetup?.(t,I),H3(t,e,"added");return}if("_gpu"in e&&"material"in e){const I=e;MzA(t,I),t.meshes.push(I),HnA(t,I),t._meshMaterialChange?.(I,I.material)}else"lightType"in e?t.lights.push(e):"fov"in e&&(t.camera=e);H3(t,e,"added");const g=e.children;if(g?.length)for(const I of g)I.parent=e,tg(A,I)}function HnA(A,e){const t=e.material?._buildGroup;if(!t)return;let g=A._groups.get(t);g||(g=[],A._groups.set(t,g),A._built||A._deferredBuilders.push(async()=>{if(!g[0]){A._groups.delete(t);return}const I=await t(A,g);A._renderables.push(...I.renderables),g.o=I.renderables,I.updater&&A._uniformUpdaters.push(I.updater),g.r=I.rebuildSingle})),g.push(e),(A._built||g.r)&&DE(A,e)}function TnA(A){const e=A;if(e._z)return;e._z=!0;const t=T3??=new WeakMap;t.set(e,()=>1),AE(e.surface,e);const g=()=>{t.set(e,()=>{for(const I of e._meshDisposables.values())I.forEach(o=>o());return e._meshDisposables.clear(),e._disposables.splice(0).forEach(I=>I()),e._renderables.length=e._uniformUpdaters.length=0,1}),e._disposables.splice(0).forEach(I=>I());for(const I of e._meshDisposables.values())for(const o of I)o();e._meshDisposables.clear();for(const I of e.meshes)GnA(e,I)&&z1(I);e._groups.clear(),e.meshes.length=0,e._renderables.length=0,e._prePasses.length=0,e._pickSources.length=0,e._uniformUpdaters.length=0,e._beforeRender.length=0,e._deferredBuilders.length=0,e._disposables.length=0,e._materialSwapQueue.length=0,e.lights.length=0,e.animationGroups.length=0,e.shadowGenerators.length=0,e.camera=null};FQ?.dispose(e),K7?K7(e,g):g()}async function qnA(A){for(const t of A.lights)t._validateLighting?.(A._lighting);const e=A;for(!e._built&&e._materialSwapQueue.splice(0)[0]&&(e._groups.forEach(t=>t.length=0),e.meshes.forEach(t=>HnA(e,t)));e._deferredBuilders.length;){const t=e._deferredBuilders.splice(0);await Promise.all(t.map(g=>g()))}await _U(e),T3?.get(e)?.()||(e._runtimeBuilds?._e(),e._renderableVersion++,e._built=!0),await e._rebuildHook?.(e)}function JzA(A){wE=A}function HzA(A){v7=A}async function PnA(A){const e=A,t=e.surface;$F(t,e)||(await qnA(A),e._renderables.sort(U7),await Promise.all(e._frameGraph._tasks.map(g=>g._preload?.())),wE&&await wE(e),e._frameGraph.build(),T3?.get(e)?.()||DQ(t,e)&&v7?.(e))}async function TzA(A){const e=A,t=e.surface;$F(t,e)||(await qnA(A),e._renderables.sort(U7),await qzA(t.engine,e),await Promise.all(e._frameGraph._tasks.map(g=>g._preload?.())),wE&&await wE(e),e._frameGraph.build(),T3?.get(e)?.()||DQ(t,e)&&v7?.(e))}async function qzA(A,e){if(e._frameGraph._tasks.some(g=>g.name==="shadow"))return;const{createShadowTask:t}=await Promise.resolve().then(()=>(UzA(),KzA));e._frameGraph._tasks.unshift(t(A,e))}function PzA(A){AE(A.surface,A)}var T3,FQ,K7,wE,v7,U7,mI=b((()=>{hI(),ar(),ds(),F7(),bnA(),yU(),nE(),Fg(),T3=null,wE=null,U7=(A,e)=>A.order-e.order}));xoA(),uCA(),mCA(),DT(),nrA(),G3(),cU(),mI();var OnA=!1,VnA=!1;function jnA(A){if(A.length===1)throw A[0];if(A.length>1)throw new AggregateError(A)}function OzA(A,e){const t=A._sceneChanges;if(!t){e();return}t.depth++;let g=!1,I;try{e()}catch(C){g=!0,I=C}if(t.depth--,t.depth>0||t.dispatching){if(g)throw I;return}const o=g?[I]:[];t.dispatching=!0;try{for(;t.pending.length;){const C=t.pending.shift();for(const r of[...t.listeners])if(t.listeners.has(r))try{r(C)}catch(n){o.push(n)}}}finally{t.dispatching=!1,!t.listeners.size&&A._sceneChanges===t&&(A._sceneChanges=void 0)}jnA(o)}function VzA(A){const e=A._sceneChanges;e&&(e.listeners.clear(),e.pending.length=0,A._sceneChanges===e&&(A._sceneChanges=void 0))}function jzA(A,e){const t=[];for(const g of A._disposables.splice(0))try{g()}catch(I){t.push(I)}A._disposables.length=0;try{e()}catch(g){t.push(g)}jnA(t)}function WnA(){VnA||(VnA=!0,YzA(jzA))}function WzA(){OnA||(OnA=!0,WnA(),LzA({run:OzA,record:(A,e,t)=>{const g=A._sceneChanges;if(g){if(t==="added"){if(g.members.has(e))return;g.members.add(e)}else if(!g.members.delete(e))return;g.pending.push({type:t,entity:e})}},dispose:VzA}))}function zzA(A){const e=new WeakSet,t=g=>{if(!e.has(g)&&(e.add(g),"children"in g&&Array.isArray(g.children)))for(const I of g.children)typeof I=="object"&&I!==null&&(!("parent"in I)||I.parent===g)&&t(I)};for(const g of[...A.meshes,...A.lights,...A.shadowGenerators])t(g);return A.camera&&t(A.camera),e}function znA(A,e){if(A._z)throw new Error("Cannot observe a disposed scene.");WzA();const t=A._sceneChanges??={listeners:new Set,pending:[],members:zzA(A),depth:0,dispatching:!1},g=o=>e(o);t.listeners.add(g);let I=!0;return()=>{I&&(I=!1,t.listeners.delete(g),!t.listeners.size&&!t.depth&&!t.dispatching&&A._sceneChanges===t&&(A._sceneChanges=void 0))}}function ZnA(A,e){WnA();const t=A._disposables,g=()=>e();t.push(g);let I=!0;return()=>{if(!I)return;I=!1;const o=t.indexOf(g);o>=0&&t.splice(o,1)}}function L7(A,e,t,g){A[3]=0,A[7]=0,A[11]=0,A[12]=e.x,A[13]=e.y,A[14]=e.z,A[15]=1;let I=t.x-e.x,o=t.y-e.y,C=t.z-e.z;const r=Math.sqrt(I*I+o*o+C*C);let n=0,s=0,B=0,Q=0;if(r>=1e-10){const c=1/r;I*=c,o*=c,C*=c,n=g.y*C-g.z*o,s=g.z*I-g.x*C,B=g.x*o-g.y*I,Q=Math.sqrt(n*n+s*s+B*B)}if(Q<1e-10){A[0]=1,A[1]=0,A[2]=0,A[4]=0,A[5]=1,A[6]=0,A[8]=0,A[9]=0,A[10]=1;return}const E=1/Q;n*=E,s*=E,B*=E,A[0]=n,A[1]=s,A[2]=B,A[4]=o*B-C*s,A[5]=C*n-I*B,A[6]=I*s-o*n,A[8]=I,A[9]=o,A[10]=C}var Y7=b((()=>{})),MU,x7=b((()=>{MU={x:0,y:1,z:0}}));Y7(),x7(),tn(),ns(),Ii(),it();function XnA(A,e,t,g){function I(){const Q=Math.cos(B.alpha),E=Math.sin(B.alpha),c=Math.cos(B.beta);let l=Math.sin(B.beta);return l===0&&(l=1e-4),{x:B.target.x+B.radius*Q*l,y:B.target.y+B.radius*c,z:B.target.z+B.radius*E*l}}const o=bg();function C(){return L7(o,I(),B.target,MU),o}const r=gE(C),n=()=>r.markLocalDirty(),s={alpha:A,beta:e,radius:t},B={alpha:0,beta:0,radius:0,target:new e1(g.x,g.y,g.z,n),fov:.8,nearPlane:.1,farPlane:1e3,children:[],inertia:.9,panningInertia:.9,angularSensibility:1e3,panningSensibility:50,wheelPrecision:3,inertialAlphaOffset:0,inertialBetaOffset:0,inertialRadiusOffset:0,inertialPanningX:0,inertialPanningY:0,_viewCache:bg(),_projCache:bg(),_vpCache:bg(),get parent(){return r.parent},set parent(Q){r.parent=Q},get worldMatrix(){return r.getWorldMatrix()},get worldMatrixVersion(){return r.getWorldMatrixVersion()}};for(const Q of["alpha","beta","radius"])Object.defineProperty(B,Q,{get:()=>s[Q],set:E=>{s[Q]!==E&&(s[Q]=E,n(),B._clampToLimits?.())},configurable:!0,enumerable:!0});return Q3(B,r),B}function kQ(A,e,t){return{x:A,y:e,z:t}}var J7=b((()=>{}));L1A(),J7();function ZzA(A){let e=1/0,t=1/0,g=1/0,I=-1/0,o=-1/0,C=-1/0;const r=v1A();for(const l of A.meshes)l.visible!==!1&&U1A(r,l);e=r.minX,t=r.minY,g=r.minZ,I=r.maxX,o=r.maxY,C=r.maxZ;const n=I-e,s=o-t,B=C-g;let Q=Math.sqrt(n*n+s*s+B*B)*1.5,E=kQ(e+n*.5,t+s*.5,g+B*.5);(!isFinite(Q)||Q===0)&&(Q=1,E=kQ(0,0,0));const c=XnA(-(Math.PI/2),Math.PI/2,Q,E);return c.nearPlane=Q*.01,c.farPlane=Q*1e3,A.camera=c,c}function PI(A,e){if(xnA()&&A._sceneChanges&&A._sceneChanges.depth===0){JnA(A,()=>PI(A,e));return}if("entities"in e){const t=e;for(const C of t.entities)PI(A,C);t.camera&&A.camera===t.camera&&(A.camera=null);const g=t.animationGroups;if(g?.length)for(const C of g)SE(A.animationGroups,C);const I=t._beforeRenderHook;I&&(SE(A._beforeRender,I),t._beforeRenderHook=void 0);const o=t._sceneCleanups;if(o){const C=o.get(A);C&&(SE(A._disposables,C),o.delete(A),A._z||C())}H3(A,e,"removed");return}if("_gpu"in e&&"material"in e){IZA(A,e),H3(A,e,"removed"),esA(A,e);return}if("lightType"in e){SE(A.lights,e);const t=e.shadowGenerator;t?$nA(A,t):AsA(A)}else"fov"in e&&"nearPlane"in e?A.camera===e&&(A.camera=null):"_shadowType"in e&&"_light"in e&&$nA(A,e);gZA(e),H3(A,e,"removed"),esA(A,e)}function XzA(A,e){for(const t of e){SE(A._disposables,t);const g=t.p;if(g){g._disposed=!0;const I=g._owner;if(I){const o=I.indexOf(g);o>=0&&I.splice(o,1),g._owner=void 0,I.length===0&&g._onOwnerEmpty?.()}else g._onOwnerEmpty?.();g._onOwnerEmpty&&(g._onOwnerEmpty=void 0)}}$zA(A,()=>{for(const t of e)t()})}function $zA(A,e){if(A._z){e();return}ag(A.surface.engine,e)}function $nA(A,e){SE(A.shadowGenerators,e);const t=e._light;t&&t.shadowGenerator===e&&(t.shadowGenerator=void 0),AsA(A);const g=e._shadowTaskState;g&&(e._shadowTaskState=void 0,AZA(A,()=>g._task.dispose()))}function AZA(A,e){A._pendingTopologyRetirements||(A._pendingTopologyRetirements=[],A._disposables.push(()=>eZA(A))),A._pendingTopologyRetirements.push(e)}function eZA(A){const e=A._pendingTopologyRetirements?.splice(0);if(!e?.length)return;const t=()=>{for(const I of e)try{I()}catch{}},g=A.surface.engine._device;g?g.queue.onSubmittedWorkDone().then(t,t):t()}function AsA(A){A._lightListVersion=(A._lightListVersion??0)+1,A._built&&(A._rebuildHook=tZA)}async function tZA(A){const{rebuildSceneRenderables:e}=await Promise.resolve().then(()=>(cU(),cnA));await e(A)}function SE(A,e){const t=A.indexOf(e);t>=0&&A.splice(t,1)}function gZA(A){A&&typeof A=="object"&&"parent"in A&&(A.parent=null)}function esA(A,e){const t=e.children;if(t?.length)for(const g of[...t])PI(A,g)}function IZA(A,e){A._meshMaterialChange?.(e);for(const n of A._frameGraph._tasks)n._removeMesh?.(e);const t=A._meshDisposables.get(e);let g=!1;const I=[];t&&(g=!0,I.push(...t),A._meshDisposables.delete(e));const o=A.meshes.indexOf(e);o>=0&&(A.meshes.splice(o,1),g=!0);const C=A._renderables.findIndex(n=>n.mesh===e);C>=0&&(A._renderables.splice(C,1),g=!0),g&&A._renderableVersion++;for(const n of A._groups.values()){const s=n.indexOf(e);s>=0&&n.splice(s,1);const B=n.o;if(B)for(let Q=B.length;Q--;)B[Q].mesh===e&&B.splice(Q,1)}const r=A._materialSwapQueue.indexOf(e);r>=0&&A._materialSwapQueue.splice(r,1),A._runtimeBuilds?.remove(e),e.parent=null;for(const n of A._frameGraph._tasks)"_renderables"in n&&PCA(n,e);GnA(A,e)&&I.push(()=>z1(e)),I.length&&XzA(A,I)}var f1=b((()=>{mI(),ds(),ar(),nE(),kg()}));function tI(A,e){tsA(A,e)&&q1()}function tsA(A,e){let t=A.visible!==e;A.visible=e;const g=A.children;for(let I=0;I<g.length;I++)tsA(g[I],e)&&(t=!0);return t}var Er=b((()=>{hI()}));function gsA(A,e){for(const t of A._frameGraph._tasks)if(t?._config&&t._colorAttachment&&(t._config.rt===e.scRT||t._config.rst===e.scRT))return t}function iZA(A){const e=A.surface,t=A._record;let g,I;A._record=()=>{const o=gsA(A,e);if(o!==g&&(g&&(g._config.clr=I,g._colorAttachment.view=g._config.rt._colorView),g=o,I=o?._config.clr),o){if(e.msaaSamples>1){let C=A._overlayBase;for(;C._overlayBase;)C=C._overlayBase;const r=gsA(C,e),n=r?.enabled!==!1&&r?.executionEnabled!==!1&&r?._config.rst===e.scRT&&r._colorAttachment.view;if(!n){const s=o.enabled;o.enabled=!1;try{return t()}finally{o.enabled=s}}o._colorAttachment.view=n}o._config.clr=!1}return t()}}hI(),mI();function oZA(A,e){let t=A._overlayBase;for(;t;){if(t===e)return!0;t=t._overlayBase}return!1}function IsA(A,e){const t=A.surface,g=t._renderingContexts,I=g.filter(o=>"_overlayBase"in o&&o._overlayBase===A);for(const o of I)e++,g[e]!==o&&TH(t,o,e),e=IsA(o,e);return e}function isA(A){let e=A;for(;e._overlayBase;)e=e._overlayBase;const t=e.surface,g=t._renderingContexts;let I=g.indexOf(e);if(I===-1)return;const o=g.findIndex(C=>oZA(C,e));o!==-1&&(o<I&&(TH(t,e,o),I=o),IsA(e,I))}function osA(A){let e=A._overlayBase;for(;e&&$F(A.surface,e);)e=e._overlayBase;return!!e}function CsA(A){const e=YnA(A.surface);e.clearColor={r:0,g:0,b:0,a:0},e._overlayBase=A,HzA(isA),iZA(e);const t=e._update,g=e._record;return e._update=()=>{osA(e)?e._drawCallsPre=0:t()},e._record=()=>osA(e)?0:g(),e}var CZA=H({_apply:()=>rZA}),rsA=/textureSampleLevel\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*0(?:\.0?)?\s*\)\.rgb/,rZA=(A,e)=>{const t=A.match(rsA),g=t?.[1],I=t?.[2],o=t?.[3];if(!g||!I||!o)throw new Error("Environment blur: skybox cubemap sample not found.");const C=`clamp(scene._envPad1*log2(f32(textureDimensions(${g}).x))*${e==="dds"?"0.8":"scene.vImageInfos.z+scene._envPad2"},0.0,f32(textureNumLevels(${g})-1))`;return A.replace(rsA,`textureSampleLevel(${g},${I},${o},0.0+(${C})).rgb`)};O1();function H7(A,e,t){const g=A._environmentSkyboxShaderPatchLoaders??=[];g[e]=t,A._environmentSkyboxShaderComposer??=async(I,o)=>{I=o==="hdr"?lo+I:I;for(const C of g.slice())C&&(I=(await C())._apply(I,o));return I}}MQ();var nZA=()=>CZA;function sZA(A,e){A[38]=e._environmentBlur??0,A[39]=e._envTextures?.lodGenerationOffset??0}function BZA(A,e){A._environmentBlur=e,H7(A,1,nZA),h9(A,sZA),w9(A)}var nsA=H({_apply:()=>BsA,_rotateSkyboxDirection:()=>ssA});function ssA(A,e){const t=A.match(T7)?.[1];t||m(470);const g=`let _erc=cos(${e});let _ers=sin(${e});${t}=vec3f(${t}.x*_erc+${t}.z*_ers,${t}.y,-${t}.x*_ers+${t}.z*_erc);`;return A.replace(T7,`$&${g}`)}var T7,BsA,QsA=b((()=>{rA(),T7=/var\s+([A-Za-z_]\w*)\s*=\s*normalize\(\w+\.positionUVW\)\s*;/,BsA=A=>ssA(A,"scene.envRotationY")}));MQ();var QZA=()=>Promise.resolve().then(()=>(QsA(),nsA));function aZA(A,e){IE(A),A._environmentRotation=e,H7(A,0,QZA),w9(A)}function EZA(A,e){IE(A),A._environmentRotation=e,w9(A)}function cZA(A,e){H7(A,0,async()=>{const{_rotateSkyboxDirection:t}=await Promise.resolve().then(()=>(QsA(),nsA));return{_apply:g=>t(g,`f32(${e})`)}})}var lZA=[A=>`AnimationGroup "${A}" is already attached to another AnimationManager`,()=>"Animation task category is required.",()=>"AnimationTask is already attached to another AnimationManager",()=>"AnimationManager autonomous mode requires requestAnimationFrame",A=>`Animation weight fade duration must be a finite positive number, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,()=>"createPropertyAnimationClip requires at least one track",()=>"Animation play range must have toTime greater than fromTime",A=>`Animation track "${A}" requires at least one key`,A=>`Animation track "${A}" requires a positive frameRate`,A=>`Animation track "${A}" key times must be monotonically increasing`,A=>`Animation track "${A}" requires at least one key`,A=>`Animation key for "${A}" must provide exactly one of time or frame`,A=>`Animation key for "${A}" must have a non-negative time`,(A,e)=>`Animation key for "${A}" expected ${e} values`,(A,e)=>`Animation key for "${A}" expected ${e} values`,A=>`Invalid animation property path "${A}"`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,A=>`Animation property path "${A}" reached a non-object value`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,(A,e)=>`Animation property path "${A}" has unsupported vector size ${e}`,(A,e)=>`Animation property path "${A}" could not resolve component "${e}"`,()=>"Additive animation reference must use either referenceFrame or referenceTime, not both",A=>`Additive animation reference time must be a finite non-negative number, got ${A}`,()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted animation channels for the same property must use the same value size",()=>"Weighted animation channels for the same property must use the same mixing strategy",()=>"Audio engine media streams require a real-time AudioContext.",()=>"Unable to get a 2D context from the visualizer canvas.",()=>"Invalid splat voxel collision data.",(A,e)=>`Collision data: HTTP ${A} for ${e}`,()=>"Collision URL must be an HTTP(S) .voxel.json URL.",()=>"setEffectUniforms: wrapper has no uniform binding.",A=>`setEffectUniforms: unknown uniform binding "${A}".`,A=>`setEffectTexture: unknown texture binding "${A}".`,A=>`EffectRenderTask "${A}" executed before record().`,A=>`EffectRenderer "${A}" recorded before registerEffectRenderer().`,A=>`createEffectWrapper: duplicate binding ${A}.`,(A,e)=>`Effect "${A}" missing uniform binding ${e}.`,(A,e)=>`Effect "${A}" missing texture binding ${e}.`,(A,e)=>`Effect "${A}" missing texture for sampler binding ${e}.`,(A,e,t)=>`writeUniformSlot: ${A} bytes exceeds uniform binding ${e} size ${t}.`,(A,e)=>`setUniformEffectUniforms: ${A} bytes exceeds uniform size ${e}.`,A=>`UniformEffectRenderTask "${A}" executed before record().`,()=>"Device-lost recovery capture requires an enabled recovery coordinator",()=>"WebGPU adapter not available during device recovery",A=>`WebGPU device recovery missing required features: ${A}`,()=>"forceWebGpuDeviceLossForTesting requires a device-lost recovery handler to be enabled first",()=>"WebGPU adapter not available",()=>"Babylon Lite: useFloatingOrigin requires useHighPrecisionMatrix on the engine.",()=>"renderFrame: surface belongs to a different engine.",()=>"Frame-bound post-submit work requires an active frame encoder.",()=>"GPU task timing could not instrument render passes on this command encoder.",()=>"GPU task timing could not instrument compute passes on this command encoder.",()=>"createMipMappedRenderTarget requires a color format and samples: 1.",()=>"Mipmapped render target has been disposed.",()=>"Mipmapped render target requires a single-sample, filterable, renderable color format.",()=>"Mipmapped render target dimensions must be positive integers.",()=>"Mipmapped render target dimensions exceed maxTextureDimension2D.",A=>`RenderTargetDescriptor.size.scale must be a positive finite number (got ${A}).`,()=>"WebGPU context not available",()=>"Babylon Lite: disposeSurface cannot dispose the engine's primary surface \u2014 use disposeEngine instead.",A=>`Flow Graph Editor: unsupported block class ${A}`,()=>"Flow Graph Editor: expected a serialized object",A=>`Flow Graph Editor: graph ${A} has no allBlocks array`,()=>"KHR_interactivity: duplicate type signatures",A=>`KHR_interactivity: unsupported type signature ${A}`,A=>`KHR_interactivity: node references missing declaration #${A}`,(A,e)=>`KHR_interactivity: variable ${A} references missing type #${e}`,(A,e,t)=>`KHR_interactivity: event ${A} value ${e} references missing type #${t}`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} references invalid variable #${t}`,A=>`KHR_interactivity: variable/set node ${A} has invalid variable indices`,(A,e)=>`KHR_interactivity: variable/set node ${A} is missing input for variable #${e}`,(A,e)=>`KHR_interactivity: variable/set node ${A} input for variable #${e} has the wrong type`,A=>`KHR_interactivity: node ${A} is missing its pointer configuration`,(A,e)=>`KHR_interactivity: node ${A} is missing pointer parameter ${e}`,(A,e)=>`KHR_interactivity: node ${A} pointer parameter ${e} has the wrong type`,(A,e)=>`KHR_interactivity: ${A} node ${e} uses a reserved pointer parameter`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} references invalid type #${t}`,(A,e)=>`KHR_interactivity: node ${A} references invalid event #${e}`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} is missing required ${t} input`,(A,e)=>`KHR_interactivity: variable/interpolate node ${A} references invalid variable #${e}`,A=>`KHR_interactivity: variable/interpolate node ${A} can only use slerp with float4`,(A,e)=>`KHR_interactivity: pointer/interpolate node ${A} references invalid type #${e}`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} cannot interpolate ${t}`,(A,e)=>`KHR_interactivity: node ${A} references missing producer node #${e}`,(A,e,t)=>`KHR_interactivity: node ${A} flow ${e} targets missing node #${t}`,A=>`invalid RFC 6901 escape in pointer segment ${A}`,A=>`literal pointer brackets must be doubled in ${A}`,()=>"JSON Pointer Templates must be absolute",A=>`duplicate pointer parameter ${A}`,A=>`ClearTextureTask "${A}": targetTexture or depthTexture is required; color target arrays must not be empty.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": color attachments must reference distinct textures.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": too many color attachments.`,A=>`ClearTextureTask "${A}": attachments must have matching dimensions and sample counts.`,A=>`ClearTextureTask "${A}": build the frame graph before execution.`,A=>`ClearTextureTask "${A}": targetTexture has no live color attachment.`,A=>`ClearTextureTask "${A}": depthTexture has no live depth/stencil attachment.`,A=>`CopyToTextureTask "${A}": either targetTexture or resolveTexture must be provided.`,A=>`CopyToTextureTask "${A}": sourceTexture cannot be the engine scRT because its GPU texture changes every frame.`,A=>`CopyToTextureTask "${A}": sourceTexture has no color texture. The source must be built before this task records.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled sourceTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,t,g,I)=>`CopyToTextureTask "${A}": sourceTexture (${e}x${t}) and resolveTexture (${g}x${I}) must have matching dimensions.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled targetTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,t)=>`CopyToTextureTask "${A}": resolveTexture format (${e}) must match targetTexture format (${t}).`,()=>"CopyToTextureTask: targetTexture has no color format.",A=>`DepthResolveTask "${A}": sourceTexture has no depth attachment.`,A=>`DepthResolveTask "${A}": sourceTexture must be multisampled (sampleCount > 1).`,A=>`DepthResolveTask "${A}": targetTexture has no depth format.`,()=>"FrameGraph target does not expose a frame graph.",A=>`addRenderPass("${A}"): no task is currently recording (called outside Task.record?)`,A=>`buildFrameGraphTask("${A}"): task is not registered in this graph.`,A=>`GenerateMipMapsTask "${A}": targetTexture is required.`,A=>`GenerateMipMapsTask "${A}": build the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture changed or was disposed; rebuild the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture cannot be a swapchain target.`,A=>`GenerateMipMapsTask "${A}": targetTexture must be a single-sample, filterable, renderable 2D color texture with sampling and render-attachment usage.`,A=>`GenerateMipMapsTask "${A}": targetTexture must have mipmaps allocated.`,A=>`GeometryRendererTask: MESH_BLEND_TAG format must be r8uint, received ${A}.`,()=>"GeometryRendererTask: MESH_BLEND_TAG clearValue must be unsigned integer zero.",()=>"GeometryRendererTask: MESH_BLEND_TAG requires samples: 1.",()=>"GeometryRendererTask: transparent Node materials cannot write MESH_BLEND_TAG because their graph alpha is unavailable to the geometry terminal. Exclude transparent meshes or omit the tag attachment.",()=>"GeometryRendererTask: textureDescriptions must contain at least one entry.",()=>"GeometryRendererTask: too many color attachments.",A=>`GeometryRendererTask: unknown texture type ${A}.`,(A,e)=>`GeometryRendererTask: depthTexture sampleCount (${A}) must match samples (${e}).`,(A,e)=>`GeometryRendererTask: targetTexture sampleCount (${A}) must match samples (${e}).`,()=>"GeometryRendererTask: targetTexture must have a format.",A=>`Transparent geometry output cannot blend integer format "${A}".`,A=>`Transparent geometry output format "${A}" requires the float32-blendable WebGPU feature or a blendable format override.`,()=>"GeometryRendererTask: MESH_BLEND_TAG is not enabled.",()=>"overdraw probe: this device has no timestamp-query feature",()=>"overdraw probe: tasks that load existing depth cannot be measured with a fresh-depth replay",()=>"overdraw probe: task render target has no size (has the task rendered yet?)",()=>"overdraw probe: task target has no color+depth signature to replicate",()=>"overdraw probe: task has no draw bindings (has the task rendered yet?)",()=>"overdraw probe: task scene bindings have not been recorded",()=>"overdraw probe: timestamp readback produced no usable samples",A=>`PostProcessTask "${A}": sourceTexture has no color texture. Render the source to an offscreen RenderTarget before post-processing.`,A=>`PostProcessTask "${A}": multisampled source textures are not supported. Use a sampleCount: 1 source RenderTarget.`,A=>`PostProcessTask "${A}": outputTexture must have a format.`,(A,e)=>`PostProcessTask "${A}": extra texture ${e} has no color texture.`,A=>`PostProcessTask "${A}": sourceTexture must have a format.`,()=>"enableRenderTaskMeshRefresh must be called before the render task is recorded.",()=>"enableRenderTaskMeshRefresh requires an explicit render task with autoMirror: false.",()=>"RenderTask has been disposed.",()=>"Material group has not completed its initial build in this scene.",()=>"RenderTask has been disposed.",()=>"Gaussian point splatting target is already enabled in another scene",()=>"Gaussian point splatting requires a live target on the scene's engine",()=>"Gaussian point sampling could not instrument the consuming render pass",()=>"Gaussian point visibility requires the consuming task's active depth pass",()=>"RectAreaLight: scene was disposed before emission preparation",()=>"RectAreaLight: emission image count exceeds the device texture-array layer limit",A=>`RectAreaLight: emission array upload failed: ${A}`,()=>"RectAreaLight: scene was disposed during emission preparation",()=>"RectAreaLight: device changed during emission preparation; preprocess on the current engine",()=>"RectAreaLight: emission capacity/assignments/topology changed during preparation; enable and rebuild again",()=>"RectAreaLight: prepare the owning scene's emission resources and rebuild its material groups before binding",()=>"RectAreaLight: emission light capacity changed; enable and rebuild again before binding",()=>"RectAreaLight: source must be a filterable, single-sampled color Texture2D with matching dimensions",()=>"RectAreaLight: texture was released",()=>"RectAreaLight: emissionTexture must be returned by processAreaLightTexture(engine, source)",()=>"RectAreaLight: emissionTexture belongs to a different device; preprocess it on the current engine",()=>"RectAreaLight: incompatible processed emissionTexture",A=>`RectAreaLight: LTC payload must contain 65536 bytes, got ${A}`,(A,e)=>`RectAreaLight: LTC request failed (${A}) at ${e}`,A=>`RectAreaLight: LTC GPU upload failed: ${A}`,()=>"RectAreaLight: scene was disposed while loading LTC data",()=>"RectAreaLight: scene was disposed during LTC upload",()=>"RectAreaLight: await enableRectAreaLights(scene) and prepare material groups on the current device before rendering",()=>"buildClusteredLightGpuState: scene.camera is required",()=>"ClusteredLightContainer: light count cannot grow after GPU state creation.",()=>"RectAreaLight: cannot enable lighting on a disposed scene",()=>"RectAreaLight: preprocess emissionTexture with processAreaLightTexture(engine, source) before enabling",()=>"RectAreaLight: NodeMaterial lighting blocks are not supported yet; use PBR or Standard materials, or an unlit node graph",()=>"RectAreaLight: scene was disposed while enabling lighting",()=>"RectAreaLight: device changed during emission preprocessing",()=>"RectAreaLight: source allocation changed during emission preprocessing",()=>"RectAreaLight: source was released during emission preprocessing",A=>`RectAreaLight: emission scale/device validation failed: ${A}`,A=>`RectAreaLight: emission upload failed: ${A}`,(A,e)=>`RectAreaLight: ${A} must be finite and nonnegative, got ${e}`,()=>"RectAreaLight: area-light shadows are not supported yet",()=>"RectAreaLight: await enableRectAreaLights(scene) before registering this scene",()=>"RectAreaLight: emissionTexture must be a Texture2D or null",A=>`setLightDiffuseColor: expected finite RGB components, got ${A}`,A=>`setLightIntensity: expected a finite intensity, got ${A}`,()=>"Device-lost Scene recovery requires environment loading after recovery was enabled",(A,e,t)=>`Device-lost Scene recovery could not refetch '${A}' (${e} ${t}).`,()=>"Procedural sky environment requires finite non-negative scattering, non-zero total scattering, a non-zero sun direction, and positive luminance.",()=>"Procedural sky environment has been disposed.",()=>"Procedural sky environment no longer owns the scene environment.",()=>"loadProceduralSkyEnvironment cannot load into a disposed scene.",()=>"loadProceduralSkyEnvironment requires a scene without an existing environment.",()=>"loadProceduralSkyEnvironment must run before the scene is registered.",()=>"A procedural sky environment is already loading for this scene.",()=>"Procedural sky environment initialization was cancelled: the scene was disposed, registered, or acquired another environment.",()=>"Procedural sky environment initialization was cancelled.",(A,e)=>`${A}: image ${e} not found`,(A,e)=>`${A}: bufferView ${e} not found`,(A,e,t)=>`${A}: failed to load image ${e} ${t}`,A=>`${A}: image has neither bufferView nor uri`,(A,e)=>`${A}: strided accessor uses unsupported component type: ${e}`,(A,e,t)=>`${A}: strided accessor ${e} uses unsupported component type: ${t}`,(A,e,t)=>`${A}: invalid accessor stride ${e} for accessor ${t}`,A=>`glTF camera ${A}: unsupported projection`,()=>"glTF camera nodes require non-zero uniform scale",A=>`EXT_mesh_gpu_instancing: accessor count mismatch on node ${A}`,A=>`EXT_meshopt_compression: compressed source buffer ${A} is not buffer 0 (unsupported)`,A=>`EXT_meshopt_compression: uncompressed bufferView in buffer ${A} is not buffer 0 (unsupported)`,A=>`glTF sparse: unsupported componentType ${A}`,A=>`glTF sparse: unsupported index componentType ${A}`,A=>`glTF sparse: unsupported value componentType ${A}`,()=>"glTF sparse: indices.componentType is required",(A,e)=>`glTF sparse: index ${A} out of range for accessor of count ${e}`,()=>"Not a valid GLB file",()=>"First GLB chunk is not JSON",()=>"Second GLB chunk is not BIN",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"loadGltf: baseless input can't resolve relative URI; use self-contained GLB or URL with base.",A=>`Unsupported component type: ${A}`,()=>"Image has neither bufferView nor uri",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"Image has neither bufferView nor uri",()=>"Invalid HDR: missing #? signature",A=>`Unsupported HDR format: ${A}`,A=>`Invalid HDR resolution: ${A}`,()=>"Invalid HDR: RLE scanline width does not match image",()=>"Invalid HDR: truncated RLE scanline",()=>"Invalid HDR: zero-length RLE packet",()=>"Invalid HDR: RLE run exceeds scanline",()=>"Invalid HDR: RLE literal exceeds scanline",()=>"Invalid HDR: truncated scanline",(A,e)=>`${A} source ${e}: expected five textures`,A=>`${A} resident environment exceeds admitted GPU capacity`,A=>`${A} active display exceeds admitted GPU capacity`,(A,e)=>`${A} source ${e}: GPU/CPU cache budget admission failed`,(A,e)=>`${A} metadata ${e}: only http and https URLs are supported`,A=>`${A} metadata: Fetch is required`,(A,e,t)=>`${A} metadata ${e}: HTTP ${t}`,(A,e)=>`${A} metadata ${e}: Content-Length exceeds maxCpuBytes admission`,(A,e)=>`${A} metadata ${e}: response has no body`,(A,e)=>`${A} metadata ${e}: streamed body exceeds maxCpuBytes admission`,(A,e,t)=>`${A} bootstrap coarse representation (${e} splats) exceeds maxSplats (${t})`,A=>`${A} attach: stream is disposed`,A=>`${A} attach: scene and stream use different engines`,A=>`${A} attach: stream is already attached to another scene`,A=>`${A} attach: attach before or during scene registration`,(A,e)=>`[GaussianSplatStream] GPU ${A} buffer size ${e} exceeds device limits`,()=>"[GaussianSplatStream] GPU budget/device limits cannot admit one canonical splat",()=>"[GaussianSplatStream] GPU budget cannot admit canonical stream state",()=>"[GaussianSplatStream] GPU upload requires exactly five source images",()=>"[GaussianSplatStream] GPU byte upload requires five exact RGBA8 images",()=>"[GaussianSplatStream] GPU state is disposed",()=>"[GaussianSplatStream] GPU interval is outside admitted source/canonical bounds",()=>"[GaussianSplatStream] GPU budget cannot admit pass-local projection and radix state",()=>"[GaussianSplatStream] GPU budget cannot protect submission-local gather parameters",()=>"[GaussianSplatStream] GPU budget cannot admit submission-local gather parameters",(A,e)=>`${A} transport ${e}: invalid Content-Length`,(A,e)=>`${A} transport ${e}: unsafe Content-Length`,(A,e)=>`${A} image ${e}: invalid WebP header`,(A,e)=>`${A} image ${e}: invalid lossless WebP header`,(A,e)=>`${A} image ${e}: unsupported WebP header`,A=>`${A} transport: Fetch and createImageBitmap are required`,A=>`${A} transport: reserveGpuBytes requires gpuLedger for reservation cleanup`,(A,e,t)=>`${A} ${e}: maxCpuBytes cannot admit ${t} bytes`,(A,e,t)=>`${A} ${e}: maxCpuBytes cannot admit ${t} bytes without blocking payloads retained by the same preparation`,(A,e)=>`${A} transport ${e}: response has no body`,(A,e)=>`${A} image ${e}: dimensions do not match the source`,A=>`${A} selection: invalid view-projection frustum`,A=>`${A} selection: viewProjectionMatrix must contain 16 values`,A=>`${A} selection: viewProjectionMatrix must be finite`,A=>`${A} selection: worldMatrix must contain 16 values`,A=>`${A} selection: world transform produced nonfinite bounds`,A=>`${A} selection: cameraPosition must be finite`,A=>`${A} selection: invalid planner parameters`,A=>`${A} selection: orthographic cameras are unsupported`,A=>`${A} selection: invalid planner parameters`,A=>`${A} bootstrap: manifest has no positive coarse source`,A=>`loadSOG: decoded WebP has zero dimensions (input size ${A})`,()=>"loadSOG: failed to acquire 2D context for WebP decode",()=>"loadSOG: means.mins/means.maxs must be arrays",()=>"loadSOG: SOG v2 missing scales codebook",()=>"loadSOG: scales.mins/maxs must be arrays for SOG v1",()=>"loadSOG: SOG v2 missing sh0 codebook",()=>"loadSOG: sh0.mins/maxs must be arrays for SOG v1",A=>`loadSOG: invalid quaternion mode ${A}`,()=>"loadSOG: SOG v2 missing shN codebook",(A,e)=>`loadSOG: HTTP ${A} for ${e}`,()=>"loadSOG: meta.json not found in archive",A=>`loadSOG: missing image '${A}' inside archive`,(A,e)=>`loadSplat: HTTP ${A} for ${e}`,A=>`loadSplat: failed to parse PLY at ${A} (unsupported property layout)`,()=>"loadSPZ: file too short to contain header",(A,e)=>`loadSPZ: unsupported SPZ stream (magic=0x${A} version=${e})`,(A,e)=>`loadSPZ: HTTP ${A} for ${e}`,()=>"Invalid compressed PLY: packed vertex properties require chunk metadata for every vertex",()=>"zip: EOCD record not found",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad central directory signature at offset ${A}`,()=>"zip: encrypted entries are not supported",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad local file header signature at offset ${A}`,(A,e)=>`zip: unsupported compression method ${A} for entry '${e}'`,(A,e,t)=>`zip: entry '${A}' decompressed size mismatch (got ${e}, expected ${t})`,A=>`Duplicate USD mesh ${A}`,()=>"Invalid USD analytic primitive",A=>`Missing USD material ${A}`,()=>"Invalid USD animation target, property, or value stride",()=>"Invalid USD animation samples",()=>"Invalid USD triangle indices",()=>"Non-finite USD positions",()=>"Non-finite USD vertex data",()=>"Invalid USD material subset index range",()=>"USD instance references a missing source",A=>`USD mesh ${A} cannot mix classic and thin instances`,()=>"USD command buffer must contain exactly one scene",()=>"Invalid USD stage metadata",A=>`Duplicate USD geometry ${A}`,A=>`Duplicate or reserved USD mesh ${A}`,A=>`Missing USD geometry ${A}`,()=>"USD mesh has no material subsets",()=>"Invalid USD material subset vertex range",A=>`Missing USD material ${A}`,(A,e)=>`Invalid USD ${A} texture output channel ${e}`,A=>`Duplicate USD material ${A}`,A=>`Non-finite USD material ${A}`,(A,e)=>`USD material ${A} has a channel without texture ${e}`,(A,e)=>`USD material ${A} references texture ${e} without a texture command`,A=>`Invalid or duplicate USD morph target ${A}`,A=>`USD morph target ${A} contains invalid vertex data`,A=>`USD morph targets reference missing mesh ${A}`,A=>`USD morph target vertex count does not match mesh ${A}`,A=>`Duplicate or reserved USD node ${A}`,()=>"Non-finite USD transform",()=>"Cyclic or missing USD parent node",()=>"Invalid USD command buffer",()=>"Unsupported USD command protocol version",()=>"Truncated USD command header",A=>`Invalid USD command ${A} payload`,()=>"Unexpected trailing USD commands",()=>"Invalid USD data range",A=>`Invalid or duplicate USD skeleton ${A}`,A=>`USD skeleton ${A} has an invalid parent or duplicate bone ID`,A=>`USD skeleton ${A} has a non-finite joint transform`,A=>`USD skeleton ${A} has a singular bind transform`,()=>"USD mesh references a missing skeleton",()=>"Missing or unsupported USD mesh skin",()=>"Invalid USD skin weights or joint indices",A=>`Duplicate USD texture ${A}`,A=>`Missing USD texture ${A}`,()=>"Unsupported USD texture encoding, wrap mode, UV set, or color space",()=>"Invalid USD texture transform",A=>`USD thin instances reference missing source ${A}`,A=>`USD mesh ${A} has duplicate or mixed instances`,A=>`USD thin instances for mesh ${A} contain a non-finite transform`,A=>`USD file path must be relative: ${A}`,A=>`Could not load USD: HTTP ${A}`,A=>`Duplicate USD virtual file: ${A}`,A=>`LineMaterial "${A}" requires thin-instance data`,()=>"createLineMaterial requires useThinInstances when useThinInstanceColors is enabled",(A,e)=>`NodeMaterial: cannot pick common numeric type from ${A} and ${e}`,A=>`NodeMaterial: AmbientOcclusionBlock "${A}" requires an ImageSourceBlock source`,()=>"BiPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: ColorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: ColorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unknown CurveBlock curveType ${A}`,A=>`NodeMaterial: CurveBlock does not support ${A}`,()=>"NodeMaterial: FragDepthBlock requires `depth` or both `worldPos` and `viewProjection` inputs",A=>`NodeMaterial: HeightToNormalBlock "${A}" requires worldTangent when generateInWorldSpace is false`,A=>`InputBlock: unknown mesh attribute "${A}"`,(A,e)=>`InputBlock: unsupported systemValue ${A} on block "${e}"`,A=>`LoopBlock "${A}": index can only be read while emitting the loop body`,A=>`LoopBlock "${A}": loopID can only be consumed by StorageReadBlock/StorageWriteBlock`,(A,e)=>`LoopBlock "${A}": unsupported output "${e}"`,A=>`NodeMaterial: MatrixSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unsupported matrix block "${A}"`,()=>"NodeMaterial: NLerpBlock requires a vector left/right input; Babylon.js emits normalize(mix(...)) for this block",()=>"NodeMaterial: PBR-MR core emitter cannot emit optional PBR feature code",()=>"NodeMaterial: PBR-MR core helper cannot emit optional PBR feature code",A=>`NodeMaterial: RandomNumberBlock requires a vector seed so Babylon.js getRand(seed.xy) can be emitted; got ${A}`,A=>`ReflectionTextureBaseBlock "${A}" is an abstract compatibility block and cannot be emitted directly.`,A=>`ReflectionTextureBlock: coordinatesMode ${A} not supported (only EQUIRECTANGULAR_MODE=7)`,A=>`NodeMaterial: ReplaceColorBlock requires a vector/color value; got ${A}`,(A,e)=>`StorageReadBlock "${A}": unsupported output "${e}"`,A=>`StorageReadBlock "${A}": loopID input is not connected`,(A,e)=>`StorageReadBlock "${A}": loop ${e} is not active`,()=>"NodeMaterial: TBNBlock object output is not supported; use row0/row1/row2 outputs",A=>`NodeMaterial: TeleportOutBlock (id=${A}) has no entryPoint`,(A,e)=>`NodeMaterial: TeleportOutBlock (id=${A}) points to missing TeleportInBlock ${e}`,()=>"TriPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: VectorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: VectorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: WaveBlock does not support ${A}`,A=>`NodeMaterial: unknown WaveBlock kind ${A}`,A=>`NodeMaterial: invalid block selection "${A}": use an exported block descriptor`,A=>`NodeMaterial: duplicate block selection "${A}"`,A=>`NodeMaterial: no emitter selected for block "${A}"`,(A,e,t)=>`NodeMaterial: cannot cast ${A} to ${e} for expression \`${t}\``,(A,e)=>`${A}: unsupported BJS connection point type 0x${e}`,(A,e,t)=>`NodeMaterial: block "${A}" (id=${e}) has no input "${t}"`,(A,e,t)=>`NodeMaterial: block "${A}" (id=${e}) input "${t}" is not connected`,(A,e,t)=>`NodeMaterial: dangling connection ${A}.${e} -> block ${t}`,A=>`NodeMaterial: no emitter loaded for block "${A}"`,()=>"NodeMaterial: only vertex->fragment varyings are supported",A=>`NodeMaterial: fragment root block ${A} not found`,A=>`NodeMaterial: no emitter for fragment root "${A}"`,A=>`NodeMaterial: vertex root block ${A} not found`,A=>`NodeMaterial: no emitter for vertex root "${A}"`,()=>"NodeMaterial: PBR/Reflection block requires scene environment but scene._envTextures is unset. Call loadEnvironment() before registerScene().",()=>"node-geometry view does not support scene group building",()=>"node-geometry rebuild requires task-owned resources",()=>"NodeMaterial geometry view: graph has no GeometryTextureOutputBlock",()=>"NodeMaterial geometry view: morph / env / shadow inputs are not supported in the geometry pass",()=>"node-geometry: render target has no color attachments",(A,e)=>`NodeMaterial geometry view: texture binding "${A}" not set. Provide it via material.inputs["${e}"].texture before the first render.`,()=>"NodeMaterial geometry view: NORMALIZED_VIEW_DEPTH requested but no geometry-params UBO was provided by the task.",()=>"NodeMaterial geometry view: emitColor (real-color target) is not supported \u2014 omit targetTexture on the geometry task.",()=>"NodeMaterial: graph has no FragmentOutputBlock",()=>"NodeMaterial: advanced PBR-MR helper request must be emitted by the full PBR-MR block",()=>"NodeMaterial: invalid source \u2014 expected `.blocks` array",A=>`NodeMaterial: block missing numeric id (name=${A})`,(A,e)=>`NodeMaterial: cycle detected through block ${A} (${e})`,A=>`NodeMaterial: dangling reference to block ${A}`,A=>`NodeMaterial: helper key "${A}" registered with conflicting source bodies`,A=>`NodeMaterial: no advanced extension emitter registered for block "${A}"`,A=>`NodeMaterial: no compatibility extension emitter registered for block "${A}"`,A=>`NodeMaterial: no math extension emitter registered for block "${A}"`,A=>`NodeMaterial: no procedural extension emitter registered for block "${A}"`,(A,e)=>`NodeMaterial: texture binding "${A}" not set. Provide it via options.textures or material.inputs["${e}"].texture before the first render.`,A=>`NodeMaterial: material requires shadow generator #${A} but none was supplied to parseNodeMaterialFromSnippet({ shadowGenerators }).`,A=>`NodeMaterial: unsupported attribute "${A}"`,(A,e)=>`NodeMaterial: snippet fetch failed (${A}) for ${e}`,A=>`NodeMaterial: snippet "${A}" has no jsonPayload`,A=>`NodeMaterial: snippet "${A}" has no nodeMaterial`,()=>"Parallax shader composition encountered an unterminated textureSample expression.",A=>`Parallax surface texture ${A} requires a 2D textureSample expression.`,()=>"Parallax shader composition could not find the Standard normal-map helper.",()=>"Parallax shader composition could not find the Standard normal-map invocation.",()=>"Parallax shader composition requires a fragment entry point.",(A,e)=>`[babylon-lite] ${A} must contain three finite${e} values`,A=>`[babylon-lite] ${A} must be finite and positive`,A=>`[babylon-lite] local probe ${A} influenceInnerRadius must be finite, non-negative, and no larger than influenceOuterRadius`,A=>`[babylon-lite] local probe ${A} inner influence box must be non-negative and contained by the outer influence box`,A=>`[babylon-lite] local probe ${A} angleRadians must be finite`,A=>`[babylon-lite] local probe ${A} debugColor must contain three finite values from 0 to 1`,()=>"[babylon-lite] local probe cubemap dimensions must differ only by power-of-two mip levels",()=>"[babylon-lite] local probe voxelGrid.cellSize must be finite and positive",()=>"[babylon-lite] local probe voxelGrid.maximum must be greater than minimum on every axis",()=>"[babylon-lite] local probe voxel grid dimensions are too large",()=>"[babylon-lite] local probe voxel grid dimensions are too large",(A,e,t,g,I)=>`[babylon-lite] local probe voxel (${A}, ${e}, ${t}) intersects ${g} probes, exceeding maxCandidates ${I}`,()=>"[babylon-lite] local probe cubemaps require COPY_SRC usage; call enablePbrLocalCubemap() before loading DDS or HDR probe environments, or create custom probe textures with COPY_SRC",()=>"[babylon-lite] local probe cubemaps must be square six-face textures with one shared format",()=>"[babylon-lite] local probe cubemaps have no common mip range",(A,e)=>`[babylon-lite] local probe set has ${A} probes, but this device supports at most ${e} cube-array probes`,(A,e)=>`[babylon-lite] local probe UBO requires ${A} bytes, but this device supports ${e}`,A=>`[babylon-lite] local probe voxel grid requires ${A} bytes, exceeding this device's storage-buffer limits`,A=>`[babylon-lite] local probe sets require 1..${A} probes`,()=>"Environment rotation: skybox direction declaration not found.",(A,e)=>`${A}: expected to rewrite 1 occurrence, rewrote ${e}`,A=>`local probe array _postCompose: expected to rewrite 1 voxel-grid binding declaration, rewrote ${A}`,A=>`local probe array _postCompose: expected to rewrite 1 cube-array binding declaration, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat reflection direction, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 sheen radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 reflection direction, rewrote ${A}`,()=>"local cubemap _postCompose: expected at least 1 environment LOD scale rewrite",A=>`local cubemap _postCompose: expected to rewrite 1 base radiance sample, rewrote ${A}`,A=>`[babylon-lite] local cubemap could not replace the scene ${A} binding`,()=>"PBR parallax settings changed after compilation; rebuild the material before rendering.",()=>"RectAreaLight: layered PBR direct lighting (clearcoat, sheen, anisotropy, subsurface, iridescence) is not supported yet",()=>"PBR transmission requires a frame-graph refraction texture.",()=>"composePbrGeometryShader: PBR fragment signature mismatch \u2014 _noColorOutput/_esmShadowOutput should be off",()=>"composePbrGeometryShader: alpha-block return statement not found \u2014 template changed?",()=>"pbr-geometry view does not support scene group building",()=>"pbr-geometry rebuild requires task-owned resources",()=>"buildPbrGeometryRenderable: scene has no PBR context. Ensure regular PBR meshes have been built before recording the geometry task.",()=>"pbr-geometry: render target has no color attachments",A=>`[babylon-lite] local cubemap maxCandidates is already ${A} and cannot be changed after initialization`,A=>`[babylon-lite] local cubemap maxCandidates must be an integer from 1 to ${A}`,()=>"PBR material plugin vertex signature is not registered.",()=>"PBR material plugin vertex uniforms require a material UBO.",A=>`Material plugin varying type "${A}" is unsupported; use a floating-point scalar or vector.`,()=>"Standard material plugin signature is not registered.",()=>"Standard material plugins require an owning scene.",()=>"Standard plugin material requires a scene mesh or a binding owner.",()=>"Standard material plugin signature is not registered.",()=>"setShadowCasterMaterial: the caster chain must not cycle back to the source material",()=>"Async ShaderMaterial pipeline preparation could not capture the synchronous descriptor.",()=>'enableShaderMaterialInstanceWorld requires the ShaderMaterial to declare the "world" system uniform.',A=>`ShaderMaterial: external texture "${A}" has no source. Call setShaderExternalTexture() before rendering.`,A=>`ShaderMaterial: external texture "${A}" is not ready.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,(A,e)=>`ShaderMaterial: ${A} name "${e}" is not a valid WGSL identifier.`,()=>"ShaderMaterial: vertexSource and fragmentSource must be non-empty WGSL strings.",()=>"ShaderMaterial: strip topologies are unsupported because indexed draws require a mesh-specific stripIndexFormat.",A=>`ShaderMaterial: unsupported attribute "${A}". Supported attributes: position, normal, uv, uv2, tangent, color, joints, weights, joints1, weights1.`,A=>`ShaderMaterial: duplicate attribute "${A}".`,()=>'ShaderMaterial: "position" attribute is required for mesh rendering.',A=>`ShaderMaterial: define "${A}" must be a boolean or number.`,()=>"ShaderMaterial: `transmissive` requires `needAlphaBlending` (the surface composites over the grabbed opaque scene color).",A=>`ShaderMaterial: custom uniform "${A}" must use an explicit typed declaration.`,(A,e)=>`ShaderMaterial: unsupported uniform type "${A}" for "${e}".`,(A,e)=>`ShaderMaterial: duplicate generated identifier "${A}" while adding ${e}.`,(A,e,t,g)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${t} value(s), got ${g}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,(A,e,t,g)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${t} value(s), got ${g}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" expects a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" cannot use a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: storage buffer "${A}" was not declared.`,()=>"setShaderStorageBuffer requires a StorageBuffer created by createStorageBuffer; raw GPUBuffer is not supported.",A=>`ShaderMaterial: storage buffer "${A}" has been disposed.`,()=>"setShaderStorageBuffer requires a live StorageBuffer created by createStorageBuffer.",()=>"ShaderMaterial external textures require setShaderExternalTexture before pipeline preparation.",A=>`ShaderMaterial: sampler "${A}" has no Texture2D. Call setShaderTexture() before rendering.`,A=>`ShaderMaterial storage "${A}" is invalid.`,(A,e,t)=>`ShaderMaterial format "${A}" for "${e}" is incompatible with canonical geometry on mesh "${t}".`,(A,e,t)=>`ShaderMaterial format "${A}" for "${e}" does not fit the aligned vertex layout on mesh "${t}".`,()=>"RectAreaLight: emission bindings require their owning scene",()=>"RectAreaLight: Standard bindings require their owning scene",()=>"Standard parallax binding requires the owning scene and resource disposers.",()=>"Standard parallax settings changed after compilation; rebuild the material before rendering.",()=>"Standard UV transform _bind requires the scene argument from the Standard bind-group builder",()=>"Standard geometry deformation velocity was not preloaded.",()=>"composeStandardGeometryShader: standard fragment signature mismatch \u2014 bypass active?",()=>"composeStandardGeometryShader: 'return color;' not found in composed fragment \u2014 template changed?",()=>"standard-geometry view does not support scene group building",()=>"standard-geometry rebuild requires task-owned resources",()=>"standard-geometry: deformation velocity feature was not preloaded",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: morph targets require the scene Standard morph context",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: render target has no color attachments",()=>"Standard material group has not completed its initial build in this scene.",()=>"Dashed lines require at least two points",()=>"createDashedLines produced no dash segments (degenerate points or dashNb)",()=>"updateDashedLines requires a mesh created by createDashedLines",A=>`Line system data requires finite ${A} components`,()=>"Line system data requires one color row per line",()=>"Line system data requires one color per point",()=>"createLineSystemData requires at least one point",()=>"createLineSystem requires material.useVertexColor to match the line color-buffer layout",()=>"updateLineSystem requires a mesh created by createLineSystem",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem cannot add colors to a mesh created without vertex colors",A=>`createCsgFromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createMeshesFromCsg("${A}") missing material for CSG material slot ${e}.`,()=>"CSG2 is not initialized. Call and await initializeCsg2Async() before using CSG2 operations.",A=>`${A} cannot use a disposed CSG2 solid.`,A=>`createCsg2FromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createCsg2FromMesh("${A}") materialSlot must be an integer from 0 to ${e}.`,()=>"CSG2 operations require solids with the same vertex property layout.",(A,e)=>`createMeshesFromCsg2("${A}") received an unknown Manifold material original ID ${e}.`,A=>`Unable to build CSG2 mesh "${A}". Manifold has 0 vertices for this output.`,(A,e)=>`createMeshesFromCsg2("${A}") missing material for CSG2 material slot ${e}.`,()=>"enableThinInstanceWorldBounds requires mesh.thinInstances",()=>"createHierarchyInstancePool capacity must be a non-negative integer",()=>"createHierarchyInstancePool requires at least one mesh in the source hierarchy",A=>`createHierarchyInstancePool mesh "${A}" already has thin instances`,A=>`createHierarchyInstancePool requires an invertible world matrix for mesh "${A}"`,()=>"addHierarchyInstance exceeded pool capacity",()=>"setHierarchyInstanceCount count must be an integer within pool capacity",A=>`setHierarchyInstanceCount mesh "${A}" is missing thin instance data`,A=>`HierarchyInstancePool mesh "${A}" is missing thin instance data`,A=>`${A} index must reference an active hierarchy instance`,()=>"setMeshDrawRange requires live, owned, unshared, tightly-packed geometry",()=>"setMeshDrawRange requires undeformed uint32 geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires ranges within geometry capacity and WebGPU limits",()=>"setMeshDrawRange index must be relative to the selected vertex window",()=>"mesh geometry update requires valid ranges within the active geometry",()=>"updateMeshGeometryCapacity requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometryCapacity requires coherent triangle-list geometry with uint32 indices",()=>"updateMeshGeometryCapacity requires unchanged optional-attribute layout",A=>`mesh attribute updates require unshared, tightly-packed geometry; update the source StorageBuffer instead: ${A}`,()=>"mesh attribute update requires a valid tightly-packed vertex range",()=>"mesh attribute update requires a valid destination vertex range",()=>"updateMeshGeometry requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometry requires unchanged vertex/index counts; use resizeMeshGeometry for topology changes",()=>"updateMeshGeometry requires unchanged optional-attribute layout; use resizeMeshGeometry for layout changes",()=>"updateMeshGeometryCapacity requires reserveFactor >= 1",A=>`resizeMeshGeometry requires owned, tightly-packed geometry; recreate or update the source StorageBuffer instead: ${A}`,()=>"resizeSharedMeshGeometry requires at least one mesh",()=>"resizeSharedMeshGeometry requires meshes sharing one owned, tightly-packed geometry",()=>"resizeSharedMeshGeometry requires distinct, live meshes sharing one geometry",()=>"createMeshFromStorageBuffer: storage must be created with { vertex: true } so it carries GPUBufferUsage.VERTEX.",A=>`createMeshFromStorageBuffer: arrayStride must be a positive multiple of 4 within maxVertexBufferArrayStride, received ${A}.`,(A,e,t)=>`createMeshFromStorageBuffer: invalid vertex range (${A} vertices at baseVertex ${e}) for a ${t}-byte allocation.`,A=>`createMeshFromStorageBuffer: unsupported attribute offset "${A}".`,A=>`createMeshFromStorageBuffer: offset for "${A}" must be a non-negative integer smaller than arrayStride.`,()=>"createMeshFromStorageBuffer: indices must be a Uint16Array, Uint32Array, or index-capable StorageBuffer.",A=>`createMeshFromStorageBuffer: indexFormat must match the typed-array format "${A}".`,()=>"createMeshFromStorageBuffer: indices must be created with { index: true }.",()=>'createMeshFromStorageBuffer: a shared index allocation requires indexFormat "uint16" or "uint32".',()=>"createMeshFromStorageBuffer: indexCount must be a positive unsigned 32-bit integer.",(A,e)=>`createMeshFromStorageBuffer: indexCount ${A} exceeds the index source capacity of ${e}.`,(A,e,t)=>`createMeshFromStorageBuffer: indices[${A}] (${e}) must be less than vertexCount ${t}.`,()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: only plain meshes without thin instances are supported.",()=>"setMeshIndexedIndirect: mesh must use a ShaderMaterial.",()=>"setMeshIndexedIndirect: mesh must have storage-backed geometry.",()=>"setMeshIndexedIndirect: storage-backed geometry must belong to the same engine and device; recreate its allocations and mesh.",()=>"setMeshIndexedIndirect: geometry changed; recreate or explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: index allocation changed; explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: arguments must be a live StorageBuffer or null.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: arguments must be created with { indirect: true }.",()=>"setMeshIndexedIndirect: byteOffset must be a non-negative safe integer and multiple of 4.",(A,e)=>`setMeshIndexedIndirect: twenty-byte arguments at offset ${A} exceed the buffer's ${e}-byte capacity.`,()=>"setMeshIndexedIndirect: unbinding requires byteOffset zero.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: unbind arguments before replacing ShaderMaterial with another material family.",()=>"setMeshIndexedIndirect: unbind arguments before enabling thin instances.",()=>"getMeshIndexedDrawInfo: mesh has been disposed.",()=>"getMeshIndexedDrawInfo: only plain meshes without thin instances are supported.",()=>"Standard mesh opacity binding requires its mesh and scene.",(A,e)=>`${A}: "${e}" is not a Lite Mesh (for example a MeshLoD instance); per-mesh opacity is not supported on MeshLoD in this release.`,(A,e)=>`setMeshOpacity: mesh "${A}" uses a "${e}" material; mesh opacity supports only "standard" and "pbr" materials.`,A=>`Mesh "${A}" cannot set opacity: it was disposed when it left its last scene. Create a new mesh instead.`,A=>`${A} mesh opacity binding requires binding-owned disposers.`,()=>"Thin-instance LOD partners require an opaque, non-transmissive material",()=>"Thin-instance LOD partner requires the source draw to provide instance colors",()=>"setThinInstanceDrawCount requires a fully synchronized fixed-capacity pool",()=>"enableThinInstanceDynamicDrawCount requires mesh.thinInstances",()=>"enableThinInstanceGpuCulling requires mesh.thinInstances",()=>"setThinInstanceCullBoundsPad requires mesh.thinInstances",()=>"setThinInstanceLodPartner requires thinInstances on both meshes",()=>"setThinInstanceLodPartner requires two distinct meshes",()=>"setThinInstanceLodPartner does not support thin-instance data shared by mesh clones",()=>"setThinInstanceLodPartner fullMesh cannot already be an LOD partner",()=>"setThinInstanceLodPartner lodMesh cannot also own an LOD partner",()=>"setThinInstanceLodPartner lodMesh is already paired with another source mesh",()=>"setThinInstanceLodPartner requires source instance colors when the LOD partner uses instance colors",()=>"Navcat connection requires a positive radius and nonnegative integer area",()=>"Navcat search result is stale or belongs to another manager",()=>"Unsupported Navcat debug primitive",()=>"Navcat generation requires indexed triangles",()=>"Navcat generation has nonfinite positions or invalid indices",()=>"Navcat generation has nonfinite positions or invalid indices",A=>`Invalid Navcat build option: ${A}`,()=>"Invalid Navcat slope or polygon vertex limit",()=>"Navcat geometry needs at least one mesh",()=>"Navcat extraction requires live static CPU triangle-list geometry",()=>"Navcat extraction requires a nonsingular finite affine transform",()=>"Navcat extraction requires a nonsingular finite affine transform",()=>"Navcat geometry contains nonfinite positions",()=>"Navcat geometry has an invalid triangle index",()=>"Navcat cost must be finite and nonnegative",()=>"Navcat location is stale or belongs to another manager",()=>"Navcat location is excluded by the current filter",()=>"Navcat query callbacks cannot run nested queries or mutate navigation",()=>"Navcat manager is disposed",()=>"Navcat mesh was replaced during an asynchronous operation",(A,e)=>`Navcat ${A} must have finite${e} components`,()=>"Navcat flags must be unsigned 16-bit integers",A=>`createNavMesh (tile cache) failed: ${A}`,A=>`createNavMesh (tiled) failed: ${A}`,A=>`createNavMesh failed: ${A}`,A=>`Mesh "${A}" missing CPU geometry for navmesh`,()=>"No navmesh generated. Call createNavMesh first.",()=>"Navmesh not ready. Call createNavMesh first.",()=>"Navmesh has no tile cache. Build with `maxObstacles > 0` to enable obstacles.",()=>"NodeParticle: BasicSpriteUpdateBlock requires SetupSpriteSheetBlock",()=>"NodeParticle: LocalPositionUpdated requires SystemBlock.isLocal",()=>"NodeParticle: LocalPositionUpdated read before local shape position creation",A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} changed value type`,()=>"NodeParticle: emitter provider must return a finite 16-element matrix",()=>"NodeParticle: emitter provider must return a finite 16-element matrix",(A,e)=>`NodeParticle: ParticleTeleportInBlock ${A} does not expose output "${e}"`,(A,e,t)=>`NodeParticle: ${A} ${e} does not expose output "${t}"`,A=>`NodeParticle: graph plumbing cycle ${A}`,(A,e,t)=>`NodeParticle: ${A} ${e} does not support ${t} connections`,A=>`NodeParticle: ParticleTeleportOutBlock ${A} has invalid entryPoint`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} references missing entryPoint ${e}`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} entryPoint ${e} is not ParticleTeleportInBlock`,A=>`NodeParticle: graph plumbing cycle ${A}`,A=>`NodeParticle: ParticleTeleportInBlock ${A} input is not connected`,(A,e)=>`NodeParticle: ${A} ${e} input is not connected`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} Particle scope requires particle-only evaluation`,()=>"NodeParticle: invalid source \u2014 expected a `blocks` array",A=>`NodeParticle: block missing numeric id (name=${A})`,()=>"NodeParticle: graph has no SystemBlock",A=>`NodeParticle: failed to load texture "${A}"`,()=>"NodeParticle: unable to decode texture content",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"createParticleBillboard: the particle system has no texture",A=>`syncParticleSprite2DBridgeWithBlendModes: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridgeWithBlendModes: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridgeWithBlendModes: bridge-owned layers cannot use the Sprite2D Handle API",()=>"createParticleSprite2DBridge: the particle system has no texture",A=>`createParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`createParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridge: the bridge-owned layer cannot use the Sprite2D Handle API",A=>`syncParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"createHeightFieldShape requires either a groundMesh or full explicit heightfield parameters.",()=>"createHeightFieldShape ground mesh has no vertex positions.",A=>`createHeightFieldShape requires a regular (N+1)\xD7(N+1) grid mesh (e.g. from createGroundFromHeightMap); got ${A} vertices, which is not the square of an integer \u2265 2.`,()=>"createHeightFieldShape ground mesh has zero extent in X or Z; cannot build a heightfield.",()=>"Failed to read physics body mass properties.",()=>"Failed to read physics body mass properties.",A=>`Unknown physics rotation axis "${A}".`,()=>"Thin-instance physics requires a nonsingular carrier world transform.",()=>"Thin-instance physics bodies do not support floating-origin worlds.",()=>"Thin-instance physics requires a non-empty matrix buffer before body creation.",()=>"Failed to read physics body mass properties.",()=>"Cannot create physics mesh shape from a singular root transform.",()=>"Cannot create physics mesh shape without vertex positions.",()=>"Cannot create physics mesh shape without triangle indices.",()=>"Physics mesh shapes require a mesh or transform hierarchy.",A=>`Unsupported shape type: ${A}`,()=>"Cannot add physics child shape from a singular parent transform.",()=>"createPhysicsAggregate supports only primitive physics shapes.",(A,e,t)=>`Default GPU picking cannot read "${A}" format "${e}" on mesh "${t}". Use compatible float32 data or exclude this mesh from picking.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`DepthOfFieldPostProcessTask "${A}": sourceTexture must have a format.`,A=>`MeshBlendingPostProcessTask "${A}": sourceTexture must have a color format.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} and outputTexture must not alias.`,A=>`MeshBlendingPostProcessTask "${A}": blended rgba32float output requires the float32-blendable WebGPU feature.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be single-sample.`,(A,e,t)=>`MeshBlendingPostProcessTask "${A}": ${e} has unsupported format "${t}".`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be a built 2D color render target.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must have the same physical dimensions as outputTexture.`,A=>`MeshBlendingPostProcessTask "${A}": camera projection matrix must be invertible.`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": camera.viewport must be fullscreen (x=0, y=0, width=1, height=1).`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": depth source has no depth attachment.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depth source has no depth attachment.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depth source has no depth attachment.`,()=>"setRenderDrawIndirect: buffer must be a live allocation of the same engine created with indirect: true.",(A,e,t)=>`setRenderDrawIndirect: ${A} argument bytes at offset ${e} must fit the ${t}-byte buffer at a multiple of 4.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" and its draw belong to different engines.`,A=>`RenderDrawTask "${A}" has been disposed.`,(A,e)=>`RenderDraw: ${A} must be an unsigned 32-bit integer, received ${e}.`,(A,e)=>`RenderDraw ${A}: ${e} buffer is disposed or belongs to a different engine.`,(A,e,t)=>`RenderDraw ${A}: ${e} buffer was not created with the ${t} usage.`,()=>"RenderDraw: binding set belongs to a different RenderShader.",(A,e,t)=>`RenderDraw "${A}": the shader declares ${e} vertex buffers, received ${t}.`,A=>`RenderDraw: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`RenderDraw: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`RenderDraw: dynamic offset for "${A}" exceeds the bound buffer range.`,()=>"Alpha-to-coverage is not supported for NodeMaterial.",()=>"Uniform copies require 4-byte-aligned sizes and destination offsets.",A=>`createStorageBuffer: byte length must be a non-negative safe integer; received ${A}.`,(A,e)=>`createStorageBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"StorageBuffer belongs to a previous device; recreate GPU-role allocations and rerun their producers after device loss.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer byteOffset must be a non-negative multiple of 4.",()=>"StorageBuffer update data must have a byte length that is a multiple of 4.",A=>`StorageBuffer update exceeds its ${A}-byte capacity.`,()=>"StorageBuffer is not a live registered allocation.",A=>`Mesh "${A}" cannot be added: it was disposed when it left its last scene. Create a new mesh instead.`,A=>`morph _postCompose: expected to rewrite 2 binding declarations, rewrote ${A}`,()=>"getCsmReceiverTexture requires a CSM shadow generator",()=>"Render-task transfers require live tasks in the same scene.",()=>"Deformable shadows require a fully initialized shadow generator",()=>"setShadowGeneratorEnabled requires a configured shadow generator.",A=>`Device-lost Scene recovery does not support shadow generator type "${A}"`,()=>"Device-lost Scene recovery could not find ESM shadow resources",()=>"Device-lost Scene recovery failed to create ESM shadow resources",()=>"AnimationController.tick requires an EngineContext for skeleton or morph animation",()=>"Cannot update disposed skeleton",()=>"Invalid bone matrices",()=>"createBillboardCustomShader: `fragment` must be a non-empty WGSL string.",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"addBillboardSprite: handle id space exhausted.",(A,e)=>`${A}: BillboardSpriteHandle ${e} has been removed.`,()=>"BillboardSpriteSystem: alphaCutoff must be a finite number.",()=>"BillboardSpriteSystem: opacity must be a finite number.",()=>"createAxisLockedBillboardSystem: axis components must be finite numbers.",()=>"createAxisLockedBillboardSystem: axis must be non-zero.",()=>"addBillboardSpriteIndex: props.position is required.",()=>"addBillboardSpriteIndex: props.sizeWorld is required.",(A,e)=>`updateBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setBillboardSpriteFrameIndex: index ${A} out of range [0, ${e})`,(A,e)=>`${A}: extra texture name "${e}" is not a valid WGSL identifier.`,(A,e,t,g)=>`${A}: frame ${e} has non-positive size ${t}x${g}.`,(A,e,t,g)=>`${A}: frame ${e} has negative sub-rect origin (srcX=${t}, srcY=${g}).`,(A,e,t,g)=>`${A}: frame ${e} sub-rect row extent (srcX + width) * 4 = ${t} exceeds srcStrideBytes ${g} (would spill into next row).`,(A,e,t,g)=>`${A}: frame ${e} width ${t} exceeds shelf max width ${g}.`,(A,e,t,g,I,o)=>`${A}: cannot fit frame ${e} (${t}x${g}) \u2014 atlas height capacity ${I} exhausted at y=${o}.`,()=>"createSpriteAtlasFromFrames: at least one frame is required, or pass options.capacityPx to create an empty atlas with reserved capacity for appendSpriteAtlasFrames.",(A,e)=>`createSpriteAtlasFromFrames: atlas dimensions must be >= 1 (got ${A}x${e}).`,(A,e,t,g)=>`createSpriteAtlasFromFrames: capacityPx ${A}x${e} too small for initial content ${t}x${g}.`,()=>"appendSpriteAtlasFrames: atlas was not built by createSpriteAtlasFromFrames (no packer state).",()=>"loadSpriteAtlas: metadataUrl unsupported.",()=>"loadSpriteAtlas: gridSize required.",(A,e)=>`resolveSpriteFrame: index ${A} out of range [0, ${e})`,()=>"addSprite2D: handle id space exhausted.",(A,e)=>`${A}: Sprite2DHandle ${e} has been removed.`,()=>"enableSprite2DInstanceParams: layer requires a customShader.",()=>"enableSprite2DInstanceParams: another instance extension is already installed.",()=>"setSprite2DInstanceParamsIndex: enableSprite2DInstanceParams must be called first.",(A,e)=>`setSprite2DInstanceParamsIndex: index ${A} out of range [0, ${e})`,()=>"setSprite2DInstanceParamsIndex: params must contain exactly four numbers.",()=>"setSprite2DInstanceParamsIndex: params must be finite Float32 values.",()=>'enableSprite2DYSort: only depth: "none" layers are supported.',()=>"enableSprite2DYSort: defaultBias must be finite.",()=>"setSprite2DYSortBias: Y-sort is not enabled for this layer.",(A,e)=>`setSprite2DYSortBias: index ${A} out of range [0, ${e})`,()=>"setSprite2DYSortBias: bias must be finite.",()=>"addSprite2DIndex: positionPx required.",(A,e)=>`updateSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setSprite2DFrameIndex: index ${A} out of range [0, ${e})`,()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"createSprite2DCustomShader: `fragment` must be a non-empty WGSL string.",()=>"Sprite pipeline: depth-enabled pipelines require a depth-stencil format.",()=>"Sprite pipeline: depth-enabled pipelines require a scene bind-group layout.",()=>'Depth-hosted sprites require depth != "none".',()=>"Depth-hosted Sprite2DLayer requires a depth-stencil render target.",()=>'SpriteRenderer requires depth: "none".',()=>"SpriteRenderer has been disposed.",A=>`TextData style palette cannot exceed ${A} entries.`,(A,e)=>`updateTextData ${A}: storage does not contain curveSet "${e}" \u2014 add it via updateGlyphStorage first.`,(A,e,t)=>`${A}: run index ${e} out of range (0..${t}).`,A=>`${A}: GlyphRun reference is not in this TextData.`,()=>"updateTextData addRun: GlyphRun reference is already in this TextData.",()=>"updateTextData removeRun: GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: previous GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: new GlyphRun reference is already in this TextData.",A=>`TextData style palette cannot exceed ${A} entries.`,()=>"Basis: no images in file",()=>"Basis: startTranscoding failed",A=>`Basis: transcoded size is 0 for mip ${A}`,A=>`Basis: transcodeImage failed for mip ${A}`,(A,e)=>`createDynamicTexture: width/height must be >= 1 (got ${A}x${e})`,()=>"createTexture2DFromExternalImage: texture creation did not produce GPU resources",()=>"createHtmlTexture: requires a DOM canvas rendering surface (HTML-in-Canvas is unavailable on OffscreenCanvas).",()=>"createHtmlTexture: the element is already hosted by another canvas; textures can share an element only within one canvas.",()=>"KTX: file too small",()=>"KTX: invalid magic",()=>"KTX: unsupported endianness",()=>"KTX: not a compressed texture (glType != 0)",()=>"KTX: not a compressed texture (glFormat != 0)",A=>`KTX: unknown glInternalFormat 0x${A}`,()=>"KTX: 3D textures not supported",()=>"KTX: texture arrays not supported",()=>"KTX: cubemaps not supported (use loadCubeTexture)",()=>"KTX: key/value data overflows buffer",A=>`KTX: truncated at mip ${A} size field`,A=>`KTX: mip ${A} data overflows buffer`,()=>"KTX: no mip levels found",A=>`KTX fetch failed: ${A}`,A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",A=>`KTX2: decoder produced an empty mip ${A}`,A=>`KTX2: device does not support ${A}`,(A,e,t)=>`KTX2: uncompressed mip ${A} has ${e} bytes, expected ${t}`,A=>`KTX2: unsupported transcoded format 0x${A}`,(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: RGBA decode size does not match image dimensions",A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",(A,e)=>`KTX2: expected ${A} base-level layers but decoded ${e}`,(A,e,t,g)=>`KTX2: base-level layer ${A} is malformed (expected ${e}x${t}, ${g} bytes)`,(A,e)=>`createTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,t,g)=>`createTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t} RGBA, got ${g}`,(A,e)=>`createRenderTexture2D: width/height must be >= 1 (got ${A}x${e})`,(A,e)=>`updateTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,t,g)=>`updateTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t} RGBA, got ${g}`,(A,e,t)=>`createTexture3DFromPixels: width/height/depth must be >= 1 (got ${A}x${e}x${t})`,(A,e,t,g,I)=>`createTexture3DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t}x${g} RGBA, got ${I}`,()=>"withSampledDepthTexture requires a single-sample depth attachment.",()=>"createSurfaceRenderTargetTexture: descriptor.size must be a SurfaceContext or { surface, scale }.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture cannot resize recursively from a resize callback.",()=>"RenderTargetTexture attachment configuration cannot change during resize.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture has been disposed.",()=>"Depth-only render-target textures require withSampledDepthTexture as the third argument.",()=>"createRenderTargetTexture: render target has no color or depth texture (no format / depthStencilFormat?).",()=>"createRenderTargetTexture: descriptor.size must be fixed { width, height } pixels, not a surface-backed size; use createSurfaceRenderTargetTexture for surface-resizing targets.",(A,e,t)=>`createTexture2DArray: width/height/layers must be >= 1 (got ${A}x${e}x${t})`,(A,e)=>`uploadImageToArrayLayer: layer must be an integer in [0, ${A}) (got ${e})`,(A,e)=>`loadImageToArrayLayer: fetch failed for ${A} (${e})`,(A,e)=>`createTexture2DArrayFromUrls: fetch failed for ${A} (${e})`,(A,e,t,g,I)=>`createTexture2DArrayFromUrls: all layers must share one size; layer 0 is ${A}x${e} but layer ${t} is ${g}x${I}`,A=>`Texture array pixel uploads require rgba8unorm or rgba8unorm-srgb, received ${A}.`,(A,e)=>`updateTexture2DArrayFromPixels: mipLevel must be an integer in [0, ${A}) (got ${e})`,(A,e,t,g,I,o)=>`updateTexture2DArrayFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t}x${g} RGBA at mip ${I}, got ${o}`,()=>"KTX2: the decoder does not report layerCount; a decoder with 2D array support is required (see setKtx2DecoderUrl)",(A,e)=>`KTX2: decoder produced ${A} mips, which is not a whole number of ${e}-layer levels`,(A,e,t)=>`KTX2: expected layer ${A} at mip index ${e} but the decoder reported layer ${t}`,(A,e)=>`KTX2: layers of one mip level must share a size (level ${A}, layer ${e})`,(A,e)=>`KTX2: decoder reported invalid dimensions ${A}x${e}`,(A,e)=>`KTX2: decoder produced invalid base mip dimensions ${A}x${e}`,(A,e,t,g,I)=>`KTX2: mip ${A} has size ${e}x${t}, expected ${g}x${I}`,(A,e,t)=>`KTX2: texture dimensions ${A}x${e} exceed maxTextureDimension2D ${t}`,(A,e)=>`KTX2: array has ${A} layers, exceeding maxTextureArrayLayers ${e}`,(A,e,t,g)=>`KTX2: texture ${A}x${e} has ${t} mip levels, exceeding the maximum ${g}`,A=>`KTX2: device does not support ${A}`,(A,e,t,g)=>`KTX2: compressed dimensions ${A}x${e} are not aligned to ${t}x${g} blocks; texture-compression-unaligned is required`,(A,e,t,g)=>`KTX2: compressed mip ${A} layer ${e} has ${t} bytes, expected ${g}`,(A,e,t,g)=>`KTX2: uncompressed mip ${A} layer ${e} has ${t} bytes, expected ${g}`,A=>`KTX2: unsupported transcoded format 0x${A}`,()=>"KTX2: texture-array upload did not produce GPU resources",A=>`KTX2: GPU device was lost or replaced during texture-array upload${A}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2: separate layer ${A} reports layerCount ${e}; expected one 2D layer`,A=>`KTX2: separate layer ${A} has a different transcoded format`,(A,e,t,g,I)=>`KTX2: separate layer ${A} has size ${e}x${t}, expected ${g}x${I}`,(A,e,t)=>`KTX2: separate layer ${A} has ${e} mip levels, expected ${t}`,(A,e,t,g,I,o)=>`KTX2: separate layer ${A} mip ${e} has size ${t}x${g}, expected ${I}x${o}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: at least one separate layer URL is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,(A,e,t,g)=>`updateTextureRegion: ${A} must be an integer in [${e}, ${t}], received ${g}.`,()=>"updateTextureRegion: the texture requires copy-destination usage and sampleCount 1.",A=>`updateTextureRegion: ${A} does not support CPU writes with the default copy aspect.`,(A,e)=>`updateTextureRegion: origin and extent must be multiples of the ${A}x${e} texel block.`,()=>"updateTextureRegion: depth/stencil copies must cover the full physical mip width and height.",(A,e,t,g,I)=>`updateTextureRegion: ${A} source bytes cannot hold ${e}\xD7${t}\xD7${g} texels at ${I} bytes per row.`,()=>"createTextureRenderTarget: the texture was not created with render-attachment usage.",A=>`createTextureRenderTarget: ${A} textures cannot be render targets.`,(A,e)=>`createTextureRenderTarget: layer must be an integer in [0, ${A}), received ${e}.`,(A,e)=>`createTextureRenderTarget: mipLevel must be an integer in [0, ${A}), received ${e}.`,()=>"Texture render target has been disposed.",()=>"CPU-only animation evaluation is unavailable for this animation controller",A=>`VAT prepared payload: ${A} must be a positive integer.`,A=>`VAT prepared payload: ${A} must be a record.`,(A,e)=>`VAT prepared payload: ${A} contains invalid bone index "${e}".`,(A,e)=>`VAT prepared payload: ${A}[${e}] has an invalid length.`,()=>"VAT prepared payload: data length must equal boneCount * frameCount * 16.",()=>"VAT prepared payload: clips must be a record.",A=>`VAT prepared payload: clip "${A}" is invalid.`,A=>`VAT preparation: mesh "${A}" has no skeleton to bake.`,(A,e)=>`VAT preparation: mesh "${A}" has no skeleton binding for clip "${e}".`,A=>`VAT preparation: mesh "${A}" has inconsistent bone counts.`,()=>"setVatInstanceStorage: mesh has no VAT data.",()=>"setVatInstanceStorage requires a live StorageBuffer from the same engine.",()=>"setVatTime: mesh has no VAT data.",()=>"attachVat: mesh has no skeleton (bake first, attach before clearing it).",()=>"controllerModels requires XR input tracking; do not pass input:false to enterXr.",()=>"handTracking requires XR input tracking; do not pass input:false to enterXr.",()=>"pointerSelection requires XR input tracking; do not pass input:false to enterXr.",()=>"WebXR is not available (navigator.xr missing).",()=>"WebGPU XR is not supported by this browser (XRGPUBinding missing).",()=>"teleportation requires XR input tracking; do not pass input:false to enterXr.",()=>"Compute binding declaration was not created by a supported resource helper.",(A,e)=>`ComputeBindingSet: resource "${A}" was not declared by ComputeShader "${e}".`,A=>`ComputeBindingSet: binding "${A}" has no resource.`,A=>`ComputeBindingSet for "${A}" has been disposed.`,A=>`ComputeBindingSet: binding "${A}" received the wrong buffer resource type.`,A=>`ComputeBindingSet: resource for "${A}" has been disposed or lost with its previous device; recreate it.`,A=>`ComputeBindingSet: resource for "${A}" belongs to a different engine.`,A=>`ComputeBindingSet: writable binding "${A}" received a read-only resource.`,(A,e)=>`ComputeBindingSet: offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeBindingSet: dynamic binding "${A}" requires size or a non-zero minBindingSize.`,A=>`ComputeBindingSet: size for "${A}" must be a positive multiple of 4.`,A=>`ComputeBindingSet: binding "${A}" must expose at least 4 bytes.`,(A,e,t)=>`ComputeBindingSet: binding "${A}" provides ${e} bytes but requires at least ${t} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds this device's maximum binding size of ${e} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds its ${e}-byte allocation.`,()=>"ComputeBindingSet contains a disposed or invalid buffer resource.",(A,e,t,g,I)=>`ComputeDispatch: ${A} workgroup dimension must be an integer in [0, ${e}], received ${t}x${g}x${I}.`,()=>"ComputeDispatch: binding set belongs to a different ComputeShader.",A=>`ComputeDispatch: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`ComputeDispatch: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeDispatch: dynamic offset for "${A}" exceeds the bound buffer range.`,A=>`WebGPU adapter does not support required feature "${A}".`,A=>`ComputeDispatch: immediate data must initialize all ${A} bytes before dispatch.`,()=>"createComputeImmediateShader requires WGSL immediate_address_space support.",A=>`createComputeImmediateShader: immediateByteLength must be a positive multiple of 4 no larger than ${A}.`,()=>"setComputeDispatchImmediates requires a shader created with createComputeImmediateShader.",(A,e)=>`setComputeDispatchImmediates requires exactly ${A} bytes, received ${e}.`,()=>"ComputeDispatch: indirect buffer must be created with { indirect: true }.",()=>"ComputeDispatch: indirect byteOffset must be a non-negative multiple of 4.",(A,e)=>`ComputeDispatch: indirect arguments at ${A} exceed the buffer's ${e}-byte capacity.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" already has one-shot scheduling.`,A=>`Compute pipeline override "${A}" must have a non-empty name or decimal @id from 0 to 65535 with a finite value.`,A=>`Compute pipeline variant for "${A}" belongs to a lost or replaced GPU device; recreate it.`,()=>"Compute pipeline variants require explicit binding layouts.",A=>`ComputeBindingSet: sampler resource for "${A}" is invalid or belongs to a different engine.`,(A,e,t)=>`ComputeBindingSet: sampler "${A}" has type ${e}, expected ${t}.`,()=>"ComputeBindingSet contains an invalid sampler resource.",A=>`ComputeShader: ${A} must not be empty.`,(A,e)=>`ComputeShader: ${A} must be a non-negative integer, received ${e}.`,()=>"ComputeShader: computeSource must not be empty.",(A,e)=>`ComputeShader: group ${A} exceeds this device's maxBindGroups (${e}).`,(A,e)=>`ComputeShader: binding ${A} exceeds this device's maxBindingsPerBindGroup (${e}).`,A=>`ComputeShader: binding name "${A}" is declared more than once.`,(A,e)=>`ComputeShader: group ${A} binding ${e} is declared more than once.`,A=>`ComputeShader: minBindingSize for "${A}" must be a non-negative multiple of 4.`,A=>`ComputeShader: automatic layouts do not support dynamic offset binding "${A}".`,(A,e,t)=>`ComputeShader: ${A} ${e} exceed this device's limit of ${t}.`,A=>`ComputeShader "${A}" has been disposed.`,A=>`ComputeShader "${A}" belongs to a lost or replaced GPU device; recreate the compute graph.`,A=>`ComputeShader "${A}" pipeline preparation did not complete on its owning device.`,A=>`computeStorageBufferBinding: access must be "read" or "read-write", received "${A}".`,A=>`ComputeBindingSet: storage texture for "${A}" is invalid or belongs to a different engine.`,(A,e,t)=>`ComputeBindingSet: storage texture "${A}" has format ${e}, expected ${t}.`,(A,e,t)=>`ComputeBindingSet: storage texture "${A}" uses a ${e} view, expected ${t}.`,(A,e)=>`ComputeBindingSet: storage texture "${A}" was not validated for ${e} access.`,()=>"ComputeBindingSet contains an invalid storage texture resource.",A=>`computeStorageTextureBinding: format "${A}" is not supported.`,()=>"Compute storage texture mipmap task requires at least one resource.",()=>"Compute storage texture mipmap task requires same-engine sampled 2D filterable-float resources created with mipMaps: true; rgba8snorm also requires texture-formats-tier1.",A=>`Compute storage texture mipmap task "${A}" contains a disposed resource.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" and its dispatch belong to different engines.`,()=>"submitComputeTasks requires tasks from the same engine.",A=>`ComputeTask "${A}" must be recorded and active before direct submission.`,()=>"submitComputeTasks cannot run while a frame is being recorded.",A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeBindingSet: texture resource for "${A}" is invalid or belongs to a different engine.`,(A,e,t)=>`ComputeBindingSet: texture "${A}" has sample type ${e}, expected ${t}.`,A=>`ComputeBindingSet: texture "${A}" multisampling does not match its declaration.`,(A,e,t)=>`ComputeBindingSet: texture "${A}" uses a ${e} view, expected ${t}.`,()=>"ComputeBindingSet contains an invalid texture resource.",()=>"ComputeBindingSet contains a texture from a different engine.",()=>"computeTextureBinding: multisampled float textures require sampleType unfilterable-float.",()=>"createComputeTextureResource: stencil texture views are not currently supported.",()=>"createComputeTextureResource: only 2D texture views are currently supported.",(A,e)=>`createComputeTextureResource: declared sample type ${A} is incompatible with texture format ${e}.`,A=>`createComputeTextureViewResource: declared multisampled=${A} does not match the texture.`,A=>`createComputeTextureViewResource: multisampled textures require a 2d view, received ${A}.`,()=>"createComputeTextureResource: engine device changed during validation; retry with the recovered texture.",A=>`createComputeTextureResource: texture is incompatible with this engine: ${A}`,()=>"ComputeBindingSet contains an invalid texture resource.",A=>`ComputeTask "${A}" has been disposed.`,()=>"ComputeUniformArena: slotByteLength must be a positive safe integer and a multiple of 4.",()=>"ComputeUniformArena: slotCount must be a positive safe integer.",()=>"ComputeUniformArena: aligned stride and total byte length must be safe integers.",()=>"ComputeUniformArena has been disposed.",A=>`ComputeUniformArena: slot must be an integer in [0, ${A}].`,()=>"ComputeUniformArena: byteOffset must be a non-negative multiple of 4.",()=>"ComputeUniformArena: update data must have a byte length that is a multiple of 4.",A=>`ComputeUniformArena: update exceeds the slot's ${A}-byte capacity.`,A=>`createUniformBuffer: byte length must be a non-negative safe integer, received ${A}.`,(A,e)=>`createUniformBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"UniformBuffer has been disposed.",()=>"UniformBuffer belongs to a different engine.",()=>"UniformBuffer is not a live registered allocation.",()=>"UniformBuffer byteOffset must be a non-negative multiple of 4.",()=>"UniformBuffer update data must have a byte length that is a multiple of 4.",A=>`UniformBuffer update exceeds its ${A}-byte capacity.`,()=>"UniformBuffer is not a live registered allocation.",()=>'createComputeUniformF16Writer requires createEngineWithFeatures(..., { requiredFeatures: ["shader-f16"] }).',A=>`ComputeUniformLayout: unsupported field type "${A}".`,()=>"ComputeUniformLayout requires at least one field.",()=>"ComputeUniformLayout: field name must not be empty.",A=>`ComputeUniformLayout: duplicate field "${A}".`,(A,e)=>`ComputeUniformWriter: layout requires ${A} bytes but arena slots contain ${e} bytes.`,()=>"ComputeUniformWriter: f16 fields require createComputeUniformF16Writer.",()=>"ComputeUniformWriter targets a disposed uniform arena.",A=>`ComputeUniformWriter: field "${A}" was not declared.`,(A,e)=>`${A}: field type ${e} is not supported by this setter.`,(A,e)=>`${A}: field type ${e} does not match this setter.`,()=>"ComputeUniformWriter: f16 writes require createComputeUniformF16Writer.",(A,e,t,g)=>`${A}: field "${e}" expects ${t} values, received ${g}.`,(A,e)=>`setComputeUniform: field "${A}" expects ${e} values, received 1.`,(A,e,t)=>`ComputeStorageTexture: ${A} must be a positive integer no larger than ${e}, received ${t}.`,()=>"ComputeStorageTexture: 1d textures require height=1 and depthOrArrayLayers=1.",()=>"ComputeStorageTexture: mipMaps is not supported for 1d textures.",()=>"ComputeStorageTexture: 2d textures require depthOrArrayLayers=1; use 2d-array for layers.",A=>`ComputeStorageTexture: unsupported access "${A}".`,()=>"ComputeStorageTexture: at least one access mode is required.",()=>"createComputeStorageTexture: engine device changed during validation; recreate the resource on the current device.",A=>`createComputeStorageTexture: unsupported format, dimension, or access combination: ${A}`,()=>"ComputeStorageTexture: format must be a GPU texture format string.",(A,e,t)=>`ComputeStorageTexture: ${A} (${e}) is incompatible with a ${t} sampler.`,A=>`ComputeStorageTexture2D: dimensions must be positive integers no larger than ${A}.`,A=>`ComputeStorageTexture2D: format "${A}" is not supported.`,()=>"ComputeStorageTexture: sampled outputs require validated sample metadata.",()=>"ComputeStorageTexture2D has been disposed.",()=>"ComputeStorageTexture2D is not a live registered allocation.",()=>"ComputeStorageTexture2D cannot be disposed while sampled facades are still owned.",A=>`Invalid ARIA attribute: ${A}`,(A,e)=>`Conflicting accessibility state: ${A} and ${e}.`,()=>"Accessibility tree is disposed.",()=>"Accessibility node does not belong to this tree.",()=>"Accessibility ordering requires a sibling in the same tree.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Scene accessibility is disposed.",()=>"Cannot create accessibility for a disposed scene.",()=>"The scene already has an accessibility projection.",()=>"A DOM canvas with a parent element is required when createSceneHtmlTwin is called without options.parent.",()=>"Geometry velocity requires a live LINEAR_VELOCITY attachment.",()=>"Geometry velocity was already enabled with a different previous-depth contract.",()=>"Geometry previous-depth velocity requires a floating-point RGBA velocity attachment.",()=>"Enable geometry velocity before registering the scene.",()=>"Geometry previous-depth velocity requires a perspective camera.",()=>"Geometry deformation velocity requires a non-instanced live skeleton or morph mesh.",()=>"Invalid geometry velocity bone matrices.",()=>"Invalid geometry velocity morph weights.",()=>"Geometry deformation velocity cannot use disposed pose resources.",()=>"Geometry deformation source changed; rebuild its geometry renderable.",()=>"PBR geometry deformation velocity was not preloaded.",()=>"PBR geometry velocity cannot reproject a singular world transform.",()=>"PBR geometry deformation velocity was not preloaded.",()=>"PBR geometry velocity cannot reproject a singular world transform.",()=>"Dynamic material binding has been retired.",()=>"Dynamic material binding must be updated before drawing and must not be disposed.",()=>"SSAO radius must be positive and finite.",()=>"SSAO intensity must be finite and in [0, 1].",()=>"SSAO normal input must be a single-sample color attachment.",()=>"SSAO currently supports only left-handed builds.",()=>"SSAO requires a single-sample depth attachment; resolve MSAA depth first.",()=>"SSAO normalSpace must be 'view' or 'world'.",()=>"SSAO temporal must be a boolean or reconstruction options.",()=>"SSAO task has been disposed.",()=>"SSAO depth source is not built; record its producer before the AO task.",()=>"SSAO normal/depth attachments must be built with identical dimensions.",()=>"SSAO currently supports perspective cameras with a full-target viewport.",()=>"SSAO camera clip planes must be finite, positive, and ordered.",()=>"SSAO camera FOV must be finite and in (0, pi).",A=>`Unsupported SSAO quality: ${A}`,()=>"SSAO requires positive integer dimensions.",()=>"SSAO dimensions exceed the device's texture limit.",()=>"SSAO GPU owner is disposed or has no bound estimation resources.",()=>"Cannot enable half-resolution rendering on a disposed SSAO task.",()=>"An SSAO working-resolution adapter is already installed.",()=>"Half-pipeline SSAO velocity and source depth must have identical built dimensions.",()=>"SSAO motion pruning requires temporal occlusion-history transport with object velocity.",()=>"Cannot enable motion pruning on a disposed SSAO task.",()=>"SSAO motion pruning requires an object velocity texture in createSsaoTask.",()=>"An SSAO temporal GPU extension is already installed.",()=>"PBR SSAO must use this scene's engine and active camera.",()=>"Cannot enable PBR SSAO on a disposed task or scene.",()=>"A PBR SSAO task cannot be shared between scenes.",()=>"enablePbrSsao accepts only PBR source materials.",()=>"Enable PBR SSAO on new materials before registerScene.",()=>"A different SSAO plugin is already attached to this material.",()=>"PBR SSAO and its consuming pass must use the same camera aspect ratio.",()=>"PBR SSAO sampling state has been disposed.",()=>"SSAO temporal enabled must be a boolean.",()=>"SSAO temporal historySamples must be an integer in [1, 16].",()=>"SSAO temporal resetVersion must be a nonnegative safe integer.",()=>"SSAO temporal resetVersion cannot be incremented further.",()=>"Temporal SSAO currently does not support floating-origin reprojection.",()=>"SSAO temporal velocityHasPreviousDepth must be a boolean.",()=>"Temporal SSAO velocity must be a single-sample signed floating-point RG/RGBA target.",()=>"Temporal SSAO previous-depth velocity requires a floating-point RGBA target.",()=>"Temporal SSAO filter has been disposed.",()=>"Temporal SSAO currently does not support floating-origin reprojection.",()=>"Temporal SSAO velocity and depth must be built with identical dimensions.",()=>"Temporal SSAO requires finite camera matrices.",()=>"Temporal SSAO cannot reproject a singular camera view."];function asA(A,e){const t=lZA[A];return t?t(...e):`Error #${A}`}rA();function uZA(){qPA(asA)}function pZA(A){if(!(A instanceof Error))return String(A);const e=A.lite;if(!Array.isArray(e))return A.message;const t=/^#(\d+)$/.exec(A.message);return t?asA(Number(t[1]),e):A.message}Er();var dZA=(function(A){return A[A.Small=0]="Small",A[A.Medium=1]="Medium",A[A.Large=2]="Large",A[A.ExtraLarge=3]="ExtraLarge",A})({});function fZA(A,e){if(!Number.isInteger(A)||A<0||A>63)throw new RangeError("Mesh-blending group ID must be an integer between 0 and 63.");if(A===0)return 0;if(!Number.isInteger(e)||e<0||e>3)throw new RangeError("Mesh-blending radius class must be an integer between 0 and 3.");return e<<6|A}function q7(A){if(!Number.isInteger(A)||A<0||A>255)throw new RangeError("Mesh-blending tag must be an integer between 0 and 255.");if(A!==0&&(A&63)===0)throw new RangeError("A nonzero mesh-blending tag must contain a group ID between 1 and 63.");return A}function DZA(A){const e=q7(A);return{groupId:e&63,radiusClass:e>>6}}function RU(A,e){let t=A,g=e;const I={};return Object.defineProperties(I,{worldRadius:{enumerable:!0,get:()=>t,set:o=>{if(!Number.isFinite(o)||o<0)throw new RangeError("Mesh-blending world radii must be finite non-negative numbers.");t=o}},minimumProjectedRadius:{enumerable:!0,get:()=>g,set:o=>{if(!Number.isFinite(o)||o<0)throw new RangeError("Mesh-blending minimum projected radii must be finite non-negative numbers.");g=o}}}),I}function EsA(){return Object.freeze([RU(.06,1.5),RU(.1,3),RU(.2,3),RU(.3,5)])}function csA(A){return q7(A.meshBlendingTag??0)}function mU(A,e){if(Array.isArray(e))for(const t of e)A._dependencies.add(t);else A._dependencies.add(e)}var _ZA={r:.2,g:.2,b:.3,a:1};function yZA(A,e){const t={name:A,_parentTask:e,_dependencies:new Set,_renderTarget:null,_renderTargetDepth:null,_renderPassDescriptor:{colorAttachments:[]},_colorAttachment:null,_depthAttachment:null,clearColor:{..._ZA},clear:!0,_executeFunc:null,_beforeExecute:null,_initialize(){const g=t._renderTarget;if(!g)throw new Error(`RenderPass "${t.name}": render target not set`);const I=g._colorView;let o=null;I&&(o={view:I,loadOp:t.clear?"clear":"load",storeOp:"store",clearValue:t.clearColor});const C=t._renderTargetDepth??g,r=C._descriptor.dFormat,n=C._depthView,s=r?r==="depth24plus-stencil8"||r==="depth32float-stencil8"||r==="stencil8":!1;let B=null;n&&(B={view:n,depthClearValue:C._descriptor.depthClearValue??0,depthLoadOp:"clear",depthStoreOp:"store",...s?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}}),t._colorAttachment=o,t._depthAttachment=B,t._renderPassDescriptor={label:t.name,colorAttachments:o?[o]:[],depthStencilAttachment:B??void 0}},_execute(){const g=t._renderTarget;if(!g)return 0;t._beforeExecute?.();const I=t._parentTask.engine,o=t._colorAttachment;o&&(o.clearValue=t.clearColor,o.loadOp=t.clear?"clear":"load",o.view=g._colorView);const C=I._currentEncoder.beginRenderPass(t._renderPassDescriptor);let r=0;return t._executeFunc&&(r=t._executeFunc(C)),C.end(),r},_dispose(){t._renderTarget=null,t._renderTargetDepth=null,t._colorAttachment=null,t._depthAttachment=null,t._renderPassDescriptor={colorAttachments:[]},t._executeFunc=null,t._beforeExecute=null,t._dependencies.clear()}};return e._passes.push(t),t}rA(),yU();function lsA(A){return typeof A=="object"&&A!==null&&"_tasks"in A}function ME(A){if(lsA(A))return A;if("_frameGraph"in A&&lsA(A._frameGraph))return A._frameGraph;m(119)}function hZA(A,e){KnA(ME(A),e)}function wZA(A,e){const t=ME(A),g=t._tasks[0]?.name==="shadow"?1:0;t._tasks.splice(g,0,e)}function SZA(A,e,t){const g=ME(A),I=g._tasks.indexOf(t);I<0?g._tasks.push(e):g._tasks.splice(I,0,e)}function MZA(A,e,t){const g=ME(A),I=g._tasks.indexOf(t);I<0?g._tasks.push(e):g._tasks.splice(I+1,0,e)}function RZA(A,e){const t=ME(A)._tasks;let g=0;for(const o of t)o!==e&&(t[g++]=o);const I=g!==t.length;return t.length=g,I}function mZA(A,e){const t=ME(A)._currentProcessedTask;return t||m(120,e),yZA(e,t)}hI(),yU();function NZA(A,e){const t=A.engine,g=e?.update,I={_kind:"frame-graph-context",name:e?.name??"frame-graph",surface:A,frameGraph:FnA(t),clearColor:e?.clearColor??{r:0,g:0,b:0,a:1},_drawCallsPre:0,_disposed:!1,_update(){I._disposed||g?.(t._currentDelta)},_record(){return I._disposed?0:I.frameGraph.execute()},_resize(){I._disposed||I.frameGraph.build()}};return I}function GZA(A){A._disposed||(A.frameGraph.build(),DQ(A.surface,A))}async function bZA(A){const e=A;e._disposed||(await Promise.all(A.frameGraph._tasks.map(t=>t._preload?.())),!e._disposed&&(A.frameGraph.build(),DQ(A.surface,A)))}function usA(A){AE(A.surface,A)}function FZA(A){const e=A;e._disposed||(usA(A),A.frameGraph.dispose(),e._disposed=!0)}function lI(A){return $H(A.texture,A)}var g1=b((()=>{s3()}));ZA(),cI(),g1(),ki();function psA(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}var kZA="@group(0)@binding(0)var src:texture_depth_2d;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{return textureLoad(src,vec2<i32>(fc.xy),0);}";function KZA(A){return`@group(0)@binding(0)var src:texture_2d<f32>;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{let c=vec2<i32>(fc.xy)*2;let sd=vec2<i32>(textureDimensions(src));let d=sd-vec2<i32>(1,1);let x1=min(c.x+1,d.x);let y1=min(c.y+1,d.y);let a=textureLoad(src,vec2<i32>(c.x,c.y),0).r;let b=textureLoad(src,vec2<i32>(x1,c.y),0).r;let e=textureLoad(src,vec2<i32>(c.x,y1),0).r;let f=textureLoad(src,vec2<i32>(x1,y1),0).r;var r=${A}(${A}(a,b),${A}(e,f));let dd=max(sd/vec2<i32>(2,2),vec2<i32>(1,1));let extraX=(sd.x&1)==1&&i32(fc.x)==dd.x-1;let extraY=(sd.y&1)==1&&i32(fc.y)==dd.y-1;if(extraX){let x2=min(c.x+2,d.x);r=${A}(r,${A}(textureLoad(src,vec2<i32>(x2,c.y),0).r,textureLoad(src,vec2<i32>(x2,y1),0).r));}if(extraY){let y2=min(c.y+2,d.y);r=${A}(r,${A}(textureLoad(src,vec2<i32>(c.x,y2),0).r,textureLoad(src,vec2<i32>(x1,y2),0).r));if(extraX){r=${A}(r,textureLoad(src,vec2<i32>(min(c.x+2,d.x),y2),0).r);}}return r;}`}function vZA(A,e){const t=A._device,g=e.reduce??"max",I=LI(A,{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}),o=t.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d"}}]}),C=t.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,texture:{sampleType:"unfilterable-float",viewDimension:"2d"}}]}),r=(w,S)=>t.createRenderPipeline({layout:t.createPipelineLayout({bindGroupLayouts:[S]}),vertex:{module:t.createShaderModule({code:w}),entryPoint:"vs"},fragment:{module:t.createShaderModule({code:w}),entryPoint:"fs",targets:[{format:"r32float"}]},primitive:{topology:"triangle-list"}}),n=r(kZA,o),s=r(KZA(g),C);let B=Math.max(1,e.width|0),Q=Math.max(1,e.height|0),E=psA(B,Q);function c(){return t.createTexture({label:"depth-pyramid",size:{width:B,height:Q},format:"r32float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING,mipLevelCount:E})}function l(w){const S={texture:w,view:w.createView(),sampler:I,width:B,height:Q,_sampleType:"float"};return Kg(S),S}let u=c(),p=l(u),d,f=[],D=null,_=null;function y(){d=u.createView({baseMipLevel:0,mipLevelCount:1}),f=[];for(let w=1;w<E;w++){const S=u.createView({baseMipLevel:w-1,mipLevelCount:1}),R=u.createView({baseMipLevel:w,mipLevelCount:1});f.push({dst:R,bindGroup:t.createBindGroup({layout:C,entries:[{binding:0,resource:S}]})})}D=null,_=null}return y(),{get texture(){return p},get mipCount(){return E},build(w,S){const R=S??t.createCommandEncoder();(D===null||_!==w)&&(D=t.createBindGroup({layout:o,entries:[{binding:0,resource:w.view}]}),_=w);const M=R.beginRenderPass({label:"depth-pyramid-copy",colorAttachments:[{view:d,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});M.setPipeline(n),M.setBindGroup(0,D),M.draw(3),M.end();for(const N of f){const G=R.beginRenderPass({label:"depth-pyramid-reduce",colorAttachments:[{view:N.dst,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});G.setPipeline(s),G.setBindGroup(0,N.bindGroup),G.draw(3),G.end()}S||t.queue.submit([R.finish()])},resize(w,S){const R=Math.max(1,w|0),M=Math.max(1,S|0);if(R===B&&M===Q)return;B=R,Q=M,E=psA(B,Q);const N=p;u=c(),p=l(u),y(),lI(N)},dispose(){lI(p)}}}function UZA(A,e,t){const{pyramid:g,source:I}=t;return{name:"depth-pyramid",engine:A,scene:e,_passes:[],record(){},execute(){const o=I();return o?(g.build(o,A._currentEncoder),g.mipCount):0},dispose(){g.dispose()}}}function dsA(A,e,t){let g=null;return{name:A.name??"image-processing",engine:e,scene:t,_passes:[],record(){fsA(g),g=LZA(e,A.source)},execute(){if(!g)return 0;const I=t.imageProcessing,o=new CA([I.exposure,I.contrast,I.toneMappingEnabled===!0?1:0,0]);e._device.queue.writeBuffer(g.params,0,o);const C=e._currentEncoder.beginRenderPass({colorAttachments:[{view:e.scRT._colorView,loadOp:"clear",storeOp:"store",clearValue:t.clearColor}]});return C.setPipeline(g.pipeline),C.setBindGroup(0,g.bindGroup),C.draw(3),C.end(),1},dispose(){fsA(g),g=null,this._passes.length=0}}}function LZA(A,e){const t=YZA(e);if(!t)throw new Error("Image processing source has no color texture");const g=A._device,I=(t.sampleCount??1)>1,o=g.createBuffer({size:16,usage:iA.UNIFORM|iA.COPY_DST}),C=g.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:I?"unfilterable-float":"float",multisampled:I}}]}),r="struct P{e:f32,c:f32,t:f32,p:f32}@group(0)@binding(0)var<uniform>p:P;@vertex fn vs(@builtin(vertex_index)i:u32)->@builtin(position)vec4f{var a=array<vec2f,3>(vec2f(-1,-3),vec2f(3,1),vec2f(-1,1));return vec4f(a[i],0,1);}fn ip(r:vec4f)->vec4f{var c=r.rgb*p.e;if(p.t>0.5){c=1.0-exp2(-1.590579*c);}c=clamp(pow(max(c,vec3f(0)),vec3f(1/2.2)),vec3f(0),vec3f(1));let h=c*c*(3.0-2.0*c);if(p.c<1.0){c=mix(vec3f(0.5),c,p.c);}else{c=mix(c,h,p.c-1.0);}return vec4f(max(c,vec3f(0)),r.a);}",n=I?"@group(0)@binding(1)var s:texture_multisampled_2d<f32>;":"@group(0)@binding(1)var s:texture_2d<f32>;",s=I?"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);let px=clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1);let n=textureNumSamples(s);var c=vec4f(0);for(var i=0u;i<n;i++){c+=ip(textureLoad(s,px,i));}return c/f32(n);}":"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);return ip(textureLoad(s,clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1),0));}",B=g.createShaderModule({code:`${r}${n}${s}`});return{pipeline:g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[C]}),vertex:{module:B,entryPoint:"vs"},fragment:{module:B,entryPoint:"fs",targets:[{format:A.format}]},primitive:{topology:"triangle-list"}}),bindGroup:g.createBindGroup({layout:C,entries:[{binding:0,resource:{buffer:o}},{binding:1,resource:t.createView()}]}),params:o}}function YZA(A){const e=typeof A=="function"?A():A;return e?"_colorTexture"in e?e._colorTexture:e.texture:null}function fsA(A){A?.params.destroy()}var DsA=b((()=>{VA(),ZA()}));DsA(),rA(),VA(),ZA(),Fg(),ni(),oo();var xZA=(A,e)=>`struct PostProcessVertexOutput{@builtin(position)position:vec4f,@location(0)uv:vec2f${A}}@vertex fn postProcessVertex(@builtin(vertex_index)vertexIndex:u32)->PostProcessVertexOutput{var positions=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));let p=positions[vertexIndex];var out:PostProcessVertexOutput;out.position=vec4f(p,0,1);out.uv=vec2f(p.x*0.5+0.5,0.5-p.y*0.5);${e}return out;}`,JZA="@group(0)@binding(0)var sourceSampler:sampler;@group(0)@binding(1)var sourceTextureSampler:texture_2d<f32>;fn samplePostProcessSource(uv:vec2f)->vec4f{return textureSample(sourceTextureSampler,sourceSampler,uv);}fn readPostProcessSource(uv:vec2f)->vec4f{let dims=vec2f(textureDimensions(sourceTextureSampler));let p=clamp(floor(uv*dims)+vec2f(0.5),vec2f(0.5),dims-vec2f(0.5));return textureSampleLevel(sourceTextureSampler,sourceSampler,p/dims,0);}",HZA="@fragment fn postProcessFragment(input:PostProcessVertexOutput)->@location(0)vec4f{return applyPostProcess(samplePostProcessSource(input.uv),input.uv);}";function qi(A,e,t){const g=A.sourceTexture,I=A.targetTexture?null:ysA(A.name??"post-process",g),o={view:void 0,loadOp:"clear",storeOp:"store"},C={name:A.name??"post-process",engine:e,scene:t,_passes:[],sourceTexture:g,sourceSamplingMode:A.sourceSamplingMode??"linear",targetTexture:A.targetTexture??null,alphaMode:A.alphaMode??0,viewport:A.viewport??null,clear:A.clear??!0,outputTexture:A.targetTexture??I,_shader:A._shader,_internalTarget:I,_internalTargetKey:I?hsA(g):"",_pipeline:null,_bindGroup:null,_bindGroupLayout:null,_pipelineLayout:null,_shaderModule:null,_shaderModuleCode:"",_uniformBuffer:null,_uniformData:null,_renderPassDescriptor:{label:A.name??"post-process",colorAttachments:[o]},_colorAttachment:o,record(){TZA(C),sI(C.outputTexture,e),_sA(C,e)},execute(){VZA(C._colorAttachment,C.outputTexture,C.clear);const r=e._currentEncoder.beginRenderPass(C._renderPassDescriptor);return jZA(r,C.viewport,C.outputTexture),r.setPipeline(C._pipeline),r.setBindGroup(0,C._bindGroup),r.draw(3),r.end(),1},updateUniforms(){MsA(C,e)},_rebuildGpuState(){_sA(C,e)},dispose(){C._passes.length=0,C._uniformBuffer?.destroy(),C._uniformBuffer=null,C._uniformData=null,C._pipeline=null,C._bindGroup=null,C._bindGroupLayout=null,C._pipelineLayout=null,C._shaderModule=null,C._shaderModuleCode="",Bg(C._internalTarget)}};return C}function _sA(A,e){const t=A.sourceTexture;(!t._colorTexture||!t._colorView)&&m(148,A.name),(t._descriptor.samples??1)!==1&&m(149,A.name);const g=A.outputTexture,I=g._descriptor.format;I||m(150,A.name),A._uniformBuffer??=PZA(A,e),A._uniformData??=OZA(A),MsA(A,e);const o=qZA(A,e);A._pipelineLayout??=e._device.createPipelineLayout({label:`${A.name}-pipeline-layout`,bindGroupLayouts:[o]});const C={_colorFormat:I,_sampleCount:g._descriptor.samples??1};A._pipeline=e._device.createRenderPipeline({label:`${A.name}-${ri(C)}-${A.alphaMode}`,layout:A._pipelineLayout,vertex:{module:SsA(A,e),entryPoint:"postProcessVertex"},fragment:{module:SsA(A,e),entryPoint:"postProcessFragment",targets:[{format:I,blend:WZA(A.alphaMode)}]},primitive:{topology:"triangle-list"},multisample:{count:C._sampleCount}});const r=[{binding:0,resource:A.sourceSamplingMode==="nearest"?s9(e):$o(e)},{binding:1,resource:t._colorSamplingView??t._colorView}],n=A._shader.extraTextures??[];A._uniformBuffer&&r.push({binding:wsA(A),resource:{buffer:A._uniformBuffer}});for(let s=0;s<n.length;s++){const B=n[s];B._colorView||m(151,A.name,s),r.push({binding:2+s,resource:B._colorSamplingView??B._colorView})}A._bindGroup=e._device.createBindGroup({label:`${A.name}-bind-group`,layout:o,entries:r})}function TZA(A){const e=A.targetTexture;if(e){A.outputTexture=e;return}const t=hsA(A.sourceTexture);if(A._internalTarget&&A._internalTargetKey===t){A.outputTexture=A._internalTarget;return}A._internalTarget&&Bg(A._internalTarget),A._internalTarget=ysA(A.name,A.sourceTexture),A._internalTargetKey=t,A.outputTexture=A._internalTarget}function ysA(A,e){const t=e._descriptor;return t.format||m(152,A),yI({lbl:`${A}-output`,format:t.format,samples:1,size:t.size})}function hsA(A){const e=A._descriptor,t=e.size,g="canvas"in t?`surface:${t._uniqueId}`:"surface"in t?`surface:${t.surface._uniqueId}@${t.scale}`:`${t.width}x${t.height}`;return`${e.format??"-"}|${e.samples??1}|${g}`}function qZA(A,e){const t=(A._shader.uniformByteLength??0)>0;if(A._bindGroupLayout)return A._bindGroupLayout;const g=[{binding:0,visibility:DA.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float"}}],I=A._shader.extraTextures??[];for(let o=0;o<I.length;o++)g.push({binding:2+o,visibility:DA.FRAGMENT,texture:{sampleType:"float"}});return t&&g.push({binding:wsA(A),visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}}),A._bindGroupLayout=e._device.createBindGroupLayout({label:`${A.name}-bind-group-layout`,entries:g}),A._bindGroupLayout}function wsA(A){return A._shader.uniformBinding??2+(A._shader.extraTextures?.length??0)}function SsA(A,e){const t=`${xZA(A._shader.vertexOutputWGSL??"",A._shader.vertexMainWGSL??"")} ${JZA} ${A._shader.extraTextureWGSL??""} ${A._shader.uniformWGSL??""} ${A._shader.fragmentWGSL} ${A._shader.fragmentWrapperWGSL??HZA}`;return(!A._shaderModule||A._shaderModuleCode!==t)&&(A._shaderModuleCode=t,A._shaderModule=e._device.createShaderModule({label:A.name,code:t})),A._shaderModule}function PZA(A,e){const t=RsA(A._shader.uniformByteLength??0);return t===0?null:e._device.createBuffer({label:`${A.name}-uniforms`,size:t,usage:iA.UNIFORM|iA.COPY_DST})}function OZA(A){const e=RsA(A._shader.uniformByteLength??0);return e===0?null:new CA(e/4)}function MsA(A,e){(A._shader.uniformByteLength??0)!==0&&(A._uniformData.fill(0),A._shader.writeUniforms?.(A._uniformData),e._device.queue.writeBuffer(A._uniformBuffer,0,A._uniformData))}function VZA(A,e,t){A.view=e._colorView,A.resolveTarget=void 0,A.loadOp=t?"clear":"load"}function jZA(A,e,t){if(!e)return;const g=Math.floor(e.x*t._width),I=Math.floor((1-e.y-e.height)*t._height),o=Math.ceil((e.x+e.width)*t._width)-g,C=Math.ceil((1-e.y)*t._height)-I;A.setViewport(g,I,o,C,0,1),A.setScissorRect(g,I,o,C)}function WZA(A){switch(A){case 1:return{color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};case 2:return{color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};case 7:return{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};default:return}}function RsA(A){return Math.ceil(A/16)*16}function zZA(A,e,t){return qi({...A,_shader:A},e,t)}var D1=128;function ZZA(A,e,t){let g=Math.imul(A^t,73244475)^Math.imul(e+t,295559667);return g=Math.imul(g^g>>>16,73244475),g=Math.imul(g^g>>>16,73244475),((g^g>>>16)>>>0)/4294967296}function msA(A,e,t){const I=new Float32Array(16384),o=new Float32Array(16384),C=new Array(16384);for(let r=0;r<D1;r++)for(let n=0;n<D1;n++){const s=r*D1+n;I[s]=ZZA(n,r,t),C[s]=s}for(let r=0;r<D1;r++){const n=r-1&127,s=r+1&127;for(let B=0;B<D1;B++){const Q=B-1&127,E=B+1&127,c=r*D1+B,l=(I[r*D1+Q]+I[r*D1+E]+I[n*D1+B]+I[s*D1+B]+I[n*D1+Q]+I[n*D1+E]+I[s*D1+Q]+I[s*D1+E])*.125;o[c]=I[c]-l}}C.sort((r,n)=>o[r]-o[n]||r-n);for(let r=0;r<16384;r++)A[C[r]*2+e]=Math.floor(r*256/16384)}function XZA(){const A=new Uint8Array(32768);return msA(A,0,1757159915),msA(A,1,795749149),A}function NsA(A){const e=q3;q3=e?t=>e(t)|A(t):A}function GsA(A){return A._gpu.tangentBuffer?1:0}function NU(A,e=!1){const t=A._gpu;let g=GsA(A);return A.vat?(g|=512,A.vat.joints1Buffer&&(g|=4)):A.skeleton&&(g|=2,A.skeleton.joints1Buffer&&(g|=4)),A.morphTargets&&(g|=8),A.thinInstances&&(g|=16,A.thinInstances.colors&&(g|=32)),t.colorBuffer&&(g|=64),t.uv2Buffer&&(g|=128),A._flatNormal&&(g|=bsA),e&&(g|=256),q3&&(g|=q3(A)),g}var bsA,q3,Pi=b((()=>{it(),bsA=1024,q3=null}));function FsA(A,e){const t=A.excludedMeshes?.has(e),g=A.includedOnlyMeshes;if(g?.size)return g.has(e)&&!t;const I=e.id,o=A.includedOnlyMeshIds;return t?!1:o?.size?!!I&&o.has(I):!I||!A.excludedMeshIds?.has(I)}function Z1(A,e,t){const g=t?new gt(t.buffer,t.byteOffset,t.byteLength/4):null;let I=0,o=-1,C=0;for(const r of e){if(C>=Ht)break;r._writeLightUbo&&(FsA(r,A)&&(o=C,g&&(g[P7+I]=C),I++),C++)}if(g){g[16]=I;for(let r=I;r<Ht;r++)g[P7+r]=0}return I===1?o+1:-I}var P7,RE=b((()=>{VA(),EI(),P7=20}));function GU(A,e,t){return e?((A.endsWith("uint")||A.endsWith("sint"))&&m(138,A),A.endsWith("32float")&&!t.features.has("float32-blendable")&&m(139,A),{format:A,blend:e}):{format:A}}function $ZA(A){NI=A}var Mt,sC,ksA,KQ,NI,on=b((()=>{rA(),Mt=(function(A){return A[A.IRRADIANCE=0]="IRRADIANCE",A[A.WORLD_POSITION=1]="WORLD_POSITION",A[A.LOCAL_POSITION=2]="LOCAL_POSITION",A[A.REFLECTIVITY=3]="REFLECTIVITY",A[A.VIEW_DEPTH=4]="VIEW_DEPTH",A[A.NORMALIZED_VIEW_DEPTH=5]="NORMALIZED_VIEW_DEPTH",A[A.SCREENSPACE_DEPTH=6]="SCREENSPACE_DEPTH",A[A.VIEW_NORMAL=7]="VIEW_NORMAL",A[A.WORLD_NORMAL=8]="WORLD_NORMAL",A[A.ALBEDO=9]="ALBEDO",A[A.LINEAR_VELOCITY=10]="LINEAR_VELOCITY",A[A.MESH_BLEND_TAG=11]="MESH_BLEND_TAG",A})({}),sC={r:0,g:0,b:0,a:0},ksA={r:1,g:1,b:1,a:1},KQ=[{name:"Irradiance",defaultFormat:"rgba16float",clearValue:sC},{name:"WorldPosition",defaultFormat:"rgba16float",clearValue:sC},{name:"LocalPosition",defaultFormat:"rgba16float",clearValue:sC},{name:"Reflectivity",defaultFormat:"rgba8unorm",clearValue:sC},{name:"ViewDepth",defaultFormat:"r32float",clearValue:sC},{name:"NormalizedViewDepth",defaultFormat:"r16float",clearValue:ksA},{name:"ScreenspaceDepth",defaultFormat:"r16float",clearValue:sC},{name:"ViewNormal",defaultFormat:"rgba16float",clearValue:sC},{name:"WorldNormal",defaultFormat:"rgba16float",clearValue:sC},{name:"Albedo",defaultFormat:"rgba8unorm",clearValue:sC},{name:"LinearVelocity",defaultFormat:"rgba16float",clearValue:sC},{name:"MeshBlendTag",defaultFormat:"r8uint",clearValue:sC,_validate:()=>{m(140)}}],NI=null}));function O7(A){const e=[];for(const t of[A.baseColorTexture,A.normalTexture,A.ormTexture,A.occlusionTexture,A.emissiveTexture,A.specGlossTexture])t&&e.push(t);for(const t of Es().values())t.textures?.(A,e);return e}var bU=b((()=>{Eg()})),AXA=H({_computePbrMaterialFeatures:()=>mE});function mE(A){let e=(A.emissiveTexture?2:0)|(A.normalTexture?1:0)|(A.alphaBlend===!0||(A._alphaCutOff??0)<=0&&A.alpha<1?64:0)|(A.specGlossTexture?128:0)|(A.doubleSided?256:0);(A.occlusionStrength??1)>0&&(e|=HT),A.enableSpecularAA&&(e|=O9);let t=0;for(const g of Es().values())if(g.detect){const I=g.detect(A);e|=I.f,t|=I.f2}return A._uv2Mask&&(t|=Z9),A.baseColorFactor&&(t|=X9),{features:e,features2:t}}var P3=b((()=>{Eg()}));function eXA(A){O3=A}function tXA(A){kU=A}function gXA(A){V7=A}function KsA(A){const e=KU;KU=e?(t,g,I)=>{e(t,g,I),A(t,g,I)}:A,NE=t=>t,j7=()=>[]}function vsA(A){vU!==A._device&&(V3.clear(),vU=A._device)}function IXA(){V3.clear(),vU=null}function iXA(A,e,t,g,I,o,C="",r=null){vsA(A);const n=r&&O3?O3(r):null,s=`${e}:${t}:${g}:${I}:${C}${n?n._key:""}`,B=V3.get(s);if(B)return B;const Q=A._device,E=Q.createBindGroupLayout(o._meshBGLDescriptor);let c=null;o._shadowBGLDescriptor&&(c=Q.createBindGroupLayout(o._shadowBGLDescriptor));const l={_features:e,_features2:t,_meshFeatures:g,_meshBGL:E,_shadowBGL:c,_composed:o,_pipelines:new Map};return n&&(l._stencil=n._desc),V3.set(s,l),l}function oXA(A,e,t,g){vsA(A);const I=GQ(),o=e._sampleCount>1&&!!I?.(g),C=`${ri(e)}${o?":a2c":""}`,r=t._pipelines.get(C);if(r)return r;const n=A._device,{_features:s,_features2:B,_composed:Q}=t,E=(B&mQ)!==0,c=!E&&(s&64)!==0,l=(s&256)!==0,u=oi(A),p=t._shadowBGL?[u,t._meshBGL,t._shadowBGL]:[u,t._meshBGL],d=I?t._a2cVertModule??=n.createShaderModule({code:Q._vertexWGSL}):n.createShaderModule({code:Q._vertexWGSL}),f=(B&EE)!==0,D=!e._colorFormat&&!f?null:I?t._a2cFragModule??=n.createShaderModule({code:Q._fragmentWGSL}):n.createShaderModule({code:Q._fragmentWGSL}),_=f?null:{format:e._colorFormat,writeMask:RC.ALL};c&&_&&(_.blend={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}});const y=n.createRenderPipeline({layout:n.createPipelineLayout({bindGroupLayouts:p}),vertex:{module:d,entryPoint:"main",buffers:Q._vertexBufferLayouts},...D?{fragment:{module:D,entryPoint:"main",targets:_?[_]:[]}}:{},...e._depthStencilFormat?{depthStencil:{format:e._depthStencilFormat,depthCompare:e._depthCompare??"greater-equal",depthWriteEnabled:f||E||!c,...O3&&t._stencil&&e._depthStencilFormat.includes("stencil")?t._stencil:{}}}:{},multisample:o?{count:e._sampleCount,alphaToCoverageEnabled:!0}:{count:e._sampleCount},primitive:{cullMode:l?"none":"back",...Q._prim}});return t._pipelines.set(C,y),y}function FU(A,e,t,g,I,o,C,r,n,s,B){const Q=A._device,E=e._features,c=e._features2,l=e._meshFeatures,u=(E&1)!==0&&(l&1)!==0,p=(E&1)!==0&&(l&1)===0,d=u||p,f=(E&2)!==0,D=(E&128)!==0,_=(c&mQ)!==0,y=[];let w=0;const S=K=>{y.push({binding:w++,resource:K.view}),y.push({binding:w++,resource:K.sampler})},R={_engine:A,_features:E,_features2:c,_meshFeatures:l,_material:o,_mesh:r,_env:C??V7?.(o)??null,_refractionTexture:n};KU?.(R,s,B);const M=ArA(),N=t._fragmentKey?t._fragmentKey.split("|").filter(K=>K.length>0):[];y.push({binding:w++,resource:{buffer:g}}),y.push({binding:w++,resource:{buffer:I}});for(const K of M)K.phase==="vertex"&&K.bind&&(w=K.bind(R,y,w));S(o.baseColorTexture??kU?.(A)),d&&S(o.normalTexture),S(o.ormTexture??kU?.(A)),(c&2048)!==0&&(l&128)!==0&&o.occlusionTexture&&o.occlusionTexCoord===1&&S(o.occlusionTexture),f&&S(o.emissiveTexture),D&&S(o.specGlossTexture),_&&y.push({binding:w++,resource:{buffer:o._esmShadowParamsUBO}});const G=[];for(const K of N){const F=M.find(v=>v.id===K||K.startsWith(v.id+"-"));!F||F.phase==="vertex"||!F.bind||G.includes(F)||(G.push(F),w=F.bind(R,y,w))}return Q.createBindGroup({layout:e._meshBGL,entries:y})}var O3,kU,V7,KU,NE,j7,V3,vU,vQ=b((()=>{ZA(),Eg(),Pi(),Fg(),ni(),Ci(),bQ(),it(),O3=null,kU=null,V7=null,KU=null,NE=null,j7=null,V3=new Map,vU=null}));function CXA(A){fs=A}var fs,UsA=b((()=>{fs=null}));function LsA(A,e){return A+e-1&~(e-1)}function rXA(A){const e=YsA[A];if(e)return e;const t=/^array<vec4<u32>,\s*(\d+)>$/.exec(A);if(t)return{align:16,size:Number(t[1])*16};throw new Error(`Unknown UBO field type: ${A}`)}function GE(A){const e=new Map,t=[];let g=0;for(const I of A){const o=rXA(I._type);g=LsA(g,o.align),e.set(I._name,g),t.push(`${I._name}: ${I._type},`),g+=o.size}return{_totalBytes:LsA(g,16),_offsets:e,_structBody:t.join(`
1
+ var NoA=Object.defineProperty,b=(A,e,t)=>()=>{if(t)throw t[0];try{return A&&(e=A(A=0)),e}catch(g){throw t=[g],g}},H=(A,e)=>{let t={};for(var g in A)NoA(t,g,{get:A[g],enumerable:!0});return e||NoA(t,Symbol.toStringTag,{value:"Module"}),t};function LPA(A){const e="ownerDocument"in A?A.ownerDocument:A.document,t=e.defaultView;if(!t)throw new Error("Keyboard input requires a document with a window.");const g=new Set,I={keys:g},o=()=>g.clear(),C=s=>{const B=s.code;B&&g.add(B)},r=s=>{g.delete(s.code)},n=()=>{e.hidden&&o()};return A.addEventListener("keydown",C,!0),A.addEventListener("blur",o,!0),t.addEventListener("keyup",r,!0),t.addEventListener("blur",o),e.addEventListener("visibilitychange",n),I._dispose=()=>{A.removeEventListener("keydown",C,{capture:!0}),A.removeEventListener("blur",o,{capture:!0}),t.removeEventListener("keyup",r,{capture:!0}),t.removeEventListener("blur",o),e.removeEventListener("visibilitychange",n),o()},I}function YPA(A,e){return A.keys.has(e)}function xPA(A){const e=A._dispose;A._dispose=void 0,e?.()}function GoA(A){A.deltaX=A.deltaY=A.wheelX=A.wheelY=A.wheelZ=A.wheelDeltaMode=0}function JPA(A){const e=A.ownerDocument,t=e.defaultView;if(!t)throw new Error("Pointer input requires a document with a window.");const g={x:0,y:0,deltaX:0,deltaY:0,wheelX:0,wheelY:0,wheelZ:0,wheelDeltaMode:0,buttons:0,pointerId:null,pointerType:""};let I=null,o=null,C="",r=0,n=0;const s=()=>{I=o=g.pointerId=null,C=g.pointerType="",g.buttons=0,GoA(g)},B=D=>D.composedPath().includes(A),Q=(D,_)=>{const y=A.getBoundingClientRect();g.x=D.clientX-y.left,g.y=D.clientY-y.top,_&&(e.pointerLockElement===A?(g.deltaX+=D.movementX,g.deltaY+=D.movementY):o===D.pointerId&&C===D.pointerType&&(g.deltaX+=D.clientX-r,g.deltaY+=D.clientY-n)),o=g.pointerId=D.pointerId,C=g.pointerType=D.pointerType,g.buttons=D.buttons,r=D.clientX,n=D.clientY},E=D=>{D.isPrimary&&B(D)&&(I===null||I===D.pointerId)&&(I=D.pointerId,Q(D,!1))},c=D=>{D.isPrimary&&(I===null?B(D)||e.pointerLockElement===A:I===D.pointerId)&&(Q(D,!0),I=D.buttons===0?null:D.pointerId)},l=D=>{I===D.pointerId&&(Q(D,!0),I=null)},u=D=>{I===D.pointerId&&s()},p=D=>{g.wheelDeltaMode!==D.deltaMode&&(g.wheelX=g.wheelY=g.wheelZ=0),g.wheelDeltaMode=D.deltaMode,g.wheelX+=D.deltaX,g.wheelY+=D.deltaY,g.wheelZ+=D.deltaZ},d=()=>{e.hidden&&s()},f=[["pointerdown",E],["pointermove",c],["pointerup",l],["pointercancel",u],["lostpointercapture",u]];for(const[D,_]of f)t.addEventListener(D,_,{capture:!0,passive:!0});return A.addEventListener("wheel",p,{passive:!0,capture:!0}),A.addEventListener("blur",s),t.addEventListener("blur",s),e.addEventListener("visibilitychange",d),e.addEventListener("pointerlockchange",s),g._dispose=()=>{for(const[D,_]of f)t.removeEventListener(D,_,{capture:!0});A.removeEventListener("wheel",p,{capture:!0}),A.removeEventListener("blur",s),t.removeEventListener("blur",s),e.removeEventListener("visibilitychange",d),e.removeEventListener("pointerlockchange",s),s()},g}function HPA(A){const e=A._dispose;A._dispose=void 0,e?.()}function TPA(A=0){if(!Number.isInteger(A)||A<0)throw new RangeError("Gamepad index must be a nonnegative integer.");if(typeof navigator>"u"||typeof navigator.getGamepads!="function")return null;let e;try{e=navigator.getGamepads()}catch{return null}const t=e[A];return t?.connected?{id:t.id,index:t.index,mapping:t.mapping,timestamp:t.timestamp,axes:Array.from(t.axes),buttons:Array.from(t.buttons,({value:g,pressed:I,touched:o})=>({value:g,pressed:I,touched:o}))}:null}function qPA(A){FH=A}function m(A,...e){const t=new Error(FH?.(A,e)??`#${A}`);throw t.lite=e,t}var FH,rA=b((()=>{FH=null})),CA,Zo,gt,Ho,l1,Tv,Te,qv,Cr,To,VA=b((()=>{CA=Float32Array,Zo=Float64Array,gt=Uint32Array,Ho=Int32Array,l1=Uint16Array,Tv=Int16Array,Te=Uint8Array,qv=Int8Array,Cr=Uint8ClampedArray,To=DataView}));function PPA(){return new CA(16)}function bg(){return(boA??PPA)()}function kH(){return bg()}function OPA(A){boA=A}var boA,Ii=b((()=>{VA()})),_A,iA,DA,RC,ZA=b((()=>{_A=globalThis.GPUTextureUsage,iA=globalThis.GPUBufferUsage,DA=globalThis.GPUShaderStage,RC=globalThis.GPUColorWrite}));function FoA(A){const e=A.size;return"canvas"in e?e.canvas:e}function Pv(A){return{_descriptor:A,_resolveSize:FoA,_colorTexture:null,_colorView:null,_depthTexture:null,_depthView:null,_width:0,_height:0}}function yI(A){const e=Pv(A);return"surface"in A.size&&(u1(A),e._resolveSize=u1),e}function sI(A,e){if(A._eager){A._syncEager?.(e);return}Bg(A);const t=A._descriptor,g=(A._resolveSize??FoA)(t);A._width=g.width,A._height=g.height;const I=e._device;t.format&&(A._colorTexture=I.createTexture(KH(t,g,t.format,_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING|_A.COPY_SRC|_A.COPY_DST)),A._colorView=A._colorTexture.createView()),t.dFormat&&(A._depthTexture=I.createTexture(KH(t,g,t.dFormat,_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING)),A._depthView=A._depthTexture.createView())}function KH(A,e,t,g){return{label:A.lbl,size:e,format:t,sampleCount:A.samples,usage:g}}function Bg(A){if(!A||A._eager&&!A._disposeAttachments)return;const e=A._colorTexture,t=A._depthTexture;if(A._colorTexture=A._depthTexture=null,A._colorView=A._depthView=null,A._width=A._height=0,A._disposeAttachments)A._disposeAttachments(e,t);else try{e?.destroy()}finally{A._ownsDepthTexture!==!1&&t?.destroy()}}function u1(A){const e=A.size;if("surface"in e){const t=e.scale;(!Number.isFinite(t)||t<=0)&&m(61,t);const g=e.surface.canvas;return{width:Math.floor(g.width*t)||1,height:Math.floor(g.height*t)||1}}return"canvas"in e?e.canvas:e}var Fg=b((()=>{rA(),ZA()})),vH,UH,LH=b((()=>{vH="1.39.1",UH=`Babylon Lite v${vH}`}));function XF(A){return"clientWidth"in A}function VPA(A){return A.endsWith("-srgb")?A:`${A}-srgb`}function jPA(A,e,t){const g=koA(A,e,t);return A._surfaces.push(g),Vv(g),Ov(g),g}function koA(A,e,t){const g=e.getContext("webgpu");g||m(62),XF(e)&&e.setAttribute("data-engine",UH);const I=t?.format??navigator.gpu.getPreferredCanvasFormat(),o=t?.srgb?VPA(I):I,C=t?.alphaMode??"opaque";g.configure({device:A._device,format:I,alphaMode:C,viewFormats:[o]});const r=t?.msaaSamples===1?1:4,n=Pv({lbl:"swapchain",format:o,samples:1,size:{width:0,height:0}});return n._eager=!0,{engine:A,canvas:e,format:o,msaaSamples:r,scRT:n,maxDevicePixelRatio:t?.maxDevicePixelRatio??1/0,_uniqueId:KoA++,_context:g,_configureFormat:I,_alphaMode:C,_renderingContexts:[]}}function Ov(A){const e=A._context.getCurrentTexture(),t=A.scRT;t._colorTexture=e,t._colorView=e.createView({format:A.format}),t._width=e.width,t._height=e.height}function Vv(A){const e=A.canvas;if(!XF(e))return;const t=A._w??e.clientWidth,g=A._h??e.clientHeight;if(!(t>0&&g>0))return;const I=Math.min(globalThis.devicePixelRatio||1,A.maxDevicePixelRatio);YH(A,t*I|0,g*I|0)}function YH(A,e,t){const g=A.canvas,I=e|0,o=t|0;if(I>0&&o>0&&!(I===g.width&&o===g.height)){g.width=I,g.height=o,A.scRT._width=I,A.scRT._height=o;for(const C of A._renderingContexts)C._resize?.()}}function WPA(A){A===A.engine&&m(63),A._renderingContexts.length=0,A._ro?.disconnect(),A._context.unconfigure();const e=A.engine._surfaces,t=e.indexOf(A);t!==-1&&e.splice(t,1)}var KoA,$a=b((()=>{rA(),Fg(),LH(),KoA=1})),zPA=H({MAT4_STORAGE_F64_BUILD_TAG:()=>xH,allocateF64Mat4:()=>voA});function voA(){return new Zo(16)}var xH,ZPA=b((()=>{VA(),xH="@@MAT4_STORAGE_F64@@",voA[xH]=!0}));function UoA(A){if(!Number.isFinite(A)||A<1)throw new Error(`setMaxLights: expected positive integer, got ${A}`);Ht=A|0}var Ht,EI=b((()=>{Ht=16})),XPA=H({applyLightFoOffset:()=>AOA,getFloatingOriginOffset:()=>LoA,lightFoVersion:()=>$PA,wrapRenderableForFO:()=>eOA});function LoA(A){const e=A.camera;if(!e)return{x:0,y:0,z:0};const t=e.worldMatrix;return{x:t[12],y:t[13],z:t[14]}}function $PA(A){const e=A.camera,t=e?e.worldMatrixVersion:-1,g=YoA??=new WeakMap;let I=g.get(A);return I?(I[0]!==e||I[1]!==t)&&(I[0]=e,I[1]=t,I[2]++):g.set(A,I=[e,t,0]),I[2]}function AOA(A,e){const t=e.camera?.worldMatrix;if(!t)return;const g=t[12],I=t[13],o=t[14];let C=0;for(const r of e.lights){if(C>=Ht)break;if(!r._writeLightUbo)continue;const n=4+C*16,s=A[n+3];if(s!==1&&s!==3){const B=r.worldMatrix;A[n]=B[12]-g,A[n+1]=B[13]-I,A[n+2]=B[14]-o}C++}}function eOA(A,e,t){let g=-1,I;return()=>{const o=e.camera,C=o?o.worldMatrixVersion:-1;(C!==g||o!==I)&&(t(),g=C,I=o),A()}}var YoA,xoA=b((()=>{EI(),YoA=null})),tOA=H({makePackMeshWorld:()=>gOA,packMat4IntoF32WithOffset:()=>JH});function JH(A,e,t,g,I,o,C){const r=e,n=g,s=t;A[s+0]=r[n+0],A[s+1]=r[n+1],A[s+2]=r[n+2],A[s+3]=r[n+3],A[s+4]=r[n+4],A[s+5]=r[n+5],A[s+6]=r[n+6],A[s+7]=r[n+7],A[s+8]=r[n+8],A[s+9]=r[n+9],A[s+10]=r[n+10],A[s+11]=r[n+11],A[s+12]=r[n+12]-I,A[s+13]=r[n+13]-o,A[s+14]=r[n+14]-C,A[s+15]=r[n+15]}function gOA(A){return(e,t,g,I)=>{const o=A.camera;if(!o){JH(e,t,g,I,0,0,0);return}const C=o.worldMatrix;JH(e,t,g,I,C[12],C[13],C[14])}}var IOA=b((()=>{})),iOA=H({createGpuFrameTimer:()=>oOA,destroyGpuFrameTimer:()=>sOA,gpuFrameTimerBegin:()=>COA,gpuFrameTimerEnd:()=>rOA,gpuFrameTimerResolve:()=>nOA,gpuTimingSupportedFor:()=>JoA});function JoA(A){return A.features.has("timestamp-query")}function oOA(A){return JoA(A)?{device:A,markerPipeline:A.createComputePipeline({layout:"auto",compute:{module:A.createShaderModule({code:"@compute @workgroup_size(1) fn main() {}"}),entryPoint:"main"}}),querySet:A.createQuerySet({type:"timestamp",count:2}),resolveBuf:A.createBuffer({size:16,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),pool:[],lastMs:0,inFlight:0}:null}function COA(A,e){const t=e.beginComputePass({timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:0}});t.setPipeline(A.markerPipeline),t.dispatchWorkgroups(1),t.end()}function rOA(A,e){const t=e.beginComputePass({timestampWrites:{querySet:A.querySet,endOfPassWriteIndex:1}});t.setPipeline(A.markerPipeline),t.dispatchWorkgroups(1),t.end()}function nOA(A){if(A.inFlight>3)return;const e=A.device,t=A.pool.pop()??e.createBuffer({size:16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),g=e.createCommandEncoder();g.resolveQuerySet(A.querySet,0,2,A.resolveBuf,0),g.copyBufferToBuffer(A.resolveBuf,0,t,0,16),e.queue.submit([g.finish()]),A.inFlight++,t.mapAsync(GPUMapMode.READ).then(()=>{const I=new BigInt64Array(t.getMappedRange()),o=Number(I[1]-I[0])/1e6;o>=0&&o<5e3&&(A.lastMs=A.lastMs>0?A.lastMs*.8+o*.2:o),t.unmap(),A.pool.push(t),A.inFlight--},()=>{A.inFlight--})}function sOA(A){A.querySet.destroy(),A.resolveBuf.destroy();for(const e of A.pool)e.destroy();A.pool.length=0}var BOA=b((()=>{}));function q1(){_Q=_Q+1|0}function QOA(A){return A._renderingContexts}function aOA(A){if(!A||typeof A._kind!="string")throw new TypeError("Invalid RenderingContext: missing internal kind discriminator");return A._kind}function $F(A,e){return A._renderingContexts.indexOf(e)!==-1}function DQ(A,e){return A._renderingContexts.indexOf(e)!==-1?!1:(A._renderingContexts.push(e),!0)}function AE(A,e){const t=A._renderingContexts,g=t.indexOf(e);return g===-1?!1:(t.splice(g,1),!0)}function EOA(A){const e=mC?.deviceFeatures;mC=A,mC.deviceFeatures=e}function HoA(){return mC?mC():{}}function ToA(A){return VoA.filter(e=>A.features.has(e))}function cOA(A){const e=mC??(()=>({}));e.deviceFeatures=A,mC=e}async function qoA(A,e){const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance",...mC?mC():{}});t||m(50);const g=mC?.deviceFeatures?.(t,e)??ToA(t),I=await t.requestDevice({requiredFeatures:g,requiredLimits:e?.requiredLimits});console.log(`${UH} - WebGPU engine`);const o=!!e?.useHighPrecisionMatrix,C=!!e?.useFloatingOrigin;if(C&&!o&&m(51),o){const{allocateF64Mat4:c}=await Promise.resolve().then(()=>(ZPA(),zPA));OPA(c)}let r,n,s,B;if(C){const[{wrapRenderableForFO:c,lightFoVersion:l,applyLightFoOffset:u},{makePackMeshWorld:p}]=await Promise.all([Promise.resolve().then(()=>(xoA(),XPA)),Promise.resolve().then(()=>(IOA(),tOA))]);r=c,n=p,s=l,B=u}const Q={_device:I},E=[Q];return Object.assign(Q,{engine:Q,surfaces:E,_surfaces:E,_device:I,_options:e,drawCallCount:0,gpuFrameTimeMs:0,useHighPrecisionMatrix:o,useFloatingOrigin:C,_animFrameId:0,_renderFn:null,_currentEncoder:void 0,_currentDelta:0,_cbs:[],_wrapRenderableForFO:r,_makePackMeshWorld:n,_lightFoVersion:s,_applyLightFoOffset:B},koA(Q,A,e)),Vv(Q),Ov(Q),Q}function HH(A){for(const e of A.surfaces)Vv(e)}function lOA(A,e,t){YH(A,e,t)}function jv(A){const e=A.canvas;return{width:e.width,height:e.height}}function A3(A){return new Promise(e=>{let t=!0,g=0;A._renderFn=I=>{const o=t?0:g>0?I-g:16.667;g=I,HH(A),PoA(A,o),t&&(t=!1,e()),A._renderFn&&(A._animFrameId=requestAnimationFrame(A._renderFn))},A._animFrameId=requestAnimationFrame(A._renderFn)})}function uOA(A){return A._device.queue.onSubmittedWorkDone()}function Wv(A){A._animFrameId&&cancelAnimationFrame(A._animFrameId),A._animFrameId=0,A._renderFn=null,A._flushGpuRetirements?.(A)}function pOA(A,e,t=A.surfaces){if(t!==A.surfaces)for(let g=t.length;g--;)t[g].engine!==A&&m(52);PoA(A,e,t)}function PoA(A,e,t=A._surfaces){let g=0;for(let C=t.length;C--;)g+=t[C]._renderingContexts.length;if(!g)return A.drawCallCount=0,A._flushGpuRetirements?.(A);const I=A._device.createCommandEncoder({label:"frame"});A._currentEncoder=I,A._currentDelta=e;let o=!1;try{A._gpuTimerBegin?.(I),g=0;for(let r=0;r<t.length;r++){const n=t[r];n._capturePreFrame?.(n),Ov(n);const s=n._renderingContexts;for(let B=0;B<s.length;B++){const Q=s[B];Q._update(),g+=Q._drawCallsPre+Q._record()}}const C=A._currentEncoder;for(let r=0;r<t.length;r++){const n=t[r];n._captureService?.(n,C)}A._gpuTimerEnd?.(C),A._cbs[0]=C.finish(),A._device.queue.submit(A._cbs),o=!0,A._flushGpuRetirements?.(A),A.drawCallCount=g,A._gpuTimerResolve?.()}finally{A._currentEncoder=void 0,A._finishOptionalFrame?.(o)}}function OoA(A){return A._device.features.has("timestamp-query")}function dOA(A,e){if(!e){A._gpuTimerWanted=!1,A.gpuFrameTimeMs=0,A._gpuTimerBegin=void 0,A._gpuTimerEnd=void 0,A._gpuTimerResolve=A._gpuTaskTimerResolve;return}OoA(A)&&(A._gpuTimerWanted=!0,Promise.resolve().then(()=>(BOA(),iOA)).then(({createGpuFrameTimer:t,gpuFrameTimerBegin:g,gpuFrameTimerEnd:I,gpuFrameTimerResolve:o})=>{A._gpuTimer===void 0&&(A._gpuTimer=t(A._device));const C=A._gpuTimer;C&&A._gpuTimerWanted&&(A._gpuTimerBegin=r=>g(C,r),A._gpuTimerEnd=r=>I(C,r),A._gpuTimerResolve=()=>{o(C),A.gpuFrameTimeMs=C.lastMs,A._gpuTaskTimerResolve?.()})}))}var _Q,mC,VoA,hI=b((()=>{rA(),Ii(),$a(),LH(),_Q=0,mC=null,VoA=["float32-filterable","texture-compression-astc","texture-compression-bc","texture-compression-etc2","texture-compression-unaligned","timestamp-query","primitive-index"]}));hI();function TH(A,e,t){if(!Number.isInteger(t))throw new RangeError("Rendering context index must be an integer.");const g=A._renderingContexts,I=g.indexOf(e);return I===-1?!1:(g.splice(I,1),g.splice(Math.max(0,Math.min(t,g.length)),0,e),!0)}rA();var joA=!1;function fOA(){joA||(joA=!0,cOA((A,e)=>{const t=ToA(A);for(const g of e?.requiredFeatures??[])A.features.has(g)||m(1012,g),t.includes(g)||t.push(g);return t}))}function DOA(A,e){return fOA(),qoA(A,e)}function WoA(A){const e=A._gpuEvents,t=A._device;e._device!==t&&(e._device?.removeEventListener("uncapturederror",e._onError),e._device=t,t.addEventListener("uncapturederror",e._onError),t.lost.then(g=>{if(e._device===t)for(const I of e._lost)I(g)}))}function zoA(A){let e=A._gpuEvents;if(!e){const t=new Set;e=A._gpuEvents={_errors:t,_lost:new Set,_device:null,_onError:g=>{const I=g.error;for(const o of t)o(I)}},A._attachGpuEvents=WoA}return WoA(A),e}function _OA(A,e){const t=zoA(A);return t._errors.add(e),()=>{t._errors.delete(e)}}function yOA(A,e){const t=zoA(A);return t._lost.add(e),()=>{t._lost.delete(e)}}function ZoA(A){return A._device.limits}function hOA(A,e){return A._device.features.has(e)}function zv(A){oC(A.splice(0))}function oC(A){for(const e of A)try{e()}catch(t){console.error("GPU resource retirement failed.",t)}}function ag(A,e){A._flushGpuRetirements??=Zv,(A._retirements??=[]).push(e)}function XoA(A,e){if(!e.length)return;const t=e.slice();ag(A,()=>oC(t))}function Zv(A){const e=A._retirements;if(!e)return;A._retirements=null;const t=A._retiring??=new Set;t.add(e),queueMicrotask(()=>{A._device.queue.onSubmittedWorkDone().then(()=>{t.delete(e),zv(e)}).catch(()=>{})})}async function wOA(A){await Promise.resolve();do{Zv(A);const e=A._retiring,t=e?[...e]:[];await A._device.queue.onSubmittedWorkDone();for(const g of t)e.delete(g),zv(g)}while(A._retirements?.length||A._retiring?.size)}function $oA(A){const e=A._retirements,t=A._retiring;A._retirements=null,A._retiring=null,e&&zv(e),t?.forEach(zv)}var kg=b((()=>{}));hI(),kg();function SOA(A){$oA(A),Wv(A);const e=A._surfaces;for(const t of e)t._renderingContexts.length=0,t._ro?.disconnect(),t._context.unconfigure();e.length=0;try{A._disposeManagedResources?.(),A._disposeStorageBuffers?.()}finally{A._device.destroy()}}function MOA(A){const e={useHighPrecisionMatrix:!1,useFloatingOrigin:!1,drawCallCount:0,gpuFrameTimeMs:0,_animFrameId:0,_renderFn:null,_currentDelta:0,_cbs:[],_renderingContexts:[]};e.engine=e;const t=[e];return e.surfaces=t,e._surfaces=t,e}function A1A(A,e,t){A._currentDelta=t,e._update()}function ROA(A,e,t,g=1e3/60){for(let I=0;I<t;I++)A1A(A,e,g)}function Xv(A,e){e.hooks.size===0&&(A._gpuTaskTimerResolve===e.dispatch&&(A._gpuTaskTimerResolve=void 0),A._gpuTimerResolve===e.dispatch&&(A._gpuTimerResolve=void 0),$v?.get(A)===e&&$v.delete(A))}function e3(A,e,t,g){const I=e==="frame"?A._currentEncoder:null;e==="frame"&&!I&&m(53);const o=$v??=new WeakMap;let C=o.get(A);if(!C){const n=new Set,s=(Q=A._currentEncoder,E=!0)=>{if(!(!Q||C.lastDispatchedEncoder===Q)){if(!E){for(const c of n)c.encoder===Q&&(n.delete(c),c.cancel?.());Xv(A,C);return}C.lastDispatchedEncoder=Q;for(const c of n){if(c.encoder&&c.encoder!==Q){n.delete(c),c.cancel?.();continue}c.encoder&&n.delete(c),c.run(Q)}Xv(A,C)}};C={hooks:n,dispatch:s,lastDispatchedEncoder:null},o.set(A,C);const B=A._gpuTaskTimerResolve;A._gpuTaskTimerResolve=s,(!A._gpuTimerResolve||A._gpuTimerResolve===B)&&(A._gpuTimerResolve=s)}const r={run:t,cancel:g,encoder:I};return C.hooks.add(r),I&&queueMicrotask(()=>{C.hooks.has(r)&&A._currentEncoder!==I&&(C.hooks.delete(r),g?.(),Xv(A,C))}),()=>{C.hooks.delete(r)&&Xv(A,C)}}var $v,A9=b((()=>{rA(),$v=null})),mOA=H({createGpuTaskTimer:()=>NOA,installGpuTaskTimer:()=>GOA});function NOA(A){return A.features.has("timestamp-query")?{device:A,querySet:A.createQuerySet({type:"timestamp",count:128}),resolveBuffer:A.createBuffer({size:1024,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),readbackPool:[],pendingReadbacks:new Set,records:[],wrappedGraphs:[],patchedContextLists:[],patchedSurfaceLists:[],taskCapacity:o1A,currentEncoder:null,patchedEncoderMethods:null,activeTaskTiming:null,nextQueryIndex:0,nextTaskIndex:0,frameIndex:0,lastPublishedFrameIndex:0,droppedTaskCount:0,inFlight:0,skipFrame:!1,disposed:!1}:null}function GOA(A,e,t){bOA(A,e._surfaces);for(const o of e.surfaces)e1A(A,o);const I=e3(e,"persistent",o=>{A.currentEncoder===o&&xOA(A,t)});return()=>{kOA(A,I),TOA(A)}}function bOA(A,e){for(const g of A.patchedSurfaceLists)if(g.list===e)return;const t=e.push;e.push=(...g)=>{const I=t.apply(e,g);for(const o of g)e1A(A,o);return I},A.patchedSurfaceLists.push({list:e,push:t})}function e1A(A,e){const t=e._renderingContexts;FOA(A,t);for(const g of t){const I=g1A(g);I&&t1A(A,I)}}function FOA(A,e){for(const g of A.patchedContextLists)if(g.list===e)return;const t=e.push;e.push=(...g)=>{const I=t.apply(e,g);for(const o of g){const C=g1A(o);C&&t1A(A,C)}return I},A.patchedContextLists.push({list:e,push:t})}function t1A(A,e){for(const I of A.wrappedGraphs)if(I.graph===e)return;const t=e.execute,g=()=>vOA(A,e);e.execute=g,A.wrappedGraphs.push({graph:e,execute:t})}function kOA(A,e){for(const t of A.patchedSurfaceLists)t.list.push=t.push;A.patchedSurfaceLists.length=0;for(const t of A.patchedContextLists)t.list.push=t.push;A.patchedContextLists.length=0;for(const t of A.wrappedGraphs)t.graph.execute=t.execute;A.wrappedGraphs.length=0,qH(A),e()}function g1A(A){const e=A,t=e._frameGraph??e.frameGraph;return KOA(t)?t:null}function KOA(A){return typeof A=="object"&&A!==null&&"_tasks"in A&&"execute"in A}function vOA(A,e){let t=0;for(const g of e._tasks)g.executionEnabled!==!1&&(t+=UOA(A,g));return t}function UOA(A,e){const t=e.engine._currentEncoder;A.currentEncoder!==t&&LOA(A,t);const g=A.nextTaskIndex++;if(A.skipFrame)return I1A(e);const I={beginQueryIndex:-1,endQueryIndex:-1,passCount:0,conflicted:!1,dropped:!1};A.activeTaskTiming=I;try{const o=I1A(e);return I.passCount>0&&!I.conflicted&&!I.dropped&&A.records.push({index:g,name:e.name,beginQueryIndex:I.beginQueryIndex,endQueryIndex:I.endQueryIndex}),o}finally{A.activeTaskTiming=null}}function I1A(A){if(A.execute)return A.execute();let e=0;for(const t of A._passes)e+=t._execute();return e}function LOA(A,e){qH(A),A.currentEncoder=e,A.patchedEncoderMethods=YOA(A,e),A.records.length=0,A.nextQueryIndex=0,A.nextTaskIndex=0,A.droppedTaskCount=0,A.skipFrame=A.inFlight>VH}function YOA(A,e){const t=e.beginRenderPass.bind(e),g=e.beginComputePass.bind(e),I=Object.getOwnPropertyDescriptor(e,"beginRenderPass"),o=Object.getOwnPropertyDescriptor(e,"beginComputePass");return Reflect.set(e,"beginRenderPass",C=>t(i1A(A,C)),e)||m(54),Reflect.set(e,"beginComputePass",C=>g(i1A(A,C)),e)||(PH(e,"beginRenderPass",I),m(55)),{encoder:e,beginRenderPass:I,beginComputePass:o}}function i1A(A,e){const t=A.activeTaskTiming;if(!t||t.conflicted||t.dropped)return e;if(e?.timestampWrites!==void 0)return t.conflicted=!0,e;const g=A.taskCapacity*2;if(t.passCount===0)return A.nextQueryIndex+2>g?(t.dropped=!0,A.droppedTaskCount++,e):(t.beginQueryIndex=A.nextQueryIndex++,t.endQueryIndex=A.nextQueryIndex++,t.passCount++,{...e,timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:t.beginQueryIndex,endOfPassWriteIndex:t.endQueryIndex}});if(A.nextQueryIndex>=g)return t.dropped=!0,A.droppedTaskCount++,e;t.endQueryIndex=A.nextQueryIndex++,t.passCount++;const I={querySet:A.querySet,endOfPassWriteIndex:t.endQueryIndex};return{...e,timestampWrites:I}}function qH(A){const e=A.patchedEncoderMethods;e&&(PH(e.encoder,"beginRenderPass",e.beginRenderPass),PH(e.encoder,"beginComputePass",e.beginComputePass)),A.currentEncoder=null,A.patchedEncoderMethods=null,A.activeTaskTiming=null}function PH(A,e,t){t?Object.defineProperty(A,e,t):Reflect.deleteProperty(A,e)}function xOA(A,e){if(A.disposed)return;A.frameIndex++;const t=A.records.slice(),g=t.length,I=A.nextQueryIndex,o=A.droppedTaskCount;if(A.records.length=0,A.nextQueryIndex=0,A.droppedTaskCount=0,qH(A),A.skipFrame||A.inFlight>VH)return;if(g===0){o>0&&OH(A,e,nr("available",!0,!0,A.frameIndex,[],o,0));return}const C=I*8,r=A.readbackPool.pop()??JOA(A),n=A.device.createCommandEncoder({label:"gpu-task-timing-resolve"});n.resolveQuerySet(A.querySet,0,I,A.resolveBuffer,0),n.copyBufferToBuffer(A.resolveBuffer,0,r,0,C),A.device.queue.submit([n.finish()]),A.inFlight++,A.pendingReadbacks.add(r),HOA(A,{buffer:r,byteLength:C,frameIndex:A.frameIndex,records:t,droppedTaskCount:o,publish:e})}function JOA(A){return A.device.createBuffer({size:A.taskCapacity*16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}async function HOA(A,e){const t=e.buffer;try{if(await Promise.resolve(),await t.mapAsync(GPUMapMode.READ,0,e.byteLength),A.disposed)return;const g=new BigUint64Array(t.getMappedRange(0,e.byteLength)),I=[];let o=null,C=null;for(const n of e.records){const s=g[n.beginQueryIndex],B=g[n.endQueryIndex];B>=s&&(I.push({index:n.index,name:n.name,durationMs:Number(B-s)/1e6}),o=o===null||s<o?s:o,C=C===null||B>C?B:C)}const r=o===null||C===null?0:Number(C-o)/1e6;t.unmap(),A.pendingReadbacks.delete(t),A.readbackPool.push(t),A.inFlight--,OH(A,e.publish,nr("available",!0,!0,e.frameIndex,I,e.droppedTaskCount,r))}catch(g){if(A.disposed)return;A.pendingReadbacks.delete(t),A.inFlight--,t.destroy(),OH(A,e.publish,nr("error",!0,!0,e.frameIndex,[],e.droppedTaskCount,0,qOA(g)))}}function OH(A,e,t){t.frameIndex>A.lastPublishedFrameIndex&&(A.lastPublishedFrameIndex=t.frameIndex,e(t))}function TOA(A){if(!A.disposed){A.disposed=!0,A.querySet.destroy(),A.resolveBuffer.destroy();for(const e of A.readbackPool)e.destroy();for(const e of A.pendingReadbacks)e.destroy();A.readbackPool.length=0,A.pendingReadbacks.clear(),A.inFlight=0}}function qOA(A){return A instanceof Error?A.message:String(A)}var o1A,VH,POA=b((()=>{rA(),A9(),s1A(),o1A=64,VH=3}));function $g(A,e,t,g,I,o){const C=t[g],r=t[g+1],n=t[g+2],s=t[g+3],B=t[g+4],Q=t[g+5],E=t[g+6],c=t[g+7],l=t[g+8],u=t[g+9],p=t[g+10],d=t[g+11],f=t[g+12],D=t[g+13],_=t[g+14],y=t[g+15];let w=I[o],S=I[o+1],R=I[o+2],M=I[o+3];A[e]=C*w+B*S+l*R+f*M,A[e+1]=r*w+Q*S+u*R+D*M,A[e+2]=n*w+E*S+p*R+_*M,A[e+3]=s*w+c*S+d*R+y*M,w=I[o+4],S=I[o+5],R=I[o+6],M=I[o+7],A[e+4]=C*w+B*S+l*R+f*M,A[e+5]=r*w+Q*S+u*R+D*M,A[e+6]=n*w+E*S+p*R+_*M,A[e+7]=s*w+c*S+d*R+y*M,w=I[o+8],S=I[o+9],R=I[o+10],M=I[o+11],A[e+8]=C*w+B*S+l*R+f*M,A[e+9]=r*w+Q*S+u*R+D*M,A[e+10]=n*w+E*S+p*R+_*M,A[e+11]=s*w+c*S+d*R+y*M,w=I[o+12],S=I[o+13],R=I[o+14],M=I[o+15],A[e+12]=C*w+B*S+l*R+f*M,A[e+13]=r*w+Q*S+u*R+D*M,A[e+14]=n*w+E*S+p*R+_*M,A[e+15]=s*w+c*S+d*R+y*M}var go=b((()=>{}));function C1A(A,e,t,g,I){const o=1/Math.tan(e*.5),C=I-g;A[0]=o/t,A[5]=o,A[10]=-g/C,A[11]=1,A[14]=I*g/C}var r1A=b((()=>{})),it=b((()=>{}));function Io(A){const e=A.worldMatrixVersion;if(A._viewVer===e)return A._viewCache;const t=A._viewCache,g=A.worldMatrix,I=A._useFloatingOrigin,o=I?0:g[12],C=I?0:g[13],r=I?0:g[14];return t[0]=g[0],t[1]=g[4],t[2]=g[8],t[3]=0,t[4]=g[1],t[5]=g[5],t[6]=g[9],t[7]=0,t[8]=g[2],t[9]=g[6],t[10]=g[10],t[11]=0,t[12]=-(g[0]*o+g[1]*C+g[2]*r),t[13]=-(g[4]*o+g[5]*C+g[6]*r),t[14]=-(g[8]*o+g[9]*C+g[10]*r),t[15]=1,A._viewVer=e,t}function OOA(A){e9=A}function p1(A){return(A._projFov!==A.fov||A._projNear!==A.nearPlane||A._projFar!==A.farPlane)&&(A._projFov=A.fov,A._projNear=A.nearPlane,A._projFar=A.farPlane,A._projRev=(A._projRev??0)+1),A.worldMatrixVersion+(A._projRev??0)}function Xo(A,e){const t=p1(A);if(A._projVer===t&&A._projAspect===e)return A._projCache;const g=A._projCache;return e9!==null&&A.ortho?e9(A,e,g):C1A(g,A.fov,e,A.nearPlane,A.farPlane),A._projVer=t,A._projAspect=e,g}function io(A,e){const t=p1(A);if(A._vpVer===t&&A._vpAspect===e)return A._vpCache;const g=A._vpCache;return $g(g,0,Xo(A,e),0,Io(A),0),A._vpVer=t,A._vpAspect=e,g}function rr(A){const e=A.worldMatrix;return{x:e[12],y:e[13],z:e[14]}}function ii(A,e,t){const g=A?.viewport;return e/t*(g?g.width/g.height:1)}function n1A(A,e,t,g){const I=e?.viewport;if(!I)return;const o=Math.floor(I.x*t),C=Math.floor((1-I.y-I.height)*g),r=Math.ceil((I.x+I.width)*t)-o,n=Math.ceil((1-I.y)*g)-C;A.setViewport(o,C,r,n,0,1),A.setScissorRect(o,C,r,n)}var e9,Mg=b((()=>{go(),r1A(),it(),e9=null})),VOA=H({_measureRenderTaskOverdrawCost:()=>jOA});async function jOA(A,e,t){const g=A._device;g.features.has("timestamp-query")||m(141);const I=t?.repeats??9;if(!Number.isInteger(I)||I<1)throw new RangeError("overdraw probe: repeats must be a positive integer");const o=e._config.rt,C=e._config.depth??o;(e._config.depth?e._config.depth._eager===!0:e._config.depthClear===!1)&&m(142);const r=o._width,n=o._height;(!r||!n)&&m(143);const s=o._descriptor.format??e._targetSignature._colorFormat,B=e._targetSignature._depthStencilFormat,Q=o._descriptor.samples??e._targetSignature._sampleCount??1;(!s||!B?.startsWith("depth"))&&m(144);const E=[],c={index:0};for(const M of[e._opaqueBindings,e._directBindings,e._transparentBindings]){for(const N of M){const G=N.renderable.mesh;G&&G.visible===!1||E.push(N)}M!==e._transparentBindings&&(c.index=E.length)}E.length===0&&m(145);const l=e._sceneBG;l||m(146);const u=e._config.cam??e.scene.camera??null,p=(()=>{const M=E.slice(0,c.index);if(!u||M.length<=1)return E;const N=Io(u),G=F=>{const v=F.renderable._worldCenter??(()=>{const U=F.renderable.mesh?.worldMatrix;return U?[U[12],U[13],U[14]]:null})();return v?v[0]*N[2]+v[1]*N[6]+v[2]*N[10]+N[14]:0},K=M.map(F=>({b:F,z:G(F)}));return K.sort((F,v)=>F.z-v.z),[...K.map(F=>F.b),...E.slice(c.index)]})(),d=g.createTexture({label:"overdraw-probe-color",size:{width:r,height:n},format:s,sampleCount:Q,usage:GPUTextureUsage.RENDER_ATTACHMENT}),f=g.createTexture({label:"overdraw-probe-depth",size:{width:r,height:n},format:B,sampleCount:Q,usage:GPUTextureUsage.RENDER_ATTACHMENT}),D=B==="depth24plus-stencil8"||B==="depth32float-stencil8",_=C._descriptor.depthClearValue??0,y=g.createQuerySet({type:"timestamp",count:I*6}),w=g.createBuffer({label:"overdraw-probe-resolve",size:I*6*8,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),S=g.createBuffer({label:"overdraw-probe-read",size:I*6*8,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),R=(M,N)=>{const G=u?.viewport;if(G){const F=Math.floor(G.x*r),v=Math.floor((1-G.y-G.height)*n),U=Math.ceil((G.x+G.width)*r)-F,L=Math.ceil((1-G.y)*n)-v;M.setViewport(F,v,U,L,0,1),M.setScissorRect(F,v,U,L)}M.setBindGroup(0,l);let K=null;for(const F of N)F.pipeline!==K&&(M.setPipeline(F.pipeline),K=F.pipeline),F.draw(M,A)};try{const M=d.createView(),N=f.createView();for(let j=0;j<I;j++){const O=g.createCommandEncoder({label:"overdraw-probe"}),z={view:N,depthClearValue:_,depthLoadOp:"clear",depthStoreOp:"store",...D?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}},Z={view:M,loadOp:"clear",storeOp:"discard",clearValue:{r:0,g:0,b:0,a:0}},AA=O.beginRenderPass({label:"overdraw-probe-a",colorAttachments:[Z],depthStencilAttachment:z,timestampWrites:{querySet:y,beginningOfPassWriteIndex:j*6,endOfPassWriteIndex:j*6+1}});R(AA,E),AA.end();const BA=O.beginRenderPass({label:"overdraw-probe-b",colorAttachments:[Z],depthStencilAttachment:{view:N,depthLoadOp:"load",depthStoreOp:"discard",...D?{stencilLoadOp:"load",stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:y,beginningOfPassWriteIndex:j*6+2,endOfPassWriteIndex:j*6+3}});R(BA,E),BA.end();const QA=O.beginRenderPass({label:"overdraw-probe-c",colorAttachments:[Z],depthStencilAttachment:{...z,depthStoreOp:"discard",...D?{stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:y,beginningOfPassWriteIndex:j*6+4,endOfPassWriteIndex:j*6+5}});R(QA,p),QA.end(),j===I-1&&(O.resolveQuerySet(y,0,I*6,w,0),O.copyBufferToBuffer(w,0,S,0,I*6*8)),g.queue.submit([O.finish()])}await S.mapAsync(GPUMapMode.READ);const G=new BigUint64Array(S.getMappedRange()),K=[],F=[],v=[];for(let j=0;j<I;j++){const O=Number(G[j*6+1]-G[j*6])/1e6,z=Number(G[j*6+3]-G[j*6+2])/1e6,Z=Number(G[j*6+5]-G[j*6+4])/1e6;O>0&&O<1e3&&K.push(O),z>0&&z<1e3&&F.push(z),Z>0&&Z<1e3&&v.push(Z)}S.unmap(),(!K.length||!F.length||!v.length)&&m(147);const U=j=>{const O=j.slice().sort((z,Z)=>z-Z);return O[O.length>>1]},L=+U(K).toFixed(3),x=+U(F).toFixed(3),P=+U(v).toFixed(3);return{width:r,height:n,sampleCount:Q,bindings:E.length,msAsIs:L,msVisibleOnly:x,overdrawMs:+(L-x).toFixed(3),ratio:x>0?+(L/x).toFixed(3):0,msFrontToBack:P,sortGainMs:+(L-P).toFixed(3),repeats:I}}finally{y.destroy(),w.destroy(),S.destroy(),d.destroy(),f.destroy()}}var WOA=b((()=>{rA(),Mg()}));function t9(A){return A._device.features.has("timestamp-query")}function g9(A){if(!t9(A))return nr("unsupported",!1,!1,0,[],0,0);const e=A._gpuTaskTimingResult;return e||(A._gpuTaskTimerWanted?nr("pending",!0,!0,0,[],0,0):nr("disabled",!0,!1,0,[],0,0))}async function zOA(A,e){if(!e){A._gpuTaskTimerEpoch=(A._gpuTaskTimerEpoch??0)+1,A._gpuTaskTimerWanted=!1,A._gpuTaskTimerDisable?.(),A._gpuTaskTimerDisable=void 0,A._gpuTaskTimer=void 0;const C=t9(A);return A._gpuTaskTimingResult=nr(C?"disabled":"unsupported",C,!1,0,[],0,0),A._gpuTaskTimingResult}if(!t9(A))return A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=nr("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult;if(A._gpuTaskTimerWanted)return g9(A);const t=(A._gpuTaskTimerEpoch??0)+1;A._gpuTaskTimerEpoch=t,A._gpuTaskTimerWanted=!0,A._gpuTaskTimingResult=nr("pending",!0,!0,0,[],0,0);const{createGpuTaskTimer:g,installGpuTaskTimer:I}=await Promise.resolve().then(()=>(POA(),mOA));if(!A._gpuTaskTimerWanted||A._gpuTaskTimerEpoch!==t)return g9(A);A._gpuTaskTimer===void 0&&(A._gpuTaskTimer=g(A._device));const o=A._gpuTaskTimer;return o?(A._gpuTaskTimerDisable=I(o,A,C=>{A._gpuTaskTimerWanted&&A._gpuTaskTimerEpoch===t&&(A._gpuTaskTimingResult=C)}),g9(A)):(A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=nr("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult)}async function ZOA(A,e,t){const{_measureRenderTaskOverdrawCost:g}=await Promise.resolve().then(()=>(WOA(),VOA));return g(A,e,t)}function nr(A,e,t,g,I,o,C,r){return{status:A,supported:e,enabled:t,frameIndex:g,tasks:I,totalDurationMs:C,droppedTaskCount:o,error:r}}var s1A=b((()=>{}));$a();function XOA(A){if(!XF(A.canvas)||typeof ResizeObserver>"u")return()=>{};A._ro?.disconnect();const e=A._ro=new ResizeObserver(([t])=>{A._w=Math.round(t.contentRect.width),A._h=Math.round(t.contentRect.height)});return e.observe(A.canvas),()=>{e.disconnect(),A._ro===e&&(A._ro=void 0,A._w=A._h=void 0)}}var $OA=H({createCapturePreFrame:()=>iVA,createCaptureService:()=>IVA});function AVA(A){return Math.ceil(A*4/256)*256}function eVA(A){const e=A._captureQueue;!e||e.length===0||A._swapchainCopySrc||(A._swapchainCopySrc=!0,A._context.configure({device:A.engine._device,format:A._configureFormat,alphaMode:A._alphaMode,usage:_A.RENDER_ATTACHMENT|_A.COPY_SRC,viewFormats:[A.format]}))}function tVA(A,e){const t=A._captureQueue;if(!t||t.length===0||!A._swapchainCopySrc)return;A._captureQueue=void 0;const g=A.scRT._colorTexture;if(!g){const n=new Error("captureScreenshot: no swapchain texture available");for(const s of t)s.reject(n);return}const I=A.scRT._width,o=A.scRT._height,C=AVA(I),r=A.engine._device.createBuffer({label:"screenshot-readback",size:C*o,usage:iA.COPY_DST|iA.MAP_READ});e.copyTextureToBuffer({texture:g},{buffer:r,bytesPerRow:C,rowsPerImage:o},{width:I,height:o,depthOrArrayLayers:1}),gVA({buffer:r,width:I,height:o,bytesPerRow:C,bgra:A.format.startsWith("bgra"),reqs:t})}async function gVA(A){const{buffer:e,width:t,height:g,bytesPerRow:I,bgra:o,reqs:C}=A;try{await Promise.resolve(),await e.mapAsync(GPUMapMode.READ);const r=new Uint8Array(e.getMappedRange()),n=new Uint8ClampedArray(t*g*4);for(let B=0;B<g;B++){const Q=B*I,E=B*t*4;for(let c=0;c<t;c++){const l=Q+c*4,u=E+c*4;o?(n[u]=r[l+2],n[u+1]=r[l+1],n[u+2]=r[l]):(n[u]=r[l],n[u+1]=r[l+1],n[u+2]=r[l+2]),n[u+3]=255}}e.unmap(),e.destroy();const s={width:t,height:g,data:n};for(const B of C)B.resolve(s)}catch(r){try{e.destroy()}catch{}for(const n of C)n.reject(r)}}function IVA(){return tVA}function iVA(){return eVA}var oVA=b((()=>{ZA()}));function CVA(A){const e=new Promise((t,g)=>{(A._captureQueue??=[]).push({resolve:t,reject:g})});return A._captureService||Promise.resolve().then(()=>(oVA(),$OA)).then(({createCaptureService:t,createCapturePreFrame:g})=>{A._captureService??=t(),A._capturePreFrame??=g()}),e}function t3(A,e){return Math.ceil(A/e)*e}var g3=b((()=>{}));function Ft(A,e,t,g){const I=A._device.createBuffer({label:g,size:t3(Math.max(e.byteLength,4),4),usage:t|iA.COPY_DST,mappedAtCreation:!0});return new Te(I.getMappedRange()).set(new Te(e.buffer,e.byteOffset,e.byteLength)),I.unmap(),I}var qI=b((()=>{VA(),ZA(),g3()})),rVA=H({getCpuStorageRecoveryLimits:()=>nVA,rebuildCpuStorageBuffers:()=>sVA});function nVA(A){for(const e of A._storageBuffers??[])if(e._data){const t=A._device.limits;return{maxBufferSize:t.maxBufferSize,maxStorageBufferBindingSize:t.maxStorageBufferBindingSize,maxStorageBuffersPerShaderStage:t.maxStorageBuffersPerShaderStage}}}function sVA(A){for(const e of A._storageBuffers??[])e._destroyed||(e._buffer=e._data?Ft(A,e._data,iA.STORAGE,e._label):null)}var BVA=b((()=>{ZA(),qI()}));function LI(A,e={},t=""){const g=A._device,I=I9??=new WeakMap;let o=I.get(g);o||I.set(g,o=new Map);let C=t;for(const n in I3){const s=n;C+=`:${e[s]??I3[s]}`}let r=o.get(C);return r||o.set(C,r=g.createSampler(e)),r}function QVA(A){I9?.delete(A._device)}function aVA(A,e){const t=I9?.get(A._device);if(t){const g=Object.keys(I3);for(const[I,o]of t)if(o===e){const C=I.split(":").slice(-g.length);return Object.fromEntries(g.map((r,n)=>[r,typeof I3[r]=="number"?Number(C[n]):C[n]]))}}}var I9,i9,o9,I3,ki=b((()=>{I9=null,i9="nearest",o9="clamp-to-edge",I3={minFilter:i9,magFilter:i9,mipmapFilter:i9,addressModeU:o9,addressModeV:o9,addressModeW:o9,maxAnisotropy:1}}));function sr(A,e={}){const t=e.compare,g=e.lodMinClamp??0,I=e.lodMaxClamp??32;return LI(A,e,t!==void 0||g!==0||I!==32?`${t??""}:${g}:${I}`:"")}var i3=b((()=>{ki()}));function C9(){return B1A??=new WeakMap}var B1A,jH=b((()=>{B1A=null}));function qo(A){const e=C9();e.set(A,(e.get(A)??0)+1)}var Br=b((()=>{jH()}));function Kg(A){qo(A.texture)}var cI=b((()=>{Br()}));function r9(A){return C9().get(A.texture)===0}function n9(A){return C9().get(A.texture)??0}var o3=b((()=>{jH()}));function s9(A){return LI(A,Q1A)}function $o(A){return LI(A,a1A)}function B9(A){return LI(A,E1A)}var Q1A,a1A,E1A,oo=b((()=>{ki(),Q1A={magFilter:"nearest",minFilter:"nearest"},a1A={magFilter:"linear",minFilter:"linear"},E1A={magFilter:"linear",minFilter:"linear",mipmapFilter:"linear"}})),Cs=H({generateMipmaps:()=>yQ,recordMipmaps:()=>Q9});function EVA(){eE?.clear(),eE=null,C3=null,a9=null,r3=null,E9=null}function cVA(A){const e=A._device;e!==E9&&(EVA(),E9=e),C3??=e.createShaderModule({code:c1A}),a9??=$o(A),r3??=e.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:DA.FRAGMENT,sampler:{}}]})}function lVA(A,e){const t=A._device;cVA(A),eE??=new Map;let g=eE.get(e);return g||(g=t.createRenderPipeline({layout:t.createPipelineLayout({bindGroupLayouts:[r3]}),vertex:{module:C3,entryPoint:"vs"},fragment:{module:C3,entryPoint:"fs",targets:[{format:e}]},primitive:{topology:"triangle-list"}}),eE.set(e,g)),g}function yQ(A,e,t){const g=A._device,I=g.createCommandEncoder();Q9(A,e,I,t),g.queue.submit([I.finish()])}function Q9(A,e,t,g){if(e.mipLevelCount<=1)return;const I=A._device,o=lVA(A,e.format),C=g!=null?{dimension:"2d",baseArrayLayer:g,arrayLayerCount:1}:{};for(let r=1;r<e.mipLevelCount;r++){const n=e.createView({baseMipLevel:r-1,mipLevelCount:1,...C}),s=e.createView({baseMipLevel:r,mipLevelCount:1,...C}),B=I.createBindGroup({layout:r3,entries:[{binding:0,resource:n},{binding:1,resource:a9}]}),Q=t.beginRenderPass({colorAttachments:[{view:s,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});Q.setPipeline(o),Q.setBindGroup(0,B),Q.draw(3),Q.end()}}var c1A,eE,C3,a9,r3,E9,A1=b((()=>{ZA(),oo(),c1A="@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1),p*vec2f(.5,-.5)+.5);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}",eE=null,C3=null,a9=null,r3=null,E9=null})),uVA=H({rebuildDynamicTexture2D:()=>pVA});async function pVA(A,e){const t=e._recoverySource;if(!t||t.kind!=="dynamic")return;const{width:g,height:I,format:o,levels:C,samplerDesc:r}=t,n=A._device.createTexture({size:{width:g,height:I},format:o,mipLevelCount:C,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(t.source)try{A._device.queue.copyExternalImageToTexture({source:t.source,flipY:t.flipY},{texture:n,premultipliedAlpha:t.premultipliedAlpha},[g,I]),C>1&&yQ(A,n)}catch{t.source=null}e.texture=n,e.view=n.createView(),e.sampler=sr(A,r),e.width=g,e.height=I,Kg(e)}var dVA=b((()=>{ZA(),cI(),i3(),A1()})),WH=H({rebuildTexture2D:()=>fVA,settleRebuiltTextureOwnership:()=>DVA});async function fVA(A,e){const t=e._recoverySource;if(!t||r9(e))return;c9??=new WeakMap;const g=c9.get(t);if(g?.device===A._device){g.tex!==e&&(await g.done,_VA(A,e,g.tex));return}const I=n9(e),o=yVA(A,e,t);if(c9.set(t,{device:A._device,tex:e,done:o}),await o,I>0){const C=A._deviceLostRecovery;C&&(C._pendingOwnership??=[]).push([e,I])}}function DVA(A){const e=A._pendingOwnership;if(A._pendingOwnership=void 0,!!e)for(const[t,g]of e)for(let I=n9(t);I<g;I++)Kg(t)}function _VA(A,e,t){const g=l1A(A,e)??t.sampler;e.texture=t.texture,e.view=t.view,e.width=t.width,e.height=t.height,e.sampler=g}function l1A(A,e){const t=A._deviceLostRecovery?._samplerDescriptors,g=t?.get(e.sampler);if(!g)return;const I=sr(A,g);return t.set(I,g),I}async function yVA(A,e,t){if(t.kind==="url"){const n=await hVA(A,t.url,t.opts);e.texture=n.texture,e.view=n.view,e.sampler=n.sampler,e.width=n.width,e.height=n.height,e._recoverySource=t;return}if(t.kind==="solid"){const n=A._device.createTexture({size:{width:1,height:1},format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST}),s=new Te(t.rgba.map(B=>Math.round(B*255)));A._device.queue.writeTexture({texture:n},s,{bytesPerRow:4,rowsPerImage:1},{width:1,height:1}),e.texture=n,e.view=n.createView(),e.sampler=$o(A),e.width=1,e.height=1;return}if(t.kind==="dynamic"){const{rebuildDynamicTexture2D:n}=await Promise.resolve().then(()=>(dVA(),uVA));await n(A,e);return}if(t.kind==="pixels"){const n=t.options,s=A._device.createTexture({size:{width:t.width,height:t.height},format:n.srgb?"rgba8unorm-srgb":"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST});A._device.queue.writeTexture({texture:s},t.data,{bytesPerRow:t.width*4,rowsPerImage:t.height},{width:t.width,height:t.height}),e.texture=s,e.view=s.createView(),e.sampler=sr(A,{addressModeU:n.addressModeU??"clamp-to-edge",addressModeV:n.addressModeV??"clamp-to-edge",minFilter:n.minFilter??"nearest",magFilter:n.magFilter??"nearest"}),e.width=t.width,e.height=t.height;return}if(t.kind==="render"){const n=A._device.createTexture({size:{width:t.width,height:t.height},format:t.format,usage:_A.TEXTURE_BINDING|_A.RENDER_ATTACHMENT|_A.COPY_DST});e.texture=n,e.view=n.createView(),e.sampler=sr(A,t.samplerDesc),e.width=t.width,e.height=t.height;return}if(t.kind==="external"){if(!t.bitmap)throw new Error("Cannot recover a released external-image texture");const n=A._device.createTexture({size:{width:t.width,height:t.height},format:t.format,mipLevelCount:t.levels,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:t.bitmap,flipY:t.flipY},{texture:n,premultipliedAlpha:t.premultipliedAlpha},{width:t.width,height:t.height}),t.levels>1){const{generateMipmaps:s}=await Promise.resolve().then(()=>(A1(),Cs));s(A,n)}e.texture=n,e.view=n.createView(),e.sampler=sr(A,t.samplerDesc),e.width=t.width,e.height=t.height;return}const g=t.bitmap?.width??1,I=t.bitmap?.height??1,o=t.srgb?"rgba8unorm-srgb":"rgba8unorm",C=t.mipMaps?Math.floor(Math.log2(Math.max(g,I)))+1:1,r=A._device.createTexture({size:{width:g,height:I},format:o,mipLevelCount:C,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.COPY_SRC|_A.RENDER_ATTACHMENT});if(t.bitmap){if(A._device.queue.copyExternalImageToTexture({source:t.bitmap},{texture:r,premultipliedAlpha:!1},{width:g,height:I}),t.mipMaps&&C>1){const{generateMipmaps:n}=await Promise.resolve().then(()=>(A1(),Cs));n(A,r)}}else A._device.queue.writeTexture({texture:r},t.fallback??new Te([255,255,255,255]),{bytesPerRow:4},{width:1,height:1});e.texture=r,e.view=r.createView(),e.sampler=l1A(A,e)??sr(A,{addressModeU:"repeat",addressModeV:"repeat",minFilter:"linear",magFilter:"linear",mipmapFilter:"linear",maxAnisotropy:4}),e.width=g,e.height=I}async function hVA(A,e,t){const g=t.mipMaps??!0,I=t.addressModeU??"repeat",o=t.addressModeV??"repeat",C=t.invertY??!0,r=t.srgb??!1,n=t.premultiplyAlpha??!1,s=r?"rgba8unorm-srgb":"rgba8unorm",B=await(await fetch(e)).blob(),Q=await createImageBitmap(B,{premultiplyAlpha:n?"premultiply":"none",colorSpaceConversion:"none"}),E=Q.width,c=Q.height,l=g?Math.floor(Math.log2(Math.max(E,c)))+1:1,u=A._device.createTexture({size:{width:E,height:c},format:s,mipLevelCount:l,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:Q,flipY:C},{texture:u,premultipliedAlpha:n},{width:E,height:c}),Q.close(),g&&l>1){const{generateMipmaps:_}=await Promise.resolve().then(()=>(A1(),Cs));_(A,u)}const p=t.minFilter??"linear",d=t.magFilter??"linear",f=g?"linear":"nearest",D=sr(A,{addressModeU:I,addressModeV:o,minFilter:p,magFilter:d,mipmapFilter:f,maxAnisotropy:p==="linear"&&d==="linear"&&f==="linear"?4:1});return{texture:u,view:u.createView(),sampler:D,width:E,height:c}}var c9,zH=b((()=>{VA(),ZA(),i3(),cI(),o3(),oo(),c9=null})),wVA=H({runDeviceLostRecovery:()=>SVA});function u1A(){return Promise.resolve().then(()=>(BVA(),rVA))}async function SVA(A,e,t){const g=new Map;for(const B of t)g.set(B._kind,B);const I=A._renderFn!==null;Wv(A),RVA(A,g),$oA(A);const o=await rs("requesting a replacement adapter",()=>navigator.gpu.requestAdapter({powerPreference:"high-performance",...HoA()}));o||m(47);const C=e._requiredFeatures.filter(B=>!o.features.has(B));C.length&&m(48,C.join(", "));const r=A._storageBuffers?.size?await u1A():void 0;A._device=await rs("requesting a replacement device",()=>o.requestDevice({requiredFeatures:e._requiredFeatures,requiredLimits:{...A._options?.requiredLimits,...r?.getCpuStorageRecoveryLimits(A)}})),A._attachGpuEvents?.(A),await rs("rebuilding engine storage buffers",async()=>{(r??(A._storageBuffers?.size?await u1A():void 0))?.rebuildCpuStorageBuffers(A)}),await rs("reconfiguring rendering surfaces",()=>{for(const B of A.surfaces){const Q=B._swapchainCopySrc?_A.RENDER_ATTACHMENT|_A.COPY_SRC:_A.RENDER_ATTACHMENT;B._context.configure({device:A._device,format:B._configureFormat,alphaMode:B._alphaMode,usage:Q,viewFormats:[B.format]}),Ov(B)}}),await rs("resizing rendering surfaces",()=>HH(A));const n=await MVA(A,e),s=Array.from(g.values()).sort((B,Q)=>(B._recoverOrder??0)-(Q._recoverOrder??0));try{for(const B of s)await rs(`running "${B._kind}" recovery`,()=>B._recover(A))}finally{n?.()}I&&await rs("restarting rendering",()=>A3(A))}async function MVA(A,e){const t=e._textures,g=[];for(const C of t){const r=C.deref();r?g.push(r):t.delete(C)}if(g.length===0)return;const{rebuildTexture2D:I,settleRebuiltTextureOwnership:o}=await Promise.resolve().then(()=>(zH(),WH));try{await rs("rebuilding recoverable textures",async()=>{const C=(await Promise.allSettled(g.map(r=>I(A,r)))).find(r=>r.status==="rejected");if(C)throw C.reason})}catch(C){throw o(e),C}return()=>o(e)}function RVA(A,e){const t=new Set;for(const g of A.surfaces)for(const I of g._renderingContexts)e.has(I._kind)||t.add(I._kind);if(t.size)throw new Error(`Device-lost recovery cannot rebuild registered rendering contexts of kind: ${Array.from(t).sort().join(", ")}. Recovering around them would leave them bound to the lost device and crash the browser's renderer process on the next frame. Enable that kind's device-lost recovery before the device is lost, or unregister the context.`)}async function rs(A,e){try{return await e()}catch(t){const g=t instanceof Error?t.message:String(t);throw new Error(`Device-lost recovery failed while ${A}: ${g}`,{cause:t})}}var mVA=b((()=>{rA(),hI(),kg(),ZA(),$a()}));function NVA(A){return A._deviceLostRecovery??={_forceNextLoss:!1,_requiredFeatures:[],_armedDevice:null,_registrations:[],_samplerDescriptors:new WeakMap,_captureRefs:0,_meshCaptureRefs:0,_textures:new Set,_texturesPruneAt:64}}function l9(A,e){const t=NVA(A),g=t._registrations;g.length===0&&(t._requiredFeatures=Array.from(A._device.features)),g.some(o=>o._kind===e._kind)||e._enable?.(A),g.push(e),p1A(A,t);let I=!1;return{disable(){if(I)return;I=!0;const o=g.indexOf(e);o>=0&&g.splice(o,1),g.some(C=>C._kind===e._kind)||e._disable?.(A)}}}function GVA(A){const e=A._deviceLostRecovery;return!!e?._registrations.length&&(e._forceNextLoss=!0)}function p1A(A,e){const t=A._device;e._armedDevice===t||e._recovering||(e._armedDevice=t,t.lost.then(g=>{if(e._registrations.length===0||e._armedDevice!==t||g.reason==="destroyed"&&!e._forceNextLoss)return;e._forceNextLoss=!1,e._recovering=!0;const I=[...e._registrations];for(const o of I)o._onLost?.(g);Promise.resolve().then(()=>(mVA(),wVA)).then(({runDeviceLostRecovery:o})=>o(A,e,I)).then(()=>{e._recovering=!1,p1A(A,e);for(const o of I)o._onRecovered?.()},o=>{e._recovering=!1;for(const C of I)C._onRecoveryFailed?.(o)})}))}rA();function bVA(A){GVA(A)||m(49),A._device.destroy()}function u9(A,e){const t={...A,...e};return ZH?.(A,t),XH?.(A,t),t}function FVA(A){ZH=A}function kVA(A){XH=A}function tE(A,e,t={}){const g=A._device;n3||(n3=new WeakMap);let I=n3.get(g);I||(I=new Map,n3.set(g,I));const o=`${e}\0${t.mipMaps??!0}\0${t.addressModeU??"repeat"}\0${t.addressModeV??"repeat"}\0${t.minFilter??"linear"}\0${t.magFilter??"linear"}\0${t.invertY??!0}\0${t.srgb??!1}\0${t.premultiplyAlpha??!1}`,C=I.get(o);if(C)return C;const r=I,n=KVA(A,e,t);return r.set(o,n),n.catch(()=>r.delete(o)),n}async function KVA(A,e,t){const g=A._device,I=t.mipMaps??!0,o=t.addressModeU??"repeat",C=t.addressModeV??"repeat",r=t.invertY??!0,n=t.srgb??!1,s=t.premultiplyAlpha??!1,B=n?"rgba8unorm-srgb":"rgba8unorm",Q=await(await fetch(e)).blob(),E=await createImageBitmap(Q,{premultiplyAlpha:s?"premultiply":"none",colorSpaceConversion:"none"}),c=E.width,l=E.height,u=I?Math.floor(Math.log2(Math.max(c,l)))+1:1,p=g.createTexture({size:{width:c,height:l},format:B,mipLevelCount:u,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});if(g.queue.copyExternalImageToTexture({source:E,flipY:r},{texture:p,premultipliedAlpha:s},{width:c,height:l}),E.close(),I&&u>1){const{generateMipmaps:w}=await Promise.resolve().then(()=>(A1(),Cs));w(A,p)}const d=t.minFilter??"linear",f=t.magFilter??"linear",D=I?"linear":"nearest",_=LI(A,{addressModeU:o,addressModeV:C,minFilter:d,magFilter:f,mipmapFilter:D,maxAnisotropy:d==="linear"&&f==="linear"&&D==="linear"?4:1}),y={texture:p,view:p.createView(),sampler:_,width:c,height:l};return A._dlr?.u(y,e,t),Kg(y),y}var ZH,XH,n3,NC=b((()=>{ZA(),cI(),ki(),ZH=null,XH=null,n3=null}));function vVA(A){AT=A}function $H(A,e){const t=C9(),g=(t.get(A)??1)-1;return g<=0?(A.destroy(),e&&AT?.(e),t.set(A,0),!0):(t.set(A,g),!1)}var AT,s3=b((()=>{jH(),AT=null}));rA(),NC(),s3();var UVA=64,d1A=null;function f1A(A,e,t){e._recoverySource=t;const g=A._textures;if(g.size>=A._texturesPruneAt){for(const I of g)I.deref()||g.delete(I);A._texturesPruneAt=Math.max(UVA,g.size*2)}g.add(new WeakRef(e))}function D1A(A,e){const t=A._recoverySource;if(!t)return;const g=d1A?.get(t)?.deref();g&&f1A(g,e,t)}function LVA(A){const e=A._recoverySource;e?.kind==="external"&&(e.bitmap?.close(),e.bitmap=null)}function YVA(A,e,t,g){const I=A._recoverySource;I?.kind==="dynamic"&&(I.source=e,I.flipY=t,I.premultipliedAlpha=g)}function xVA(A){const e=A._deviceLostRecovery,t=new WeakRef(e),g=(I,o)=>{(d1A??=new WeakMap).set(o,t),f1A(e,I,o)};kVA(D1A),vVA(LVA),A._updateCapturedDynamicTexture=YVA,A._dlr={t:g,dt(I,o,C,r,n,s){g(I,{kind:"dynamic",width:o,height:C,format:r,levels:n,samplerDesc:s,source:null,flipY:!0,premultipliedAlpha:!1})},c(I,o,...C){e._meshCaptureRefs&&(I._rebuild=()=>o(...C))},async x(I,o,C,r,n,s,B,Q,E){const c=await createImageBitmap(I,{premultiplyAlpha:Q?"premultiply":"none",colorSpaceConversion:"none"});try{const l=await E(c);return g(l,{kind:"external",bitmap:c,width:o,height:C,format:r,levels:n,samplerDesc:s,flipY:B,premultipliedAlpha:Q}),l}catch(l){throw c.close(),l}},d:D1A,u(I,o,C){g(I,{kind:"url",url:o,opts:{...C}})},s(I,o,C,r,n){g(I,{kind:"solid",rgba:[o,C,r,n]})},b(I,o,C,r,n){g(I,{kind:"bitmap",bitmap:o,srgb:C,mipMaps:r,fallback:n})},p(I,o,C){g(I,{kind:"pixels",data:o.slice(0,I.width*I.height*4),width:I.width,height:I.height,options:{...C}})},r(I,o,C,r,n){g(I,{kind:"render",width:o,height:C,format:r,samplerDesc:n})},w(I,o,C,r,n,s,B=0,Q=n*4){const E=I._recoverySource;if(E?.kind!=="pixels")return;const c=new Uint8Array(o.buffer,o.byteOffset,o.byteLength),l=n*4;for(let u=0;u<s;u++){const p=B+u*Q,d=((r+u)*E.width+C)*4;E.data.set(c.subarray(p,p+l),d)}},m(I,o,C,r,n,s){A._deviceLostRecovery?._meshCaptureRefs&&(I._cpuUv2s=o??null,I._cpuTangents=C??null,I._cpuColors=r??null,I._cpuGpuIndices=n,I._cpuIndexFormat=s)},e(I,o,C){e._meshCaptureRefs&&(I._envRecoverySource={kind:"env",url:o,brdfUrl:C})},h(I,o,C){e._meshCaptureRefs&&(I._envRecoverySource={kind:"hdr",url:o,faceSize:C})}}}function _1A(A,e=!1){const t=A._deviceLostRecovery;t||m(46),t._captureRefs++,e&&t._meshCaptureRefs++,t._captureRefs===1&&xVA(A)}function y1A(A,e=!1){const t=A._deviceLostRecovery;!t||t._captureRefs===0||(t._captureRefs--,e&&t._meshCaptureRefs>0&&t._meshCaptureRefs--,t._captureRefs===0&&(A._dlr=void 0))}var e1,ns=b((()=>{e1=class{_x;_y;_z;_onDirty;constructor(A,e,t,g){this._x=A,this._y=e,this._z=t,this._onDirty=g}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._onDirty())}set(A,e,t){this._x=A,this._y=e,this._z=t,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z}}})),B3,p9=b((()=>{B3=class{_x;_y;_z;_w;_onDirty;_version=0;constructor(A,e,t,g,I){this._x=A,this._y=e,this._z=t,this._w=g,this._onDirty=I}get version(){return this._version}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._version++,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._version++,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._version++,this._onDirty())}get w(){return this._w}set w(A){this._w!==A&&(this._w=A,this._version++,this._onDirty())}set(A,e,t,g){this._x=A,this._y=e,this._z=t,this._w=g,this._version++,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z,A.w)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z,A[e+3]=this._w}}}));function P1(A,e,t,g,I,o,C,r,n,s,B,Q){const E=o*o,c=C*C,l=r*r,u=o*C,p=o*r,d=C*r,f=n*o,D=n*C,_=n*r;A[e]=(1-2*(c+l))*s,A[e+1]=2*(u+_)*s,A[e+2]=2*(p-D)*s,A[e+3]=0,A[e+4]=2*(u-_)*B,A[e+5]=(1-2*(E+l))*B,A[e+6]=2*(d+f)*B,A[e+7]=0,A[e+8]=2*(p+D)*Q,A[e+9]=2*(d-f)*Q,A[e+10]=(1-2*(E+c))*Q,A[e+11]=0,A[e+12]=t,A[e+13]=g,A[e+14]=I,A[e+15]=1}var GC=b((()=>{}));function Q3(A,e){A[tT]=e}function eT(A){return A===null?null:A[tT]??null}function hQ(A){eT(A)?._invalidate()}function JVA(A){eT(A)?.markLocalDirty()}function h1A(A,e,t){const g=bg();return w1A(g,A,e,t),g}function w1A(A,e,t,g){e.x===0&&e.y===0&&e.z===0&&t.x===0&&t.y===0&&t.z===0&&t.w===1&&g.x===1&&g.y===1&&g.z===1?(A.fill(0),A[0]=A[5]=A[10]=A[15]=1):P1(A,0,e.x,e.y,e.z,t.x,t.y,t.z,t.w,g.x,g.y,g.z)}function gE(A){let e=0,t=-1,g=null,I=null;const o=bg();let C=null,r=null;const n=[];function s(){I=null,e++;for(const E of n)E._invalidate()}function B(){const E=C.worldMatrixVersion;E!==t&&(t=E,s())}const Q={get parent(){return C},set parent(E){E!==C&&(r!==null&&r._removeChild(Q),C=E,r=eT(E),r!==null&&r._addChild(Q),t=-1,s())},markLocalDirty(){g=null,s()},getWorldMatrix(){if(r===null&&C!==null&&B(),I!==null)return I;const E=g??=A();if(C!==null){const c=C.worldMatrix;$g(o,0,c,0,E,0),I=o}else I=E;return I},getWorldMatrixVersion(){return r===null&&C!==null&&B(),e},_invalidate:s,_addChild(E){n.push(E)},_removeChild(E){const c=n.indexOf(E);c>=0&&n.splice(c,1)}};return Q}var tT,tn=b((()=>{go(),Ii(),GC(),tT=Symbol("wmState")}));function d9(A,e,t){const g=Math.cos(A*.5),I=Math.sin(A*.5),o=Math.cos(e*.5),C=Math.sin(e*.5),r=Math.cos(t*.5),n=Math.sin(t*.5);return[I*o*r+g*C*n,g*C*r-I*o*n,g*o*n+I*C*r,g*o*r-I*C*n]}function S1A(A,e,t,g){const I=2*(A*t+g*e),o=Math.asin(Math.max(-1,Math.min(1,I)));return[Math.atan2(-(2*(e*t-g*A)),1-2*(A*A+e*e)),o,Math.atan2(-(2*(A*e-g*t)),1-2*(e*e+t*t))]}var f9=b((()=>{}));function gT(A){let e=0,t=0,g=0,I=-1;const o=()=>{if(A.version!==I){const r=S1A(A.x,A.y,A.z,A.w);e=r[0],t=r[1],g=r[2],I=A.version}},C=(r,n,s)=>{e=r,t=n,g=s;const[B,Q,E,c]=d9(r,n,s);A.set(B,Q,E,c),I=A.version};return{get x(){return o(),e},set x(r){o(),C(r,t,g)},get y(){return o(),t},set y(r){o(),C(e,r,g)},get z(){return o(),g},set z(r){o(),C(e,t,r)},set:C}}function HVA(A,e,t,g,I,o,C,r,n,s,B){return M1A(A,null,e,t,g,I,o,C,r,n,s,B)}function wQ(A,e,t,g,I){const o=M1A(A,e,t?.x,t?.y,t?.z,g?.x,g?.y,g?.z,g?.w,I?.x,I?.y,I?.z);return o._localMatrixLocked=t?void 0:!0,o}function M1A(A,e,t,g,I,o,C,r,n,s,B,Q){const E=a3({name:A,children:[]},t,g,I,o,C,r,n,s,B,Q);return e&&(E._localMatrix=e),E}function a3(A,e=0,t=0,g=0,I=0,o=0,C=0,r=1,n=1,s=1,B=1){let Q;const E=gE(()=>f._localMatrix?f._localMatrix:(Q??=bg(),w1A(Q,l,u,d),Q)),c=()=>{f._localMatrixLocked||(f._localMatrix=void 0,E.markLocalDirty())},l=new e1(e,t,g,c),u=new B3(I,o,C,r,c),p=gT(u),d=new e1(n,s,B,c),f={...A,position:l,rotationQuaternion:u,rotation:p,scaling:d,get parent(){return E.parent},set parent(D){E.parent=D},get worldMatrix(){return E.getWorldMatrix()},get worldMatrixVersion(){return E.getWorldMatrixVersion()}};return Q3(f,E),f}var CC=b((()=>{ns(),p9(),tn(),f9(),Ii()}));function SQ(A,e=0,t=0,g=0,I=0,o=0,C=0,r=1,n=1,s=1){const[B,Q,E,c]=d9(I,o,C),l=a3({children:[],...A},e,t,g,B,Q,E,c,r,n,s);return Object.defineProperties(l,{worldMatrix:{enumerable:!1},worldMatrixVersion:{enumerable:!1}}),l}function D9(A,e,t,g,I,o,C,r){const n=A._device,s=Ft(A,e,iA.VERTEX),B=Ft(A,t,iA.VERTEX),Q=Ft(A,g,iA.INDEX);let E;I&&I.length>0?E=Ft(A,I,iA.VERTEX):(E=n.createBuffer({size:e.length/3*8,usage:iA.VERTEX,mappedAtCreation:!0}),E.unmap());let c=null;o&&o.length>0&&(c=Ft(A,o,iA.VERTEX));const l=C&&C.length>0?Ft(A,C,iA.VERTEX):null,u=r&&r.length>0?Ft(A,r,iA.VERTEX):null;return{positionBuffer:s,normalBuffer:B,uvBuffer:E,uv2Buffer:c,tangentBuffer:l,colorBuffer:u,hasUv:!!I&&I.length>0,hasUv2:!!o&&o.length>0,hasTangent:!!C&&C.length>0,hasColor:!!r&&r.length>0,indexBuffer:Q,indexCount:g.length,indexFormat:"uint32"}}var ss=b((()=>{ZA(),qI(),CC(),f9()}));function R1A(A,e){const t=A.indexCount;A._drawRangeSource=e,Object.defineProperty(A,"indexCount",{enumerable:!0,configurable:!0,get:()=>A._drawRangeSource?.indexCount??t})}var m1A=b((()=>{}));function XI(A,e,t){return A._device.createBuffer({label:t,size:t3(e,16),usage:iA.UNIFORM|iA.COPY_DST})}var co=b((()=>{ZA(),g3()}));function oi(A){const e=A._device,t=N1A??=new WeakMap;let g=t.get(e);return g||(g=e.createBindGroupLayout({label:"scene",entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,buffer:{type:"uniform"}}]}),t.set(e,g)),g}function IT(A){const e=A._blend?{format:A._format,blend:A._blend}:{format:A._format};return{label:A._label,layout:A._engine._device.createPipelineLayout({bindGroupLayouts:A._bgls}),vertex:{module:A._vertModule,entryPoint:"main",buffers:A._vertexBuffers},fragment:{module:A._fragModule,entryPoint:"main",targets:[e]},depthStencil:{format:A._depthStencilFormat??"depth24plus-stencil8",depthCompare:A._depthCompare??"greater-equal",depthWriteEnabled:A._depthWriteEnabled??!0},multisample:{count:A._msaaSamples},primitive:{topology:"triangle-list",cullMode:A._cullMode??"back",frontFace:"ccw"}}}var N1A,Ci=b((()=>{ZA(),Fg(),it(),N1A=null}));function Rg(A,e,t){const g=A._device,I=XI(A,e.byteLength,t);try{g.queue.writeBuffer(I,0,e.buffer,e.byteOffset,e.byteLength)}catch(o){throw I.destroy(),o}return I}var gI=b((()=>{co()}));function iT(){return 16+Ht*16*4}function G1A(A){let e=0;for(const t of A)e+=t._lightVersion??0;return e}function oT(A,e){A.fill(0);let t=0;const g=4;for(const I of e){if(t>=Ht)break;I._writeLightUbo&&(I._writeLightUbo(A,g+t*16),t++)}CT[0]=t,A[0]=b1A[0]}function _9(A,e){let t=e._lightGpuState;const g=iT();if(t&&t._byteSize===g)return t;const I=!t;t?._buffer.destroy();const o=new CA(g/4);return oT(o,e.lights),A._applyLightFoOffset?.(o,e),t={_buffer:Rg(A,o),_scratch:o,_version:G1A(e.lights)+(A._lightFoVersion?.(e)??0),_listVersion:e._lightListVersion??0,_lightCount:e.lights.length,_byteSize:g},e._lightGpuState=t,I&&e._disposables.push(()=>{e._lightGpuState?._buffer.destroy(),e._lightGpuState=void 0}),t}function TVA(A,e){const t=_9(A,e),g=G1A(e.lights)+(A._lightFoVersion?.(e)??0),I=e._lightListVersion??0;return(g!==t._version||I!==t._listVersion||e.lights.length!==t._lightCount)&&(t._version=g,t._listVersion=I,t._lightCount=e.lights.length,oT(t._scratch,e.lights),A._applyLightFoOffset?.(t._scratch,e),A._device.queue.writeBuffer(t._buffer,0,t._scratch)),t._buffer}function qVA(A,e,t){oT(e,t.lights),A._applyLightFoOffset?.(e,t)}var CT,b1A,rT=b((()=>{VA(),EI(),gI(),CT=new gt(1),b1A=new CA(CT.buffer)})),y9=b((()=>{}));function t1(A){return $H(A)}var Bs=b((()=>{s3()}));function gn(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}function PVA(A,e,t){return Math.max(1,Math.floor(Math.log2(Math.max(A,e))-t)+1)}var Qr=b((()=>{}));function F1A(A){const e=new Te(A);for(let l=0;l<8;l++)if(e[l]!==k1A[l])throw new Error("Invalid .env file: bad magic");let t=8;for(;t<e.length&&e[t]!==0;)t++;const g=new TextDecoder().decode(e.subarray(8,t));t++;const I=t,o=JSON.parse(g),C=o.width,r=gn(C,C),n=o.irradiance,s=new CA(27),B=["x","y","z","xx","yy","zz","yz","zx","xy"];for(let l=0;l<9;l++){const u=n[B[l]];s[l*3]=u[0],s[l*3+1]=u[1],s[l*3+2]=u[2]}const Q=o.specular.mipmaps,E=o.imageType||"image/png",c=[];for(const l of Q){const u=I+l.position,p=A.slice(u,u+l.length);c.push(new Blob([p],{type:E}))}return{faceBlobs:c,irradianceSH:s,width:C,mipCount:r}}var k1A,K1A=b((()=>{VA(),Qr(),k1A=new Te([134,22,135,150,246,214,150,54])}));function v1A(){return{minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}}function OVA(A,e,t,g){const I=t-g,o=t+g,C=e===0?"minX":e===1?"minY":"minZ",r=e===0?"maxX":e===1?"maxY":"maxZ";I<A[C]&&(A[C]=I),o>A[r]&&(A[r]=o)}function U1A(A,e){const t=e.boundMin,g=e.boundMax;if(!t||!g)return;if(e._expandWorldBounds!==void 0){e._expandWorldBounds(A,e);return}const I=e.worldMatrix,o=[(t[0]+g[0])*.5,(t[1]+g[1])*.5,(t[2]+g[2])*.5],C=[(g[0]-t[0])*.5,(g[1]-t[1])*.5,(g[2]-t[2])*.5];for(let r=0;r<3;r++){let n=I[12+r],s=0;for(let B=0;B<3;B++){const Q=I[B*4+r];n+=Q*o[B],s+=Math.abs(Q)*C[B]}OVA(A,r,n,s)}}var L1A=b((()=>{})),Y1A=H({computeSceneSize:()=>x1A});function x1A(A,e){const t=v1A();for(const d of A.meshes)U1A(t,d);const g=t.minX,I=t.minY,o=t.minZ,C=t.maxX,r=t.maxY,n=t.maxZ;if(!isFinite(g))return{groundSize:15,skyboxSize:e??20,rootPosition:[0,0,0]};const s=C-g,B=r-I,Q=n-o,E=Math.sqrt(s*s+B*B+Q*Q);let c=15,l=e??20;const u=A.camera;u&&"upperRadiusLimit"in u&&u.upperRadiusLimit&&(c=u.upperRadiusLimit*2,l=c),E>c&&(c=E*2,l=c),c*=1.1,l*=1.5;const p=[g+s*.5,I-1e-5,o+Q*.5];return{groundSize:c,skyboxSize:l,rootPosition:p}}var nT=b((()=>{L1A()}));function VVA(A,e){const t=e.fog;t&&(A[80]=t.mode,A[81]=t.start,A[82]=t.end,A[83]=t.density,A[84]=t.color[0],A[85]=t.color[1],A[86]=t.color[2])}function jVA(A,e){const t=e.clipPlane;t&&(A[88]=t[0],A[89]=t[1],A[90]=t[2],A[91]=t[3])}function WVA(A,e){A[36]=e._environmentRotation??0;const t=e._envTextures?.sphericalHarmonics;t&&A.set(t,40)}function h9(A,e){const t=A._sceneUboContributors??=[];t.includes(e)||t.push(e)}function w9(A){for(const e of A._frameGraph._tasks)e._sceneUboCacheKey&&(e._sceneUboCacheKey.length=0)}function zVA(A,e){A.fog=e,h9(A,VVA)}function ZVA(A,e){A.clipPlane=e,h9(A,jVA)}function IE(A){h9(A,WVA)}var MQ=b((()=>{})),S9=H({decodeBrdfPng:()=>XVA,uploadCubemapRGBD:()=>$VA});function J1A(A,e){A!==BT&&(BT=A,QT=A.createShaderModule({code:q1A}),M9=null,R9=null);const t=e?R9:M9;if(t)return t;const g=A.createComputePipeline({layout:"auto",compute:{module:QT,entryPoint:"main",constants:{[sT]:e?1:0}}});return e?R9=g:M9=g,g}function H1A(A,e,t,g){return A.createBindGroup({layout:e.getBindGroupLayout(0),entries:[{binding:0,resource:t},{binding:1,resource:g}]})}function T1A(A,e,t,g,I){const o=A.beginComputePass();o.setPipeline(e),o.setBindGroup(0,t),o.dispatchWorkgroups(Math.ceil(g/8),Math.ceil(I/8)),o.end()}function XVA(A,e){const t=A._device,g=J1A(t,!1),I=e.width,o=e.height,C=t.createTexture({size:{width:I,height:o},format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});t.queue.copyExternalImageToTexture({source:e,flipY:!1},{texture:C,premultipliedAlpha:!1},{width:I,height:o});const r=t.createTexture({size:{width:I,height:o},format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING}),n=H1A(t,g,C.createView(),r.createView()),s=t.createCommandEncoder();return T1A(s,g,n,I,o),t.queue.submit([s.finish()]),C.destroy(),r}function $VA(A,e,t,g){const I=A._device,o=J1A(I,!0),C=I.createTexture({size:{width:t,height:t,depthOrArrayLayers:6},format:"rgba16float",mipLevelCount:g,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.COPY_SRC|_A.RENDER_ATTACHMENT,dimension:"2d"});for(let r=0;r<g;r++){const n=Math.max(1,t>>r),s=I.createTexture({size:{width:n,height:n},format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT}),B=I.createTexture({size:{width:n,height:n},format:"rgba16float",usage:_A.STORAGE_BINDING|_A.COPY_SRC}),Q=H1A(I,o,s.createView(),B.createView());for(let E=0;E<6;E++){const c=r*6+E;if(c>=e.length)break;I.queue.copyExternalImageToTexture({source:e[c],flipY:!1},{texture:s,premultipliedAlpha:!1},{width:n,height:n});const l=I.createCommandEncoder();T1A(l,o,Q,n,n),l.copyTextureToTexture({texture:B},{texture:C,origin:{x:0,y:0,z:E},mipLevel:r},{width:n,height:n}),I.queue.submit([l.finish()])}s.destroy(),B.destroy()}return C}var sT,q1A,BT,QT,M9,R9,m9=b((()=>{ZA(),sT=0,q1A=`@id(${sT})override f:bool=false;@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var o:texture_storage_2d<rgba16float,write>;@compute@workgroup_size(8,8)fn main(@builtin(global_invocation_id)g:vec3u){let d=textureDimensions(t);if(any(g.xy>=d)){return;}let c=textureLoad(t,vec2u(g.x,select(g.y,d.y-1u-g.y,f)),0);textureStore(o,g.xy,vec4f(pow(c.rgb,vec3f(2.2))/max(c.a,1.0/255.0),1));}`,BT=null,QT=null,M9=null,R9=null})),aT,P1A=b((()=>{aT="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,0.0)).xyz+scene.vEyePosition.xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),O1A,AjA=b((()=>{O1A="struct c{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32}@group(1) @binding(0) var<uniform> mesh:c;struct d{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:d)->@location(0) vec4<f32>{var a=vec4<f32>(mesh.skyOutputColor,1.0);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.positionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"}));function ri(A){return`${A._colorFormat??"-"}|${A._depthStencilFormat??"-"}|${A._depthCompare??""}|${A._sampleCount}`}var ni=b((()=>{})),V1A,N9,ET,G9=b((()=>{V1A="fn perturbNormal(vNormalW:vec3<f32>,positionW:vec3<f32>,uv:vec2<f32>,bumpScale:f32)->vec3<f32>{let normalSample=textureSample(bT,bS,uv).rgb*2.0-1.0;let N=normalize(vNormalW)*bumpScale;let dp1=dpdx(positionW);let dp2=-dpdy(positionW);let duv1=dpdx(uv);let duv2=-dpdy(uv);let dp2perp=cross(dp2,N);let dp1perp=cross(N,dp1);var tangent=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent=dp2perp*duv1.y+dp1perp*duv2.y;let det=max(dot(tangent,tangent),dot(bitangent,bitangent));let invmax=select(inverseSqrt(det),0.0,det==0.0);let cotangentFrame=mat3x3<f32>(tangent*invmax,bitangent*invmax,N);return normalize(cotangentFrame*normalSample);}",N9="fn dither(seed:vec2<f32>,varianceAmount:f32)->f32{let rand=fract(sin(dot(seed,vec2<f32>(12.9898,78.233)))*43758.5453);let normVariance=varianceAmount/255.0;return mix(-normVariance,normVariance,rand);}",ET="fn dither(a:vec2<f32>,b:f32)->f32{return 0.0;}"})),j1A,ejA=b((()=>{j1A="struct a{viewProjection:mat4x4<f32>,view:mat4x4<f32>,vEyePosition:vec4<f32>,envRotationY:f32,_envPad0:f32,_envPad1:f32,_envPad2:f32,vSphericalL00:vec4<f32>,vSphericalL1_1:vec4<f32>,vSphericalL10:vec4<f32>,vSphericalL11:vec4<f32>,vSphericalL2_2:vec4<f32>,vSphericalL2_1:vec4<f32>,vSphericalL20:vec4<f32>,vSphericalL21:vec4<f32>,vSphericalL22:vec4<f32>,vImageInfos:vec4<f32>,vFogInfos:vec4<f32>,vFogColor:vec4<f32>,clipPlane:vec4<f32>}@group(0) @binding(0) var<uniform> scene:a;"})),lo,O1=b((()=>{ejA(),y9(),lo=j1A}));function E3(A,e,t){return A._device.createBindGroupLayout({label:e,entries:[{binding:0,visibility:t,buffer:{type:"uniform"}}]})}var c3=b((()=>{})),W1A=H({buildSolidSkyboxRenderable:()=>z1A});function tjA(A,e){const t=new CA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),g=new l1([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return{posBuffer:Ft(A,t,iA.VERTEX),idxBuffer:Ft(A,g,iA.INDEX)}}function gjA(){function A(e){const t=e._device;return iE&&F9===t||(iE=E3(e,"skybox-material",DA.VERTEX|DA.FRAGMENT)),iE}return{getPipeline(e,t){const g=e._device;F9!==g&&(b9.clear(),iE=null,F9=g);const I=ri(t),o=b9.get(I);if(o)return o;const C=g.createShaderModule({code:lo+aT,label:"skybox-vert"}),r=g.createShaderModule({code:N9+O1A,label:"skybox-frag"}),n=g.createRenderPipeline(IT({_label:"skybox-pipeline",_engine:e,_bgls:[oi(e),A(e)],_vertModule:C,_fragModule:r,_vertexBuffers:X1A,_format:t._colorFormat,_depthStencilFormat:t._depthStencilFormat,_depthCompare:t._depthCompare,_msaaSamples:t._sampleCount,_depthWriteEnabled:!1}));return b9.set(I,n),n},createBindGroup(e,t,g){return e._device.createBindGroup({layout:A(e),entries:[{binding:0,resource:{buffer:t}}]})}}}function z1A(A,e,t,g,I){const o=A.surface.engine,C=A.clearColor,r=tjA(o,t),n=gjA(),s=IjA(o,g,I,[C.r,C.g,C.b]),B=n.createBindGroup(o,s,e),Q={order:0,isTransparent:!1,bind(E,c){return{renderable:Q,pipeline:n.getPipeline(E,c),draw(l){return l.setBindGroup(1,B),l.setVertexBuffer(0,r.posBuffer),l.setIndexBuffer(r.idxBuffer,"uint16"),l.drawIndexed(36),1}}}};return o._dlr?.c(Q,z1A,A,e,t,g,I),Q}function IjA(A,e,t,g){const I=new CA(Z1A/4);return I[0]=I[5]=I[10]=I[15]=1,I[12]=e[0],I[13]=e[1],I[14]=e[2],I[16]=t[0],I[17]=t[1],I[18]=t[2],I[20]=g[0],I[21]=g[1],I[22]=g[2],Rg(A,I)}var Z1A,X1A,b9,iE,F9,$1A=b((()=>{VA(),ZA(),P1A(),AjA(),Ci(),ni(),G9(),O1(),qI(),gI(),c3(),Z1A=96,X1A=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],b9=new Map,iE=null,F9=null})),ACA,ijA=b((()=>{ACA="struct g{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:g;struct h{@location(0) position:vec3<f32>,@location(1) normal:vec3<f32>,@location(2) uv:vec2<f32>}struct e{@builtin(position) clipPos:vec4<f32>,@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@vertex fn main(c:h)->e{var a:e;let b=mesh.world;let d=b*vec4<f32>(c.position,1.0);a.vPositionW=d.xyz;a.clipPos=scene.viewProjection*d;let f=mat3x3<f32>(b[0].xyz,b[1].xyz,b[2].xyz);a.vNormalW=normalize(f*c.normal);a.vUV=c.uv;return a;}"})),eCA,ojA=b((()=>{eCA="struct o{world:mat4x4<f32>,primaryColor:vec3<f32>,alpha:f32,backgroundCenter:vec3<f32>,_pad:f32}@group(1) @binding(0) var<uniform> mesh:o;@group(1) @binding(1) var n:texture_2d<f32>;@group(1) @binding(2) var m:sampler;struct p{@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@fragment fn main(b:p)->@location(0) vec4<f32>{let g=normalize(b.vNormalW);let c=textureSample(n,m,b.vUV);let h=c.rgb;let f=max(h,vec3<f32>(0.0));let i=mesh.primaryColor;let j=f*i;var e=mesh.alpha*c.a;let k=dot(g,normalize(scene.vEyePosition.xyz-mesh.backgroundCenter));const l:f32=0.1;let d=clamp(k/l,0.0,1.0);e*=d*d;var a=vec4<f32>(j,e);if (scene.vImageInfos.w>=0.0){a=applyImageProcessing(a);}a=vec4<f32>(a.rgb*a.a,a.a);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.vPositionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"})),tCA=H({buildGroundRenderable:()=>gCA});async function gCA(A,e,t,g,I,o,C=!0){const r=CjA(C,lo+ICA+(C?N9:ET)+eCA),n=rjA(A,e),s=njA(A,t,g),B=(await sjA(A,I,o)).createView(),Q=$o(A),E=r.createBindGroup(A,s,B,Q),c={order:200,isTransparent:!0,bind(l,u){return{renderable:c,pipeline:r.getPipeline(l,u),draw(p){return p.setBindGroup(1,E),p.setVertexBuffer(0,n.posBuffer),p.setVertexBuffer(1,n.normBuffer),p.setVertexBuffer(2,n.uvBuffer),p.setIndexBuffer(n.idxBuffer,"uint16"),p.drawIndexed(6),1}}}};return A._dlr?.c(c,gCA,A,e,t,g,I,void 0,C),c}function CjA(A,e){function t(g){const I=g._device;return oE&&l3===I||(oE=I.createBindGroupLayout({label:"ground-material",entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}]}),l3=I),oE}return{getPipeline(g,I){const o=g._device;l3!==o&&(k9.clear(),oE=null,l3=o);const C=`${+A}|${ri(I)}`,r=k9.get(C);if(r)return r;const n=o.createShaderModule({code:lo+ACA,label:"ground-vert"}),s=o.createShaderModule({code:e,label:"ground-frag"}),B=o.createRenderPipeline({label:"ground-pipeline",layout:o.createPipelineLayout({bindGroupLayouts:[oi(g),t(g)]}),vertex:{module:n,entryPoint:"main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:12,attributes:[{shaderLocation:1,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:2,offset:0,format:"float32x2"}]}]},fragment:{module:s,entryPoint:"main",targets:[{format:I._colorFormat,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},depthStencil:{format:I._depthStencilFormat??"depth24plus-stencil8",depthCompare:I._depthCompare??"greater-equal",depthWriteEnabled:!1},multisample:{count:I._sampleCount},primitive:{topology:"triangle-list",cullMode:"back",frontFace:"ccw"}});return k9.set(C,B),B},createBindGroup(g,I,o,C){return g._device.createBindGroup({layout:t(g),entries:[{binding:0,resource:{buffer:I}},{binding:1,resource:o},{binding:2,resource:C}]})}}}function rjA(A,e){const t=e/2,g=new CA([-t,-t,0,t,-t,0,t,t,0,-t,t,0]),I=new CA([0,0,1,0,0,1,0,0,1,0,0,1]),o=new CA([0,0,1,0,1,1,0,1]),C=new l1([0,2,1,0,3,2]);return{posBuffer:Ft(A,g,iA.VERTEX),normBuffer:Ft(A,I,iA.VERTEX),uvBuffer:Ft(A,o,iA.VERTEX),idxBuffer:Ft(A,C,iA.INDEX)}}function njA(A,e,t){const g=new CA(iCA/4),I=2220446049250313e-31;return g[0]=g[15]=1,g[5]=g[10]=I,g[6]=-1,g[9]=1,g[12]=e[0],g[13]=e[1],g[14]=e[2],g[16]=t[0],g[17]=t[1],g[18]=t[2],g[19]=.9,g[20]=0,g[21]=0,g[22]=0,Rg(A,g)}async function sjA(A,e,t){const g=A._device;if(!e){const C=g.createTexture({size:[1,1],format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST});return g.queue.writeTexture({texture:C},new Te([255,255,255,255]),{bytesPerRow:4},[1,1]),C}const I=t?await t:await fetch(e).then(C=>C.blob()).then(C=>createImageBitmap(C,{premultiplyAlpha:"none"})),o=g.createTexture({size:[I.width,I.height],format:"rgba8unorm",usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});return g.queue.copyExternalImageToTexture({source:I},{texture:o},[I.width,I.height]),I.close(),o}var ICA,iCA,k9,oE,l3,oCA=b((()=>{VA(),ZA(),oo(),gI(),Ci(),ni(),ijA(),ojA(),qI(),O1(),G9(),it(),ICA="fn applyImageProcessing(result:vec4<f32>)->vec4<f32>{var rgb=result.rgb;rgb*=scene.vImageInfos.x;const tonemappingCalibration:f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb);rgb=pow(rgb,vec3<f32>(1.0/2.2));rgb=clamp(rgb,vec3<f32>(0.0),vec3<f32>(1.0));let highContrast=rgb*rgb*(3.0-2.0*rgb);if(scene.vImageInfos.y<1.0){rgb=mix(vec3<f32>(0.5),rgb,scene.vImageInfos.y);}else{rgb=mix(rgb,highContrast,scene.vImageInfos.y-1.0);}rgb=max(rgb,vec3<f32>(0.0));return vec4<f32>(rgb,result.a);}",iCA=96,k9=new Map,oE=null,l3=null}));function CCA(A,e){const t=new CA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),g=new l1([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return[Ft(A,t,iA.VERTEX),Ft(A,g,iA.INDEX)]}async function rCA(A,e,t){return await A._environmentSkyboxShaderComposer?.(e,t)??e}function nCA(A,e,t,g){const I={order:0,isTransparent:!1,bind(o,C){return{renderable:I,pipeline:A.getPipeline(o,C),draw(r){return r.setBindGroup(1,e),r.setVertexBuffer(0,t),r.setIndexBuffer(g,"uint16"),r.drawIndexed(36),1}}}};return I}function sCA(A,e,t){function g(I){const o=I._device;d3!==o&&(u3.clear(),p3.clear(),d3=o);const C=p3.get(A);if(C)return C;const r=o.createBindGroupLayout({label:`${A}-material`,entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}]});return p3.set(A,r),r}return{getPipeline(I,o){const C=I._device;d3!==C&&(u3.clear(),p3.clear(),d3=C);const r=`${t}|${ri(o)}`,n=u3.get(r);if(n)return n;const s=C.createShaderModule({code:e,label:`${A}-vert`}),B=C.createShaderModule({code:t,label:`${A}-frag`}),Q=C.createRenderPipeline(IT({_label:`${A}-pipeline`,_engine:I,_bgls:[oi(I),g(I)],_vertModule:s,_fragModule:B,_vertexBuffers:BCA,_format:o._colorFormat,_depthStencilFormat:o._depthStencilFormat,_depthCompare:o._depthCompare,_msaaSamples:o._sampleCount,_depthWriteEnabled:!1}));return u3.set(r,Q),Q},createBindGroup(I,o,C,r){return I._device.createBindGroup({layout:g(I),entries:[{binding:0,resource:{buffer:o}},{binding:1,resource:C},{binding:2,resource:r}]})}}}var BCA,u3,p3,d3,QCA=b((()=>{VA(),ZA(),Ci(),ni(),qI(),it(),BCA=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],u3=new Map,p3=new Map,d3=null})),aCA,BjA=b((()=>{aCA="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,1.0)).xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),ECA,QjA=b((()=>{ECA="struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,exposureLinear:f32,contrast:f32,_pad1:f32,_pad2:f32,_pad3:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var c:texture_cube<f32>;@group(1) @binding(2) var d:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:h)->@location(0) vec4<f32>{var e=normalize(b.positionUVW);var a=textureSampleLevel(c,d,e,0.0).rgb;a*=mesh.primaryColor;if (scene.vImageInfos.w>=0.0){a*=mesh.exposureLinear;a=1.0-exp2(-1.590579*a);a=pow(a,vec3<f32>(1.0/2.2));a=saturate(a);let f=a*a*(3.0-2.0*a);a=mix(a,f,mesh.contrast-1.0);a=a+vec3<f32>(dither(b.positionW.xy,0.5));a=max(a,vec3<f32>(0.0));}return vec4<f32>(a,1.0);}"})),ajA=H({buildDdsSkyboxRenderable:()=>cT});async function cT(A,e,t,g,I,o=!0){const C=A.surface.engine,[r,n]=CCA(C,e),{cubeView:s,sampler:B}=await cjA(C,I??lCA),Q=await rCA(A,ECA,"dds"),E=lo+(o?N9:ET)+Q,c=sCA(o?"skybox-dds":"skybox-dds0",lo+aCA,E),l=EjA(C,t,g,A.imageProcessing.exposure,A.imageProcessing.contrast),u=nCA(c,c.createBindGroup(C,l,s,B),r,n);return C._dlr?.c(u,cT,A,e,t,g,I,o),u}function EjA(A,e,t,g,I){const o=new CA(cCA/4);return o[0]=o[5]=o[10]=o[15]=1,o[12]=e[0],o[13]=e[1],o[14]=e[2],o[16]=t[0],o[17]=t[1],o[18]=t[2],o[19]=g,o[20]=I,Rg(A,o)}async function cjA(A,e){const t=A._device,g=await(await fetch(e)).arrayBuffer(),I=new Ho(g,0,32),o=I[3],C=Math.max(I[7],1),r=I[21]===808540228?148:128,n=new Te(g,r),s=t.createTexture({size:[o,o,6],format:"rgba16float",mipLevelCount:C,usage:_A.TEXTURE_BINDING|_A.COPY_DST|_A.RENDER_ATTACHMENT});let B=0;for(let Q=0;Q<6;Q++)for(let E=0;E<C;E++){const c=Math.max(o>>E,1);t.queue.writeTexture({texture:s,origin:{x:0,y:0,z:Q},mipLevel:E},n.buffer,{offset:n.byteOffset+B,bytesPerRow:c*8},{width:c,height:c}),B+=c*c*8}return{cubeView:s.createView({dimension:"cube"}),sampler:LI(A,{magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",maxAnisotropy:4})}}var cCA,lCA,uCA=b((()=>{VA(),ZA(),ki(),gI(),G9(),O1(),QCA(),BjA(),QjA(),cCA=96,lCA="https://assets.babylonjs.com/core/environments/backgroundSkybox.dds"})),pCA,ljA=b((()=>{pCA="struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32,exposureLinear:f32,contrast:f32,_pad3:f32,_pad4:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var b:texture_cube<f32>;@group(1) @binding(2) var c:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(d:h)->@location(0) vec4<f32>{var e=normalize(d.positionUVW);var a=textureSampleLevel(b,c,e,0.0).rgb;a*=mesh.exposureLinear;a=pow(a,vec3<f32>(1.0/2.2));a=clamp(a,vec3<f32>(0.0),vec3<f32>(1.0));let f=a*a*(3.0-2.0*a);if (mesh.contrast<1.0){a=mix(vec3<f32>(0.5),a,mesh.contrast);} else{a=mix(a,f,mesh.contrast-1.0);}a=max(a,vec3<f32>(0.0));return vec4<f32>(a,1.0);}"})),dCA=H({buildHdrSkyboxRenderable:()=>fCA});async function fCA(A,e,t,g,I){const o=A.surface.engine,[C,r]=CCA(o,t),n=await rCA(A,pCA,"hdr"),s=sCA("skybox-hdr",lo+aT,n),B=ujA(o,g,I,A.clearColor,A.imageProcessing.exposure,A.imageProcessing.contrast),Q=nCA(s,s.createBindGroup(o,B,e.specularCubeView,e.cubeSampler),C,r);return o._dlr?.c(Q,fCA,A,e,t,g,I),Q}function ujA(A,e,t,g,I,o){const C=new CA(DCA/4);return C[0]=C[5]=C[10]=C[15]=1,C[12]=e[0],C[13]=e[1],C[14]=e[2],C[16]=t[0],C[17]=t[1],C[18]=t[2],C[20]=g.r,C[21]=g.g,C[22]=g.b,C[24]=I,C[25]=o,Rg(A,C)}var DCA,_CA=b((()=>{VA(),QCA(),P1A(),ljA(),O1(),gI(),DCA=112}));async function pjA(A,e,t){const g=A.surface.engine,I=fetch(e).then(w=>w.arrayBuffer()),o=K9(t.brdfUrl),{faceBlobs:C,irradianceSH:r,width:n,mipCount:s}=F1A(await I),B=await Promise.all(C.map(w=>createImageBitmap(w,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),Q=await Promise.resolve().then(()=>(m9(),S9)),E=Q.uploadCubemapRGBD(g,B,n,s);for(const w of B)w.close();const c=await o,l=Q.decodeBrdfPng(g,c);c.close();const u=CE(E,l,r,.8,g);A._envTextures=u,IE(A),qo(E),qo(l),A._disposables.push(()=>{t1(E),t1(l)}),A.imageProcessing.toneMappingEnabled=!0,A.imageProcessing.exposure=.8,A.imageProcessing.contrast=1.2;const p=t?.groundTextureUrl,d=p?fetch(p).then(w=>w.blob()).then(w=>createImageBitmap(w,{premultiplyAlpha:"none"})):void 0,f=t?.skyboxUrl,D=f!=null&&f.toLowerCase().endsWith(".dds"),_=f!=null&&(f===e||f.toLowerCase().endsWith(".env")),y={skipSkybox:D||_||t?.skipSkybox,skipGround:t?.skipGround};return g._dlr?.e(A,e,t.brdfUrl),A._deferredBuilders.push(async()=>{const w=A.environmentPrimaryColor??[.08697355964132344,.08697355964132344,.2122208331110881],{groundSize:S,skyboxSize:R,rootPosition:M}=x1A(A,t?.skyboxSize),N=R/2;if(!y.skipSkybox){const G=await Promise.resolve().then(()=>($1A(),W1A));A._renderables.push(G.buildSolidSkyboxRenderable(A,u,N,M,w))}if(!y.skipGround){const G=await Promise.resolve().then(()=>(oCA(),tCA));A._renderables.push(await G.buildGroundRenderable(g,S,M,w,p,d))}if(D){const G=await Promise.resolve().then(()=>(uCA(),ajA));A._renderables.push(await G.buildDdsSkyboxRenderable(A,N,M,w,f))}if(_){const G=await Promise.resolve().then(()=>(_CA(),dCA));A._renderables.push(await G.buildHdrSkyboxRenderable(A,u,N,M,w))}}),u}function yCA(A){const e=.3333338747897695,t=.33333298856284405,g=1.4999984284682104,I=3.999982863580422,o=1.3333326611423701,C=.6666653397393608,r=1.999991431790211,n=new CA(36);for(let s=0;s<3;s++){const B=A[s],Q=A[3+s],E=A[6+s],c=A[9+s],l=A[12+s],u=A[15+s],p=A[18+s],d=A[21+s],f=A[24+s];n[s]=(c+l)*e+u*t,n[4+s]=Q*g,n[8+s]=E*g,n[12+s]=B*g,n[16+s]=f*I,n[20+s]=p*I,n[24+s]=u*o-(c+l)*C,n[28+s]=d*I,n[32+s]=(c-l)*r}return n}var lT=b((()=>{VA(),Br(),Bs(),f3(),K1A(),nT(),MQ()}));async function K9(A){const e=await fetch(A);if(e.ok)try{return await createImageBitmap(await e.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"})}catch{}throw new Error(`BRDF LUT '${A}' is not an image (${e.status} ${e.headers.get("content-type")??""}).`)}function CE(A,e,t,g,I,o){return{specularCube:A,specularCubeView:A.createView({dimension:"cube"}),brdfLut:e,brdfLutView:e.createView(),cubeSampler:B9(I),brdfSampler:$o(I),irradianceSH:t,sphericalHarmonics:o??yCA(t),lodGenerationScale:g}}var f3=b((()=>{lT(),oo()}));function hCA(A){const e=1/Math.PI,t=new CA(27);for(let g=0;g<3;g++){const I=g*9,o=A[I],C=A[I+1],r=A[I+2],n=A[I+3],s=A[I+4],B=A[I+5],Q=A[I+6],E=A[I+7],c=A[I+8];t[0+g]=n*1.02333*e,t[3+g]=C*1.02333*e,t[6+g]=r*1.02333*e,t[9+g]=(o*.886227-Q*.247708+c*.429043)*e,t[12+g]=(o*.886227-Q*.247708-c*.429043)*e,t[15+g]=(o*.886227+Q*.495417)*e,t[18+g]=B*.858086*e,t[21+g]=E*.858086*e,t[24+g]=s*.858086*e}return t}var wCA=b((()=>{VA()})),djA=H({computeSHFromEquirect:()=>RCA,parseRGBE:()=>SCA});function SCA(A){const e=new Te(A);let t=0;function g(){let Q="";for(;t<e.length;){const E=e[t++];if(E===10)break;E!==13&&(Q+=String.fromCharCode(E))}return Q}g().startsWith("#?")||m(235);let I="";for(;t<e.length;){const Q=g();if(Q==="")break;Q.startsWith("FORMAT=")&&(I=Q.slice(7))}I&&I!=="32-bit_rle_rgbe"&&m(236,I);const o=g(),C=o.match(/-Y\s+(\d+)\s+\+X\s+(\d+)/);C||m(237,o);const r=parseInt(C[1],10),n=parseInt(C[2],10),s=new CA(n*r*3),B=new Te(n*4);for(let Q=0;Q<r;Q++)t=fjA(e,t,n,s,Q*n*3,B);return{width:n,height:r,data:s}}function fjA(A,e,t,g,I,o){if(t>=8&&t<=32767&&A[e]===2&&A[e+1]===2&&(A[e+2]&128)===0){(A[e+2]<<8)+A[e+3]!==t&&m(238),e+=4;for(let C=0;C<4;C++){let r=C,n=0;for(;n<t;){e>=A.length&&m(239);const s=A[e++];if(s===0&&m(240),s>128){const B=s-128;(B>t-n||e>=A.length)&&m(241);const Q=A[e++];for(let E=0;E<B;E++)o[r]=Q,r+=4;n+=B}else{(s>t-n||e+s>A.length)&&m(242);for(let B=0;B<s;B++)o[r]=A[e++],r+=4;n+=s}}}for(let C=0;C<t;C++)MCA(o[C*4],o[C*4+1],o[C*4+2],o[C*4+3],g,I+C*3)}else{e+t*4>A.length&&m(243);for(let C=0;C<t;C++)MCA(A[e],A[e+1],A[e+2],A[e+3],g,I+C*3),e+=4}return e}function MCA(A,e,t,g,I,o){if(g===0)I[o]=I[o+1]=I[o+2]=0;else{const C=Math.pow(2,g-136);I[o]=A*C,I[o+1]=e*C,I[o+2]=t*C}}function RCA(A,e,t){const g=.282094791773878,I=.48860251190292,o=1.092548430592079,C=.31539156525252,r=.54627421529604,n=new Zo(27);let s=0;for(let E=0;E<t;E++){const c=(E+.5)/t*Math.PI,l=Math.sin(c),u=Math.cos(c),p=l*(Math.PI/t)*(2*Math.PI/e);for(let d=0;d<e;d++){const f=(2*(d+.5)/e-1)*Math.PI,D=l*Math.sin(f),_=u,y=l*Math.cos(f),w=(E*e+d)*3;let S=A[w],R=A[w+1],M=A[w+2];const N=Math.max(S,R,M);if(N>4096){const F=4096/N;S*=F,R*=F,M*=F}const G=p;s+=G;const K=[g,I*_,I*y,I*D,o*D*_,o*_*y,C*(3*y*y-1),o*D*y,r*(D*D-_*_)];for(let F=0;F<9;F++){const v=K[F]*G;n[F]=n[F]+S*v,n[9+F]=n[9+F]+R*v,n[18+F]=n[18+F]+M*v}}}const B=4*Math.PI/s;for(let E=0;E<27;E++)n[E]=n[E]*B;const Q=[1,2/3,2/3,2/3,.25,.25,.25,.25,.25];for(let E=0;E<3;E++)for(let c=0;c<9;c++)n[E*9+c]=n[E*9+c]*Q[c];return hCA(n)}var mCA=b((()=>{rA(),VA(),wCA()})),NCA,DjA=b((()=>{NCA="struct t{faceSize:u32,equirectWidth:u32,equirectHeight:u32,_pad:u32}@group(0) @binding(0) var p:texture_2d<f32>;@group(0) @binding(1) var k:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(2) var<uniform> params:t;const i=3.14159265359;const d=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) a:vec3u){let h=a.z;let c=params.faceSize;if (a.x>=c||a.y>=c||h>=6u){return;}let f=f32(a.x)/f32(c);let e=f32(a.y)/f32(c);let b=h*4u;let g=normalize(d[b]*(1.0-f)*(1.0-e)+d[b+1u]*f*(1.0-e)+d[b+2u]*(1.0-f)*e+d[b+3u]*f*e);let l=atan2(g.z,g.x);let m=acos(clamp(g.y,-1.0,1.0));let n=l/i*0.5+0.5;let o=m/i;let j=clamp(i32(round(n*f32(params.equirectWidth))),0,i32(params.equirectWidth)-1);let q=clamp(i32(round(o*f32(params.equirectHeight))),0,i32(params.equirectHeight)-1);let r=i32(params.equirectHeight)-q-1;let s=textureLoad(p,vec2<i32>(j,r),0);textureStore(k,vec2<i32>(a.xy),i32(h),vec4<f32>(s.rgb,1.0));}"})),GCA,_jA=b((()=>{GCA="struct ha{faceSize:u32,mipLevel:u32,totalMips:u32,srcSize:u32}@group(0) @binding(0) var x:texture_cube<f32>;@group(0) @binding(1) var F:sampler;@group(0) @binding(2) var z:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(3) var<uniform> params:ha;const k=3.14159265359;const n=1024u;const g=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));fn I(ca:u32,j:f32,d:f32)->vec3<f32>{let i=ca*4u;return normalize(g[i]*(1.0-j)*(1.0-d)+g[i+1u]*j*(1.0-d)+g[i+2u]*(1.0-j)*d+g[i+3u]*j*d);}fn J(ba:u32)->f32{var a=ba;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn K(aa:f32,C:f32,s:f32)->vec3<f32>{let Z=s*s;let u=2.0*k*aa;let o=sqrt((1.0-C)/(1.0+(Z-1.0)*C));let w=sqrt(1.0-o*o);return vec3<f32>(cos(u)*w,sin(u)*w,o);}fn L(y:f32,t:f32)->f32{let A=y*y*(t-1.0)+1.0;return t/(k*A*A);}fn H(Y:u32,M:f32,S:f32)->vec3<f32>{return I(Y,M,S);}@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) c:vec3u){let f=c.z;let h=params.faceSize>>params.mipLevel;if (c.x>=h||c.y>=h||f>=6u){return;}let R=f32(c.x)/f32(h);let Q=f32(c.y)/f32(h);let b=normalize(H(f,R,Q));let q=pow(2.0,f32(params.mipLevel)/0.8)/f32(params.srcSize);if (params.mipLevel==0u){let O=textureSampleLevel(x,F,b,0.0);textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(O.rgb,1.0));return;}var X=select(vec3<f32>(1.0,0.0,0.0),vec3<f32>(0.0,0.0,1.0),abs(b.z)<0.999);let v=normalize(cross(X,b));let P=cross(b,v);var p=vec3<f32>(0.0);var m=0.0;let E=f32(params.srcSize);let T=4.0*k/(6.0*E*E);let U=f32(params.totalMips)-1.0;for(var e=0u;e<n;e++){let W=f32(e)/f32(n);let N=J(e);let r=K(W,N,q);let B=v*r.x+P*r.y+b*r.z;let D=max(dot(b,B),0.0);let G=2.0*D*B-b;let l=dot(b,G);if (l>0.0){let da=q*q;let ea=L(D,da)/4.0;let fa=1.0/(f32(n)*max(ea,0.0001));let ga=clamp(0.5*log2(fa/T)+1.0,0.0,U);let V=textureSampleLevel(x,F,G,ga);p+=V.rgb*l;m+=l;}}if (m>0.0){p/=m;}textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(p,1.0));}"})),uT,bCA=b((()=>{uT="@group(0) @binding(0) var z:texture_storage_2d<rgba16float,write>;fn x(G:u32)->f32{var a=G;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn w(B:f32,u:f32,J:f32)->vec3f{let t=2.0*3.14159265359*B;let k=sqrt((1.0-u)/(1.0+(J-1.0)*u));let q=sqrt(1.0-k*k);return vec3f(cos(t)*q,sin(t)*q,k);}fn y(b:f32,n:f32)->vec2f{let o=vec3f(sqrt(1.0-b*b),0.0,b);let p=n*n;let e=p*p;var r=0.0;var l=0.0;let g=1024u;for(var f=0u;f<g;f++){let F=f32(f)/f32(g);let E=x(f);let j=w(F,E,e);let i=max(dot(o,j),0.0);let A=2.0*i*j-o;let d=max(A.z,0.0);let s=max(j.z,0.0);if (d>0.0&&s>0.0){let C=d*sqrt(b*b*(1.0-e)+e);let D=b*sqrt(d*d*(1.0-e)+e);let v=(0.5/max(C+D,1e-6))*d*(4.0*i/s);let m=pow(1.0-i,5.0);r+=(1.0-m)*v;l+=m*v;}}return vec2f(r/f32(g),l/f32(g));}@compute @workgroup_size(8,8) fn main(@builtin(global_invocation_id) c:vec3u){if (c.x>=256u||c.y>=256u){return;}let H=max((f32(c.x)+0.5)/256.0,0.001);let I=max((f32(c.y)+0.5)/256.0,0.04);let h=y(H,I);textureStore(z,vec2u(c.x,c.y),vec4f(h.y,h.x+h.y,0.0,1.0));}"})),yjA=H({HDR_LOD_GENERATION_SCALE:()=>pT,_enableHdrEnvironmentCopySource:()=>FCA,equirectToCubemapGPU:()=>kCA,generateBrdfLut:()=>vCA,prefilterCubemapGPU:()=>KCA});function FCA(){dT=_A.COPY_SRC}function kCA(A,e,t){const g=A._device,I=g.createTexture({size:[e.width,e.height],format:"rgba32float",usage:_A.TEXTURE_BINDING|_A.COPY_DST});{const E=new CA(e.width*e.height*4);for(let c=0;c<e.width*e.height;c++)E[c*4]=e.data[c*3],E[c*4+1]=e.data[c*3+1],E[c*4+2]=e.data[c*3+2],E[c*4+3]=1;g.queue.writeTexture({texture:I},E.buffer,{bytesPerRow:e.width*16},{width:e.width,height:e.height})}const o=g.createTexture({size:[t,t,6],format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING|_A.COPY_SRC,dimension:"2d"}),C=g.createShaderModule({code:NCA}),r=g.createComputePipeline({layout:"auto",compute:{module:C,entryPoint:"main"}}),n=Rg(A,new gt([t,e.width,e.height,0])),s=g.createBindGroup({layout:r.getBindGroupLayout(0),entries:[{binding:0,resource:I.createView()},{binding:1,resource:o.createView()},{binding:2,resource:{buffer:n}}]}),B=g.createCommandEncoder(),Q=B.beginComputePass();return Q.setPipeline(r),Q.setBindGroup(0,s),Q.dispatchWorkgroups(Math.ceil(t/8),Math.ceil(t/8),6),Q.end(),g.queue.submit([B.finish()]),I.destroy(),n.destroy(),o}function KCA(A,e,t,g){const I=A._device,o=I.createTexture({size:{width:t,height:t,depthOrArrayLayers:6},mipLevelCount:g,format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING|_A.COPY_DST|dT}),C=e.createView({dimension:"cube"}),r=$o(A),n=I.createComputePipeline({layout:"auto",compute:{module:I.createShaderModule({code:GCA}),entryPoint:"main"}}),s=XI(A,16);{const B=I.createCommandEncoder();B.copyTextureToTexture({texture:e},{texture:o,mipLevel:0},{width:t,height:t,depthOrArrayLayers:6}),I.queue.submit([B.finish()])}for(let B=1;B<g;B++){const Q=t>>B;if(Q<1)break;I.queue.writeBuffer(s,0,new gt([t,B,g,t]));const E=o.createView({baseMipLevel:B,mipLevelCount:1}),c=I.createBindGroup({layout:n.getBindGroupLayout(0),entries:[{binding:0,resource:C},{binding:1,resource:r},{binding:2,resource:E},{binding:3,resource:{buffer:s}}]}),l=I.createCommandEncoder(),u=l.beginComputePass();u.setPipeline(n),u.setBindGroup(0,c),u.dispatchWorkgroups(Math.ceil(Q/8),Math.ceil(Q/8),6),u.end(),I.queue.submit([l.finish()])}return e.destroy(),s.destroy(),o}function vCA(A){const e=A._device;(!D3||fT!==e)&&(D3=e.createComputePipeline({layout:"auto",compute:{module:e.createShaderModule({code:uT}),entryPoint:"main"}}),fT=e);const t=256,g=e.createTexture({size:{width:t,height:t},format:"rgba16float",usage:_A.TEXTURE_BINDING|_A.STORAGE_BINDING}),I=e.createBindGroup({layout:D3.getBindGroupLayout(0),entries:[{binding:0,resource:g.createView()}]}),o=e.createCommandEncoder(),C=o.beginComputePass();return C.setPipeline(D3),C.setBindGroup(0,I),C.dispatchWorkgroups(Math.ceil(t/8),Math.ceil(t/8)),C.end(),e.queue.submit([o.finish()]),g}var pT,dT,D3,fT,DT=b((()=>{VA(),ZA(),oo(),gI(),co(),DjA(),_jA(),bCA(),pT=.8,dT=0,D3=null,fT=null})),hjA=H({rebuildSceneEnvironment:()=>wjA});async function wjA(A,e){const t=e._envTextures;if(!t)return;const g=e._envRecoverySource;g||m(198);const I=t.sphericalHarmonics;e._envTextures=void 0;let o;if(g.kind==="env")o=await SjA(A,g,I);else{const n=await Promise.resolve().then(()=>(mCA(),djA)),s=await Promise.resolve().then(()=>(DT(),yjA)),B=await UCA(g.url),Q=n.parseRGBE(B),E=n.computeSHFromEquirect(Q.data,Q.width,Q.height),c=s.equirectToCubemapGPU(A,Q,g.faceSize);o=CE(s.prefilterCubemapGPU(A,c,g.faceSize,Math.floor(Math.log2(g.faceSize))+1),s.generateBrdfLut(A),E,s.HDR_LOD_GENERATION_SCALE,A,I)}Object.assign(t,o);const{specularCube:C,brdfLut:r}=t;qo(C),qo(r),e._disposables.push(()=>{t1(C),t1(r)}),e._envTextures=t,e._envRecoverySource=g}async function SjA(A,e,t){const g=K9(e.brdfUrl);g.catch(()=>{});const{faceBlobs:I,irradianceSH:o,width:C,mipCount:r}=F1A(await UCA(e.url)),n=await Promise.all(I.map(c=>createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),s=await Promise.resolve().then(()=>(m9(),S9)),B=s.uploadCubemapRGBD(A,n,C,r);for(const c of n)c.close();const Q=await g,E=s.decodeBrdfPng(A,Q);return Q.close(),CE(B,E,o,.8,A,t)}async function UCA(A){const e=await fetch(A);return e.ok||m(199,A,e.status,e.statusText),e.arrayBuffer()}var MjA=b((()=>{rA(),Br(),Bs(),f3(),K1A()}));function Cg(A,e,t=0,g=0){const I=e;if(g===0&&I.length===16){A.set(I,t);return}const o=g,C=t;A[C+0]=I[o+0],A[C+1]=I[o+1],A[C+2]=I[o+2],A[C+3]=I[o+3],A[C+4]=I[o+4],A[C+5]=I[o+5],A[C+6]=I[o+6],A[C+7]=I[o+7],A[C+8]=I[o+8],A[C+9]=I[o+9],A[C+10]=I[o+10],A[C+11]=I[o+11],A[C+12]=I[o+12],A[C+13]=I[o+13],A[C+14]=I[o+14],A[C+15]=I[o+15]}var Hi=b((()=>{}));function _T(A,e){Cg(A,e._lightMatrix,0),A[16]=e._depthValues[0],A[17]=e._depthValues[1],A[18]=0,A[19]=0,A[20]=e._shadowsInfo[0],A[21]=e._shadowsInfo[1],A[22]=e._shadowsInfo[2],A[23]=e._shadowsInfo[3]}function LCA(A,e,t,g,I,o){const C=Math.sqrt(A*A+e*e+t*t)||1,r=A/C,n=e/C,s=t/C;let B=0,Q=1,E=0;Math.abs(n)>.99&&(B=0,Q=0,E=1);let c=Q*s-E*n,l=E*r-B*s,u=B*n-Q*r;const p=Math.sqrt(c*c+l*l+u*u)||1;c/=p,l/=p,u/=p;const d=n*u-s*l,f=s*c-r*u,D=r*l-n*c;return new CA([c,d,r,0,l,f,n,0,u,D,s,0,-(c*g+l*I+u*o),-(d*g+f*I+D*o),-(r*g+n*I+s*o),1])}function YCA(A,e){const t=new CA(16);for(let g=0;g<4;g++)for(let I=0;I<4;I++){let o=0;for(let C=0;C<4;C++)o+=A[g+C*4]*e[C+I*4];t[g+I*4]=o}return t}function xCA(A,e,t,g,I=0,o=0,C=0){const r=A.worldMatrix,n=A.direction,s=LCA(r[0]*n.x+r[4]*n.y+r[8]*n.z,r[1]*n.x+r[5]*n.y+r[9]*n.z,r[2]*n.x+r[6]*n.y+r[10]*n.z,r[12]-I,r[13]-o,r[14]-C);let B=1/0,Q=-1/0,E=1/0,c=-1/0;for(const d of e){const f=d.worldMatrix,D=d.boundMin??[-.5,-.5,-.5],_=d.boundMax??[.5,.5,.5];for(let y=0;y<8;y++){const w=y&1?_[0]:D[0],S=y&2?_[1]:D[1],R=y&4?_[2]:D[2],M=f[0]*w+f[4]*S+f[8]*R+f[12]-I,N=f[1]*w+f[5]*S+f[9]*R+f[13]-o,G=f[2]*w+f[6]*S+f[10]*R+f[14]-C,K=s[0]*M+s[4]*N+s[8]*G+s[12],F=s[1]*M+s[5]*N+s[9]*G+s[13];B=Math.min(B,K),Q=Math.max(Q,K),E=Math.min(E,F),c=Math.max(c,F)}}Number.isFinite(B)||(B=-1,Q=1,E=-1,c=1);const l=(Q-B)*.1,u=(c-E)*.1;B-=l,Q+=l,E-=u,c+=u;const p=new CA(16);return p[0]=2/(Q-B),p[5]=2/(c-E),p[10]=1/(g-t),p[12]=-(Q+B)/(Q-B),p[13]=-(c+E)/(c-E),p[14]=-t/(g-t),p[15]=1,{_view:s,_viewProj:YCA(p,s),_near:t,_far:g}}function _3(A,e,t){const g=new CA(8);return g[0]=e,g[2]=t,g[4]=0,g[5]=1,Rg(A,g)}function JCA(A,e=null,t=A._depthTexture){const g=A._config._mapSize;return{_descriptor:{size:{width:g,height:g},format:e?"rgba16float":void 0,dFormat:"depth32float",depthClearValue:1,depthCompare:"less-equal",samples:1},_colorTexture:e,_colorView:e?.createView()??null,_depthTexture:t,_depthView:t.createView(),_width:g,_height:g,_eager:!0,_ownsDepthTexture:!1}}function yT(A,e,t,g){const I=new CA(24);return _T(I,{_lightMatrix:e,_depthValues:t,_shadowsInfo:g}),{ubo:Rg(A,I),data:I}}function hT(A){let e=0;for(const t of A)e+=t.worldMatrixVersion+~~t.thinInstances?._version;return e}function v9(A){return{fov:1,nearPlane:1,farPlane:1,children:[],_viewCache:bg(),_projCache:bg(),_vpCache:bg(),get worldMatrix(){return A._light.worldMatrix},get worldMatrixVersion(){return this._shadowCameraVersion??A._light._lightVersion}}}function U9(A,e,t,g,I,o){A.nearPlane=t,A.farPlane=g,A._shadowCameraVersion=e,A._viewCache=I,A._viewVer=e,A._vpCache=o,A._vpVer=p1(A),A._vpAspect=1}var Qs=b((()=>{VA(),it(),Mg(),gI(),Hi(),Ii()}));function HCA(A,e,t,g,I){A.fill(0);const o=io(g,I),C=Io(g),r=g.worldMatrix;Cg(A,o,0),Cg(A,C,16),e.useFloatingOrigin?(A[32]=0,A[33]=0,A[34]=0):(A[32]=r[12],A[33]=r[13],A[34]=r[14]),A[87]=e.canvas.width;const n=t.imageProcessing;A[76]=n.exposure,A[77]=n.contrast,A[78]=t._envTextures?.lodGenerationScale??.8,A[79]=+n.toneMappingEnabled,A[37]=e.canvas.height}var TCA=b((()=>{Mg(),Hi()}));function RjA(A){d1=A}var d1,wT=b((()=>{d1=null}));function qCA(A,e){return{_renderables:A,_opaqueBindings:[],_directBindings:[],_transparentBindings:[],_ob:[],_lastVersion:e}}function ST(A,e,t){A.clr??=!0;const g=A.rt._descriptor,I=A.depth?._descriptor,o={_colorFormat:g.format,_depthStencilFormat:I?.dFormat??g.dFormat,_depthCompare:g.depthCompare??I?.depthCompare,_sampleCount:g.samples},C={loadOp:"clear",storeOp:"store"},r={targetWidth:0,targetHeight:0},n={...qCA([],-1),name:A.name,_config:A,_ownsTargets:!A.sharedRt,engine:e,scene:t,_passes:[],_renderPassDescriptor:{colorAttachments:[C]},_colorAttachment:C,_sceneUBO:XI(e,368),_suData:new CA(92),_sceneUboCacheKey:[],_targetSignature:o,_updateContext:r,record(){if(n._disposed)throw new Error("RenderTask has been disposed.");n._recordExplicit?n._recordExplicit(n,!0):L9(n,A.autoMirror!==!1?t._renderables.slice():n._renderables,!0)},execute(){return FjA(n,e,o)},dispose(){if(n._disposed)return;n._disposed=!0,d1&&d1._retire([n._opaqueBindings,n._directBindings,n._transparentBindings]);const s=n._pendingMeshes;s&&(s.length=0);for(const Q of n._renderables)n._retireRenderable?.(n.engine,Q);n._passes.length=n._opaqueBindings.length=n._directBindings.length=0,n._transparentBindings.length=n._renderables.length=n._ob.length=0,n._ownsTargets&&(Bg(A.rt),Bg(A.rst)),A.depth?._eager||Bg(A.depth);const B=n._sceneUBO;ag(n.engine,()=>B.destroy()),n._batchState?._release(n.engine),n._batchState=void 0}};return n}function PCA(A,e){if(!A._renderables)return;A._removeMesh?.(e);let t=!1;for(let g=A._renderables.length-1;g>=0;g--)A._renderables[g].mesh===e&&(A._retireRenderable?.(A.engine,A._renderables[g]),A._renderables.splice(g,1),t=!0);for(const g of[A._opaqueBindings,A._directBindings,A._transparentBindings])for(let I=g.length-1;I>=0;I--)g[I].renderable.mesh===e&&(d1&&d1._retire([[g[I]]]),g.splice(I,1),t=!0);if(t){const g=A._batchState;A._batchState=g?._select([A._opaqueBindings,A._directBindings,A._transparentBindings]),g?._release(A.engine,[A._batchState]),A._ob.length=0,A._lastVersion=-1}}function mjA(A,e){return e._sortDistance-A._sortDistance||A.renderable.order-e.renderable.order}function OCA(A,e){return A.renderable.order-e.renderable.order}function NjA(A,e){const t=A._transparentBindings;if(t.length<=1||!e)return;const g=Io(e);for(const I of t){const o=I.renderable._worldCenter;I._sortDistance=o?o[0]*g[2]+o[1]*g[6]+o[2]*g[10]+g[14]:0}t.sort(mjA)}function L9(A,e=A._renderables,t=!1,g=!0,I){const o=A._config,C=o.rt,r=A._batchState,n=qCA(e,A.scene._renderableVersion);if(t){const E=(c,l)=>{c&&(l||A._ownsTargets||c._eager)&&sI(c,A.engine)};E(C),C._descriptor.samples>1&&E(o.rst),E(o.depth,!0)}const{_opaqueBindings:s,_directBindings:B,_transparentBindings:Q}=n;try{for(const E of e){const c=E.bind(A.engine,A._targetSignature);n._batchState=A._targetSignature._collectBatches?.(n._batchState,c),E.isTransparent||E._transmissive?Q.push(c):E._direct?B.push(c):s.push(c)}s.sort(OCA),B.sort(OCA),t&&VCA(A,A.engine,!1)}catch(E){throw d1&&d1._retire([n._opaqueBindings,n._directBindings,n._transparentBindings],[A._opaqueBindings,A._directBindings,A._transparentBindings]),n._batchState?._release(void 0,I??[r]),E}return t&&(GjA(A,C),A._updateContext.targetWidth=C._width,A._updateContext.targetHeight=C._height),g&&(d1&&d1._retire([A._opaqueBindings,A._directBindings,A._transparentBindings],[s,B,Q]),Object.assign(A,n),r?._release(A.engine,[n._batchState])),n}function GjA(A,e){const t=A._config,g=A._colorAttachment;g.view=e._colorView,A._renderPassDescriptor.colorAttachments=e._colorView?[g]:[];const I=t.depth??e,o=I._depthView;let C;if(o){const r=I._descriptor,n=(t.depth?I._eager:t.depthClear===!1)?"load":"clear";C={view:o,depthClearValue:r.depthClearValue??0,depthLoadOp:n,depthStoreOp:"store"},r.dFormat?.includes("stencil")&&(C.stencilClearValue=0,C.stencilLoadOp=n,C.stencilStoreOp="store")}A._renderPassDescriptor.depthStencilAttachment=C}function bjA(A,e,t){const g=A.scene;A._config.autoMirror!==!1&&A._lastVersion!==g._renderableVersion&&L9(A,g._renderables.slice()),VCA(A,e);const I=A._updateContext,o=A._config.cam??g.camera;t._colorFormat&&(A._config._skipClusteredLights||g._clusteredLightUpdater?.(o,I.targetWidth,I.targetHeight),TVA(e,g)),KjA(A,e,g,o),I._camera=o,A._batchState?._reset(),MT(A._opaqueBindings,I),MT(A._directBindings,I),MT(A._transparentBindings,I),A._batchState?._flush(e),NjA(A,o)}function FjA(A,e,t){if(A.enabled===!1)return 0;const g=A.scene;bjA(A,e,t);const I=A._colorAttachment,o=A._config;if(o.rt._colorView&&(o.rt===g.surface.scRT&&(I.view=o.rt._colorView),I.resolveTarget=o.rst?._colorView??void 0,I.clearValue=o.clrColor??g.clearColor,I.loadOp=o.clr?"clear":"load"),A._executeWithTransmission)return A._executeWithTransmission(t._sampleCount);const C=e._currentEncoder.beginRenderPass(A._renderPassDescriptor),r=kjA(A,C);return C.end(),r}function kjA(A,e){const t=A.engine,g=A._config,I=g.rt,o=A.scene,C=A._opaqueBindings,r=A._ob,n=A._sceneBG;if(n1A(e,g.cam??o.camera,I._width,I._height),e.setBindGroup(0,n),A._lastVis!==_Q||!r.length){const B=I._descriptor,Q=t._device.createRenderBundleEncoder({colorFormats:B.format?[B.format]:[],depthStencilFormat:A._targetSignature._depthStencilFormat,sampleCount:B.samples});Q.setBindGroup(0,n),rE(Q,C,t),r[0]=Q.finish(),A._lastVis=_Q}let s=C.length;return e.executeBundles(r),e.setBindGroup(0,n),s+=rE(e,A._directBindings,t),s+=rE(e,A._transparentBindings,t,!0),s}function VCA(A,e,t=!0){const g=_9(e,A.scene)._buffer;if(g===A._lightsUBO)return;const I=e._device.createBindGroup({layout:oi(e),entries:[{binding:0,resource:{buffer:A._sceneUBO}},{binding:1,resource:{buffer:g}}]});A._lightsUBO=g,A._sceneBG=I,t&&(A._ob=[])}function KjA(A,e,t,g){if(!g)return;const I=g.viewport,o=A._config.rt,C=(A._config.cs?e.canvas.width/e.canvas.height:o._width/o._height)*(I?I.width/I.height:1);d1&&d1._setProjectionAspect(A._updateContext,C);const r=t.fog,n=t.imageProcessing,s=p1(g),B=t._envTextures,Q=A._sceneUboCacheKey;if(Q[0]===g&&Q[1]===r&&Q[2]===s&&Q[3]===C&&Q[4]===n.exposure&&Q[5]===n.contrast&&Q[6]===B)return;Q[0]=g,Q[1]=r,Q[2]=s,Q[3]=C,Q[4]=n.exposure,Q[5]=n.contrast,Q[6]=B;const E=A._suData;HCA(E,e,t,g,C);const c=t._sceneUboContributors;if(c)for(const l of c)l(E,t);e._device.queue.writeBuffer(A._sceneUBO,0,E)}function MT(A,e){for(const t of A)t.update?.(e)}function rE(A,e,t,g){let I=null,o=0;for(const C of e){const r=C.renderable.mesh;r&&(r.visible===!1||g&&r._skipColorDraw)||(C.pipeline!==I&&(A.setPipeline(C.pipeline),I=C.pipeline),o+=C.draw(A,t))}return o}var nE=b((()=>{VA(),hI(),kg(),Fg(),Mg(),Ci(),TCA(),co(),y9(),rT(),wT()}));function RT(A,e){const t=A._groups.get(e);return t?t.r:e._sceneIndependentRebuild?e._rebuildSingle:void 0}var mT=b((()=>{}));function NT(A,e=[]){for(const{mesh:t,material:g}of A._pendingMeshes){if(!g)continue;const I={_lifetimeDisposers:[]},o=RT(A.scene,g._buildGroup);o||m(156),e.push(I);const C=o(A.scene,t,g,I);C._lifetimeDisposers=I._lifetimeDisposers,A._renderables.push(C)}return A._pendingMeshes.length=0,e}function vjA(A){const e=[],t={scene:A.scene,_renderables:A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()},g=()=>{for(const I of e)oC(I._lifetimeDisposers);e.length=0};try{A._prepareTaskMeshes?.(t),NT(t,e)}catch(I){throw g(),I}return{renderables:t._renderables,dispose:g}}function jCA(A,e=!1){A._disposed&&m(157);const t=A._batchState,g=[],I=A._pendingMeshes.length>0,o=A._config.autoMirror!==!1,C={scene:A.scene,_renderables:o?I?[]:A.scene._renderables.slice():A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()};let r;try{A._prepareTaskMeshes?.(C,!0),NT(C,g),r=L9(A,C._renderables,e,!1)}catch(n){for(const s of g)oC(s._lifetimeDisposers);throw n}I&&(A._config.autoMirror=!1),A._pendingMeshes=C._pendingMeshes,d1&&d1._retire([A._opaqueBindings,A._directBindings,A._transparentBindings],[r._opaqueBindings,r._directBindings,r._transparentBindings]),Object.assign(A,r),t?._release(A.engine,[r._batchState])}var WCA=b((()=>{rA(),kg(),mT(),nE(),wT()}));function sE(A,e,t){return ST(A,e,t)}function y3(A,e,t){h3(A),A._addMesh(e,t)}function h3(A){A._addMesh||(A._pendingMeshes??=[],A._addMesh=LjA,A._recordExplicit=jCA,A._retireRenderable=UjA)}function UjA(A,e){e._lifetimeDisposers&&XoA(A,e._lifetimeDisposers)}function LjA(A,e){if(this._disposed)throw new Error("RenderTask has been disposed.");const t=e?.material??A.material;t&&(this._pendingMeshes.push({mesh:A,material:t}),this._sceneBG&&GT(this))}function YjA(A,e){const t=A._pendingMeshes;if(t)for(let g=t.length-1;g>=0;g--)t[g].mesh===e&&t.splice(g,1);PCA(A,e)}function GT(A){jCA(A)}var BE=b((()=>{kg(),nE(),WCA()})),zCA,xjA=b((()=>{zCA="struct c{@builtin(position) clipPos:vec4<f32>,@location(0) sampleCenter:vec2<f32>}@vertex fn main(@builtin(vertex_index) d:u32)->c{var e=array<vec2<f32>,3>(vec2<f32>(-1.0,-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));var a:c;let b=e[d];a.clipPos=vec4<f32>(b,0.0,1.0);a.sampleCenter=b*vec2<f32>(0.5,-0.5)+0.5;return a;}"}));function rC(A,e){const t=si(A);return Object.create(t,{source:{value:t,enumerable:!0},_renderFeatures:{value:{features:e.features,features2:e.features2},writable:!0,enumerable:!0,configurable:!0}})}function Y9(A){const e=A;return!!e.source&&!!e._renderFeatures}function si(A){return Y9(A)?A.source:A}var wI=b((()=>{}));function JjA(){JT=A=>A}function HjA(A){S3=A}function Po(A){(T9??=new Map).set(A._id,A),M3=null}function ZCA(){return T9??=new Map}function w3(){if(!M3){const A=T9;M3=A?Array.from(A.values()).sort((e,t)=>e._id.localeCompare(t._id)):[]}return M3}var x9,J9,bT,FT,kT,as,KT,QE,vT,RQ,XCA,UT,LT,H9,YT,xT,JT,S3,T9,M3,q9,mg=b((()=>{x9=1024,J9=2048,bT=4096,FT=8192,kT=16384,as=65536,KT=1<<17,QE=1<<18,vT=1<<19,RQ=1<<20,XCA=1<<21,UT=32768,LT=1<<22,H9=1<<24,YT=1<<26,xT=1<<27,JT=null,S3=null,T9=null,M3=null,q9=3456})),TjA=H({createStandardEsmShadowMaterialView:()=>qjA});function qjA(A,e){const t=rC(A,{features:(A._renderFeatures??{features:0}).features&~as|RQ});return Object.defineProperty(t,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(t,"_esmShadowDepthCode",{value:$CA,enumerable:!1}),t}var $CA,PjA=b((()=>{wI(),mg(),$CA="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),R3,m3,P9,HT,O9,V9,TT,j9,W9,qT,aE,PT,z9,Z9,X9,EE,mQ,Ti=b((()=>{R3=1024,m3=2048,P9=4096,HT=32768,O9=1<<17,V9=1<<21,TT=1<<22,j9=1<<25,W9=1<<26,qT=1<<27,aE=1<<28,PT=1<<29,z9=1024,Z9=2048,X9=4096,EE=32768,mQ=65536})),OjA=H({PBR2_ESM_SHADOW_OUTPUT:()=>mQ,PBR2_HAS_BASE_COLOR_FACTOR:()=>X9,PBR2_HAS_REFLECTANCE_FACTORS:()=>z9,PBR2_HAS_REFRACTION:()=>16,PBR2_HAS_UV2:()=>Z9,PBR2_HAS_UV_TRANSFORM:()=>512,PBR2_NO_COLOR_OUTPUT:()=>EE,PBR_HAS_ALPHA_BLEND:()=>64,PBR_HAS_ALPHA_TEST:()=>8,PBR_HAS_ANISOTROPY:()=>W9,PBR_HAS_COTANGENT_NORMAL:()=>512,PBR_HAS_DOUBLE_SIDED:()=>256,PBR_HAS_EMISSIVE:()=>2,PBR_HAS_EMISSIVE_COLOR:()=>V9,PBR_HAS_ENV:()=>4,PBR_HAS_FOG:()=>32,PBR_HAS_GAMMA_ALBEDO:()=>j9,PBR_HAS_METALLIC_REFLECTANCE_MAP:()=>R3,PBR_HAS_NORMAL_MAP:()=>1,PBR_HAS_OCCLUSION:()=>HT,PBR_HAS_REFLECTANCE_MAP:()=>m3,PBR_HAS_SHEEN:()=>TT,PBR_HAS_SKYBOX:()=>PT,PBR_HAS_SPECULAR_AA:()=>O9,PBR_HAS_SPEC_GLOSS:()=>128,PBR_HAS_SUBSURFACE:()=>qT,PBR_HAS_THICKNESS_MAP:()=>aE,PBR_HAS_TONEMAP:()=>16,PBR_HAS_USE_ALPHA_ONLY_MR:()=>P9,_getPbrExts:()=>Es,_getPbrExtsSorted:()=>ArA,_getPbrSceneHooks:()=>erA,_registerPbrExt:()=>AI,_registerPbrSceneHook:()=>$9});function AI(A){(AU??=new Map).set(A.id,A),N3=null}function Es(){return AU??=new Map}function ArA(){if(!N3){const A=AU;N3=A?Array.from(A.values()).sort((e,t)=>e.id.localeCompare(t.id)):[]}return N3}function $9(A){(OT??=new Set).add(A)}function erA(){return OT??[]}var AU,N3,OT,Eg=b((()=>{Ti(),AU=null,N3=null,OT=null})),VjA=H({createPbrEsmShadowMaterialView:()=>jjA});function jjA(A,e){const t=A._renderFeatures??{features:0,features2:0},g=rC(A,{features:t.features&-194,features2:(t.features2??0)&-17|mQ});return Object.defineProperty(g,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(g,"_esmShadowDepthCode",{value:trA,enumerable:!1}),g}var trA,WjA=b((()=>{wI(),Eg(),trA="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),eU=b((()=>{})),zjA=H({createNodeEsmShadowMaterialView:()=>ZjA});function ZjA(A,e){const t=rC(A,{features:(A._renderFeatures??{features:0}).features|2});return Object.defineProperty(t,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(t,"_esmShadowDepthCode",{value:grA,enumerable:!1}),t}var grA,XjA=b((()=>{wI(),eU(),grA="let depthMetricSM=(in.position.z+nmeShadowParams.depthValues.x)/nmeShadowParams.depthValues.y+nmeShadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,nmeShadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),$jA=H({createEsmDirectionalShadowGenerator:()=>rrA,ensureEsmShadowTaskState:()=>orA,getEsmShadowTaskResources:()=>VT,setEsmShadowTaskResources:()=>IrA});function IrA(A,e){A._esmResources=e}function VT(A){return A._esmResources??null}async function AWA(A){const e=[];let t=!1,g=!1,I=!1;for(const o of A){const C=o.material?._buildGroup._materialFamily;t||=C==="standard",g||=C==="pbr",I||=C==="node"}t&&!jT&&e.push(Promise.resolve().then(()=>(PjA(),TjA)).then(o=>{jT=o.createStandardEsmShadowMaterialView})),g&&!WT&&e.push(Promise.resolve().then(()=>(WjA(),VjA)).then(o=>{WT=o.createPbrEsmShadowMaterialView})),I&&!zT&&e.push(Promise.resolve().then(()=>(XjA(),zjA)).then(o=>{zT=o.createNodeEsmShadowMaterialView})),await Promise.all(e)}function eWA(A){const e=Math.round(Math.max(A,1));for(const t of[e,e-1,e+1,e-2,e+2])if(t%2!==0&&Math.floor(t/2)%2===0&&t>0)return Math.max(t,3);return Math.max(e,3)}function tWA(A){const e=.3333333333333333;return Math.exp(-(A*A/(2*e*e)))/(Math.sqrt(2*Math.PI)*e)}function gWA(A){const e=eWA(A),t=(e-1)/2,g=[],I=[];let o=0;for(let n=0;n<e;n++){const s=tWA(n/(e-1)*2-1);g[n]=n-t,I[n]=s,o+=s}for(let n=0;n<I.length;n++)I[n]=I[n]/o;const C=[],r=[];for(let n=0;n<=t;n+=2){const s=Math.min(n+1,Math.floor(t));if(n===s){C.push(g[n]),r.push(I[n]);continue}const B=s===t,Q=I[n]+I[s]*(B?.5:1),E=g[n]+1/(1+I[n]/I[s]);E===0?(C.push(g[n],g[n+1]),r.push(I[n],I[n+1])):(C.push(E,-E),r.push(Q,Q))}return{offsets:C,weights:r}}function irA(A){let e=(Object.is(A,-0)?0:A).toPrecision(10);return/[.eE]/.test(e)||(e+=".0"),e}function IWA(A){const{offsets:e,weights:t}=gWA(A),g=e.length;return`struct BlurParams{delta:vec2<f32>,_pad:vec2<f32>,};@group(0)@binding(0)var<uniform>params:BlurParams;@group(0)@binding(1)var srcTex:texture_2d<f32>;@group(0)@binding(2)var srcSampler:sampler;const OFFSETS=array<f32,${g}>(${e.map(irA).join(",")});const WEIGHTS=array<f32,${g}>(${t.map(irA).join(",")});@fragment fn main(@location(0)sampleCenter:vec2<f32>)->@location(0)vec4<f32>{var blend=vec4<f32>(0.0);for(var i=0u;i<${g}u;i=i+1u){blend+=textureSample(srcTex,srcSampler,sampleCenter+params.delta*OFFSETS[i])*WEIGHTS[i];}return blend;}`}function orA(A,e,t,g,I){const o=I;if(o){if(o._casterMeshes===g)return o;ag(A,o._task.dispose)}const C=VT(t);if(!C)throw new Error("ShadowTask: missing ESM metadata.");const r=new Map,n=v9(t),s={_task:sE({name:"esm",rt:JCA(t,C._esmTexture,C._depthBuffer),clr:!0,clrColor:{r:0,g:0,b:0,a:0},cam:n,autoMirror:!1,_skipClusteredLights:!0},A,e),_camera:n,_lastCasterVersion:-1,_lastLightVersion:-1,_lastFoVersion:-1,_casterMeshes:g,_scene:e};for(const B of g){const Q=B.material;Q&&y3(s._task,B,{material:CWA(Q,r,t._shadowParamsUBO)})}return s}function iWA(A,e,t){const g=VT(e);if(!g)return 0;const I=t._casterMeshes,o=hT(I),C=e._light._lightVersion,r=A.useFloatingOrigin?t._scene.camera:null,n=r?r.worldMatrixVersion:0,s=r?r.worldMatrix[12]:0,B=r?r.worldMatrix[13]:0,Q=r?r.worldMatrix[14]:0;if(!e._config._forceRefreshEveryFrame&&o===t._lastCasterVersion&&C===t._lastLightVersion&&n===t._lastFoVersion&&r===t._lastFoCamera)return 0;const E=xCA(e._light,I,e._config._orthoMinZ,e._config._orthoMaxZ,s,B,Q);rWA(e._lightMatrix,E._viewProj)&&(Cg(e._lightMatrix,E._viewProj,0),e._version++,_T(g._shadowUboData,e),A._device.queue.writeBuffer(e._shadowUBO,0,g._shadowUboData)),oWA(t,E),t._lastCasterVersion=o,t._lastLightVersion=C,t._lastFoVersion=n,t._lastFoCamera=r;const c=t._task.execute?.()??0,l=A._currentEncoder;return CrA(l,g._blurPipeline,g._blurTexH,g._blurHBG),CrA(l,g._blurPipeline,e._depthTexture,g._blurVBG),c+2}function CrA(A,e,t,g){const I=A.beginRenderPass({colorAttachments:[{view:t.createView(),loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});I.setPipeline(e),I.setBindGroup(0,g),I.draw(3),I.end()}function oWA(A,e){const t=A._camera;U9(t,t.worldMatrixVersion+1,e._near,e._far,e._view,e._viewProj)}function CWA(A,e,t){const g=e.get(A);if(g)return g;const I=A._buildGroup._materialFamily;let o;return I==="standard"?o=jT(A,t):I==="pbr"?o=WT(A,t):I==="node"&&(o=zT(A,t)),e.set(A,o),o}function rWA(A,e){for(let t=0;t<16;t++)if(A[t]!==e[t])return!0;return!1}function rrA(A,e,t={}){const g=A._device,I=t.mapSize??1024,o=t.depthScale??50,C=t.bias??5e-5,r=t.blurKernel??1,n=t.blurScale??2,s=t.darkness??0,B=t.frustumEdgeFalloff??0,Q=t.orthoMinZ??1,E=t.orthoMaxZ??1e4,c=t.forceRefreshEveryFrame??!1,l=I/n,u={_mapSize:I,_bias:C,_orthoMinZ:Q,_orthoMaxZ:E,_forceRefreshEveryFrame:c},p=_3(A,C,o),d=g.createTexture({size:{width:I,height:I},format:"rgba16float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING}),f=g.createTexture({size:{width:I,height:I},format:"depth32float",usage:_A.RENDER_ATTACHMENT}),D=g.createTexture({size:{width:l,height:l},format:"rgba16float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING}),_=g.createTexture({size:{width:l,height:l},format:"rgba16float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING}),y=g.createShaderModule({code:zCA}),w=g.createShaderModule({code:IWA(r)}),S=g.createBindGroupLayout({entries:[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}]}),R=g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[S]}),vertex:{module:y,entryPoint:"main"},fragment:{module:w,entryPoint:"main",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list",cullMode:"none"}}),M=$o(A),N=Rg(A,new CA([1/l,0,0,0])),G=g.createBindGroup({layout:S,entries:[{binding:0,resource:{buffer:N}},{binding:1,resource:d.createView()},{binding:2,resource:M}]}),K=Rg(A,new CA([0,1/l,0,0])),F=g.createBindGroup({layout:S,entries:[{binding:0,resource:{buffer:K}},{binding:1,resource:D.createView()},{binding:2,resource:M}]}),v=new CA(16),U=new CA([s,0,o,B]),L=new CA([0,1]),{ubo:x,data:P}=yT(A,v,L,U),j={_shadowType:"esm",_light:e,_depthTexture:_,_depthSampler:M,_lightMatrix:v,_shadowsInfo:U,_depthValues:L,_shadowParamsUBO:p,_shadowUBO:x,_config:u,_version:0};return j._preloadShadowTask=AWA,j._ensureShadowTaskState=(O,z,Z)=>{const AA=orA(O,z,j,Z,j._shadowTaskState??null);return j._shadowTaskState=AA,AA},j._renderShadowMap=(O,z)=>iWA(O,j,z),IrA(j,{_esmTexture:d,_depthBuffer:f,_blurTexH:D,_blurPipeline:R,_blurHBG:G,_blurVBG:F,_shadowUboData:P,_blurKernel:r,_blurScale:n}),j}var jT,WT,zT,nrA=b((()=>{VA(),kg(),ZA(),gI(),oo(),BE(),Qs(),xjA(),Hi()})),nWA=H({rebuildSceneShadowGenerators:()=>sWA});async function sWA(A,e){const t=new Set(e.shadowGenerators);for(const g of e.lights)g.shadowGenerator&&t.add(g.shadowGenerator);for(const g of t){if(g._shadowType!=="esm"&&g._shadowType!=="csm"&&m(798,g._shadowType),g._shadowTaskState?._task.dispose(),g._shadowTaskState=void 0,g._preloadPending=void 0,g._shadowType==="csm"){const n=A._device,s=g._config._mapSize;g._depthTexture=n.createTexture({size:{width:s,height:s,depthOrArrayLayers:g._csmCascadeCount},format:"depth32float",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|(g._csmCache?GPUTextureUsage.COPY_DST:0)}),g._depthSampler=n.createSampler({compare:"less",magFilter:"linear",minFilter:"linear"}),g._shadowParamsUBO=_3(A,g._config._bias,1/s),g._shadowUBO=Rg(A,new Float32Array(80));const B=g._csmReceiverTexture;B&&(B.texture=g._depthTexture,B.view=g._depthTexture.createView({dimension:"2d-array"}),B.sampler=g._depthSampler,B.width=s,B.height=s,Kg(B)),g._version++;continue}const I=await Promise.resolve().then(()=>(nrA(),$jA)),o=I.getEsmShadowTaskResources(g);o||m(799);const C=I.createEsmDirectionalShadowGenerator(A,g._light,{mapSize:g._config._mapSize,depthScale:g._shadowsInfo[2],bias:g._config._bias,blurKernel:o._blurKernel,blurScale:o._blurScale,darkness:g._shadowsInfo[0],frustumEdgeFalloff:g._shadowsInfo[3],orthoMinZ:g._config._orthoMinZ,orthoMaxZ:g._config._orthoMaxZ,forceRefreshEveryFrame:g._config._forceRefreshEveryFrame}),r=I.getEsmShadowTaskResources(C);r||m(800),g._depthTexture=C._depthTexture,g._depthSampler=C._depthSampler,g._lightMatrix=C._lightMatrix,g._shadowsInfo=C._shadowsInfo,g._depthValues=C._depthValues,g._shadowParamsUBO=C._shadowParamsUBO,g._shadowUBO=C._shadowUBO,g._version++,I.setEsmShadowTaskResources(g,r)}}var BWA=b((()=>{rA(),cI(),gI(),Qs()})),ZT=H({createSkeleton:()=>QWA});function QWA(A,e,t,g,I,o,C){const r=A._device,n=g*4,s=r.createTexture({size:[n,1],format:"rgba32float",usage:_A.TEXTURE_BINDING|_A.COPY_DST});r.queue.writeTexture({texture:s},I.buffer,{bytesPerRow:n*16},{width:n,height:1});const B=new gt(e.length);for(let u=0;u<e.length;u++)B[u]=e[u];const Q=Ft(A,B,iA.VERTEX),E=Ft(A,t,iA.VERTEX);let c=null,l=null;if(o&&C){const u=new gt(o.length);for(let p=0;p<o.length;p++)u[p]=o[p];c=Ft(A,u,iA.VERTEX),l=Ft(A,C,iA.VERTEX)}return{boneTexture:s,boneCount:g,jointsBuffer:Q,weightsBuffer:E,joints:e,weights:t,boneMatrices:I,joints1Buffer:c,weights1Buffer:l,joints1:o??null,weights1:C??null,_skinBuffers:{jointsBuffer:Q,weightsBuffer:E,joints1Buffer:c,weights1Buffer:l}}}var XT=b((()=>{VA(),ZA(),qI()})),$T=H({MORPH_WEIGHTS_HEADER_BYTES:()=>16,createMorphTargets:()=>srA,setMorphTargetWeights:()=>BrA});function srA(A,e,t,g,I){const o=e.length,C=new CA(o*t*tU);for(let c=0;c<o;c++){const l=e[c],u=c*t*tU;for(let p=0;p<t;p++){const d=u+p*tU;C[d]=l.positions[p*3],C[d+1]=l.positions[p*3+1],C[d+2]=l.positions[p*3+2],l.normals&&(C[d+3]=l.normals[p*3],C[d+4]=l.normals[p*3+1],C[d+5]=l.normals[p*3+2])}}const r=Ft(A,C,iA.STORAGE),n=new ArrayBuffer(16+o*4),s=new gt(n,0,2);s[0]=o,s[1]=t;const B=new CA(n,16,o);for(let c=0;c<o;c++)B[c]=g?.[c]??0;const Q=Ft(A,new Te(n),iA.STORAGE),E=new CA(o);return E.set(B),{deltasBuffer:r,count:o,weightsBuffer:Q,targets:e,weights:E,...I?{names:I}:{}}}function BrA(A,e,t){if(e._disposed)throw new Error("Cannot update disposed morph targets");const g=Math.min(e.count,t.length);e.weights.fill(0);for(let I=0;I<g;I++)e.weights[I]=t[I]??0;A._device.queue.writeBuffer(e.weightsBuffer,16,e.weights)}var tU,G3=b((()=>{VA(),ZA(),qI(),tU=6})),aWA=H({_rebuildMeshes:()=>arA,rebuildRegisteredScenes:()=>EWA,rebuildRenderables:()=>QrA});async function EWA(A){A._pbrFallbackTex=void 0;for(const e of A.surfaces)for(const t of e._renderingContexts){if(t._kind!=="scene")continue;const g=t;!$F(e,g)||g._z||await cWA(A,g)}}async function cWA(A,e){if(e._envTextures){const{rebuildSceneEnvironment:g}=await Promise.resolve().then(()=>(MjA(),hjA));await cE("rebuilding environment textures",()=>g(A,e))}if(await cE("rebuilding material textures",()=>uWA(A,e)),await cE("rebuilding meshes",()=>arA(A,e)),e._z)return;if(e.shadowGenerators.length>0||e.lights.some(g=>g.shadowGenerator)){const{rebuildSceneShadowGenerators:g}=await Promise.resolve().then(()=>(BWA(),nWA));await cE("rebuilding shadows",()=>g(A,e))}if(e._z)return;const t=e._renderables.filter(g=>!!g._rebuild).map(g=>g._rebuild);e._renderables.length=e._uniformUpdaters.length=0,e._meshDisposables.clear(),e._lightGpuState&&(e._lightGpuState=void 0);for(const[g,I]of e._groups){const o=await cE("rebuilding material groups",()=>g(e,I));if(e._z)return;I.r=e._runtimeBuilds?.base(g,o.rebuildSingle)??o.rebuildSingle,o._w!==void 0&&(I._w=o._w),I.o=o.renderables,e._renderables.push(...o.renderables),o.updater&&e._uniformUpdaters.push(o.updater)}t.length>0&&e._renderables.push(...await cE("rebuilding renderables",()=>QrA(t))),e._renderables.sort((g,I)=>g.order-I.order),e._renderableVersion++,lWA(A,e),e._frameGraph.build()}async function QrA(A){const e=[];for(const t of A){const g=await t();g&&e.push(g)}return e}async function cE(A,e){try{return await e()}catch(t){const g=t instanceof Error?t.message:String(t);throw new Error(`Device-lost Scene recovery failed while ${A}: ${g}`,{cause:t})}}function lWA(A,e){for(const t of e._frameGraph._tasks){if(!("_sceneUBO"in t&&"_targetSignature"in t&&"_opaqueBindings"in t))continue;const g=t;g._sceneUBO=XI(A,368),g._lightsUBO=_9(A,e)._buffer,g._sceneBG=A._device.createBindGroup({layout:oi(A),entries:[{binding:0,resource:{buffer:g._sceneUBO}},{binding:1,resource:{buffer:g._lightsUBO}}]}),g._opaqueBindings.length=0,g._directBindings.length=0,g._transparentBindings.length=0,g._ob.length=0,g._lastVersion=-1,g._sceneUboCacheKey.length=0}}async function arA(A,e){let t=null,g=null;for(const I of e.meshes){if(I._cpuPositions&&I._cpuNormals&&I._cpuIndices){const o=I._gpu._recoverShared;I._gpu=o?o(A,I,ErA):ErA(A,I)}if(I.skeleton){t??=(await Promise.resolve().then(()=>(XT(),ZT))).createSkeleton;const o=I.skeleton,C=t(A,o.joints,o.weights,o.boneCount,o.boneMatrices,o.joints1,o.weights1);Object.assign(o,C)}if(I.morphTargets){g??=(await Promise.resolve().then(()=>(G3(),$T))).createMorphTargets;const o=I.morphTargets,C=g(A,o.targets.map(r=>({positions:r.positions,normals:r.normals})),I._cpuPositions?I._cpuPositions.length/3:0,Array.from(o.weights));Object.assign(o,C)}}}function ErA(A,e){const t=e._gpu,g=t._drawRangeSource;if(g){const B=D9(A,g.positions,g.normals,g.indices,g.uvs,g.uvs2,g.tangents,g.colors);return R1A(B,{...g}),B._firstIndex=t._firstIndex,B._baseVertex=t._baseVertex,B._vertexCapacity=g.positions.length/3,B._indexCapacity=g.indices.length,B}const I=e._cpuPositions,o=e._cpuNormals,C=e._cpuUvs,r=e._cpuGpuIndices??e._cpuIndices,n=A._device;let s;return C&&C.length>0?s=Ft(A,C,iA.VERTEX):(s=n.createBuffer({size:I.length/3*8,usage:iA.VERTEX,mappedAtCreation:!0}),s.unmap()),{positionBuffer:Ft(A,I,iA.VERTEX),normalBuffer:Ft(A,o,iA.VERTEX),tangentBuffer:e._cpuTangents?.length?Ft(A,e._cpuTangents,iA.VERTEX):null,uvBuffer:s,uv2Buffer:e._cpuUv2s?Ft(A,e._cpuUv2s,iA.VERTEX):null,colorBuffer:e._cpuColors?Ft(A,e._cpuColors,iA.VERTEX):null,hasUv:!!C&&C.length>0,hasUv2:!!e._cpuUv2s&&e._cpuUv2s.length>0,hasTangent:!!e._cpuTangents&&e._cpuTangents.length>0,hasColor:!!e._cpuColors&&e._cpuColors.length>0,indexBuffer:Ft(A,r,iA.INDEX),indexCount:r.length,indexFormat:e._cpuIndexFormat??e._gpu.indexFormat}}async function uWA(A,e){const t=new Set,g=new WeakSet,I=[],o=r=>{if(!r||typeof r!="object")return;const n=r;if(n.texture&&n.view&&n.sampler&&typeof n.width=="number"&&typeof n.height=="number"){const s=n;t.has(s)||(t.add(s),I.push(s));return}if(!g.has(r)){g.add(r);for(const s of Object.values(n))o(s)}};for(const r of e.meshes)o(r.material);if(I.length===0)return;const{rebuildTexture2D:C}=await Promise.resolve().then(()=>(zH(),WH));await Promise.all(I.map(r=>C(A,r)))}var pWA=b((()=>{ZA(),hI(),ss(),m1A(),co(),qI(),Ci(),rT(),y9()}));function dWA(A,e={}){return l9(A,{_kind:"scene",_recoverOrder:100,_enable(t){_1A(t,!0)},_disable(t){y1A(t,!0)},async _recover(t){const{rebuildRegisteredScenes:g}=await Promise.resolve().then(()=>(pWA(),aWA));await g(t)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function fWA(A){A7=A}function V1(){return A7}function crA(A){e7=A}function cs(){return e7}var A7,e7,bC=b((()=>{A7=null,e7=null}));function gU(A,e){const t=e.cellWidthPx,g=e.cellHeightPx,I=e.marginPx??0,o=e.spacingPx??0,C=e.columns??Math.max(1,Math.floor((A.width-I*2+o)/(t+o))),r=e.rows??Math.max(1,Math.floor((A.height-I*2+o)/(g+o))),n=e.pivot??[.5,.5],s=A.width,B=A.height,Q=[];for(let E=0;E<r;E++)for(let c=0;c<C;c++){const l=I+c*(t+o),u=I+E*(g+o);Q.push({uvMin:[l/s,u/B],uvMax:[(l+t)/s,(u+g)/B],sourceSizePx:[t,g],pivot:[n[0],n[1]]})}return{texture:A,textureSizePx:[s,B],frames:Q,premultipliedAlpha:e.premultipliedAlpha??!1}}async function DWA(A,e,t={}){return t.metadataUrl!==void 0&&m(827),t.gridSize||m(828),gU(await tE(A,e,{invertY:!1,addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",mipMaps:!1,minFilter:t.sampling==="nearest"?"nearest":"linear",magFilter:t.sampling==="nearest"?"nearest":"linear",premultiplyAlpha:t.premultiplyOnLoad??!1,...t.textureOptions}),{cellWidthPx:t.gridSize[0],cellHeightPx:t.gridSize[1],premultipliedAlpha:t.premultipliedAlpha??!1})}function b3(A,e){return(e<0||e>=A.frames.length)&&m(829,e,A.frames.length),e}function _WA(A){A.texture.texture.destroy()}var F3=b((()=>{rA(),NC()})),t7,g7,lrA=b((()=>{t7={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},g7={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}})),urA,IU,prA,I7,i7,drA,o7=b((()=>{lrA(),urA={_key:"opaque"},IU={_key:"alpha",_descriptor:t7},prA={_key:"premultiplied",_descriptor:g7,_premultipliedOpacity:!0},I7={_key:"additive",_descriptor:{color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},i7={_key:"oneone",_descriptor:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},drA={_key:"multiply",_descriptor:{color:{srcFactor:"dst",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"dst-alpha",dstFactor:"zero",operation:"add"}}}}));function yWA(A){s7=A}function lE(){return s7}function C7(A,e={}){const t=e.depth??"none",g=e.blendMode??IU,I=Math.max(1,e.capacity??yrA),o={positionPx:[e.view?.positionPx?.[0]??0,e.view?.positionPx?.[1]??0],zoom:e.view?.zoom??1,rotation:e.view?.rotation??0},C=t==="none"?13:14,r=C*4,n=new CA(I*C),s={_entityType:"sprite-2d-layer",atlas:A,depth:t,blendMode:g,opacity:e.opacity??1,visible:e.visible??!0,order:e.order??0,view:o,pivot:[e.pivot?.[0]??.5,e.pivot?.[1]??.5],layerZ:e.layerZ??.5,count:0,_capacity:I,_instanceFloatsPerSprite:C,_instanceStrideBytes:r,_instanceData:n,_savedSize:new CA(I*2),_version:0,_dirtyMin:0,_dirtyMax:0};return V1()?.initLayer(s,e),s}function hWA(A,e){const t=A.shaderParams??=[0,0,0,0];t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3]}function wWA(A,e){let t=A._capacity;for(;t<e;)t*=2;const g=new CA(t*A._instanceFloatsPerSprite);g.set(A._instanceData),A._instanceData=g;const I=new CA(t*2);I.set(A._savedSize),A._savedSize=I,A._capacity=t}function iU(A,e){A.count=e}function frA(A,e,t,g){const I=A._instanceData,o=e*A._instanceFloatsPerSprite,C=e*2,r=g===null,n=t.frame!==void 0?A.atlas.frames[b3(A.atlas,t.frame)]:null,s=t.positionPx?t.positionPx[0]:g[0],B=t.positionPx?t.positionPx[1]:g[1];let Q,E;t.sizePx?(Q=t.sizePx[0],E=t.sizePx[1]):n?(Q=n.sourceSizePx[0],E=n.sourceSizePx[1]):r?(Q=0,E=0):(Q=A._savedSize[C],E=A._savedSize[C+1]),A._savedSize[C]=Q,A._savedSize[C+1]=E;let c;t.visible!==void 0?c=t.visible:r?c=!0:c=g[2]!==0||g[3]!==0;let l,u,p,d;n?(l=n.uvMin[0],u=n.uvMin[1],p=n.uvMax[0],d=n.uvMax[1]):r?(l=0,u=0,p=1,d=1):(l=g[4],u=g[5],p=g[6],d=g[7]);const f=l>p,D=u>d,_=!r&&g[4]>g[6],y=!r&&g[5]>g[7],w=t.flipX!==void 0?t.flipX===!0:_,S=t.flipY!==void 0?t.flipY===!0:y;if(f!==w){const G=l;l=p,p=G}if(D!==S){const G=u;u=d,d=G}const R=t.rotation??(g?g[8]:0),M=A.depth!=="none",N=M?t.z??(g?g[13]:A.layerZ):0;I[o+0]=s,I[o+1]=B,I[o+2]=c?Q:0,I[o+3]=c?E:0,I[o+4]=l,I[o+5]=u,I[o+6]=p,I[o+7]=d,I[o+8]=R,t.color?(I[o+9]=t.color[0],I[o+10]=t.color[1],I[o+11]=t.color[2],I[o+12]=t.color[3]):r&&(I[o+9]=1,I[o+10]=1,I[o+11]=1,I[o+12]=1),M&&(I[o+13]=N)}function k3(A,e,t){A._dirtyMin>=A._dirtyMax?(A._dirtyMin=e,A._dirtyMax=t):(e<A._dirtyMin&&(A._dirtyMin=e),t>A._dirtyMax&&(A._dirtyMax=t)),A._version=A._version+1|0,lE()?.dirty(A,e,t)}function NQ(A,e,t){k3(A,e,t)}function DrA(A,e){e.positionPx===void 0&&m(843);const t=A.count;return t>=A._capacity&&wWA(A,t+1),frA(A,t,e,null),A._vertexExtension?._initInstance(A._instanceData,t*A._instanceFloatsPerSprite),iU(A,A.count+1),lE()?.add(A,t),k3(A,t,t+1),t}function _rA(A,e,t){(e<0||e>=A.count)&&m(844,e,A.count);const g=e*A._instanceFloatsPerSprite;frA(A,e,t,A._instanceData.subarray(g,g+A._instanceFloatsPerSprite)),k3(A,e,e+1)}function r7(A,e){(e<0||e>=A.count)&&m(845,e,A.count);const t=A.count-1;A._handleHooks?.removeIndex(e,t),e!==t&&(A._instanceData.copyWithin(e*A._instanceFloatsPerSprite,t*A._instanceFloatsPerSprite,(t+1)*A._instanceFloatsPerSprite),A._savedSize.copyWithin(e*2,t*2,(t+1)*2)),A._savedSize[t*2]=0,A._savedSize[t*2+1]=0,iU(A,t),lE()?.remove(A,e,t),k3(A,e,e+1)}function SWA(A){const e=A.count;A._dirtyMin=0,A._dirtyMax=0,A._handleHooks?.clear(),e!==0&&(A._savedSize.fill(0,0,e*2),iU(A,0),lE()?.clear(A,e),A._version=A._version+1|0)}function n7(A,e,t){(e<0||e>=A.count)&&m(846,e,A.count);const g=b3(A.atlas,t),I=A.atlas.frames[g],o=e*A._instanceFloatsPerSprite,C=A._instanceData[o+4]>A._instanceData[o+6],r=A._instanceData[o+5]>A._instanceData[o+7];A._instanceData[o+4]=C?I.uvMax[0]:I.uvMin[0],A._instanceData[o+5]=r?I.uvMax[1]:I.uvMin[1],A._instanceData[o+6]=C?I.uvMin[0]:I.uvMax[0],A._instanceData[o+7]=r?I.uvMin[1]:I.uvMax[1],k3(A,e,e+1)}var s7,yrA,FC=b((()=>{rA(),VA(),F3(),bC(),o7(),s7=null,yrA=16}));function MWA(A){Q7=A}function B7(){return Q7}var Q7,hrA=b((()=>{Q7=null}));function RWA(A){a7=A}function GQ(){return a7}var a7,bQ=b((()=>{a7=null}));function mWA(A,e,t){return`${E7(A,e,t)} @fragment fn fs(in:O)->@location(0)vec4f{let s=textureSample(atlasTex,atlasSamp,in.uv);return s*in.tint*L.opacityMul;}`}function E7(A,e,t=!1,g){const I=`@group(${e})`,o=A?",@location(6)z:f32":"",C=t?",@location(7)o:vec2f":"",r=A?"1 - in.z":"0";return`struct Lr{viewPos:vec2f,viewScale:f32,viewRot:f32,screenSize:vec2f,pivot:vec2f,opacityMul:vec4f,aa:vec4f,};${I} @binding(0)var<uniform>L:Lr;${I} @binding(1)var atlasTex:texture_2d<f32>;${I} @binding(2)var atlasSamp:sampler;struct I{@builtin(vertex_index)vid:u32,@location(0)p:vec2f,@location(1)s:vec2f,@location(2)a:vec2f,@location(3)b:vec2f,@location(4)r:f32,@location(5)c:vec4f${o}${C}${g?._input??""}};struct O{@builtin(position)p:vec4f,@location(0)uv:vec2f,@location(1)tint:vec4f,${g?._output??""}};@vertex fn vs(in:I)->O{var q=array<vec2f,4>(vec2f(0,0),vec2f(1,0),vec2f(1,1),vec2f(0,1));let c=q[in.vid];let l=(c-L.pivot)*in.s;let cr=cos(in.r);let sr=sin(in.r);let r=vec2f(l.x*cr-l.y*sr,l.x*sr+l.y*cr);let p=in.p+r-L.viewPos;let lc=cos(L.viewRot);let ls=sin(L.viewRot);let v=vec2f(p.x*lc-p.y*ls,p.x*ls+p.y*lc)*L.viewScale;let n=vec2f(v.x/L.screenSize.x*2-1,1-v.y/L.screenSize.y*2);let uv=mix(in.a,in.b,c)${t?" + in.o":""};var out:O;out.p=vec4f(n,${r},1);out.uv=uv;out.tint=in.c;${g?._assignment??""} return out;}`}function wrA(){return{_devices:new WeakMap}}function SrA(A){A._devices=new WeakMap}function NWA(){return uE??=wrA(),CU++,uE}function MrA(){CU>0&&--CU===0&&uE&&(SrA(uE),uE=null)}function K3(A,e,t,g,I,o,C=!1,r,n,s,B="greater-equal"){const Q=GWA(A,e),E=bWA(o,r),c=GQ(),l=o&&C&&g>1&&!!s&&!!c?.(s),u=FWA(t,g,I,o,C,E,l,s,B),p=Q._pipelines.get(u);if(p)return p;const d=KWA(A,Q,t,g,I,o,C,E,l,n,s,B);return Q._pipelines.set(u,d),d}function RrA(A,e,t,g,I,o){const C=g.atlas.texture,r=[{binding:0,resource:{buffer:I}},{binding:1,resource:C.view},{binding:2,resource:C.sampler}];if(o)for(const n of V1().bindEntries(o,3))r.push(n);return A._device.createBindGroup({layout:e.getBindGroupLayout(t),entries:r})}function GWA(A,e){let t=e._devices.get(A._device);return t||(t={_shaderModules:new Map,_pipelines:new Map},e._devices.set(A._device,t)),t}function bWA(A,e){return A?(e||m(858),e):null}function FWA(A,e,t,g,I,o,C,r,n="greater-equal"){const s=r?V1()?.pipelineKeyPart(r)??"":"",B=r?._uvScrollAttr?"1":"0",Q=r?B7()?.pipelineKeyPart(r)??"0":"0";return`${A}:${e}:${t._key}:${g?1:0}:${I?1:0}:${o??"-"}:${g?n:"-"}:${C?"a":"n"}:cs${s}:uv${B}:cg${Q}`}function kWA(A,e,t,g){const I=g?V1()?.shaderModule(A,t,g):null;if(I)return I;const o=g?B7()?.shaderModule(A,t,g):null;if(o)return o;const C=g?._uvScrollAttr!=null,r=`${t?1:0}:${C?1:0}`;let n=e._shaderModules.get(r);return n||(n=A._device.createShaderModule({code:mWA(t,t?1:0,C)}),e._shaderModules.set(r,n)),n}function KWA(A,e,t,g,I,o,C,r,n,s,B,Q="greater-equal"){const E=A._device,c=[{binding:0,visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:DA.FRAGMENT,sampler:{type:"filtering"}}],l=B?V1()?.layoutEntries(B,3):null;if(l)for(const w of l)c.push(w);const u=E.createBindGroupLayout({entries:c}),p=kWA(A,e,o,B);o&&!s&&m(859);const d=o?[s,u]:[u],f=[{shaderLocation:0,offset:FrA,format:"float32x2"},{shaderLocation:1,offset:krA,format:"float32x2"},{shaderLocation:2,offset:KrA,format:"float32x2"},{shaderLocation:3,offset:vrA,format:"float32x2"},{shaderLocation:4,offset:UrA,format:"float32"},{shaderLocation:5,offset:LrA,format:"float32x4"}];o&&f.push({shaderLocation:6,offset:YrA,format:"float32"}),B?._uvScrollAttr&&f.push(B._uvScrollAttr);const D=B?V1()?.vertexAttribute(B):null;D&&f.push(D);const _=B?._instanceStrideBytes??(o?56:52),y={layout:E.createPipelineLayout({bindGroupLayouts:d}),vertex:{module:p,entryPoint:"vs",buffers:[{arrayStride:_,stepMode:"instance",attributes:f}]},fragment:{module:p,entryPoint:"fs",targets:[{format:t,blend:I._descriptor,writeMask:RC.ALL}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:n?{count:g,alphaToCoverageEnabled:!0}:{count:g}};return o&&(y.depthStencil={format:r,depthCompare:Q,depthWriteEnabled:C}),E.createRenderPipeline(y)}function oU(A,e,t){return A.createBuffer({size:e._capacity*e._instanceStrideBytes,usage:iA.VERTEX|iA.COPY_DST,label:t})}function mrA(A,e,t,g,I){const o=e._capacity*e._instanceStrideBytes;return t.size>=o?{buffer:t,capacity:g,reallocated:!1}:(t.destroy(),{buffer:oU(A,e,I),capacity:e._capacity,reallocated:!0})}function NrA(A,e,t,g){const I=lE()?.upload(A,e,t,g);if(I!==void 0)return I;if(g===e._version)return g;if(e.count===0)return e._dirtyMin=0,e._dirtyMax=0,e._version;let o,C;if(g===-1?(o=0,C=e.count):(o=e._dirtyMin,C=Math.min(e._dirtyMax,e.count)),C>o){const r=o*e._instanceStrideBytes,n=(C-o)*e._instanceStrideBytes;A.queue.writeBuffer(t,r,e._instanceData.buffer,e._instanceData.byteOffset+r,n)}return e._dirtyMin=0,e._dirtyMax=0,e._version}function GrA(A,e,t,g){g[0]=A.view.positionPx[0],g[1]=A.view.positionPx[1],g[2]=A.view.zoom,g[3]=A.view.rotation,g[4]=e,g[5]=t,g[6]=A.pivot[0],g[7]=A.pivot[1];const I=A.opacity;A.blendMode._premultipliedOpacity?(g[8]=I,g[9]=I,g[10]=I,g[11]=I):(g[8]=1,g[9]=1,g[10]=1,g[11]=I),B7()?.writeUbo(A,g)}function brA(A,e,t,g,I){let o=!I;if(!o){for(let C=0;C<16;C++)if(g[C]!==t[C]){o=!0;break}}return o&&(A.queue.writeBuffer(e,0,t.buffer,t.byteOffset,64),g.set(t)),!0}var FrA,krA,KrA,vrA,UrA,LrA,YrA,uE,CU,rU,v3=b((()=>{rA(),VA(),ZA(),FC(),bC(),hrA(),bQ(),FrA=0,krA=8,KrA=16,vrA=24,UrA=32,LrA=36,YrA=52,uE=null,CU=0,rU=new l1([0,1,2,0,2,3])})),vWA=H({rebuildRegisteredSpriteRenderers:()=>UWA});async function UWA(A){const e=[],t=new Set;for(const g of A.surfaces)for(const I of g._renderingContexts){if(I._kind!=="sprite-renderer")continue;const o=I;e.push(o),o._target&&t.add(o._target);for(const C of o.layers){t.add(C.atlas.texture);for(const r of C.customShader?._extraTextures??[])t.add(r.texture)}}if(t.size>0){const{rebuildTexture2D:g}=await Promise.resolve().then(()=>(zH(),WH));await Promise.all(Array.from(t,I=>g(A,I)))}for(const g of e)LWA(g)}function LWA(A){const e=A._surface.engine,t=V1();A._indexBuffer=Ft(e,rU,iA.INDEX),A._targetView=A._target?.view??null,A._visibleBundles.length=0;for(const g of A._layerGpu.values())g.instanceBuffer=oU(e._device,g.layer),g.instanceBufferCapacity=g.layer._capacity,g.uniformBuffer=XI(e,64),g.bindGroup=null,g.uploadedVersion=-1,g.fx&&(t.disposeFx(g.fx),g.fx=t.createLayerFx(e,"sprite-layer-fx-ubo",g.layer)),g.pipeline=null,g.lastUbo.fill(0),g.uboUploaded=!1,g.renderBundle=null,g.bundleCount=-1;for(const g of A.layers)K3(e,A._pipelineCache,A._surface.format,1,g.blendMode,!1,!1,void 0,void 0,g)}var YWA=b((()=>{ZA(),co(),qI(),bC(),v3()}));function xWA(A,e={}){return l9(A,{_kind:"sprite-renderer",_enable:_1A,_disable:y1A,async _recover(t){const{rebuildRegisteredSpriteRenderers:g}=await Promise.resolve().then(()=>(YWA(),vWA));await g(t)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function JWA(A){BU=A}function c7(A){return BU?._key(A)??A.curveSet}function HWA(A,e,t,g,I,o,C,r){const n=g._atlas._glyphSlots.get(I);if(!n)return!1;const s=n._index;if(s>d7||r>d7)return!1;const B=t*3;return A[B]=o,A[B+1]=C,e[B+2]=s|r<<16,!0}function xrA(A,e,t){const g=t*3;A[g]=0,A[g+1]=0,e[g+2]=tnA}function JrA(A,e){e>pE&&m(864,pE);const t=e*8;if(A._styles.length>=t)return;let g=Math.max(A._styles.length*2,8);for(;g<t;)g*=2;g=Math.min(g,pE*8);const I=new Float32Array(g);I.set(A._styles),A._styles=I}function U3(A){const e=A.glyphs;let t=1;for(let g=0;g<e.length;g++)e[g].color!==void 0&&t++;return t}function HrA(A,e){for(let t=0;t<e.length;t++)A._freeStyleSlots.push(e[t])}function TrA(A,e,t){if(t?.length===e)return t;const g=A._freeStyleSlots,I=Math.max(0,e-g.length-(t?.length??0));JrA(A,A._styleCount+I),t&&HrA(A,t);const o=A._styleCount,C=new Array(e);for(let r=0;r<e;r++)C[r]=g.pop()??A._styleCount++;return A._styleCount!==o&&A._styleVersion++,C}function qrA(A,e,t,g,I){const o=e*8,C=A._styles,r=Math.fround(t[0]),n=Math.fround(t[1]),s=Math.fround(t[2]),B=Math.fround(t[3]),Q=Math.fround(g),E=Math.fround(I);C[o]===r&&C[o+1]===n&&C[o+2]===s&&C[o+3]===B&&C[o+4]===Q&&C[o+5]===E||(C[o]=r,C[o+1]=n,C[o+2]=s,C[o+3]=B,C[o+4]=Q,C[o+5]=E,A._styleVersion++)}function TWA(A,e){const t=e*3;if(A._instances.length>=t)return;let g=Math.max(A._instances.length*2,3);for(;g<t;)g*=2;const I=new Float32Array(g);I.set(A._instances.subarray(0,A._instanceCount*3)),A._instances=I,A._instancesU32=new Uint32Array(I.buffer),A._dirtyStart=0,A._dirtyEnd=A._instanceCount}function nU(A,e,t){t<=e||(A._dirtyStart===A._dirtyEnd?(A._dirtyStart=e,A._dirtyEnd=t):(e<A._dirtyStart&&(A._dirtyStart=e),t>A._dirtyEnd&&(A._dirtyEnd=t)),A._version++)}function qWA(A){return A._freeSlots.length>0?A._freeSlots.pop():-1}function PrA(A,e,t,g){for(const I of A._groups)if(I!==g&&I._slotStart>=e){I._slotStart+=t;for(let o=0;o<I._freeSlots.length;o++)I._freeSlots[o]=I._freeSlots[o]+t}for(const I of A._runRecords.values()){const o=I._slots;for(let C=0;C<o.length;C++)o[C]>=e&&(o[C]=o[C]+t)}A._layoutVersion++}function PWA(A,e,t){const g=e._slotStart+e._slotCount;if(t<=0)return g;TWA(A,A._instanceCount+t);const I=t*3,o=g*3,C=A._instanceCount*3;return C>o&&A._instances.copyWithin(o+I,o,C),PrA(A,g,t,e),A._instanceCount+=t,e._slotCount+=t,nU(A,g,A._instanceCount),g}function OrA(A,e,t){const g=new Array(t).fill(-1);let I=!0,o=-1,C=t;for(let r=0;r<t;r++){const n=qWA(e);if(n===-1){C=r;break}g[r]=n,I&&=n>=o,o=n}if(C<t){const r=PWA(A,e,t-C);I&&=r>=o;for(let n=C,s=r;n<t;n++)g[n]=s++}return I||g.sort(OWA),g}function OWA(A,e){return A-e}function VrA(A,e,t){let g=Number.POSITIVE_INFINITY,I=-1;for(const o of t)xrA(A._instances,A._instancesU32,o),e._freeSlots.push(o),o<g&&(g=o),o>I&&(I=o);I>=0&&nU(A,g,I+1)}function VWA(A,e){for(const t of A._groups)if(t._groupKey===e)return t}function sU(A,e,t){const g=A._curveSets.get(e);return g||m(865,t,e),g}function jrA(A,e,t,g){return{_curveSetId:A,_curveSet:e,_slotStart:t,_slotCount:0,_liveCount:0,_freeSlots:[],_bindGroup:null,_bindGroupVersion:-1,_groupKey:g}}function jWA(A,e,t){const g=VWA(A,t);if(g)return g;const I=jrA(e,sU(A._storage,e,"addRun"),A._instanceCount,t);return A._groups.push(I),I}function l7(A,e,t,g,I){const o=t.pixelsPerFontUnit,C=o!==0?1/o:0,r=BU?._param(t)??0,n=I[0];qrA(A,n,t.defaultColor??gnA,C,r);let s=0,B=null,Q=Number.POSITIVE_INFINITY,E=-1;for(let c=0;c<t.glyphs.length;c++){const l=t.glyphs[c],u=g[c];let p=n;const d=l.color;d!==void 0&&(p=I[++s],qrA(A,p,d,C,r)),HWA(A._instances,A._instancesU32,u,e._curveSet,l.glyphId,l.x,l.y,p)?B!==null&&B.push(u):(B===null&&(B=g.slice(0,c)),xrA(A._instances,A._instancesU32,u),e._freeSlots.push(u)),u<Q&&(Q=u),u>E&&(E=u)}return E>=0&&nU(A,Q,E+1),B??g}function WrA(A,e,t){let g=0,I=0;for(const Q of e)g+=Q.glyphs.length,I+=U3(Q);JrA(A,I);const o=g*3;if(A._instances.length<o){let Q=Math.max(A._instances.length*2,3);for(;Q<o;)Q*=2;A._instances=new Float32Array(Q),A._instancesU32=new Uint32Array(A._instances.buffer)}const C=new Map;for(const Q of A._groups)C.set(Q._groupKey,Q);A._storage=t;const r=new Map;for(const Q of e){const E=c7(Q);let c=r.get(E);c||(c=[],r.set(E,c)),c.push(Q)}const n=[],s=new Map;let B=0;A._styleCount=0,A._freeStyleSlots.length=0,A._styleVersion++;for(const[Q,E]of r){const c=E[0].curveSet,l=sU(t,c,"reset"),u=C.get(Q)??jrA(c,l,B,Q);u._curveSet!==l&&(u._curveSet=l,u._bindGroup=null,u._bindGroupVersion=-1),u._slotStart=B,u._freeSlots=[];const p=n.length;let d=0;for(const f of E){const D=new Array(f.glyphs.length).fill(-1);for(let S=0;S<f.glyphs.length;S++)D[S]=B++;const _=U3(f),y=new Array(_);for(let S=0;S<_;S++)y[S]=A._styleCount++;const w=l7(A,u,f,D,y);d+=w.length,s.set(f,{_run:f,_groupIdx:p,_slots:w,_styleSlots:y})}u._slotCount=B-u._slotStart,u._liveCount=d,n.push(u)}A._instanceCount=B,A._groups=n,A._runs.length=0;for(const Q of e)A._runs.push(Q);A._runRecords=s,A._dirtyStart=0,A._dirtyEnd=B,A._version++,A._layoutVersion++}function zrA(A,e){return typeof e=="number"?ZrA(A,e,"updateTextData"):e}function ZrA(A,e,t){if(typeof e=="number"){const g=A._runs[e];return g||m(866,t,e,A._runs.length-1),g}return A._runRecords.has(e)||m(867,t),e}function u7(A,e){return typeof e=="number"?e:A._runs.indexOf(e)}function XrA(A,e,t){A._runRecords.has(e)&&m(868);const g=t??A._runs.length;sU(A._storage,e.curveSet,"addRun");const I=TrA(A,U3(e)),o=jWA(A,e.curveSet,c7(e)),C=A._groups.indexOf(o),r=l7(A,o,e,OrA(A,o,e.glyphs.length),I);o._liveCount+=r.length,A._runRecords.set(e,{_run:e,_groupIdx:C,_slots:r,_styleSlots:I}),A._runs.splice(g,0,e)}function $rA(A,e){const t=zrA(A,e),g=A._runRecords.get(t);g||m(869);const I=A._groups[g._groupIdx];VrA(A,I,g._slots),I._liveCount-=g._slots.length,HrA(A,g._styleSlots),A._runRecords.delete(t);const o=u7(A,e);o>=0&&A._runs.splice(o,1),I._liveCount===0&&WWA(A,I)}function WWA(A,e){const t=A._groups.indexOf(e);if(t<0)return;const g=e._slotStart,I=e._slotCount;A._groups.splice(t,1);for(const o of A._runRecords.values())o._groupIdx>t&&o._groupIdx--;if(I>0){const o=I*3,C=(g+I)*3,r=A._instanceCount*3;r>C&&A._instances.copyWithin(C-o,C,r),PrA(A,g,-I),A._instanceCount-=I,nU(A,g,A._instanceCount)}}function zWA(A,e,t){const g=zrA(A,e),I=A._runRecords.get(g);I||m(870),g!==t&&A._runRecords.has(t)&&m(871);const o=A._groups[I._groupIdx];if(c7(t)===o._groupKey&&t.glyphs.length>0){const r=TrA(A,U3(t),I._styleSlots),n=I._slots.length;let s=I._slots;t.glyphs.length!==n&&(VrA(A,o,s),s=OrA(A,o,t.glyphs.length));const B=l7(A,o,t,s,r);if(o._liveCount+=B.length-n,g===t)I._slots=B,I._styleSlots=r;else{A._runRecords.delete(g),A._runRecords.set(t,{_run:t,_groupIdx:I._groupIdx,_slots:B,_styleSlots:r});const Q=u7(A,e);Q>=0&&(A._runs[Q]=t)}return}const C=u7(A,e);sU(A._storage,t.curveSet,"replaceRun"),U3(t)>A._freeStyleSlots.length+I._styleSlots.length+pE-A._styleCount&&m(872,pE),$rA(A,C>=0?C:g),XrA(A,t,C>=0?C:void 0)}function AnA(A,e){const t=[],g=new Float32Array(3),I={runs:t,_runs:t,_groups:[],_runRecords:new Map,_instances:g,_instancesU32:new Uint32Array(g.buffer),_instanceCount:0,_styles:new Float32Array(8),_styleCount:0,_freeStyleSlots:[],_styleVersion:1,_storage:A,_version:1,_layoutVersion:0,_dirtyStart:0,_dirtyEnd:0};return e&&e.length>0&&WrA(I,e,A),I}function p7(A,e){switch(e.update){case"reset":WrA(A,e.runs??A._runs.slice(),e.storage??A._storage);return;case"addRun":XrA(A,e.run,e.insertBefore);return;case"removeRun":$rA(A,e.run);return;case"replaceRun":zWA(A,e.previous,e.run);return}}function enA(A){for(const e of A._groups)e._bindGroup=null;A._groups=[],A._instanceCount=0,A._styleCount=0,A._freeStyleSlots.length=0,A._runs.length=0,A._runRecords.clear()}var tnA,d7,pE,gnA,BU,ls=b((()=>{rA(),tnA=4294967295,d7=65534,pE=65535,gnA=[1,1,1,1],BU=null}));function QU(A,e){return A.createBuffer({label:"text-styles",size:e*32,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function InA(A,e,t){const g=Math.max(1,e._styleCount);let I=!1;if(g*32>t._styleBuf.size&&(t._styleBuf.destroy(),t._styleBuf=QU(A,e._styles.byteLength/32),t._uploadedStyleVersion=-1,I=!0),t._uploadedStyleVersion!==e._styleVersion){if(e._styleCount>0){const o=e._styles;A.queue.writeBuffer(t._styleBuf,0,o.buffer,o.byteOffset,e._styleCount*32)}t._uploadedStyleVersion=e._styleVersion}return I}var f7=b((()=>{ls()}));function inA(A){const e=new Map;if(A)for(const[t,g]of A)e.set(t,rnA(g));return{_curveSets:e}}function onA(A,e,t){let g=A._curveSets.get(e);g||(g=rnA(new Map),A._curveSets.set(e,g));for(const[I,o]of t)g._curves.has(I)||(g._curves.set(I,o),g._atlas._glyphSlots.set(I,snA(g._atlas,o)))}function CnA(A){for(const e of A._curveSets.values()){const t=e._atlas._gpu;t&&(t._curveTex.destroy(),t._bandTex.destroy(),t._metaBuf.destroy(),e._atlas._gpu=null)}A._curveSets.clear()}function ZWA(){return{_curveTexData:new Float32Array(BnA),_curveTexelsUsed:0,_bandTexData:new Uint32Array(j1*2),_bandTexelsUsed:0,_glyphSlots:new Map,_metaData:new Float32Array(192),_slotCount:0,_version:0,_gpu:null}}function rnA(A){const e=ZWA();for(const[t,g]of A)e._glyphSlots.set(t,snA(e,g));return{_curves:A,_atlas:e}}function nnA(A,e,t,g=4){const I=e*g,o=j1*g;if(A.length>=I)return A;let C=Math.max(A.length*2,o);for(;C<I;)C*=2;C=Math.ceil(C/o)*o;const r=new t(C);return r.set(A),r}function snA(A,e){const t=$WA(e),g=e.curves;let I=A._curveTexelsUsed;const o=new Array(g.length);for(let F=0;F<g.length;F++){const v=I/j1|0,U=(I+1)/j1|0;v!==U&&(I=U*j1),o[F]=I,I+=2}const C=I;A._curveTexData=nnA(A._curveTexData,C,Float32Array);const r=A._curveTexData;for(let F=0;F<g.length;F++){const v=g[F],U=o[F],L=U*4;r[L]=v.p0x,r[L+1]=v.p0y,r[L+2]=v.p1x,r[L+3]=v.p1y;const x=(U+1)*4;r[x]=v.p2x,r[x+1]=v.p2y}A._curveTexelsUsed=C;const n=t._hBandCount+t._vBandCount;let s=A._bandTexelsUsed;s%4096+n>4096&&(s=((s/j1|0)+1)*j1);const B=s%j1,Q=s/j1|0,E=[...t._hBands,...t._vBands];let c=n;const l=new Array(E.length);for(let F=0;F<E.length;F++)l[F]=c,c+=E[F]._curveIndices.length;const u=s+c;A._bandTexData=nnA(A._bandTexData,u,Uint32Array,2);const p=A._bandTexData;for(let F=0;F<E.length;F++){const v=(s+F)*2;p[v]=E[F]._curveIndices.length,p[v+1]=l[F]}for(let F=0;F<E.length;F++){const v=E[F],U=s+l[F];for(let L=0;L<v._curveIndices.length;L++){const x=o[v._curveIndices[L]],P=x%j1,j=x/j1|0,O=(U+L)*2;p[O]=P,p[O+1]=j}}A._bandTexelsUsed=u,A._version++;const{xMin:d,yMin:f,xMax:D,yMax:_}=e.bounds,y=D-d,w=_-f,S=y>0?t._vBandCount/y:0,R=w>0?t._hBandCount/w:0,M=A._slotCount++,N=A._slotCount*12;if(A._metaData.length<N){const F=new Float32Array(Math.max(A._metaData.length*2,N));F.set(A._metaData),A._metaData=F}const G=M*12,K=A._metaData;return K[G]=d,K[G+1]=f,K[G+2]=D,K[G+3]=_,K[G+4]=B,K[G+5]=Q,K[G+6]=t._vBandCount-1,K[G+7]=t._hBandCount-1,K[G+8]=S,K[G+9]=R,K[G+10]=-d*S,K[G+11]=-f*R,{_index:M}}function L3(A,e){const t=A[e];if(!t)throw new Error("buildGlyphBands: invalid curve index");return t}function XWA(A){const{curves:e,bounds:t}=A,g=Math.max(1,Math.min(8,Math.floor(e.length/2))),{xMin:I,yMin:o,xMax:C,yMax:r}=t,n=C-I,s=r-o,B=s/g,Q=n/g,E=[],c=[];for(let l=0;l<g;l++)E.push({_curveIndices:[]}),c.push({_curveIndices:[]});for(let l=0;l<e.length;l++){const u=L3(e,l),p=Math.min(u.p0y,u.p1y,u.p2y),d=Math.max(u.p0y,u.p1y,u.p2y),f=Math.min(u.p0x,u.p1x,u.p2x),D=Math.max(u.p0x,u.p1x,u.p2x);if(s>0)for(let _=0;_<g;_++){const y=o+_*B,w=o+(_+1)*B;d>=y&&p<=w&&E[_]._curveIndices.push(l)}if(n>0)for(let _=0;_<g;_++){const y=I+_*Q,w=I+(_+1)*Q;D>=y&&f<=w&&c[_]._curveIndices.push(l)}}for(const l of E)l._curveIndices.sort((u,p)=>{const d=L3(e,u),f=L3(e,p);return Math.max(f.p0x,f.p1x,f.p2x)-Math.max(d.p0x,d.p1x,d.p2x)});for(const l of c)l._curveIndices.sort((u,p)=>{const d=L3(e,u),f=L3(e,p);return Math.max(f.p0y,f.p1y,f.p2y)-Math.max(d.p0y,d.p1y,d.p2y)});return{_hBands:E,_vBands:c,_hBandCount:g,_vBandCount:g}}function $WA(A){return A._bands??=XWA(A)}var j1,BnA,D7=b((()=>{j1=4096,BnA=j1*4}));function dE(A){let e=1;for(;e<A;)e<<=1;return e}function QnA(A,e){return A.createBuffer({label:"text-glyph-metadata",size:e*h7,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function _7(A){return A<=0?1:Math.ceil(A/Y3)}function aU(A,e,t,g){return A.createTexture({label:t,format:g,size:{width:Y3,height:e,depthOrArrayLayers:1},usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC})}function anA(A,e,t,g,I){if(g===0)return;const o=_7(g);A.queue.writeTexture({texture:e},t.buffer,{offset:t.byteOffset,bytesPerRow:Y3*I*4,rowsPerImage:o},{width:Y3,height:o,depthOrArrayLayers:1})}function y7(A,e){let t=e._gpu;const g=_7(e._curveTexelsUsed),I=_7(e._bandTexelsUsed),o=Math.max(1,e._slotCount);t&&t._device!==A&&(t._curveTex.destroy(),t._bandTex.destroy(),t._metaBuf.destroy(),t=null);let C=!1;if(t)g>t._curveTexRows&&(t._curveTex.destroy(),t._curveTexRows=dE(g),t._curveTex=aU(A,t._curveTexRows,"text-slug-curves","rgba32float"),t._uploadedVersion=-1,C=!0),I>t._bandTexRows&&(t._bandTex.destroy(),t._bandTexRows=dE(I),t._bandTex=aU(A,t._bandTexRows,"text-slug-bands","rg32uint"),t._uploadedVersion=-1,C=!0),o>t._metaCap&&(t._metaBuf.destroy(),t._metaCap=dE(o),t._metaBuf=QnA(A,t._metaCap),t._uploadedVersion=-1,C=!0);else{const r=dE(Math.max(1,g)),n=dE(Math.max(1,I)),s=dE(o);t={_device:A,_curveTex:aU(A,r,"text-slug-curves","rgba32float"),_bandTex:aU(A,n,"text-slug-bands","rg32uint"),_curveTexRows:r,_bandTexRows:n,_metaBuf:QnA(A,s),_metaCap:s,_uploadedVersion:-1},e._gpu=t,C=!0}if(t._uploadedVersion!==e._version){if(anA(A,t._curveTex,e._curveTexData,e._curveTexelsUsed,4),anA(A,t._bandTex,e._bandTexData,e._bandTexelsUsed,2),e._slotCount>0){const r=e._metaData;A.queue.writeBuffer(t._metaBuf,0,r.buffer,r.byteOffset,e._slotCount*h7)}t._uploadedVersion=e._version}return{_rebuilt:C,_gpu:t}}var Y3,h7,w7=b((()=>{D7(),Y3=4096,h7=48})),AzA=H({rebuildRegisteredTextRenderers:()=>ezA});function ezA(A){for(const e of A.surfaces)for(const t of e._renderingContexts)t._kind==="text-renderer"&&tzA(t)}function tzA(A){const e=A._surface.engine,t=e._device;A._visibleBundles.length=0;for(const g of A._layerGpu.values())g._textU=XI(e,EnA,"text-layer-ubo"),g._instanceBuf=t.createBuffer({label:"text-layer-instances",size:g._instanceCap*12,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),g._styleBuf=QU(t,g._styleBuf.size/32),g._uploadedStyleVersion=-1,g._pipeline=null,g._bindGroupCache.length=0,g._uploadedDataVersion=-1,g._uploadedViewportW=0,g._uploadedViewportH=0,g._lastMvpInputs.fill(0),g._mvpUploaded=!1,g._renderBundle=null,g._bundleLayoutVersion=-1,g._bundleDrawCalls=0;for(const g of A.layers)for(const I of g.data._groups)y7(t,I._curveSet._atlas);A._update()}var EnA,gzA=b((()=>{co(),f7(),w7(),ls(),EnA=96}));function IzA(A,e={}){return l9(A,{_kind:"text-renderer",async _recover(t){const{rebuildRegisteredTextRenderers:g}=await Promise.resolve().then(()=>(gzA(),AzA));g(t)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function nC(A){A._refCount=(A._refCount??1)+1}function W1(A){const e=A._refCount;return e===void 0||e<=1?!0:(A._refCount=e-1,!1)}var us=b((()=>{})),cnA=H({rebuildScenePbrPipelines:()=>S7,rebuildSceneRenderables:()=>M7});async function S7(A,e=!1){await lnA(A,"pbr",e)}async function M7(A){await lnA(A,void 0,!1)}async function lnA(A,e,t){const g=A;if(!g._built&&!t)return;const I=g._lightListVersion??0,o=g.surface.engine,C=p=>{g._z?p.forEach(d=>d()):ag(o,()=>p.forEach(d=>d()))};let r=!1,n=!1,s=!1,B=!1;try{for(let p=1;;p++){if(e!==void 0){await Q();break}if(c(g),await Q(),!E(g))break;if(p>=pnA){g._rebuildHook=EU,B=!0,n=!0;break}}s=!0}finally{if(r&&(g._renderables.sort(unA),g._renderableVersion++,g._materialEpoch++,g._built&&g._frameGraph.build()),e===void 0&&s&&!n&&(g._lightListVersion??0)===I){const p=g._pendingTopologyRetirements?.splice(0);p?.length&&C(p),B||(g._rebuildHook=void 0)}}async function Q(){for(const[p,d]of g._groups){if(e!==void 0&&p._materialFamily!==e)continue;if(d.length===0){(d.o||d.r)&&(l(p,d),r=!0);continue}const f=g._runtimeBuilds;await f?.wait(d);let D=!1;const _=async()=>{const S=g._runtimeBuilds,R=[...d].filter(z=>g.meshes.includes(z)&&z.material?._buildGroup===p);if(R.length===0){l(p,d);return}const M=!!d.r,N=g._disposables.length,G=new Map,K=new Map(R.map(z=>[z,z.material]));for(const z of R){const Z=g._meshDisposables.get(z);Z&&(G.set(z,Z),g._meshDisposables.delete(z),S?.holdPendingDisposers(z,Z))}let F,v;g._p=z=>(v=z,!0);try{F=await p(g,R)}catch(z){v?.[1]();for(const Z of R){const AA=G.get(Z),BA=g._meshDisposables.get(Z);if(BA&&BA!==AA)for(const sA of BA)sA();const QA=g.meshes.includes(Z)&&Z.material===K.get(Z)&&Z.material?._buildGroup===p&&d.includes(Z);AA&&QA?g._meshDisposables.set(Z,AA):(g._meshDisposables.delete(Z),AA&&C(AA)),AA&&S?.releasePendingDisposers(Z,AA)}throw z}finally{delete g._p}if(g._z||f?._d()){v?.[1]();for(const Z of R){const AA=g._meshDisposables.get(Z),BA=G.get(Z);if(AA&&AA!==BA)for(const QA of AA)QA();g._meshDisposables.delete(Z)}for(const Z of g._disposables.splice(0))Z();const z=[...G.values()].flat();C(z);for(const[Z,AA]of G)S?.releasePendingDisposers(Z,AA);return}v?.[0](),p._rebuildSingle=F.rebuildSingle,d.r=g._runtimeBuilds?.base(p,F.rebuildSingle)??F.rebuildSingle,F._w!==void 0&&(d._w=F._w),M&&u(g,N);const U=new Set(R.filter(z=>g.meshes.includes(z)&&z.material===K.get(z)&&z.material?._buildGroup===p&&d.includes(z)));if(U.size!==R.length&&F.renderables.some(z=>!z.mesh)){for(const z of R){const Z=g._meshDisposables.get(z),AA=G.get(z);if(Z&&Z!==AA)for(const BA of Z)BA();AA&&g.meshes.includes(z)?g._meshDisposables.set(z,AA):(g._meshDisposables.delete(z),AA&&C(AA)),AA&&S?.releasePendingDisposers(z,AA)}D=!0;return}const L=new Set;for(const z of R){if(!U.has(z)){const Z=G.get(z),AA=g._meshDisposables.get(z);if(AA&&AA!==Z)for(const BA of AA)BA();Z&&g.meshes.includes(z)?(g._meshDisposables.set(z,Z),G.delete(z),S?.releasePendingDisposers(z,Z)):g._meshDisposables.delete(z);continue}L.add(z.material),z._renderableGen=-~z._renderableGen,g._runtimeBuilds?.reset(z)}for(const z of L)z._csmGen=(z._csmGen??0)+1;const x=d.o,P=x?.length?new Set(x):null;for(let z=g._renderables.length-1;z>=0;z--){const Z=g._renderables[z];(U.has(Z.mesh)||P?.has(Z))&&g._renderables.splice(z,1)}const j=F.renderables.filter(z=>!z.mesh||U.has(z.mesh));g._renderables.push(...j),d.o=j;const O=[...G.values()].flat();C(O);for(const[z,Z]of G)S?.releasePendingDisposers(z,Z)},{X:y}=await Promise.resolve().then(()=>(pU(),lU)),w=3;for(let S=1;;S++){if(D=!1,await y(g,p,_),g._z||f?._d()){n=!0;return}if(!D)break;if(S>=w){l(p,d),g._rebuildHook=EU,B=!0,n=!0;break}}if(D){r=!0;continue}r=!0}}function E(p){for(const d of p.meshes){const f=d.material?._buildGroup;if(f&&!p._groups.get(f)?.includes(d))return!0}return!1}function c(p){const d=new Map;for(const f of p.meshes){const D=f.material?._buildGroup;if(!D)continue;const _=d.get(D);_?_.push(f):d.set(D,[f])}for(const[f,D]of p._groups){const _=d.get(f)??[];(D.length!==_.length||_.some((y,w)=>D[w]!==y))&&(D.length=0,D.push(..._)),d.delete(f)}for(const[f,D]of d){const _=D;p._groups.set(f,_)}}function l(p,d){const f=d.o;if(f?.length){const D=new Set(f);for(let _=g._renderables.length-1;_>=0;_--)D.has(g._renderables[_])&&g._renderables.splice(_,1)}d.o=void 0,d.r=void 0,g._runtimeBuilds?.dropBase(p),g._rebuildHook=EU,B=!0}function u(p,d){const f=new Set(p._disposables.slice(0,d));for(let D=p._disposables.length-1;D>=d;D--)f.has(p._disposables[D])&&p._disposables.splice(D,1)}}var unA,pnA,EU,cU=b((()=>{kg(),unA=(A,e)=>A.order-e.order,pnA=8,EU=A=>M7(A)})),lU=H({A:()=>fnA,B:()=>DnA,C:()=>izA,X:()=>ozA});function dnA(A,e,t){A.pendingDisposers.set(e,t)}function R7(A,e,t){t&&A.pendingDisposers.get(e)===t&&A.pendingDisposers.delete(e)}function fnA(A,e,t,g){if(!e||t.material!==e)return g??Promise.resolve();const I=DnA(A,e._buildGroup,t);return g?Promise.all([g,I]).then(()=>{}):I}function izA(A,e,t){let g=t;for(const I of e){const o=Array.isArray(I),C=o?I[0]:I;g=fnA(A,o?I[1]:C.material,C,g)}return(g??Promise.resolve()).catch(I=>{A._runtimeBuilds?._x(I)})}function DnA(A,e,t){if(A._z||!A.meshes.includes(t))return A._runtimeBuilds?.all().catch(()=>{})??Promise.resolve();CzA(A,e,t);const g=A._runtimeBuilds??_nA(A);return e._materialFamily==="pbr"&&(A._built||A._groups.get(e)?.r)?(g._n||(g._l=Promise.resolve(g._l).then(()=>Promise.resolve().then(()=>(cU(),cnA))).finally(()=>{g._n=void 0}).then(({rebuildScenePbrPipelines:I})=>A._z?void 0:I(A,!0)).catch(I=>{A._runtimeBuilds?._x(I)}),g._n=g.track(g._l)),g._n):g.queue(e,t).catch(()=>{})}function ozA(A,e,t){return A._z?Promise.resolve(void 0):(A._runtimeBuilds??_nA(A)).exclusive(e,t)}function _nA(A){const e={disposed:!1,error:null,active:new Set,chains:new WeakMap,generations:new WeakMap,installed:new WeakMap,installedMeshes:new Set,pendingDisposers:new WeakMap,tail:null},t=A,g={queue:(I,o)=>{const C=(e.generations.get(o)??0)+1,r=o.material;e.generations.set(o,C);const n=e.chains.get(o),s=[e.tail,In?.get(I)].filter(c=>!!c);let B=()=>{};const Q=new Promise(c=>{B=c});e.tail=Q,(In??=new WeakMap).set(I,Q);const E=(n?n.catch(()=>{}):Promise.resolve()).then(()=>Promise.all(s)).then(()=>rzA(A,e,I,o,r,C)).catch(c=>{throw uU(A,e,I,o,r,C)&&(e.error=c instanceof Error?c:new Error("Runtime mesh build failed",{cause:c})),c}).finally(()=>{B(),e.tail===Q&&(e.tail=null),In?.get(I)===Q&&In.delete(I)}).finally(()=>{e.chains.get(o)===E&&e.chains.delete(o)});return e.chains.set(o,E),g.track(E)},all:()=>Promise.all(e.active).then(()=>{}),track:I=>{const o=I.finally(()=>e.active.delete(o));return e.active.add(o),Promise.all(e.active).then(()=>{})},base:(I,o)=>{const C=ps?.get(I);return C&&C.bases.set(A,o),C?.dispatch??o},get w(){return!!e.tail},pendingDisposers:I=>e.pendingDisposers.get(I),holdPendingDisposers:(I,o)=>dnA(e,I,o),releasePendingDisposers:(I,o)=>R7(e,I,o),reset:I=>{hnA(A,e,I),t._pbrMeshGeomContexts?.delete(I)},remove:I=>{e.generations.set(I,(e.generations.get(I)??0)+1),e.chains.delete(I),ynA(A,e,I),t._pbrMeshGeomContexts?.delete(I)},dropBase:I=>{const o=ps?.get(I);o&&(o.bases.delete(A),o.scenes.delete(A))},wait:async I=>{const o=new Set;for(const C of I){const r=e.chains.get(C);r&&o.add(r)}await Promise.all(o)},_e:(I=!0)=>{if(e.error){const o=e.error;throw I&&(e.error=null),o}},_x:I=>{e.error=I instanceof Error?I:new Error("Runtime mesh build failed",{cause:I})},_d:()=>e.disposed,exclusive:(I,o)=>{const C=[];e.tail&&C.push(e.tail);const r=In?.get(I);r&&C.push(r);const n=Promise.all(C).then(o),s=n.then(()=>{},()=>{});return e.tail=s,(In??=new WeakMap).set(I,s),s.then(()=>{e.tail===s&&(e.tail=null),In?.get(I)===s&&In.delete(I)}),n}};return A._runtimeBuilds=g,(A._beforeRender??=[]).push(()=>{g._e()}),A._disposables.push(()=>{e.disposed=!0,e.active.clear();for(const I of e.installedMeshes)hnA(A,e,I);for(const I of A._groups.keys())ps?.get(I)?.bases.delete(A);A._runtimeBuilds=void 0,t._pbrMeshGeomContexts=void 0}),g}function CzA(A,e,t){for(const[I,o]of A._groups)if(I!==e){const C=o.indexOf(t);C>=0&&o.splice(C,1)}let g=A._groups.get(e);g||(g=[],A._groups.set(e,g)),g.includes(t)||g.push(t)}async function rzA(A,e,t,g,I,o){if(!uU(A,e,t,g,I,o))return;const C=A._meshDisposables.get(g);C&&(A._meshDisposables.delete(g),dnA(e,g,C));const r=t._rebuildSingle,n=ps?.get(t)?.bases.get(A)??A._groups.get(t)?.r,s=!!A._groups.get(t)?.r,B=A._disposables.length,Q=A,E=Q._pbrGeomContext;let c,l;try{l=await t(A,[g]),c=Q._pbrGeomContext}catch(d){if(wnA(A,e,g,C),SnA(A,e),!uU(A,e,t,g,I,o))return;throw d}finally{t._rebuildSingle=r,t._materialFamily==="pbr"&&s&&(Q._pbrGeomContext=E)}if(!uU(A,e,t,g,I,o)){wnA(A,e,g,C),SnA(A,e);return}for(let d=A._renderables.length-1;d>=0;d--)A._renderables[d].mesh===g&&A._renderables.splice(d,1);if(C){for(const d of C){const f=A._disposables.indexOf(d);f>=0&&A._disposables.splice(f,1);const D=d.p;if(D){D._disposed=!0;const _=D._owner;if(_){const y=_.indexOf(D);y>=0&&_.splice(y,1),D._owner=void 0,_.length===0&&D._onOwnerEmpty?.()}else D._onOwnerEmpty?.();D._onOwnerEmpty&&(D._onOwnerEmpty=void 0)}}ag(A.surface.engine,()=>{for(const d of C)d()})}R7(e,g,C),A._renderables.push(...l.renderables);const u=A._groups.get(t);u&&(u.o=[...(u.o??[]).filter(d=>d.mesh!==g),...l.renderables]),l.updater&&A._uniformUpdaters.push(l.updater),s&&szA(A,B),t._materialFamily==="pbr"&&s&&c&&(Q._pbrMeshGeomContexts??=new WeakMap).set(g,c),nzA(A,e,t,g,l.rebuildSingle,s?n:l.rebuildSingle),g._renderableGen=-~g._renderableGen;const p=A._groups.get(t);p&&!s&&(p.r=l.rebuildSingle),A._renderables.sort(MnA),A._renderableVersion++,A._materialEpoch++}function nzA(A,e,t,g,I,o){let C=ps?.get(t);if(!C){const B=new WeakMap,Q=new WeakMap;C={bases:Q,dispatch:(c,l,u,p)=>{const d=B.get(c)?.get(l);if(d)return d(c,l,u,p);const f=Q.get(c)??c._groups.get(t)?.r;if(f)return f(c,l,u,p);throw new Error("Material group has not completed its initial build")},scenes:B},(ps??=new WeakMap).set(t,C)}let r=C.scenes.get(A);r||(r=new WeakMap,C.scenes.set(A,r)),r.set(g,I),C.bases.has(A)||C.bases.set(A,o??I);const n=A._groups.get(t);n&&(n.r=C.dispatch);let s=e.installed.get(g);s||(s=new Set,e.installed.set(g,s)),s.add(t),e.installedMeshes.add(g)}function ynA(A,e,t){const g=e.installed.get(t);if(g){for(const I of g)ps?.get(I)?.scenes.get(A)?.delete(t);e.installed.delete(t),e.installedMeshes.delete(t)}}function hnA(A,e,t){ynA(A,e,t)}function uU(A,e,t,g,I,o){return!e.disposed&&e.generations.get(g)===o&&A.meshes.includes(g)&&g.material===I&&I._buildGroup===t}function wnA(A,e,t,g){const I=A._meshDisposables.get(t);if(I&&I!==g){A._meshDisposables.delete(t);for(const o of I)o()}if(g)if(A.meshes.includes(t))A._meshDisposables.set(t,g);else if(e.disposed)for(const o of g)o();else ag(A.surface.engine,()=>{for(const o of g)o()});R7(e,t,g)}function SnA(A,e){if(!e.disposed)return;const t=A._disposables.splice(0);for(const g of t)g()}function szA(A,e){const t=new Set(A._disposables.slice(0,e));for(let g=A._disposables.length-1;g>=e;g--)t.has(A._disposables[g])&&A._disposables.splice(g,1)}var MnA,In,ps,pU=b((()=>{kg(),MnA=(A,e)=>A.order-e.order,In=null,ps=null}));function RnA(A,e,t,g=e.material){return Promise.resolve().then(()=>(pU(),lU)).then(I=>I.A(A,g,e,t)).catch(I=>console.error(I))}function dU(A,e,t){A._runtimeThinBuild=RnA,A.thinInstances?(A.thinInstances.matrices=e,A.thinInstances.count=t,A.thinInstances._capacity=t,A.thinInstances._version++,A.thinInstances._dirtyMin=0,A.thinInstances._dirtyMax=t):A.thinInstances={matrices:e,count:t,_capacity:t,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:t,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1}}function m7(A,e){const t=A.thinInstances;t&&(t.count=e,t._version++,t._dirtyMin=0,t._dirtyMax=e)}function BzA(A,e){const t=A.thinInstances;if(t){if(!Number.isInteger(e)||e<0||e>t._capacity)throw new RangeError(`Thin instance draw count ${e} must be an integer between 0 and capacity ${t._capacity}`);t.count!==e&&((!t._gpuBuffer||t._gpuVersion!==t._version||t.colors&&(!t._colorGpuBuffer||t._colorGpuVersion!==t._colorVersion))&&m(645),t.count=e,t._gpuVersion=++t._version)}}function QzA(A){const e=A.thinInstances;e||m(646),e._drawArgsBuffer||(e._drawArgsInstanceCount=-1)}function azA(A,e){A._runtimeThinBuild=RnA;const t=A.thinInstances;if(!t){const o=new CA(256);return o.set(e,0),A.thinInstances={matrices:o,count:1,_capacity:16,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:1,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1},0}const g=t.count;if(g>=t._capacity){const I=t._capacity*2,o=new CA(I*16);o.set(t.matrices),t.matrices=o,t._capacity=I}return t.matrices.set(e,g*16),t.count++,t._version++,t._dirtyMin=0,t._dirtyMax=t.count,g}function EzA(A,e,t){const g=A.thinInstances;g.matrices.set(t,e*16),g._version++,g._dirtyMin=Math.min(g._dirtyMin,e),g._dirtyMax=Math.max(g._dirtyMax,e+1)}function czA(A,e){const t=A.thinInstances,g=t.count-1;e!==g&&t.matrices.copyWithin(e*16,g*16,g*16+16),t.count--,t._version++,t._dirtyMin=0,t._dirtyMax=t.count}function N7(A){const e=A.thinInstances;e._version++,e._dirtyMin=0,e._dirtyMax=e.count}function lzA(A,e){const t=A.thinInstances;t.colors=e,t._version++,t._colorVersion++,t._colorDirtyMin=0,t._colorDirtyMax=t.count}function uzA(A,e,t,g,I,o){const C=A.thinInstances,r=C.colors,n=e*4;r[n]=t,r[n+1]=g,r[n+2]=I,r[n+3]=o,C._version++,C._colorVersion++,C._colorDirtyMin=Math.min(C._colorDirtyMin,e),C._colorDirtyMax=Math.max(C._colorDirtyMax,e+1)}function pzA(A,e=!0){const t=A.thinInstances;t||m(647),t._gpuCullingEnabled!==e&&(t._gpuCullingEnabled=e,t._gpuVersion=-1,t._colorGpuVersion=-1)}function dzA(A,e){const t=A.thinInstances;t||m(648),t._cullBoundsPad=e}function fzA(A,e,t){const g=A.thinInstances,I=e.thinInstances;if((!g||!I)&&m(649),A===e&&m(650),((g._refCount??1)>1||(I._refCount??1)>1)&&m(651),!Number.isFinite(t.distance)||t.distance<0)throw new RangeError("setThinInstanceLodPartner distance must be a finite non-negative number");const o=t.band??0;if(!Number.isFinite(o)||o<0)throw new RangeError("setThinInstanceLodPartner band must be a finite non-negative number");g._lodSource&&m(652),I._lodPartner&&m(653),I._lodSource&&I._lodSource!==A&&m(654),I.colors&&!g.colors&&m(655);const C=g._lodPartner;if(C&&C!==e){const n=C.thinInstances;n&&n._lodSource===A&&fU(n),C._clone=void 0,g._lodBuckets=null}g._lodPartner=e,g._lodDistance=t.distance,g._lodBand=o,I._lodSource=A,A._clone=e._clone="Cannot clone LOD-paired mesh";const r=g._lodBuckets??new WeakMap;g._lodBuckets=r,I._lodBuckets=r,I._gpuCullingEnabled||(I._lodAutoCull=!0,I._gpuCullingEnabled=!0,I._gpuVersion=-1,I._colorGpuVersion=-1)}function DzA(A){const e=A.thinInstances;if(!e?._lodPartner)return;const t=e._lodPartner,g=t.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,t._clone=void 0,g&&g._lodSource===A&&fU(g)}function _zA(A){const e=A.thinInstances;if(!e)return;const t=e._lodSource,g=t?.thinInstances;t&&g?._lodPartner===A&&(g._lodPartner=null,g._lodDistance=void 0,g._lodBand=void 0,g._lodBuckets=null,t._clone=void 0),e._lodSource&&fU(e);const I=e._lodPartner,o=I?.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,I&&o?._lodSource===A&&(I._clone=void 0,fU(o))}function fU(A){A._lodSource=null,A._lodBuckets=null,A._lodAutoCull&&(A._lodAutoCull=!1,A._gpuCullingEnabled=!1,A._gpuVersion=-1,A._colorGpuVersion=-1)}var fE=b((()=>{rA(),VA()}));function yzA(A){G7=A}function hzA(A){DU=A}function mnA(A){A.positionBuffer.destroy(),A.normalBuffer.destroy(),A.uvBuffer.destroy(),A.tangentBuffer?.destroy(),A.uv2Buffer?.destroy(),A.colorBuffer?.destroy()}function z1(A){if(A._disposed)return;A._disposed=!0,G7?.(A);const e=A._gpu;W1(e)&&(DU?DU(e,mnA):(mnA(e),e.indexBuffer.destroy()),e._shaderColorFallback?.destroy());const t=A.thinInstances;t&&W1(t)&&(_zA(A),t._gpuBuffer?.destroy(),t._colorGpuBuffer?.destroy(),t._drawArgsBuffer?.destroy());const g=A.skeleton;g&&W1(g)&&(g._disposed=!0,g.boneTexture.destroy(),W1(g._skinBuffers)&&(g.jointsBuffer.destroy(),g.weightsBuffer.destroy(),g.joints1Buffer?.destroy(),g.weights1Buffer?.destroy()));const I=A.vat;I&&W1(I)&&(I.settingsBuffer.destroy(),I.instanceTexture?.destroy(),W1(I._textureResource)&&I._textureResource.texture.destroy(),W1(I._skinBuffers)&&(I.jointsBuffer.destroy(),I.weightsBuffer.destroy(),I.joints1Buffer?.destroy(),I.weights1Buffer?.destroy()));const o=A.morphTargets;o&&W1(o)&&(o._disposed=!0,o.deltasBuffer.destroy(),o.weightsBuffer.destroy())}var DU,G7,ar=b((()=>{us(),fE(),DU=null,G7=null}));function NnA(A){const e=x3;x3=e?(t,g)=>{e(t,g),A(t,g)}:A}function DE(A,e){A._materialSwapQueue.includes(e)||A._materialSwapQueue.push(e)}function b7(A){const e=_E?.get(A);if(e)for(const t of e)DE(t,A)}function wzA(A){return _E?.get(A)}function SzA(A){let e=A.material;Object.defineProperty(A,"material",{get(){return e},set(t){if(t!==e){x3?.(A,t),e=t;const g=_E?.get(A);if(g)for(const I of g)DE(I,A),I._meshMaterialChange?.(A,t)}},configurable:!0,enumerable:!0})}function MzA(A,e){e._disposed&&m(792,e.name),x3?.(e,e.material);const t=_E??=new WeakMap;let g=t.get(e);g||(t.set(e,g=new Set),SzA(e)),g.add(A)}function GnA(A,e){const t=_E?.get(e);return t?(t.delete(A),t.size===0):!0}var _E,x3,ds=b((()=>{rA(),_E=null,x3=null}));function _U(A){const e=A._materialSwapQueue;if(!e[0]||A._runtimeBuilds?.w)return;let t,g,I;const o=A._renderables;for(const r of e){const n=r.material;if(!n)continue;const s=r._runtimeThinBuild;if(s){g=s(A,r,g);continue}const B=A._groups.get(n._buildGroup),Q=B?.r;if(!Q){(I??=[]).push(r);continue}if(B._w?.(r)){(I??=[]).push([r,n]);continue}const E=A._meshDisposables.get(r);E&&(A._meshDisposables.delete(r),ag(A.surface.engine,()=>E.forEach(p=>p())));const c=B.o;let l;for(let p=o.length;p--;)o[p].mesh===r&&(l=o.splice(p,1)[0]);r._renderableGen=-~r._renderableGen;const u=Q(A,r);if(c){const p=c.indexOf(l);p<0?c.push(u):c[p]=u}t=o.push(u)}if(t&&(o.sort((r,n)=>r.order-n.order),A._renderableVersion++,A._materialEpoch++),e.length=0,!I)return g;const C=I;return Promise.resolve().then(()=>(pU(),lU)).then(({C:r})=>r(A,C,g),r=>{const n=A._runtimeBuilds;n?n._x(r):console.error(r)})}var F7=b((()=>{kg()}));function RzA(A){k7=A}function mzA(A,e,t){k7?.(A,e,t)}var k7,bnA=b((()=>{k7=null}));function FnA(A){const e={_tasks:[],_currentProcessedTask:null,build(){for(let t=0;t<e._tasks.length;t++)knA(e,e._tasks[t]);for(const t of e._tasks)for(const g of t._passes)g._initialize()},execute(){let t=0;for(const g of e._tasks)if(g.executionEnabled!==!1)if(g.execute)t+=g.execute();else for(const I of g._passes)t+=I._execute();return t},dispose(){for(const t of e._tasks)t.dispose();e._tasks.length=0,e._currentProcessedTask=null}};return e}function NzA(A){return A._tasks}function GzA(A,e){A._tasks.includes(e)||m(121,e.name),knA(A,e);for(const t of e._passes)t._initialize()}function knA(A,e){e._passes.length=0,A._currentProcessedTask=e;try{e.record()}finally{A._currentProcessedTask=null}}function KnA(A,e){A._tasks.push(e)}var yU=b((()=>{rA()}));function bzA(){return hU??=new WeakMap,hU}function vnA(A,e){bzA().set(A,e),wU&&wU(A,e).catch(t=>console.error(t))}function J3(A){return hU?.get(A)}function FzA(A,e){if(e!==1/0&&(!Number.isInteger(e)||e<0))throw new RangeError("setShadowCasterMaxCascade requires a non-negative integer or Infinity");A._shadowMaxCascade=e===1/0?void 0:e}function kzA(A){wU=A}var hU,wU,SU=b((()=>{hU=null,wU=null})),KzA=H({createShadowTask:()=>vzA});function vzA(A,e){const t=new Set;kzA(UnA);const g={name:"shadow",engine:A,scene:e,_passes:[],async _preload(){const I=[];for(const o of e.lights){const C=o.shadowGenerator,r=C?J3(C):null;C?._preloadShadowTask&&r&&I.push(UnA(C,r))}await Promise.all(I)},record(){g._passes.length=0;for(const I of e.lights){const o=I.shadowGenerator,C=o?J3(o):null;if(o?._ensureShadowTaskState&&C&&!o._preloadPending){t.add(o);const r=o._ensureShadowTaskState(A,e,C),n=e._renderableVersion;r._task.record(),r._recordedVersion=n}}},execute(){let I=0;for(const o of e.lights){const C=o.shadowGenerator,r=C?J3(C):null;if(C?._ensureShadowTaskState&&C._renderShadowMap&&r&&!C._preloadPending){t.add(C);const n=C._shadowTaskState??null,s=C._ensureShadowTaskState(A,e,r);if(s!==n||s._recordedVersion!==e._renderableVersion){const B=e._renderableVersion;s._task.record(),s._recordedVersion=B}I+=C._renderShadowMap(A,s)}}return I},dispose(){g._passes.length=0;for(const I of t){const o=I._shadowTaskState;o&&(o._task.dispose(),I._shadowTaskState=void 0)}t.clear()}};return g}async function UnA(A,e){A._preloadPending=e,await A._preloadShadowTask?.(e),A._preloadPending===e&&(A._preloadPending=void 0)}var UzA=b((()=>{SU()}));function LzA(A){FQ=A}function YzA(A){K7=A}function LnA(A,e){const t=A.camera;t&&!t._useFloatingOrigin!=!e&&(t._useFloatingOrigin=e,t._viewVer=-1,t._projFov=void 0)}function YnA(A,e){const t=A.engine,g={_kind:"scene",surface:A,clearColor:{r:.2,g:.2,b:.3,a:1},camera:null,lights:[],meshes:[],animationGroups:[],fog:null,clipPlane:null,shadowGenerators:[],imageProcessing:{exposure:1,contrast:1,toneMappingEnabled:!1},_renderables:[],_prePasses:[],_pickSources:[],_uniformUpdaters:[],fixedDeltaMs:0,_beforeRender:[],_deferredBuilders:[],_groups:new Map,_disposables:[],_meshDisposables:new Map,_materialSwapQueue:[],_renderableVersion:0,_materialEpoch:0,_built:!1,_drawCallsPre:0,_update(){const o=g.fixedDeltaMs>0?g.fixedDeltaMs:t._currentDelta,C=t._currentEncoder;let r=0;LnA(g,t.useFloatingOrigin);for(const n of g._beforeRender)n(o);LnA(g,t.useFloatingOrigin),g._materialSwapQueue.length&&_U(g);for(const n of g._prePasses)r+=n.execute(C,t);for(const n of g._uniformUpdaters)n.update(t);g._drawCallsPre=r},_record(){return g._frameGraph.execute()},_resize(){g._frameGraph.build()}},I=FnA(t);if(g._frameGraph=I,e?.defaultRenderTask!==!1){const o=A.msaaSamples>1,C=o?Pv({lbl:"scene-color",format:A.format,dFormat:"depth24plus-stencil8",samples:A.msaaSamples,size:A}):A.scRT,r=o?void 0:Pv({lbl:"scene-depth",dFormat:"depth24plus-stencil8",samples:1,size:A});KnA(I,ST({name:"scene",rt:C,rst:o?A.scRT:void 0,depth:r},t,g))}return g._disposables.push(()=>I.dispose()),g}function yE(A,e){A._beforeRender.unshift(e)}function xnA(){return FQ!==void 0}function JnA(A,e){FQ?.run(A,e)}function H3(A,e,t){FQ?.record(A,e,t)}function xzA(A){return A._frameGraph}function hE(A,e){const t=A;t._deferredBuilders.push(async()=>{const g=await e(t.surface.engine,t);t._renderables.push(...g.renderables),g.dispose&&t._disposables.push(g.dispose)})}function tg(A,e){if(FQ&&A._sceneChanges&&A._sceneChanges.depth===0){FQ.run(A,()=>tg(A,e));return}const t=A;if("entities"in e){const I=e;for(const o of I.entities)tg(A,o);if(I.clearColor&&(t.clearColor=I.clearColor),I.camera&&!t.camera&&(t.camera=I.camera),I.animationGroups?.length){const o=t.surface.engine,C=I.animationGroups;t.animationGroups.push(...C);const r=n=>{for(const s of C)mzA(s,n,o)};I._beforeRenderHook=r,t._beforeRender.push(r)}I._sceneSetup?.(t,I),H3(t,e,"added");return}if("_gpu"in e&&"material"in e){const I=e;MzA(t,I),t.meshes.push(I),HnA(t,I),t._meshMaterialChange?.(I,I.material)}else"lightType"in e?t.lights.push(e):"fov"in e&&(t.camera=e);H3(t,e,"added");const g=e.children;if(g?.length)for(const I of g)I.parent=e,tg(A,I)}function HnA(A,e){const t=e.material?._buildGroup;if(!t)return;let g=A._groups.get(t);g||(g=[],A._groups.set(t,g),A._built||A._deferredBuilders.push(async()=>{if(!g[0]){A._groups.delete(t);return}const I=await t(A,g);A._renderables.push(...I.renderables),g.o=I.renderables,I.updater&&A._uniformUpdaters.push(I.updater),g.r=I.rebuildSingle})),g.push(e),(A._built||g.r)&&DE(A,e)}function TnA(A){const e=A;if(e._z)return;e._z=!0;const t=T3??=new WeakMap;t.set(e,()=>1),AE(e.surface,e);const g=()=>{t.set(e,()=>{for(const I of e._meshDisposables.values())I.forEach(o=>o());return e._meshDisposables.clear(),e._disposables.splice(0).forEach(I=>I()),e._renderables.length=e._uniformUpdaters.length=0,1}),e._disposables.splice(0).forEach(I=>I());for(const I of e._meshDisposables.values())for(const o of I)o();e._meshDisposables.clear();for(const I of e.meshes)GnA(e,I)&&z1(I);e._groups.clear(),e.meshes.length=0,e._renderables.length=0,e._prePasses.length=0,e._pickSources.length=0,e._uniformUpdaters.length=0,e._beforeRender.length=0,e._deferredBuilders.length=0,e._disposables.length=0,e._materialSwapQueue.length=0,e.lights.length=0,e.animationGroups.length=0,e.shadowGenerators.length=0,e.camera=null};FQ?.dispose(e),K7?K7(e,g):g()}async function qnA(A){for(const t of A.lights)t._validateLighting?.(A._lighting);const e=A;for(!e._built&&e._materialSwapQueue.splice(0)[0]&&(e._groups.forEach(t=>t.length=0),e.meshes.forEach(t=>HnA(e,t)));e._deferredBuilders.length;){const t=e._deferredBuilders.splice(0);await Promise.all(t.map(g=>g()))}await _U(e),T3?.get(e)?.()||(e._runtimeBuilds?._e(),e._renderableVersion++,e._built=!0),await e._rebuildHook?.(e)}function JzA(A){wE=A}function HzA(A){v7=A}async function PnA(A){const e=A,t=e.surface;$F(t,e)||(await qnA(A),e._renderables.sort(U7),await Promise.all(e._frameGraph._tasks.map(g=>g._preload?.())),wE&&await wE(e),e._frameGraph.build(),T3?.get(e)?.()||DQ(t,e)&&v7?.(e))}async function TzA(A){const e=A,t=e.surface;$F(t,e)||(await qnA(A),e._renderables.sort(U7),await qzA(t.engine,e),await Promise.all(e._frameGraph._tasks.map(g=>g._preload?.())),wE&&await wE(e),e._frameGraph.build(),T3?.get(e)?.()||DQ(t,e)&&v7?.(e))}async function qzA(A,e){if(e._frameGraph._tasks.some(g=>g.name==="shadow"))return;const{createShadowTask:t}=await Promise.resolve().then(()=>(UzA(),KzA));e._frameGraph._tasks.unshift(t(A,e))}function PzA(A){AE(A.surface,A)}var T3,FQ,K7,wE,v7,U7,mI=b((()=>{hI(),ar(),ds(),F7(),bnA(),yU(),nE(),Fg(),T3=null,wE=null,U7=(A,e)=>A.order-e.order}));xoA(),uCA(),mCA(),DT(),nrA(),G3(),cU(),mI();var OnA=!1,VnA=!1;function jnA(A){if(A.length===1)throw A[0];if(A.length>1)throw new AggregateError(A)}function OzA(A,e){const t=A._sceneChanges;if(!t){e();return}t.depth++;let g=!1,I;try{e()}catch(C){g=!0,I=C}if(t.depth--,t.depth>0||t.dispatching){if(g)throw I;return}const o=g?[I]:[];t.dispatching=!0;try{for(;t.pending.length;){const C=t.pending.shift();for(const r of[...t.listeners])if(t.listeners.has(r))try{r(C)}catch(n){o.push(n)}}}finally{t.dispatching=!1,!t.listeners.size&&A._sceneChanges===t&&(A._sceneChanges=void 0)}jnA(o)}function VzA(A){const e=A._sceneChanges;e&&(e.listeners.clear(),e.pending.length=0,A._sceneChanges===e&&(A._sceneChanges=void 0))}function jzA(A,e){const t=[];for(const g of A._disposables.splice(0))try{g()}catch(I){t.push(I)}A._disposables.length=0;try{e()}catch(g){t.push(g)}jnA(t)}function WnA(){VnA||(VnA=!0,YzA(jzA))}function WzA(){OnA||(OnA=!0,WnA(),LzA({run:OzA,record:(A,e,t)=>{const g=A._sceneChanges;if(g){if(t==="added"){if(g.members.has(e))return;g.members.add(e)}else if(!g.members.delete(e))return;g.pending.push({type:t,entity:e})}},dispose:VzA}))}function zzA(A){const e=new WeakSet,t=g=>{if(!e.has(g)&&(e.add(g),"children"in g&&Array.isArray(g.children)))for(const I of g.children)typeof I=="object"&&I!==null&&(!("parent"in I)||I.parent===g)&&t(I)};for(const g of[...A.meshes,...A.lights,...A.shadowGenerators])t(g);return A.camera&&t(A.camera),e}function znA(A,e){if(A._z)throw new Error("Cannot observe a disposed scene.");WzA();const t=A._sceneChanges??={listeners:new Set,pending:[],members:zzA(A),depth:0,dispatching:!1},g=o=>e(o);t.listeners.add(g);let I=!0;return()=>{I&&(I=!1,t.listeners.delete(g),!t.listeners.size&&!t.depth&&!t.dispatching&&A._sceneChanges===t&&(A._sceneChanges=void 0))}}function ZnA(A,e){WnA();const t=A._disposables,g=()=>e();t.push(g);let I=!0;return()=>{if(!I)return;I=!1;const o=t.indexOf(g);o>=0&&t.splice(o,1)}}function L7(A,e,t,g){A[3]=0,A[7]=0,A[11]=0,A[12]=e.x,A[13]=e.y,A[14]=e.z,A[15]=1;let I=t.x-e.x,o=t.y-e.y,C=t.z-e.z;const r=Math.sqrt(I*I+o*o+C*C);let n=0,s=0,B=0,Q=0;if(r>=1e-10){const c=1/r;I*=c,o*=c,C*=c,n=g.y*C-g.z*o,s=g.z*I-g.x*C,B=g.x*o-g.y*I,Q=Math.sqrt(n*n+s*s+B*B)}if(Q<1e-10){A[0]=1,A[1]=0,A[2]=0,A[4]=0,A[5]=1,A[6]=0,A[8]=0,A[9]=0,A[10]=1;return}const E=1/Q;n*=E,s*=E,B*=E,A[0]=n,A[1]=s,A[2]=B,A[4]=o*B-C*s,A[5]=C*n-I*B,A[6]=I*s-o*n,A[8]=I,A[9]=o,A[10]=C}var Y7=b((()=>{})),MU,x7=b((()=>{MU={x:0,y:1,z:0}}));Y7(),x7(),tn(),ns(),Ii(),it();function XnA(A,e,t,g){function I(){const Q=Math.cos(B.alpha),E=Math.sin(B.alpha),c=Math.cos(B.beta);let l=Math.sin(B.beta);return l===0&&(l=1e-4),{x:B.target.x+B.radius*Q*l,y:B.target.y+B.radius*c,z:B.target.z+B.radius*E*l}}const o=bg();function C(){return L7(o,I(),B.target,MU),o}const r=gE(C),n=()=>r.markLocalDirty(),s={alpha:A,beta:e,radius:t},B={alpha:0,beta:0,radius:0,target:new e1(g.x,g.y,g.z,n),fov:.8,nearPlane:.1,farPlane:1e3,children:[],inertia:.9,panningInertia:.9,angularSensibility:1e3,panningSensibility:50,wheelPrecision:3,inertialAlphaOffset:0,inertialBetaOffset:0,inertialRadiusOffset:0,inertialPanningX:0,inertialPanningY:0,_viewCache:bg(),_projCache:bg(),_vpCache:bg(),get parent(){return r.parent},set parent(Q){r.parent=Q},get worldMatrix(){return r.getWorldMatrix()},get worldMatrixVersion(){return r.getWorldMatrixVersion()}};for(const Q of["alpha","beta","radius"])Object.defineProperty(B,Q,{get:()=>s[Q],set:E=>{s[Q]!==E&&(s[Q]=E,n(),B._clampToLimits?.())},configurable:!0,enumerable:!0});return Q3(B,r),B}function kQ(A,e,t){return{x:A,y:e,z:t}}var J7=b((()=>{}));L1A(),J7();function ZzA(A){let e=1/0,t=1/0,g=1/0,I=-1/0,o=-1/0,C=-1/0;const r=v1A();for(const l of A.meshes)l.visible!==!1&&U1A(r,l);e=r.minX,t=r.minY,g=r.minZ,I=r.maxX,o=r.maxY,C=r.maxZ;const n=I-e,s=o-t,B=C-g;let Q=Math.sqrt(n*n+s*s+B*B)*1.5,E=kQ(e+n*.5,t+s*.5,g+B*.5);(!isFinite(Q)||Q===0)&&(Q=1,E=kQ(0,0,0));const c=XnA(-(Math.PI/2),Math.PI/2,Q,E);return c.nearPlane=Q*.01,c.farPlane=Q*1e3,A.camera=c,c}function PI(A,e){if(xnA()&&A._sceneChanges&&A._sceneChanges.depth===0){JnA(A,()=>PI(A,e));return}if("entities"in e){const t=e;for(const C of t.entities)PI(A,C);t.camera&&A.camera===t.camera&&(A.camera=null);const g=t.animationGroups;if(g?.length)for(const C of g)SE(A.animationGroups,C);const I=t._beforeRenderHook;I&&(SE(A._beforeRender,I),t._beforeRenderHook=void 0);const o=t._sceneCleanups;if(o){const C=o.get(A);C&&(SE(A._disposables,C),o.delete(A),A._z||C())}H3(A,e,"removed");return}if("_gpu"in e&&"material"in e){IZA(A,e),H3(A,e,"removed"),esA(A,e);return}if("lightType"in e){SE(A.lights,e);const t=e.shadowGenerator;t?$nA(A,t):AsA(A)}else"fov"in e&&"nearPlane"in e?A.camera===e&&(A.camera=null):"_shadowType"in e&&"_light"in e&&$nA(A,e);gZA(e),H3(A,e,"removed"),esA(A,e)}function XzA(A,e){for(const t of e){SE(A._disposables,t);const g=t.p;if(g){g._disposed=!0;const I=g._owner;if(I){const o=I.indexOf(g);o>=0&&I.splice(o,1),g._owner=void 0,I.length===0&&g._onOwnerEmpty?.()}else g._onOwnerEmpty?.();g._onOwnerEmpty&&(g._onOwnerEmpty=void 0)}}$zA(A,()=>{for(const t of e)t()})}function $zA(A,e){if(A._z){e();return}ag(A.surface.engine,e)}function $nA(A,e){SE(A.shadowGenerators,e);const t=e._light;t&&t.shadowGenerator===e&&(t.shadowGenerator=void 0),AsA(A);const g=e._shadowTaskState;g&&(e._shadowTaskState=void 0,AZA(A,()=>g._task.dispose()))}function AZA(A,e){A._pendingTopologyRetirements||(A._pendingTopologyRetirements=[],A._disposables.push(()=>eZA(A))),A._pendingTopologyRetirements.push(e)}function eZA(A){const e=A._pendingTopologyRetirements?.splice(0);if(!e?.length)return;const t=()=>{for(const I of e)try{I()}catch{}},g=A.surface.engine._device;g?g.queue.onSubmittedWorkDone().then(t,t):t()}function AsA(A){A._lightListVersion=(A._lightListVersion??0)+1,A._built&&(A._rebuildHook=tZA)}async function tZA(A){const{rebuildSceneRenderables:e}=await Promise.resolve().then(()=>(cU(),cnA));await e(A)}function SE(A,e){const t=A.indexOf(e);t>=0&&A.splice(t,1)}function gZA(A){A&&typeof A=="object"&&"parent"in A&&(A.parent=null)}function esA(A,e){const t=e.children;if(t?.length)for(const g of[...t])PI(A,g)}function IZA(A,e){A._meshMaterialChange?.(e);for(const n of A._frameGraph._tasks)n._removeMesh?.(e);const t=A._meshDisposables.get(e);let g=!1;const I=[];t&&(g=!0,I.push(...t),A._meshDisposables.delete(e));const o=A.meshes.indexOf(e);o>=0&&(A.meshes.splice(o,1),g=!0);const C=A._renderables.findIndex(n=>n.mesh===e);C>=0&&(A._renderables.splice(C,1),g=!0),g&&A._renderableVersion++;for(const n of A._groups.values()){const s=n.indexOf(e);s>=0&&n.splice(s,1);const B=n.o;if(B)for(let Q=B.length;Q--;)B[Q].mesh===e&&B.splice(Q,1)}const r=A._materialSwapQueue.indexOf(e);r>=0&&A._materialSwapQueue.splice(r,1),A._runtimeBuilds?.remove(e),e.parent=null;for(const n of A._frameGraph._tasks)"_renderables"in n&&PCA(n,e);GnA(A,e)&&I.push(()=>z1(e)),I.length&&XzA(A,I)}var f1=b((()=>{mI(),ds(),ar(),nE(),kg()}));function tI(A,e){tsA(A,e)&&q1()}function tsA(A,e){let t=A.visible!==e;A.visible=e;const g=A.children;for(let I=0;I<g.length;I++)tsA(g[I],e)&&(t=!0);return t}var Er=b((()=>{hI()}));function gsA(A,e){for(const t of A._frameGraph._tasks)if(t?._config&&t._colorAttachment&&(t._config.rt===e.scRT||t._config.rst===e.scRT))return t}function iZA(A){const e=A.surface,t=A._record;let g,I;A._record=()=>{const o=gsA(A,e);if(o!==g&&(g&&(g._config.clr=I,g._colorAttachment.view=g._config.rt._colorView),g=o,I=o?._config.clr),o){if(e.msaaSamples>1){let C=A._overlayBase;for(;C._overlayBase;)C=C._overlayBase;const r=gsA(C,e),n=r?.enabled!==!1&&r?.executionEnabled!==!1&&r?._config.rst===e.scRT&&r._colorAttachment.view;if(!n){const s=o.enabled;o.enabled=!1;try{return t()}finally{o.enabled=s}}o._colorAttachment.view=n}o._config.clr=!1}return t()}}hI(),mI();function oZA(A,e){let t=A._overlayBase;for(;t;){if(t===e)return!0;t=t._overlayBase}return!1}function IsA(A,e){const t=A.surface,g=t._renderingContexts,I=g.filter(o=>"_overlayBase"in o&&o._overlayBase===A);for(const o of I)e++,g[e]!==o&&TH(t,o,e),e=IsA(o,e);return e}function isA(A){let e=A;for(;e._overlayBase;)e=e._overlayBase;const t=e.surface,g=t._renderingContexts;let I=g.indexOf(e);if(I===-1)return;const o=g.findIndex(C=>oZA(C,e));o!==-1&&(o<I&&(TH(t,e,o),I=o),IsA(e,I))}function osA(A){let e=A._overlayBase;for(;e&&$F(A.surface,e);)e=e._overlayBase;return!!e}function CsA(A){const e=YnA(A.surface);e.clearColor={r:0,g:0,b:0,a:0},e._overlayBase=A,HzA(isA),iZA(e);const t=e._update,g=e._record;return e._update=()=>{osA(e)?e._drawCallsPre=0:t()},e._record=()=>osA(e)?0:g(),e}var CZA=H({_apply:()=>rZA}),rsA=/textureSampleLevel\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*0(?:\.0?)?\s*\)\.rgb/,rZA=(A,e)=>{const t=A.match(rsA),g=t?.[1],I=t?.[2],o=t?.[3];if(!g||!I||!o)throw new Error("Environment blur: skybox cubemap sample not found.");const C=`clamp(scene._envPad1*log2(f32(textureDimensions(${g}).x))*${e==="dds"?"0.8":"scene.vImageInfos.z+scene._envPad2"},0.0,f32(textureNumLevels(${g})-1))`;return A.replace(rsA,`textureSampleLevel(${g},${I},${o},0.0+(${C})).rgb`)};O1();function H7(A,e,t){const g=A._environmentSkyboxShaderPatchLoaders??=[];g[e]=t,A._environmentSkyboxShaderComposer??=async(I,o)=>{I=o==="hdr"?lo+I:I;for(const C of g.slice())C&&(I=(await C())._apply(I,o));return I}}MQ();var nZA=()=>CZA;function sZA(A,e){A[38]=e._environmentBlur??0,A[39]=e._envTextures?.lodGenerationOffset??0}function BZA(A,e){A._environmentBlur=e,H7(A,1,nZA),h9(A,sZA),w9(A)}var nsA=H({_apply:()=>BsA,_rotateSkyboxDirection:()=>ssA});function ssA(A,e){const t=A.match(T7)?.[1];t||m(470);const g=`let _erc=cos(${e});let _ers=sin(${e});${t}=vec3f(${t}.x*_erc+${t}.z*_ers,${t}.y,-${t}.x*_ers+${t}.z*_erc);`;return A.replace(T7,`$&${g}`)}var T7,BsA,QsA=b((()=>{rA(),T7=/var\s+([A-Za-z_]\w*)\s*=\s*normalize\(\w+\.positionUVW\)\s*;/,BsA=A=>ssA(A,"scene.envRotationY")}));MQ();var QZA=()=>Promise.resolve().then(()=>(QsA(),nsA));function aZA(A,e){IE(A),A._environmentRotation=e,H7(A,0,QZA),w9(A)}function EZA(A,e){IE(A),A._environmentRotation=e,w9(A)}function cZA(A,e){H7(A,0,async()=>{const{_rotateSkyboxDirection:t}=await Promise.resolve().then(()=>(QsA(),nsA));return{_apply:g=>t(g,`f32(${e})`)}})}var lZA=[A=>`AnimationGroup "${A}" is already attached to another AnimationManager`,()=>"Animation task category is required.",()=>"AnimationTask is already attached to another AnimationManager",()=>"AnimationManager autonomous mode requires requestAnimationFrame",A=>`Animation weight fade duration must be a finite positive number, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,()=>"createPropertyAnimationClip requires at least one track",()=>"Animation play range must have toTime greater than fromTime",A=>`Animation track "${A}" requires at least one key`,A=>`Animation track "${A}" requires a positive frameRate`,A=>`Animation track "${A}" key times must be monotonically increasing`,A=>`Animation track "${A}" requires at least one key`,A=>`Animation key for "${A}" must provide exactly one of time or frame`,A=>`Animation key for "${A}" must have a non-negative time`,(A,e)=>`Animation key for "${A}" expected ${e} values`,(A,e)=>`Animation key for "${A}" expected ${e} values`,A=>`Invalid animation property path "${A}"`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,A=>`Animation property path "${A}" reached a non-object value`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,(A,e)=>`Animation property path "${A}" has unsupported vector size ${e}`,(A,e)=>`Animation property path "${A}" could not resolve component "${e}"`,()=>"Additive animation reference must use either referenceFrame or referenceTime, not both",A=>`Additive animation reference time must be a finite non-negative number, got ${A}`,()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted animation channels for the same property must use the same value size",()=>"Weighted animation channels for the same property must use the same mixing strategy",()=>"Audio engine media streams require a real-time AudioContext.",()=>"Unable to get a 2D context from the visualizer canvas.",()=>"Invalid splat voxel collision data.",(A,e)=>`Collision data: HTTP ${A} for ${e}`,()=>"Collision URL must be an HTTP(S) .voxel.json URL.",()=>"setEffectUniforms: wrapper has no uniform binding.",A=>`setEffectUniforms: unknown uniform binding "${A}".`,A=>`setEffectTexture: unknown texture binding "${A}".`,A=>`EffectRenderTask "${A}" executed before record().`,A=>`EffectRenderer "${A}" recorded before registerEffectRenderer().`,A=>`createEffectWrapper: duplicate binding ${A}.`,(A,e)=>`Effect "${A}" missing uniform binding ${e}.`,(A,e)=>`Effect "${A}" missing texture binding ${e}.`,(A,e)=>`Effect "${A}" missing texture for sampler binding ${e}.`,(A,e,t)=>`writeUniformSlot: ${A} bytes exceeds uniform binding ${e} size ${t}.`,(A,e)=>`setUniformEffectUniforms: ${A} bytes exceeds uniform size ${e}.`,A=>`UniformEffectRenderTask "${A}" executed before record().`,()=>"Device-lost recovery capture requires an enabled recovery coordinator",()=>"WebGPU adapter not available during device recovery",A=>`WebGPU device recovery missing required features: ${A}`,()=>"forceWebGpuDeviceLossForTesting requires a device-lost recovery handler to be enabled first",()=>"WebGPU adapter not available",()=>"Babylon Lite: useFloatingOrigin requires useHighPrecisionMatrix on the engine.",()=>"renderFrame: surface belongs to a different engine.",()=>"Frame-bound post-submit work requires an active frame encoder.",()=>"GPU task timing could not instrument render passes on this command encoder.",()=>"GPU task timing could not instrument compute passes on this command encoder.",()=>"createMipMappedRenderTarget requires a color format and samples: 1.",()=>"Mipmapped render target has been disposed.",()=>"Mipmapped render target requires a single-sample, filterable, renderable color format.",()=>"Mipmapped render target dimensions must be positive integers.",()=>"Mipmapped render target dimensions exceed maxTextureDimension2D.",A=>`RenderTargetDescriptor.size.scale must be a positive finite number (got ${A}).`,()=>"WebGPU context not available",()=>"Babylon Lite: disposeSurface cannot dispose the engine's primary surface \u2014 use disposeEngine instead.",A=>`Flow Graph Editor: unsupported block class ${A}`,()=>"Flow Graph Editor: expected a serialized object",A=>`Flow Graph Editor: graph ${A} has no allBlocks array`,()=>"KHR_interactivity: duplicate type signatures",A=>`KHR_interactivity: unsupported type signature ${A}`,A=>`KHR_interactivity: node references missing declaration #${A}`,(A,e)=>`KHR_interactivity: variable ${A} references missing type #${e}`,(A,e,t)=>`KHR_interactivity: event ${A} value ${e} references missing type #${t}`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} references invalid variable #${t}`,A=>`KHR_interactivity: variable/set node ${A} has invalid variable indices`,(A,e)=>`KHR_interactivity: variable/set node ${A} is missing input for variable #${e}`,(A,e)=>`KHR_interactivity: variable/set node ${A} input for variable #${e} has the wrong type`,A=>`KHR_interactivity: node ${A} is missing its pointer configuration`,(A,e)=>`KHR_interactivity: node ${A} is missing pointer parameter ${e}`,(A,e)=>`KHR_interactivity: node ${A} pointer parameter ${e} has the wrong type`,(A,e)=>`KHR_interactivity: ${A} node ${e} uses a reserved pointer parameter`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} references invalid type #${t}`,(A,e)=>`KHR_interactivity: node ${A} references invalid event #${e}`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} is missing required ${t} input`,(A,e)=>`KHR_interactivity: variable/interpolate node ${A} references invalid variable #${e}`,A=>`KHR_interactivity: variable/interpolate node ${A} can only use slerp with float4`,(A,e)=>`KHR_interactivity: pointer/interpolate node ${A} references invalid type #${e}`,(A,e,t)=>`KHR_interactivity: ${A} node ${e} cannot interpolate ${t}`,(A,e)=>`KHR_interactivity: node ${A} references missing producer node #${e}`,(A,e,t)=>`KHR_interactivity: node ${A} flow ${e} targets missing node #${t}`,A=>`invalid RFC 6901 escape in pointer segment ${A}`,A=>`literal pointer brackets must be doubled in ${A}`,()=>"JSON Pointer Templates must be absolute",A=>`duplicate pointer parameter ${A}`,A=>`ClearTextureTask "${A}": targetTexture or depthTexture is required; color target arrays must not be empty.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": color attachments must reference distinct textures.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": too many color attachments.`,A=>`ClearTextureTask "${A}": attachments must have matching dimensions and sample counts.`,A=>`ClearTextureTask "${A}": build the frame graph before execution.`,A=>`ClearTextureTask "${A}": targetTexture has no live color attachment.`,A=>`ClearTextureTask "${A}": depthTexture has no live depth/stencil attachment.`,A=>`CopyToTextureTask "${A}": either targetTexture or resolveTexture must be provided.`,A=>`CopyToTextureTask "${A}": sourceTexture cannot be the engine scRT because its GPU texture changes every frame.`,A=>`CopyToTextureTask "${A}": sourceTexture has no color texture. The source must be built before this task records.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled sourceTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,t,g,I)=>`CopyToTextureTask "${A}": sourceTexture (${e}x${t}) and resolveTexture (${g}x${I}) must have matching dimensions.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled targetTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,t)=>`CopyToTextureTask "${A}": resolveTexture format (${e}) must match targetTexture format (${t}).`,()=>"CopyToTextureTask: targetTexture has no color format.",A=>`DepthResolveTask "${A}": sourceTexture has no depth attachment.`,A=>`DepthResolveTask "${A}": sourceTexture must be multisampled (sampleCount > 1).`,A=>`DepthResolveTask "${A}": targetTexture has no depth format.`,()=>"FrameGraph target does not expose a frame graph.",A=>`addRenderPass("${A}"): no task is currently recording (called outside Task.record?)`,A=>`buildFrameGraphTask("${A}"): task is not registered in this graph.`,A=>`GenerateMipMapsTask "${A}": targetTexture is required.`,A=>`GenerateMipMapsTask "${A}": build the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture changed or was disposed; rebuild the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture cannot be a swapchain target.`,A=>`GenerateMipMapsTask "${A}": targetTexture must be a single-sample, filterable, renderable 2D color texture with sampling and render-attachment usage.`,A=>`GenerateMipMapsTask "${A}": targetTexture must have mipmaps allocated.`,A=>`GeometryRendererTask: MESH_BLEND_TAG format must be r8uint, received ${A}.`,()=>"GeometryRendererTask: MESH_BLEND_TAG clearValue must be unsigned integer zero.",()=>"GeometryRendererTask: MESH_BLEND_TAG requires samples: 1.",()=>"GeometryRendererTask: transparent Node materials cannot write MESH_BLEND_TAG because their graph alpha is unavailable to the geometry terminal. Exclude transparent meshes or omit the tag attachment.",()=>"GeometryRendererTask: textureDescriptions must contain at least one entry.",()=>"GeometryRendererTask: too many color attachments.",A=>`GeometryRendererTask: unknown texture type ${A}.`,(A,e)=>`GeometryRendererTask: depthTexture sampleCount (${A}) must match samples (${e}).`,(A,e)=>`GeometryRendererTask: targetTexture sampleCount (${A}) must match samples (${e}).`,()=>"GeometryRendererTask: targetTexture must have a format.",A=>`Transparent geometry output cannot blend integer format "${A}".`,A=>`Transparent geometry output format "${A}" requires the float32-blendable WebGPU feature or a blendable format override.`,()=>"GeometryRendererTask: MESH_BLEND_TAG is not enabled.",()=>"overdraw probe: this device has no timestamp-query feature",()=>"overdraw probe: tasks that load existing depth cannot be measured with a fresh-depth replay",()=>"overdraw probe: task render target has no size (has the task rendered yet?)",()=>"overdraw probe: task target has no color+depth signature to replicate",()=>"overdraw probe: task has no draw bindings (has the task rendered yet?)",()=>"overdraw probe: task scene bindings have not been recorded",()=>"overdraw probe: timestamp readback produced no usable samples",A=>`PostProcessTask "${A}": sourceTexture has no color texture. Render the source to an offscreen RenderTarget before post-processing.`,A=>`PostProcessTask "${A}": multisampled source textures are not supported. Use a sampleCount: 1 source RenderTarget.`,A=>`PostProcessTask "${A}": outputTexture must have a format.`,(A,e)=>`PostProcessTask "${A}": extra texture ${e} has no color texture.`,A=>`PostProcessTask "${A}": sourceTexture must have a format.`,()=>"enableRenderTaskMeshRefresh must be called before the render task is recorded.",()=>"enableRenderTaskMeshRefresh requires an explicit render task with autoMirror: false.",()=>"RenderTask has been disposed.",()=>"Material group has not completed its initial build in this scene.",()=>"RenderTask has been disposed.",()=>"Gaussian point splatting target is already enabled in another scene",()=>"Gaussian point splatting requires a live target on the scene's engine",()=>"Gaussian point sampling could not instrument the consuming render pass",()=>"Gaussian point visibility requires the consuming task's active depth pass",()=>"RectAreaLight: scene was disposed before emission preparation",()=>"RectAreaLight: emission image count exceeds the device texture-array layer limit",A=>`RectAreaLight: emission array upload failed: ${A}`,()=>"RectAreaLight: scene was disposed during emission preparation",()=>"RectAreaLight: device changed during emission preparation; preprocess on the current engine",()=>"RectAreaLight: emission capacity/assignments/topology changed during preparation; enable and rebuild again",()=>"RectAreaLight: prepare the owning scene's emission resources and rebuild its material groups before binding",()=>"RectAreaLight: emission light capacity changed; enable and rebuild again before binding",()=>"RectAreaLight: source must be a filterable, single-sampled color Texture2D with matching dimensions",()=>"RectAreaLight: texture was released",()=>"RectAreaLight: emissionTexture must be returned by processAreaLightTexture(engine, source)",()=>"RectAreaLight: emissionTexture belongs to a different device; preprocess it on the current engine",()=>"RectAreaLight: incompatible processed emissionTexture",A=>`RectAreaLight: LTC payload must contain 65536 bytes, got ${A}`,(A,e)=>`RectAreaLight: LTC request failed (${A}) at ${e}`,A=>`RectAreaLight: LTC GPU upload failed: ${A}`,()=>"RectAreaLight: scene was disposed while loading LTC data",()=>"RectAreaLight: scene was disposed during LTC upload",()=>"RectAreaLight: await enableRectAreaLights(scene) and prepare material groups on the current device before rendering",()=>"buildClusteredLightGpuState: scene.camera is required",()=>"ClusteredLightContainer: light count cannot grow after GPU state creation.",()=>"RectAreaLight: cannot enable lighting on a disposed scene",()=>"RectAreaLight: preprocess emissionTexture with processAreaLightTexture(engine, source) before enabling",()=>"RectAreaLight: NodeMaterial lighting blocks are not supported yet; use PBR or Standard materials, or an unlit node graph",()=>"RectAreaLight: scene was disposed while enabling lighting",()=>"RectAreaLight: device changed during emission preprocessing",()=>"RectAreaLight: source allocation changed during emission preprocessing",()=>"RectAreaLight: source was released during emission preprocessing",A=>`RectAreaLight: emission scale/device validation failed: ${A}`,A=>`RectAreaLight: emission upload failed: ${A}`,(A,e)=>`RectAreaLight: ${A} must be finite and nonnegative, got ${e}`,()=>"RectAreaLight: area-light shadows are not supported yet",()=>"RectAreaLight: await enableRectAreaLights(scene) before registering this scene",()=>"RectAreaLight: emissionTexture must be a Texture2D or null",A=>`setLightDiffuseColor: expected finite RGB components, got ${A}`,A=>`setLightIntensity: expected a finite intensity, got ${A}`,()=>"Device-lost Scene recovery requires environment loading after recovery was enabled",(A,e,t)=>`Device-lost Scene recovery could not refetch '${A}' (${e} ${t}).`,()=>"Procedural sky environment requires finite non-negative scattering, non-zero total scattering, a non-zero sun direction, and positive luminance.",()=>"Procedural sky environment has been disposed.",()=>"Procedural sky environment no longer owns the scene environment.",()=>"loadProceduralSkyEnvironment cannot load into a disposed scene.",()=>"loadProceduralSkyEnvironment requires a scene without an existing environment.",()=>"loadProceduralSkyEnvironment must run before the scene is registered.",()=>"A procedural sky environment is already loading for this scene.",()=>"Procedural sky environment initialization was cancelled: the scene was disposed, registered, or acquired another environment.",()=>"Procedural sky environment initialization was cancelled.",(A,e)=>`${A}: image ${e} not found`,(A,e)=>`${A}: bufferView ${e} not found`,(A,e,t)=>`${A}: failed to load image ${e} ${t}`,A=>`${A}: image has neither bufferView nor uri`,(A,e)=>`${A}: strided accessor uses unsupported component type: ${e}`,(A,e,t)=>`${A}: strided accessor ${e} uses unsupported component type: ${t}`,(A,e,t)=>`${A}: invalid accessor stride ${e} for accessor ${t}`,A=>`glTF camera ${A}: unsupported projection`,()=>"glTF camera nodes require non-zero uniform scale",A=>`EXT_mesh_gpu_instancing: accessor count mismatch on node ${A}`,A=>`EXT_meshopt_compression: compressed source buffer ${A} is not buffer 0 (unsupported)`,A=>`EXT_meshopt_compression: uncompressed bufferView in buffer ${A} is not buffer 0 (unsupported)`,A=>`glTF sparse: unsupported componentType ${A}`,A=>`glTF sparse: unsupported index componentType ${A}`,A=>`glTF sparse: unsupported value componentType ${A}`,()=>"glTF sparse: indices.componentType is required",(A,e)=>`glTF sparse: index ${A} out of range for accessor of count ${e}`,()=>"Not a valid GLB file",()=>"First GLB chunk is not JSON",()=>"Second GLB chunk is not BIN",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"loadGltf: baseless input can't resolve relative URI; use self-contained GLB or URL with base.",A=>`Unsupported component type: ${A}`,()=>"Image has neither bufferView nor uri",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"Image has neither bufferView nor uri",()=>"Invalid HDR: missing #? signature",A=>`Unsupported HDR format: ${A}`,A=>`Invalid HDR resolution: ${A}`,()=>"Invalid HDR: RLE scanline width does not match image",()=>"Invalid HDR: truncated RLE scanline",()=>"Invalid HDR: zero-length RLE packet",()=>"Invalid HDR: RLE run exceeds scanline",()=>"Invalid HDR: RLE literal exceeds scanline",()=>"Invalid HDR: truncated scanline",(A,e)=>`${A} source ${e}: expected five textures`,A=>`${A} resident environment exceeds admitted GPU capacity`,A=>`${A} active display exceeds admitted GPU capacity`,(A,e)=>`${A} source ${e}: GPU/CPU cache budget admission failed`,(A,e)=>`${A} metadata ${e}: only http and https URLs are supported`,A=>`${A} metadata: Fetch is required`,(A,e,t)=>`${A} metadata ${e}: HTTP ${t}`,(A,e)=>`${A} metadata ${e}: Content-Length exceeds maxCpuBytes admission`,(A,e)=>`${A} metadata ${e}: response has no body`,(A,e)=>`${A} metadata ${e}: streamed body exceeds maxCpuBytes admission`,(A,e,t)=>`${A} bootstrap coarse representation (${e} splats) exceeds maxSplats (${t})`,A=>`${A} attach: stream is disposed`,A=>`${A} attach: scene and stream use different engines`,A=>`${A} attach: stream is already attached to another scene`,A=>`${A} attach: attach before or during scene registration`,(A,e)=>`[GaussianSplatStream] GPU ${A} buffer size ${e} exceeds device limits`,()=>"[GaussianSplatStream] GPU budget/device limits cannot admit one canonical splat",()=>"[GaussianSplatStream] GPU budget cannot admit canonical stream state",()=>"[GaussianSplatStream] GPU upload requires exactly five source images",()=>"[GaussianSplatStream] GPU byte upload requires five exact RGBA8 images",()=>"[GaussianSplatStream] GPU state is disposed",()=>"[GaussianSplatStream] GPU interval is outside admitted source/canonical bounds",()=>"[GaussianSplatStream] GPU budget cannot admit pass-local projection and radix state",()=>"[GaussianSplatStream] GPU budget cannot protect submission-local gather parameters",()=>"[GaussianSplatStream] GPU budget cannot admit submission-local gather parameters",(A,e)=>`${A} transport ${e}: invalid Content-Length`,(A,e)=>`${A} transport ${e}: unsafe Content-Length`,(A,e)=>`${A} image ${e}: invalid WebP header`,(A,e)=>`${A} image ${e}: invalid lossless WebP header`,(A,e)=>`${A} image ${e}: unsupported WebP header`,A=>`${A} transport: Fetch and createImageBitmap are required`,A=>`${A} transport: reserveGpuBytes requires gpuLedger for reservation cleanup`,(A,e,t)=>`${A} ${e}: maxCpuBytes cannot admit ${t} bytes`,(A,e,t)=>`${A} ${e}: maxCpuBytes cannot admit ${t} bytes without blocking payloads retained by the same preparation`,(A,e)=>`${A} transport ${e}: response has no body`,(A,e)=>`${A} image ${e}: dimensions do not match the source`,A=>`${A} selection: invalid view-projection frustum`,A=>`${A} selection: viewProjectionMatrix must contain 16 values`,A=>`${A} selection: viewProjectionMatrix must be finite`,A=>`${A} selection: worldMatrix must contain 16 values`,A=>`${A} selection: world transform produced nonfinite bounds`,A=>`${A} selection: cameraPosition must be finite`,A=>`${A} selection: invalid planner parameters`,A=>`${A} selection: orthographic cameras are unsupported`,A=>`${A} selection: invalid planner parameters`,A=>`${A} bootstrap: manifest has no positive coarse source`,A=>`loadSOG: decoded WebP has zero dimensions (input size ${A})`,()=>"loadSOG: failed to acquire 2D context for WebP decode",()=>"loadSOG: means.mins/means.maxs must be arrays",()=>"loadSOG: SOG v2 missing scales codebook",()=>"loadSOG: scales.mins/maxs must be arrays for SOG v1",()=>"loadSOG: SOG v2 missing sh0 codebook",()=>"loadSOG: sh0.mins/maxs must be arrays for SOG v1",A=>`loadSOG: invalid quaternion mode ${A}`,()=>"loadSOG: SOG v2 missing shN codebook",(A,e)=>`loadSOG: HTTP ${A} for ${e}`,()=>"loadSOG: meta.json not found in archive",A=>`loadSOG: missing image '${A}' inside archive`,(A,e)=>`loadSplat: HTTP ${A} for ${e}`,A=>`loadSplat: failed to parse PLY at ${A} (unsupported property layout)`,()=>"loadSPZ: file too short to contain header",(A,e)=>`loadSPZ: unsupported SPZ stream (magic=0x${A} version=${e})`,(A,e)=>`loadSPZ: HTTP ${A} for ${e}`,()=>"Invalid compressed PLY: packed vertex properties require chunk metadata for every vertex",()=>"zip: EOCD record not found",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad central directory signature at offset ${A}`,()=>"zip: encrypted entries are not supported",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad local file header signature at offset ${A}`,(A,e)=>`zip: unsupported compression method ${A} for entry '${e}'`,(A,e,t)=>`zip: entry '${A}' decompressed size mismatch (got ${e}, expected ${t})`,A=>`Duplicate USD mesh ${A}`,()=>"Invalid USD analytic primitive",A=>`Missing USD material ${A}`,()=>"Invalid USD animation target, property, or value stride",()=>"Invalid USD animation samples",()=>"Invalid USD triangle indices",()=>"Non-finite USD positions",()=>"Non-finite USD vertex data",()=>"Invalid USD material subset index range",()=>"USD instance references a missing source",A=>`USD mesh ${A} cannot mix classic and thin instances`,()=>"USD command buffer must contain exactly one scene",()=>"Invalid USD stage metadata",A=>`Duplicate USD geometry ${A}`,A=>`Duplicate or reserved USD mesh ${A}`,A=>`Missing USD geometry ${A}`,()=>"USD mesh has no material subsets",()=>"Invalid USD material subset vertex range",A=>`Missing USD material ${A}`,(A,e)=>`Invalid USD ${A} texture output channel ${e}`,A=>`Duplicate USD material ${A}`,A=>`Non-finite USD material ${A}`,(A,e)=>`USD material ${A} has a channel without texture ${e}`,(A,e)=>`USD material ${A} references texture ${e} without a texture command`,A=>`Invalid or duplicate USD morph target ${A}`,A=>`USD morph target ${A} contains invalid vertex data`,A=>`USD morph targets reference missing mesh ${A}`,A=>`USD morph target vertex count does not match mesh ${A}`,A=>`Duplicate or reserved USD node ${A}`,()=>"Non-finite USD transform",()=>"Cyclic or missing USD parent node",()=>"Invalid USD command buffer",()=>"Unsupported USD command protocol version",()=>"Truncated USD command header",A=>`Invalid USD command ${A} payload`,()=>"Unexpected trailing USD commands",()=>"Invalid USD data range",A=>`Invalid or duplicate USD skeleton ${A}`,A=>`USD skeleton ${A} has an invalid parent or duplicate bone ID`,A=>`USD skeleton ${A} has a non-finite joint transform`,A=>`USD skeleton ${A} has a singular bind transform`,()=>"USD mesh references a missing skeleton",()=>"Missing or unsupported USD mesh skin",()=>"Invalid USD skin weights or joint indices",A=>`Duplicate USD texture ${A}`,A=>`Missing USD texture ${A}`,()=>"Unsupported USD texture encoding, wrap mode, UV set, or color space",()=>"Invalid USD texture transform",A=>`USD thin instances reference missing source ${A}`,A=>`USD mesh ${A} has duplicate or mixed instances`,A=>`USD thin instances for mesh ${A} contain a non-finite transform`,A=>`USD file path must be relative: ${A}`,A=>`Could not load USD: HTTP ${A}`,A=>`Duplicate USD virtual file: ${A}`,A=>`LineMaterial "${A}" requires thin-instance data`,()=>"createLineMaterial requires useThinInstances when useThinInstanceColors is enabled",(A,e)=>`NodeMaterial: cannot pick common numeric type from ${A} and ${e}`,A=>`NodeMaterial: AmbientOcclusionBlock "${A}" requires an ImageSourceBlock source`,()=>"BiPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: ColorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: ColorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unknown CurveBlock curveType ${A}`,A=>`NodeMaterial: CurveBlock does not support ${A}`,()=>"NodeMaterial: FragDepthBlock requires `depth` or both `worldPos` and `viewProjection` inputs",A=>`NodeMaterial: HeightToNormalBlock "${A}" requires worldTangent when generateInWorldSpace is false`,A=>`InputBlock: unknown mesh attribute "${A}"`,(A,e)=>`InputBlock: unsupported systemValue ${A} on block "${e}"`,A=>`LoopBlock "${A}": index can only be read while emitting the loop body`,A=>`LoopBlock "${A}": loopID can only be consumed by StorageReadBlock/StorageWriteBlock`,(A,e)=>`LoopBlock "${A}": unsupported output "${e}"`,A=>`NodeMaterial: MatrixSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unsupported matrix block "${A}"`,()=>"NodeMaterial: NLerpBlock requires a vector left/right input; Babylon.js emits normalize(mix(...)) for this block",()=>"NodeMaterial: PBR-MR core emitter cannot emit optional PBR feature code",()=>"NodeMaterial: PBR-MR core helper cannot emit optional PBR feature code",A=>`NodeMaterial: RandomNumberBlock requires a vector seed so Babylon.js getRand(seed.xy) can be emitted; got ${A}`,A=>`ReflectionTextureBaseBlock "${A}" is an abstract compatibility block and cannot be emitted directly.`,A=>`ReflectionTextureBlock: coordinatesMode ${A} not supported (only EQUIRECTANGULAR_MODE=7)`,A=>`NodeMaterial: ReplaceColorBlock requires a vector/color value; got ${A}`,(A,e)=>`StorageReadBlock "${A}": unsupported output "${e}"`,A=>`StorageReadBlock "${A}": loopID input is not connected`,(A,e)=>`StorageReadBlock "${A}": loop ${e} is not active`,()=>"NodeMaterial: TBNBlock object output is not supported; use row0/row1/row2 outputs",A=>`NodeMaterial: TeleportOutBlock (id=${A}) has no entryPoint`,(A,e)=>`NodeMaterial: TeleportOutBlock (id=${A}) points to missing TeleportInBlock ${e}`,()=>"TriPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: VectorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: VectorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: WaveBlock does not support ${A}`,A=>`NodeMaterial: unknown WaveBlock kind ${A}`,A=>`NodeMaterial: invalid block selection "${A}": use an exported block descriptor`,A=>`NodeMaterial: duplicate block selection "${A}"`,A=>`NodeMaterial: no emitter selected for block "${A}"`,(A,e,t)=>`NodeMaterial: cannot cast ${A} to ${e} for expression \`${t}\``,(A,e)=>`${A}: unsupported BJS connection point type 0x${e}`,(A,e,t)=>`NodeMaterial: block "${A}" (id=${e}) has no input "${t}"`,(A,e,t)=>`NodeMaterial: block "${A}" (id=${e}) input "${t}" is not connected`,(A,e,t)=>`NodeMaterial: dangling connection ${A}.${e} -> block ${t}`,A=>`NodeMaterial: no emitter loaded for block "${A}"`,()=>"NodeMaterial: only vertex->fragment varyings are supported",A=>`NodeMaterial: fragment root block ${A} not found`,A=>`NodeMaterial: no emitter for fragment root "${A}"`,A=>`NodeMaterial: vertex root block ${A} not found`,A=>`NodeMaterial: no emitter for vertex root "${A}"`,()=>"NodeMaterial: PBR/Reflection block requires scene environment but scene._envTextures is unset. Call loadEnvironment() before registerScene().",()=>"node-geometry view does not support scene group building",()=>"node-geometry rebuild requires task-owned resources",()=>"NodeMaterial geometry view: graph has no GeometryTextureOutputBlock",()=>"NodeMaterial geometry view: morph / env / shadow inputs are not supported in the geometry pass",()=>"node-geometry: render target has no color attachments",(A,e)=>`NodeMaterial geometry view: texture binding "${A}" not set. Provide it via material.inputs["${e}"].texture before the first render.`,()=>"NodeMaterial geometry view: NORMALIZED_VIEW_DEPTH requested but no geometry-params UBO was provided by the task.",()=>"NodeMaterial geometry view: emitColor (real-color target) is not supported \u2014 omit targetTexture on the geometry task.",()=>"NodeMaterial: graph has no FragmentOutputBlock",()=>"NodeMaterial: advanced PBR-MR helper request must be emitted by the full PBR-MR block",()=>"NodeMaterial: invalid source \u2014 expected `.blocks` array",A=>`NodeMaterial: block missing numeric id (name=${A})`,(A,e)=>`NodeMaterial: cycle detected through block ${A} (${e})`,A=>`NodeMaterial: dangling reference to block ${A}`,A=>`NodeMaterial: helper key "${A}" registered with conflicting source bodies`,A=>`NodeMaterial: no advanced extension emitter registered for block "${A}"`,A=>`NodeMaterial: no compatibility extension emitter registered for block "${A}"`,A=>`NodeMaterial: no math extension emitter registered for block "${A}"`,A=>`NodeMaterial: no procedural extension emitter registered for block "${A}"`,(A,e)=>`NodeMaterial: texture binding "${A}" not set. Provide it via options.textures or material.inputs["${e}"].texture before the first render.`,A=>`NodeMaterial: material requires shadow generator #${A} but none was supplied to parseNodeMaterialFromSnippet({ shadowGenerators }).`,A=>`NodeMaterial: unsupported attribute "${A}"`,(A,e)=>`NodeMaterial: snippet fetch failed (${A}) for ${e}`,A=>`NodeMaterial: snippet "${A}" has no jsonPayload`,A=>`NodeMaterial: snippet "${A}" has no nodeMaterial`,()=>"Parallax shader composition encountered an unterminated textureSample expression.",A=>`Parallax surface texture ${A} requires a 2D textureSample expression.`,()=>"Parallax shader composition could not find the Standard normal-map helper.",()=>"Parallax shader composition could not find the Standard normal-map invocation.",()=>"Parallax shader composition requires a fragment entry point.",(A,e)=>`[babylon-lite] ${A} must contain three finite${e} values`,A=>`[babylon-lite] ${A} must be finite and positive`,A=>`[babylon-lite] local probe ${A} influenceInnerRadius must be finite, non-negative, and no larger than influenceOuterRadius`,A=>`[babylon-lite] local probe ${A} inner influence box must be non-negative and contained by the outer influence box`,A=>`[babylon-lite] local probe ${A} angleRadians must be finite`,A=>`[babylon-lite] local probe ${A} debugColor must contain three finite values from 0 to 1`,()=>"[babylon-lite] local probe cubemap dimensions must differ only by power-of-two mip levels",()=>"[babylon-lite] local probe voxelGrid.cellSize must be finite and positive",()=>"[babylon-lite] local probe voxelGrid.maximum must be greater than minimum on every axis",()=>"[babylon-lite] local probe voxel grid dimensions are too large",()=>"[babylon-lite] local probe voxel grid dimensions are too large",(A,e,t,g,I)=>`[babylon-lite] local probe voxel (${A}, ${e}, ${t}) intersects ${g} probes, exceeding maxCandidates ${I}`,()=>"[babylon-lite] local probe cubemaps require COPY_SRC usage; call enablePbrLocalCubemap() before loading DDS or HDR probe environments, or create custom probe textures with COPY_SRC",()=>"[babylon-lite] local probe cubemaps must be square six-face textures with one shared format",()=>"[babylon-lite] local probe cubemaps have no common mip range",(A,e)=>`[babylon-lite] local probe set has ${A} probes, but this device supports at most ${e} cube-array probes`,(A,e)=>`[babylon-lite] local probe UBO requires ${A} bytes, but this device supports ${e}`,A=>`[babylon-lite] local probe voxel grid requires ${A} bytes, exceeding this device's storage-buffer limits`,A=>`[babylon-lite] local probe sets require 1..${A} probes`,()=>"Environment rotation: skybox direction declaration not found.",(A,e)=>`${A}: expected to rewrite 1 occurrence, rewrote ${e}`,A=>`local probe array _postCompose: expected to rewrite 1 voxel-grid binding declaration, rewrote ${A}`,A=>`local probe array _postCompose: expected to rewrite 1 cube-array binding declaration, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat reflection direction, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 sheen radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 reflection direction, rewrote ${A}`,()=>"local cubemap _postCompose: expected at least 1 environment LOD scale rewrite",A=>`local cubemap _postCompose: expected to rewrite 1 base radiance sample, rewrote ${A}`,A=>`[babylon-lite] local cubemap could not replace the scene ${A} binding`,()=>"PBR parallax settings changed after compilation; rebuild the material before rendering.",()=>"RectAreaLight: layered PBR direct lighting (clearcoat, sheen, anisotropy, subsurface, iridescence) is not supported yet",()=>"PBR transmission requires a frame-graph refraction texture.",()=>"composePbrGeometryShader: PBR fragment signature mismatch \u2014 _noColorOutput/_esmShadowOutput should be off",()=>"composePbrGeometryShader: alpha-block return statement not found \u2014 template changed?",()=>"pbr-geometry view does not support scene group building",()=>"pbr-geometry rebuild requires task-owned resources",()=>"buildPbrGeometryRenderable: scene has no PBR context. Ensure regular PBR meshes have been built before recording the geometry task.",()=>"pbr-geometry: render target has no color attachments",A=>`[babylon-lite] local cubemap maxCandidates is already ${A} and cannot be changed after initialization`,A=>`[babylon-lite] local cubemap maxCandidates must be an integer from 1 to ${A}`,()=>"PBR material plugin vertex signature is not registered.",()=>"PBR material plugin vertex uniforms require a material UBO.",A=>`Material plugin varying type "${A}" is unsupported; use a floating-point scalar or vector.`,()=>"Standard material plugin signature is not registered.",()=>"Standard material plugins require an owning scene.",()=>"Standard plugin material requires a scene mesh or a binding owner.",()=>"Standard material plugin signature is not registered.",()=>"setShadowCasterMaterial: the caster chain must not cycle back to the source material",()=>"Async ShaderMaterial pipeline preparation could not capture the synchronous descriptor.",()=>'enableShaderMaterialInstanceWorld requires the ShaderMaterial to declare the "world" system uniform.',A=>`ShaderMaterial: external texture "${A}" has no source. Call setShaderExternalTexture() before rendering.`,A=>`ShaderMaterial: external texture "${A}" is not ready.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,(A,e)=>`ShaderMaterial: ${A} name "${e}" is not a valid WGSL identifier.`,()=>"ShaderMaterial: vertexSource and fragmentSource must be non-empty WGSL strings.",()=>"ShaderMaterial: strip topologies are unsupported because indexed draws require a mesh-specific stripIndexFormat.",A=>`ShaderMaterial: unsupported attribute "${A}". Supported attributes: position, normal, uv, uv2, tangent, color, joints, weights, joints1, weights1.`,A=>`ShaderMaterial: duplicate attribute "${A}".`,()=>'ShaderMaterial: "position" attribute is required for mesh rendering.',A=>`ShaderMaterial: define "${A}" must be a boolean or number.`,()=>"ShaderMaterial: `transmissive` requires `needAlphaBlending` (the surface composites over the grabbed opaque scene color).",A=>`ShaderMaterial: custom uniform "${A}" must use an explicit typed declaration.`,(A,e)=>`ShaderMaterial: unsupported uniform type "${A}" for "${e}".`,(A,e)=>`ShaderMaterial: duplicate generated identifier "${A}" while adding ${e}.`,(A,e,t,g)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${t} value(s), got ${g}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,(A,e,t,g)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${t} value(s), got ${g}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" expects a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" cannot use a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: storage buffer "${A}" was not declared.`,()=>"setShaderStorageBuffer requires a StorageBuffer created by createStorageBuffer; raw GPUBuffer is not supported.",A=>`ShaderMaterial: storage buffer "${A}" has been disposed.`,()=>"setShaderStorageBuffer requires a live StorageBuffer created by createStorageBuffer.",()=>"ShaderMaterial external textures require setShaderExternalTexture before pipeline preparation.",A=>`ShaderMaterial: sampler "${A}" has no Texture2D. Call setShaderTexture() before rendering.`,A=>`ShaderMaterial storage "${A}" is invalid.`,(A,e,t)=>`ShaderMaterial format "${A}" for "${e}" is incompatible with canonical geometry on mesh "${t}".`,(A,e,t)=>`ShaderMaterial format "${A}" for "${e}" does not fit the aligned vertex layout on mesh "${t}".`,()=>"RectAreaLight: emission bindings require their owning scene",()=>"RectAreaLight: Standard bindings require their owning scene",()=>"Standard parallax binding requires the owning scene and resource disposers.",()=>"Standard parallax settings changed after compilation; rebuild the material before rendering.",()=>"Standard UV transform _bind requires the scene argument from the Standard bind-group builder",()=>"Standard geometry deformation velocity was not preloaded.",()=>"composeStandardGeometryShader: standard fragment signature mismatch \u2014 bypass active?",()=>"composeStandardGeometryShader: 'return color;' not found in composed fragment \u2014 template changed?",()=>"standard-geometry view does not support scene group building",()=>"standard-geometry rebuild requires task-owned resources",()=>"standard-geometry: deformation velocity feature was not preloaded",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: morph targets require the scene Standard morph context",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: render target has no color attachments",()=>"Standard material group has not completed its initial build in this scene.",()=>"Dashed lines require at least two points",()=>"createDashedLines produced no dash segments (degenerate points or dashNb)",()=>"updateDashedLines requires a mesh created by createDashedLines",A=>`Line system data requires finite ${A} components`,()=>"Line system data requires one color row per line",()=>"Line system data requires one color per point",()=>"createLineSystemData requires at least one point",()=>"createLineSystem requires material.useVertexColor to match the line color-buffer layout",()=>"updateLineSystem requires a mesh created by createLineSystem",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem cannot add colors to a mesh created without vertex colors",A=>`createCsgFromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createMeshesFromCsg("${A}") missing material for CSG material slot ${e}.`,()=>"CSG2 is not initialized. Call and await initializeCsg2Async() before using CSG2 operations.",A=>`${A} cannot use a disposed CSG2 solid.`,A=>`createCsg2FromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createCsg2FromMesh("${A}") materialSlot must be an integer from 0 to ${e}.`,()=>"CSG2 operations require solids with the same vertex property layout.",(A,e)=>`createMeshesFromCsg2("${A}") received an unknown Manifold material original ID ${e}.`,A=>`Unable to build CSG2 mesh "${A}". Manifold has 0 vertices for this output.`,(A,e)=>`createMeshesFromCsg2("${A}") missing material for CSG2 material slot ${e}.`,()=>"enableThinInstanceWorldBounds requires mesh.thinInstances",()=>"createHierarchyInstancePool capacity must be a non-negative integer",()=>"createHierarchyInstancePool requires at least one mesh in the source hierarchy",A=>`createHierarchyInstancePool mesh "${A}" already has thin instances`,A=>`createHierarchyInstancePool requires an invertible world matrix for mesh "${A}"`,()=>"addHierarchyInstance exceeded pool capacity",()=>"setHierarchyInstanceCount count must be an integer within pool capacity",A=>`setHierarchyInstanceCount mesh "${A}" is missing thin instance data`,A=>`HierarchyInstancePool mesh "${A}" is missing thin instance data`,A=>`${A} index must reference an active hierarchy instance`,()=>"setMeshDrawRange requires live, owned, unshared, tightly-packed geometry",()=>"setMeshDrawRange requires undeformed uint32 geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires ranges within geometry capacity and WebGPU limits",()=>"setMeshDrawRange index must be relative to the selected vertex window",()=>"mesh geometry update requires valid ranges within the active geometry",()=>"updateMeshGeometryCapacity requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometryCapacity requires coherent triangle-list geometry with uint32 indices",()=>"updateMeshGeometryCapacity requires unchanged optional-attribute layout",A=>`mesh attribute updates require unshared, tightly-packed geometry; update the source StorageBuffer instead: ${A}`,()=>"mesh attribute update requires a valid tightly-packed vertex range",()=>"mesh attribute update requires a valid destination vertex range",()=>"updateMeshGeometry requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometry requires unchanged vertex/index counts; use resizeMeshGeometry for topology changes",()=>"updateMeshGeometry requires unchanged optional-attribute layout; use resizeMeshGeometry for layout changes",()=>"updateMeshGeometryCapacity requires reserveFactor >= 1",A=>`resizeMeshGeometry requires owned, tightly-packed geometry; recreate or update the source StorageBuffer instead: ${A}`,()=>"resizeSharedMeshGeometry requires at least one mesh",()=>"resizeSharedMeshGeometry requires meshes sharing one owned, tightly-packed geometry",()=>"resizeSharedMeshGeometry requires distinct, live meshes sharing one geometry",()=>"createMeshFromStorageBuffer: storage must be created with { vertex: true } so it carries GPUBufferUsage.VERTEX.",A=>`createMeshFromStorageBuffer: arrayStride must be a positive multiple of 4 within maxVertexBufferArrayStride, received ${A}.`,(A,e,t)=>`createMeshFromStorageBuffer: invalid vertex range (${A} vertices at baseVertex ${e}) for a ${t}-byte allocation.`,A=>`createMeshFromStorageBuffer: unsupported attribute offset "${A}".`,A=>`createMeshFromStorageBuffer: offset for "${A}" must be a non-negative integer smaller than arrayStride.`,()=>"createMeshFromStorageBuffer: indices must be a Uint16Array, Uint32Array, or index-capable StorageBuffer.",A=>`createMeshFromStorageBuffer: indexFormat must match the typed-array format "${A}".`,()=>"createMeshFromStorageBuffer: indices must be created with { index: true }.",()=>'createMeshFromStorageBuffer: a shared index allocation requires indexFormat "uint16" or "uint32".',()=>"createMeshFromStorageBuffer: indexCount must be a positive unsigned 32-bit integer.",(A,e)=>`createMeshFromStorageBuffer: indexCount ${A} exceeds the index source capacity of ${e}.`,(A,e,t)=>`createMeshFromStorageBuffer: indices[${A}] (${e}) must be less than vertexCount ${t}.`,()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: only plain meshes without thin instances are supported.",()=>"setMeshIndexedIndirect: mesh must use a ShaderMaterial.",()=>"setMeshIndexedIndirect: mesh must have storage-backed geometry.",()=>"setMeshIndexedIndirect: storage-backed geometry must belong to the same engine and device; recreate its allocations and mesh.",()=>"setMeshIndexedIndirect: geometry changed; recreate or explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: index allocation changed; explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: arguments must be a live StorageBuffer or null.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: arguments must be created with { indirect: true }.",()=>"setMeshIndexedIndirect: byteOffset must be a non-negative safe integer and multiple of 4.",(A,e)=>`setMeshIndexedIndirect: twenty-byte arguments at offset ${A} exceed the buffer's ${e}-byte capacity.`,()=>"setMeshIndexedIndirect: unbinding requires byteOffset zero.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: unbind arguments before replacing ShaderMaterial with another material family.",()=>"setMeshIndexedIndirect: unbind arguments before enabling thin instances.",()=>"getMeshIndexedDrawInfo: mesh has been disposed.",()=>"getMeshIndexedDrawInfo: only plain meshes without thin instances are supported.",()=>"Standard mesh opacity binding requires its mesh and scene.",(A,e)=>`${A}: "${e}" is not a Lite Mesh (for example a MeshLoD instance); per-mesh opacity is not supported on MeshLoD in this release.`,(A,e)=>`setMeshOpacity: mesh "${A}" uses a "${e}" material; mesh opacity supports only "standard" and "pbr" materials.`,A=>`Mesh "${A}" cannot set opacity: it was disposed when it left its last scene. Create a new mesh instead.`,A=>`${A} mesh opacity binding requires binding-owned disposers.`,()=>"Thin-instance LOD partners require an opaque, non-transmissive material",()=>"Thin-instance LOD partner requires the source draw to provide instance colors",()=>"setThinInstanceDrawCount requires a fully synchronized fixed-capacity pool",()=>"enableThinInstanceDynamicDrawCount requires mesh.thinInstances",()=>"enableThinInstanceGpuCulling requires mesh.thinInstances",()=>"setThinInstanceCullBoundsPad requires mesh.thinInstances",()=>"setThinInstanceLodPartner requires thinInstances on both meshes",()=>"setThinInstanceLodPartner requires two distinct meshes",()=>"setThinInstanceLodPartner does not support thin-instance data shared by mesh clones",()=>"setThinInstanceLodPartner fullMesh cannot already be an LOD partner",()=>"setThinInstanceLodPartner lodMesh cannot also own an LOD partner",()=>"setThinInstanceLodPartner lodMesh is already paired with another source mesh",()=>"setThinInstanceLodPartner requires source instance colors when the LOD partner uses instance colors",()=>"Navcat connection requires a positive radius and nonnegative integer area",()=>"Navcat search result is stale or belongs to another manager",()=>"Unsupported Navcat debug primitive",()=>"Navcat generation requires indexed triangles",()=>"Navcat generation has nonfinite positions or invalid indices",()=>"Navcat generation has nonfinite positions or invalid indices",A=>`Invalid Navcat build option: ${A}`,()=>"Invalid Navcat slope or polygon vertex limit",()=>"Navcat geometry needs at least one mesh",()=>"Navcat extraction requires live static CPU triangle-list geometry",()=>"Navcat extraction requires a nonsingular finite affine transform",()=>"Navcat extraction requires a nonsingular finite affine transform",()=>"Navcat geometry contains nonfinite positions",()=>"Navcat geometry has an invalid triangle index",()=>"Navcat cost must be finite and nonnegative",()=>"Navcat location is stale or belongs to another manager",()=>"Navcat location is excluded by the current filter",()=>"Navcat query callbacks cannot run nested queries or mutate navigation",()=>"Navcat manager is disposed",()=>"Navcat mesh was replaced during an asynchronous operation",(A,e)=>`Navcat ${A} must have finite${e} components`,()=>"Navcat flags must be unsigned 16-bit integers",A=>`createNavMesh (tile cache) failed: ${A}`,A=>`createNavMesh (tiled) failed: ${A}`,A=>`createNavMesh failed: ${A}`,A=>`Mesh "${A}" missing CPU geometry for navmesh`,()=>"No navmesh generated. Call createNavMesh first.",()=>"Navmesh not ready. Call createNavMesh first.",()=>"Navmesh has no tile cache. Build with `maxObstacles > 0` to enable obstacles.",()=>"NodeParticle: BasicSpriteUpdateBlock requires SetupSpriteSheetBlock",()=>"NodeParticle: LocalPositionUpdated requires SystemBlock.isLocal",()=>"NodeParticle: LocalPositionUpdated read before local shape position creation",A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} changed value type`,()=>"NodeParticle: emitter provider must return a finite 16-element matrix",()=>"NodeParticle: emitter provider must return a finite 16-element matrix",(A,e)=>`NodeParticle: ParticleTeleportInBlock ${A} does not expose output "${e}"`,(A,e,t)=>`NodeParticle: ${A} ${e} does not expose output "${t}"`,A=>`NodeParticle: graph plumbing cycle ${A}`,(A,e,t)=>`NodeParticle: ${A} ${e} does not support ${t} connections`,A=>`NodeParticle: ParticleTeleportOutBlock ${A} has invalid entryPoint`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} references missing entryPoint ${e}`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} entryPoint ${e} is not ParticleTeleportInBlock`,A=>`NodeParticle: graph plumbing cycle ${A}`,A=>`NodeParticle: ParticleTeleportInBlock ${A} input is not connected`,(A,e)=>`NodeParticle: ${A} ${e} input is not connected`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} Particle scope requires particle-only evaluation`,()=>"NodeParticle: invalid source \u2014 expected a `blocks` array",A=>`NodeParticle: block missing numeric id (name=${A})`,()=>"NodeParticle: graph has no SystemBlock",A=>`NodeParticle: failed to load texture "${A}"`,()=>"NodeParticle: unable to decode texture content",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"createParticleBillboard: the particle system has no texture",A=>`syncParticleSprite2DBridgeWithBlendModes: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridgeWithBlendModes: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridgeWithBlendModes: bridge-owned layers cannot use the Sprite2D Handle API",()=>"createParticleSprite2DBridge: the particle system has no texture",A=>`createParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`createParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridge: the bridge-owned layer cannot use the Sprite2D Handle API",A=>`syncParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"createHeightFieldShape requires either a groundMesh or full explicit heightfield parameters.",()=>"createHeightFieldShape ground mesh has no vertex positions.",A=>`createHeightFieldShape requires a regular (N+1)\xD7(N+1) grid mesh (e.g. from createGroundFromHeightMap); got ${A} vertices, which is not the square of an integer \u2265 2.`,()=>"createHeightFieldShape ground mesh has zero extent in X or Z; cannot build a heightfield.",()=>"Failed to read physics body mass properties.",()=>"Failed to read physics body mass properties.",A=>`Unknown physics rotation axis "${A}".`,()=>"Thin-instance physics requires a nonsingular carrier world transform.",()=>"Thin-instance physics bodies do not support floating-origin worlds.",()=>"Thin-instance physics requires a non-empty matrix buffer before body creation.",()=>"Failed to read physics body mass properties.",()=>"Cannot create physics mesh shape from a singular root transform.",()=>"Cannot create physics mesh shape without vertex positions.",()=>"Cannot create physics mesh shape without triangle indices.",()=>"Physics mesh shapes require a mesh or transform hierarchy.",A=>`Unsupported shape type: ${A}`,()=>"Cannot add physics child shape from a singular parent transform.",()=>"createPhysicsAggregate supports only primitive physics shapes.",(A,e,t)=>`Default GPU picking cannot read "${A}" format "${e}" on mesh "${t}". Use compatible float32 data or exclude this mesh from picking.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`DepthOfFieldPostProcessTask "${A}": sourceTexture must have a format.`,A=>`MeshBlendingPostProcessTask "${A}": sourceTexture must have a color format.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} and outputTexture must not alias.`,A=>`MeshBlendingPostProcessTask "${A}": blended rgba32float output requires the float32-blendable WebGPU feature.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be single-sample.`,(A,e,t)=>`MeshBlendingPostProcessTask "${A}": ${e} has unsupported format "${t}".`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be a built 2D color render target.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must have the same physical dimensions as outputTexture.`,A=>`MeshBlendingPostProcessTask "${A}": camera projection matrix must be invertible.`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": camera.viewport must be fullscreen (x=0, y=0, width=1, height=1).`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceAmbientOcclusionPostProcessTask "${A}": depth source has no depth attachment.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depth source has no depth attachment.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depth source has no depth attachment.`,()=>"setRenderDrawIndirect: buffer must be a live allocation of the same engine created with indirect: true.",(A,e,t)=>`setRenderDrawIndirect: ${A} argument bytes at offset ${e} must fit the ${t}-byte buffer at a multiple of 4.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" and its draw belong to different engines.`,A=>`RenderDrawTask "${A}" has been disposed.`,(A,e)=>`RenderDraw: ${A} must be an unsigned 32-bit integer, received ${e}.`,(A,e)=>`RenderDraw ${A}: ${e} buffer is disposed or belongs to a different engine.`,(A,e,t)=>`RenderDraw ${A}: ${e} buffer was not created with the ${t} usage.`,()=>"RenderDraw: binding set belongs to a different RenderShader.",(A,e,t)=>`RenderDraw "${A}": the shader declares ${e} vertex buffers, received ${t}.`,A=>`RenderDraw: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`RenderDraw: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`RenderDraw: dynamic offset for "${A}" exceeds the bound buffer range.`,()=>"Alpha-to-coverage is not supported for NodeMaterial.",()=>"Uniform copies require 4-byte-aligned sizes and destination offsets.",A=>`createStorageBuffer: byte length must be a non-negative safe integer; received ${A}.`,(A,e)=>`createStorageBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"StorageBuffer belongs to a previous device; recreate GPU-role allocations and rerun their producers after device loss.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer byteOffset must be a non-negative multiple of 4.",()=>"StorageBuffer update data must have a byte length that is a multiple of 4.",A=>`StorageBuffer update exceeds its ${A}-byte capacity.`,()=>"StorageBuffer is not a live registered allocation.",A=>`Mesh "${A}" cannot be added: it was disposed when it left its last scene. Create a new mesh instead.`,A=>`morph _postCompose: expected to rewrite 2 binding declarations, rewrote ${A}`,()=>"getCsmReceiverTexture requires a CSM shadow generator",()=>"Render-task transfers require live tasks in the same scene.",()=>"Deformable shadows require a fully initialized shadow generator",()=>"setShadowGeneratorEnabled requires a configured shadow generator.",A=>`Device-lost Scene recovery does not support shadow generator type "${A}"`,()=>"Device-lost Scene recovery could not find ESM shadow resources",()=>"Device-lost Scene recovery failed to create ESM shadow resources",()=>"AnimationController.tick requires an EngineContext for skeleton or morph animation",()=>"Cannot update disposed skeleton",()=>"Invalid bone matrices",()=>"createBillboardCustomShader: `fragment` must be a non-empty WGSL string.",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"addBillboardSprite: handle id space exhausted.",(A,e)=>`${A}: BillboardSpriteHandle ${e} has been removed.`,()=>"BillboardSpriteSystem: alphaCutoff must be a finite number.",()=>"BillboardSpriteSystem: opacity must be a finite number.",()=>"createAxisLockedBillboardSystem: axis components must be finite numbers.",()=>"createAxisLockedBillboardSystem: axis must be non-zero.",()=>"addBillboardSpriteIndex: props.position is required.",()=>"addBillboardSpriteIndex: props.sizeWorld is required.",(A,e)=>`updateBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setBillboardSpriteFrameIndex: index ${A} out of range [0, ${e})`,(A,e)=>`${A}: extra texture name "${e}" is not a valid WGSL identifier.`,(A,e,t,g)=>`${A}: frame ${e} has non-positive size ${t}x${g}.`,(A,e,t,g)=>`${A}: frame ${e} has negative sub-rect origin (srcX=${t}, srcY=${g}).`,(A,e,t,g)=>`${A}: frame ${e} sub-rect row extent (srcX + width) * 4 = ${t} exceeds srcStrideBytes ${g} (would spill into next row).`,(A,e,t,g)=>`${A}: frame ${e} width ${t} exceeds shelf max width ${g}.`,(A,e,t,g,I,o)=>`${A}: cannot fit frame ${e} (${t}x${g}) \u2014 atlas height capacity ${I} exhausted at y=${o}.`,()=>"createSpriteAtlasFromFrames: at least one frame is required, or pass options.capacityPx to create an empty atlas with reserved capacity for appendSpriteAtlasFrames.",(A,e)=>`createSpriteAtlasFromFrames: atlas dimensions must be >= 1 (got ${A}x${e}).`,(A,e,t,g)=>`createSpriteAtlasFromFrames: capacityPx ${A}x${e} too small for initial content ${t}x${g}.`,()=>"appendSpriteAtlasFrames: atlas was not built by createSpriteAtlasFromFrames (no packer state).",()=>"loadSpriteAtlas: metadataUrl unsupported.",()=>"loadSpriteAtlas: gridSize required.",(A,e)=>`resolveSpriteFrame: index ${A} out of range [0, ${e})`,()=>"addSprite2D: handle id space exhausted.",(A,e)=>`${A}: Sprite2DHandle ${e} has been removed.`,()=>"enableSprite2DInstanceParams: layer requires a customShader.",()=>"enableSprite2DInstanceParams: another instance extension is already installed.",()=>"setSprite2DInstanceParamsIndex: enableSprite2DInstanceParams must be called first.",(A,e)=>`setSprite2DInstanceParamsIndex: index ${A} out of range [0, ${e})`,()=>"setSprite2DInstanceParamsIndex: params must contain exactly four numbers.",()=>"setSprite2DInstanceParamsIndex: params must be finite Float32 values.",()=>'enableSprite2DYSort: only depth: "none" layers are supported.',()=>"enableSprite2DYSort: defaultBias must be finite.",()=>"setSprite2DYSortBias: Y-sort is not enabled for this layer.",(A,e)=>`setSprite2DYSortBias: index ${A} out of range [0, ${e})`,()=>"setSprite2DYSortBias: bias must be finite.",()=>"addSprite2DIndex: positionPx required.",(A,e)=>`updateSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setSprite2DFrameIndex: index ${A} out of range [0, ${e})`,()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"createSprite2DCustomShader: `fragment` must be a non-empty WGSL string.",()=>"Sprite pipeline: depth-enabled pipelines require a depth-stencil format.",()=>"Sprite pipeline: depth-enabled pipelines require a scene bind-group layout.",()=>'Depth-hosted sprites require depth != "none".',()=>"Depth-hosted Sprite2DLayer requires a depth-stencil render target.",()=>'SpriteRenderer requires depth: "none".',()=>"SpriteRenderer has been disposed.",A=>`TextData style palette cannot exceed ${A} entries.`,(A,e)=>`updateTextData ${A}: storage does not contain curveSet "${e}" \u2014 add it via updateGlyphStorage first.`,(A,e,t)=>`${A}: run index ${e} out of range (0..${t}).`,A=>`${A}: GlyphRun reference is not in this TextData.`,()=>"updateTextData addRun: GlyphRun reference is already in this TextData.",()=>"updateTextData removeRun: GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: previous GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: new GlyphRun reference is already in this TextData.",A=>`TextData style palette cannot exceed ${A} entries.`,()=>"Basis: no images in file",()=>"Basis: startTranscoding failed",A=>`Basis: transcoded size is 0 for mip ${A}`,A=>`Basis: transcodeImage failed for mip ${A}`,(A,e)=>`createDynamicTexture: width/height must be >= 1 (got ${A}x${e})`,()=>"createTexture2DFromExternalImage: texture creation did not produce GPU resources",()=>"createHtmlTexture: requires a DOM canvas rendering surface (HTML-in-Canvas is unavailable on OffscreenCanvas).",()=>"createHtmlTexture: the element is already hosted by another canvas; textures can share an element only within one canvas.",()=>"KTX: file too small",()=>"KTX: invalid magic",()=>"KTX: unsupported endianness",()=>"KTX: not a compressed texture (glType != 0)",()=>"KTX: not a compressed texture (glFormat != 0)",A=>`KTX: unknown glInternalFormat 0x${A}`,()=>"KTX: 3D textures not supported",()=>"KTX: texture arrays not supported",()=>"KTX: cubemaps not supported (use loadCubeTexture)",()=>"KTX: key/value data overflows buffer",A=>`KTX: truncated at mip ${A} size field`,A=>`KTX: mip ${A} data overflows buffer`,()=>"KTX: no mip levels found",A=>`KTX fetch failed: ${A}`,A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",A=>`KTX2: decoder produced an empty mip ${A}`,A=>`KTX2: device does not support ${A}`,(A,e,t)=>`KTX2: uncompressed mip ${A} has ${e} bytes, expected ${t}`,A=>`KTX2: unsupported transcoded format 0x${A}`,(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: RGBA decode size does not match image dimensions",A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",(A,e)=>`KTX2: expected ${A} base-level layers but decoded ${e}`,(A,e,t,g)=>`KTX2: base-level layer ${A} is malformed (expected ${e}x${t}, ${g} bytes)`,(A,e)=>`createTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,t,g)=>`createTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t} RGBA, got ${g}`,(A,e)=>`createRenderTexture2D: width/height must be >= 1 (got ${A}x${e})`,(A,e)=>`updateTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,t,g)=>`updateTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t} RGBA, got ${g}`,(A,e,t)=>`createTexture3DFromPixels: width/height/depth must be >= 1 (got ${A}x${e}x${t})`,(A,e,t,g,I)=>`createTexture3DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t}x${g} RGBA, got ${I}`,()=>"withSampledDepthTexture requires a single-sample depth attachment.",()=>"createSurfaceRenderTargetTexture: descriptor.size must be a SurfaceContext or { surface, scale }.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture cannot resize recursively from a resize callback.",()=>"RenderTargetTexture attachment configuration cannot change during resize.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture has been disposed.",()=>"Depth-only render-target textures require withSampledDepthTexture as the third argument.",()=>"createRenderTargetTexture: render target has no color or depth texture (no format / depthStencilFormat?).",()=>"createRenderTargetTexture: descriptor.size must be fixed { width, height } pixels, not a surface-backed size; use createSurfaceRenderTargetTexture for surface-resizing targets.",(A,e,t)=>`createTexture2DArray: width/height/layers must be >= 1 (got ${A}x${e}x${t})`,(A,e)=>`uploadImageToArrayLayer: layer must be an integer in [0, ${A}) (got ${e})`,(A,e)=>`loadImageToArrayLayer: fetch failed for ${A} (${e})`,(A,e)=>`createTexture2DArrayFromUrls: fetch failed for ${A} (${e})`,(A,e,t,g,I)=>`createTexture2DArrayFromUrls: all layers must share one size; layer 0 is ${A}x${e} but layer ${t} is ${g}x${I}`,A=>`Texture array pixel uploads require rgba8unorm or rgba8unorm-srgb, received ${A}.`,(A,e)=>`updateTexture2DArrayFromPixels: mipLevel must be an integer in [0, ${A}) (got ${e})`,(A,e,t,g,I,o)=>`updateTexture2DArrayFromPixels: data too short \u2014 need ${A} bytes for ${e}x${t}x${g} RGBA at mip ${I}, got ${o}`,()=>"KTX2: the decoder does not report layerCount; a decoder with 2D array support is required (see setKtx2DecoderUrl)",(A,e)=>`KTX2: decoder produced ${A} mips, which is not a whole number of ${e}-layer levels`,(A,e,t)=>`KTX2: expected layer ${A} at mip index ${e} but the decoder reported layer ${t}`,(A,e)=>`KTX2: layers of one mip level must share a size (level ${A}, layer ${e})`,(A,e)=>`KTX2: decoder reported invalid dimensions ${A}x${e}`,(A,e)=>`KTX2: decoder produced invalid base mip dimensions ${A}x${e}`,(A,e,t,g,I)=>`KTX2: mip ${A} has size ${e}x${t}, expected ${g}x${I}`,(A,e,t)=>`KTX2: texture dimensions ${A}x${e} exceed maxTextureDimension2D ${t}`,(A,e)=>`KTX2: array has ${A} layers, exceeding maxTextureArrayLayers ${e}`,(A,e,t,g)=>`KTX2: texture ${A}x${e} has ${t} mip levels, exceeding the maximum ${g}`,A=>`KTX2: device does not support ${A}`,(A,e,t,g)=>`KTX2: compressed dimensions ${A}x${e} are not aligned to ${t}x${g} blocks; texture-compression-unaligned is required`,(A,e,t,g)=>`KTX2: compressed mip ${A} layer ${e} has ${t} bytes, expected ${g}`,(A,e,t,g)=>`KTX2: uncompressed mip ${A} layer ${e} has ${t} bytes, expected ${g}`,A=>`KTX2: unsupported transcoded format 0x${A}`,()=>"KTX2: texture-array upload did not produce GPU resources",A=>`KTX2: GPU device was lost or replaced during texture-array upload${A}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2: separate layer ${A} reports layerCount ${e}; expected one 2D layer`,A=>`KTX2: separate layer ${A} has a different transcoded format`,(A,e,t,g,I)=>`KTX2: separate layer ${A} has size ${e}x${t}, expected ${g}x${I}`,(A,e,t)=>`KTX2: separate layer ${A} has ${e} mip levels, expected ${t}`,(A,e,t,g,I,o)=>`KTX2: separate layer ${A} mip ${e} has size ${t}x${g}, expected ${I}x${o}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: at least one separate layer URL is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,(A,e,t,g)=>`updateTextureRegion: ${A} must be an integer in [${e}, ${t}], received ${g}.`,()=>"updateTextureRegion: the texture requires copy-destination usage and sampleCount 1.",A=>`updateTextureRegion: ${A} does not support CPU writes with the default copy aspect.`,(A,e)=>`updateTextureRegion: origin and extent must be multiples of the ${A}x${e} texel block.`,()=>"updateTextureRegion: depth/stencil copies must cover the full physical mip width and height.",(A,e,t,g,I)=>`updateTextureRegion: ${A} source bytes cannot hold ${e}\xD7${t}\xD7${g} texels at ${I} bytes per row.`,()=>"createTextureRenderTarget: the texture was not created with render-attachment usage.",A=>`createTextureRenderTarget: ${A} textures cannot be render targets.`,(A,e)=>`createTextureRenderTarget: layer must be an integer in [0, ${A}), received ${e}.`,(A,e)=>`createTextureRenderTarget: mipLevel must be an integer in [0, ${A}), received ${e}.`,()=>"Texture render target has been disposed.",()=>"CPU-only animation evaluation is unavailable for this animation controller",A=>`VAT prepared payload: ${A} must be a positive integer.`,A=>`VAT prepared payload: ${A} must be a record.`,(A,e)=>`VAT prepared payload: ${A} contains invalid bone index "${e}".`,(A,e)=>`VAT prepared payload: ${A}[${e}] has an invalid length.`,()=>"VAT prepared payload: data length must equal boneCount * frameCount * 16.",()=>"VAT prepared payload: clips must be a record.",A=>`VAT prepared payload: clip "${A}" is invalid.`,A=>`VAT preparation: mesh "${A}" has no skeleton to bake.`,(A,e)=>`VAT preparation: mesh "${A}" has no skeleton binding for clip "${e}".`,A=>`VAT preparation: mesh "${A}" has inconsistent bone counts.`,()=>"setVatInstanceStorage: mesh has no VAT data.",()=>"setVatInstanceStorage requires a live StorageBuffer from the same engine.",()=>"setVatTime: mesh has no VAT data.",()=>"attachVat: mesh has no skeleton (bake first, attach before clearing it).",()=>"controllerModels requires XR input tracking; do not pass input:false to enterXr.",()=>"handTracking requires XR input tracking; do not pass input:false to enterXr.",()=>"pointerSelection requires XR input tracking; do not pass input:false to enterXr.",()=>"WebXR is not available (navigator.xr missing).",()=>"WebGPU XR is not supported by this browser (XRGPUBinding missing).",()=>"teleportation requires XR input tracking; do not pass input:false to enterXr.",()=>"Compute binding declaration was not created by a supported resource helper.",(A,e)=>`ComputeBindingSet: resource "${A}" was not declared by ComputeShader "${e}".`,A=>`ComputeBindingSet: binding "${A}" has no resource.`,A=>`ComputeBindingSet for "${A}" has been disposed.`,A=>`ComputeBindingSet: binding "${A}" received the wrong buffer resource type.`,A=>`ComputeBindingSet: resource for "${A}" has been disposed or lost with its previous device; recreate it.`,A=>`ComputeBindingSet: resource for "${A}" belongs to a different engine.`,A=>`ComputeBindingSet: writable binding "${A}" received a read-only resource.`,(A,e)=>`ComputeBindingSet: offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeBindingSet: dynamic binding "${A}" requires size or a non-zero minBindingSize.`,A=>`ComputeBindingSet: size for "${A}" must be a positive multiple of 4.`,A=>`ComputeBindingSet: binding "${A}" must expose at least 4 bytes.`,(A,e,t)=>`ComputeBindingSet: binding "${A}" provides ${e} bytes but requires at least ${t} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds this device's maximum binding size of ${e} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds its ${e}-byte allocation.`,()=>"ComputeBindingSet contains a disposed or invalid buffer resource.",(A,e,t,g,I)=>`ComputeDispatch: ${A} workgroup dimension must be an integer in [0, ${e}], received ${t}x${g}x${I}.`,()=>"ComputeDispatch: binding set belongs to a different ComputeShader.",A=>`ComputeDispatch: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`ComputeDispatch: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeDispatch: dynamic offset for "${A}" exceeds the bound buffer range.`,A=>`WebGPU adapter does not support required feature "${A}".`,A=>`ComputeDispatch: immediate data must initialize all ${A} bytes before dispatch.`,()=>"createComputeImmediateShader requires WGSL immediate_address_space support.",A=>`createComputeImmediateShader: immediateByteLength must be a positive multiple of 4 no larger than ${A}.`,()=>"setComputeDispatchImmediates requires a shader created with createComputeImmediateShader.",(A,e)=>`setComputeDispatchImmediates requires exactly ${A} bytes, received ${e}.`,()=>"ComputeDispatch: indirect buffer must be created with { indirect: true }.",()=>"ComputeDispatch: indirect byteOffset must be a non-negative multiple of 4.",(A,e)=>`ComputeDispatch: indirect arguments at ${A} exceed the buffer's ${e}-byte capacity.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" already has one-shot scheduling.`,A=>`Compute pipeline override "${A}" must have a non-empty name or decimal @id from 0 to 65535 with a finite value.`,A=>`Compute pipeline variant for "${A}" belongs to a lost or replaced GPU device; recreate it.`,()=>"Compute pipeline variants require explicit binding layouts.",A=>`ComputeBindingSet: sampler resource for "${A}" is invalid or belongs to a different engine.`,(A,e,t)=>`ComputeBindingSet: sampler "${A}" has type ${e}, expected ${t}.`,()=>"ComputeBindingSet contains an invalid sampler resource.",A=>`ComputeShader: ${A} must not be empty.`,(A,e)=>`ComputeShader: ${A} must be a non-negative integer, received ${e}.`,()=>"ComputeShader: computeSource must not be empty.",(A,e)=>`ComputeShader: group ${A} exceeds this device's maxBindGroups (${e}).`,(A,e)=>`ComputeShader: binding ${A} exceeds this device's maxBindingsPerBindGroup (${e}).`,A=>`ComputeShader: binding name "${A}" is declared more than once.`,(A,e)=>`ComputeShader: group ${A} binding ${e} is declared more than once.`,A=>`ComputeShader: minBindingSize for "${A}" must be a non-negative multiple of 4.`,A=>`ComputeShader: automatic layouts do not support dynamic offset binding "${A}".`,(A,e,t)=>`ComputeShader: ${A} ${e} exceed this device's limit of ${t}.`,A=>`ComputeShader "${A}" has been disposed.`,A=>`ComputeShader "${A}" belongs to a lost or replaced GPU device; recreate the compute graph.`,A=>`ComputeShader "${A}" pipeline preparation did not complete on its owning device.`,A=>`computeStorageBufferBinding: access must be "read" or "read-write", received "${A}".`,A=>`ComputeBindingSet: storage texture for "${A}" is invalid or belongs to a different engine.`,(A,e,t)=>`ComputeBindingSet: storage texture "${A}" has format ${e}, expected ${t}.`,(A,e,t)=>`ComputeBindingSet: storage texture "${A}" uses a ${e} view, expected ${t}.`,(A,e)=>`ComputeBindingSet: storage texture "${A}" was not validated for ${e} access.`,()=>"ComputeBindingSet contains an invalid storage texture resource.",A=>`computeStorageTextureBinding: format "${A}" is not supported.`,()=>"Compute storage texture mipmap task requires at least one resource.",()=>"Compute storage texture mipmap task requires same-engine sampled 2D filterable-float resources created with mipMaps: true; rgba8snorm also requires texture-formats-tier1.",A=>`Compute storage texture mipmap task "${A}" contains a disposed resource.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" and its dispatch belong to different engines.`,()=>"submitComputeTasks requires tasks from the same engine.",A=>`ComputeTask "${A}" must be recorded and active before direct submission.`,()=>"submitComputeTasks cannot run while a frame is being recorded.",A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeBindingSet: texture resource for "${A}" is invalid or belongs to a different engine.`,(A,e,t)=>`ComputeBindingSet: texture "${A}" has sample type ${e}, expected ${t}.`,A=>`ComputeBindingSet: texture "${A}" multisampling does not match its declaration.`,(A,e,t)=>`ComputeBindingSet: texture "${A}" uses a ${e} view, expected ${t}.`,()=>"ComputeBindingSet contains an invalid texture resource.",()=>"ComputeBindingSet contains a texture from a different engine.",()=>"computeTextureBinding: multisampled float textures require sampleType unfilterable-float.",()=>"createComputeTextureResource: stencil texture views are not currently supported.",()=>"createComputeTextureResource: only 2D texture views are currently supported.",(A,e)=>`createComputeTextureResource: declared sample type ${A} is incompatible with texture format ${e}.`,A=>`createComputeTextureViewResource: declared multisampled=${A} does not match the texture.`,A=>`createComputeTextureViewResource: multisampled textures require a 2d view, received ${A}.`,()=>"createComputeTextureResource: engine device changed during validation; retry with the recovered texture.",A=>`createComputeTextureResource: texture is incompatible with this engine: ${A}`,()=>"ComputeBindingSet contains an invalid texture resource.",A=>`ComputeTask "${A}" has been disposed.`,()=>"ComputeUniformArena: slotByteLength must be a positive safe integer and a multiple of 4.",()=>"ComputeUniformArena: slotCount must be a positive safe integer.",()=>"ComputeUniformArena: aligned stride and total byte length must be safe integers.",()=>"ComputeUniformArena has been disposed.",A=>`ComputeUniformArena: slot must be an integer in [0, ${A}].`,()=>"ComputeUniformArena: byteOffset must be a non-negative multiple of 4.",()=>"ComputeUniformArena: update data must have a byte length that is a multiple of 4.",A=>`ComputeUniformArena: update exceeds the slot's ${A}-byte capacity.`,A=>`createUniformBuffer: byte length must be a non-negative safe integer, received ${A}.`,(A,e)=>`createUniformBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"UniformBuffer has been disposed.",()=>"UniformBuffer belongs to a different engine.",()=>"UniformBuffer is not a live registered allocation.",()=>"UniformBuffer byteOffset must be a non-negative multiple of 4.",()=>"UniformBuffer update data must have a byte length that is a multiple of 4.",A=>`UniformBuffer update exceeds its ${A}-byte capacity.`,()=>"UniformBuffer is not a live registered allocation.",()=>'createComputeUniformF16Writer requires createEngineWithFeatures(..., { requiredFeatures: ["shader-f16"] }).',A=>`ComputeUniformLayout: unsupported field type "${A}".`,()=>"ComputeUniformLayout requires at least one field.",()=>"ComputeUniformLayout: field name must not be empty.",A=>`ComputeUniformLayout: duplicate field "${A}".`,(A,e)=>`ComputeUniformWriter: layout requires ${A} bytes but arena slots contain ${e} bytes.`,()=>"ComputeUniformWriter: f16 fields require createComputeUniformF16Writer.",()=>"ComputeUniformWriter targets a disposed uniform arena.",A=>`ComputeUniformWriter: field "${A}" was not declared.`,(A,e)=>`${A}: field type ${e} is not supported by this setter.`,(A,e)=>`${A}: field type ${e} does not match this setter.`,()=>"ComputeUniformWriter: f16 writes require createComputeUniformF16Writer.",(A,e,t,g)=>`${A}: field "${e}" expects ${t} values, received ${g}.`,(A,e)=>`setComputeUniform: field "${A}" expects ${e} values, received 1.`,(A,e,t)=>`ComputeStorageTexture: ${A} must be a positive integer no larger than ${e}, received ${t}.`,()=>"ComputeStorageTexture: 1d textures require height=1 and depthOrArrayLayers=1.",()=>"ComputeStorageTexture: mipMaps is not supported for 1d textures.",()=>"ComputeStorageTexture: 2d textures require depthOrArrayLayers=1; use 2d-array for layers.",A=>`ComputeStorageTexture: unsupported access "${A}".`,()=>"ComputeStorageTexture: at least one access mode is required.",()=>"createComputeStorageTexture: engine device changed during validation; recreate the resource on the current device.",A=>`createComputeStorageTexture: unsupported format, dimension, or access combination: ${A}`,()=>"ComputeStorageTexture: format must be a GPU texture format string.",(A,e,t)=>`ComputeStorageTexture: ${A} (${e}) is incompatible with a ${t} sampler.`,A=>`ComputeStorageTexture2D: dimensions must be positive integers no larger than ${A}.`,A=>`ComputeStorageTexture2D: format "${A}" is not supported.`,()=>"ComputeStorageTexture: sampled outputs require validated sample metadata.",()=>"ComputeStorageTexture2D has been disposed.",()=>"ComputeStorageTexture2D is not a live registered allocation.",()=>"ComputeStorageTexture2D cannot be disposed while sampled facades are still owned.",A=>`Invalid ARIA attribute: ${A}`,(A,e)=>`Conflicting accessibility state: ${A} and ${e}.`,()=>"Accessibility tree is disposed.",()=>"Accessibility node does not belong to this tree.",()=>"Accessibility ordering requires a sibling in the same tree.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Scene accessibility is disposed.",()=>"Cannot create accessibility for a disposed scene.",()=>"The scene already has an accessibility projection.",()=>"A DOM canvas with a parent element is required when createSceneHtmlTwin is called without options.parent.",()=>"Geometry velocity requires a live LINEAR_VELOCITY attachment.",()=>"Geometry velocity was already enabled with a different previous-depth contract.",()=>"Geometry previous-depth velocity requires a floating-point RGBA velocity attachment.",()=>"Enable geometry velocity before registering the scene.",()=>"Geometry previous-depth velocity requires a perspective camera.",()=>"Geometry deformation velocity requires a non-instanced live skeleton or morph mesh.",()=>"Invalid geometry velocity bone matrices.",()=>"Invalid geometry velocity morph weights.",()=>"Geometry deformation velocity cannot use disposed pose resources.",()=>"Geometry deformation source changed; rebuild its geometry renderable.",()=>"PBR geometry deformation velocity was not preloaded.",()=>"PBR geometry velocity cannot reproject a singular world transform.",()=>"PBR geometry deformation velocity was not preloaded.",()=>"PBR geometry velocity cannot reproject a singular world transform.",()=>"Dynamic material binding has been retired.",()=>"Dynamic material binding must be updated before drawing and must not be disposed.",()=>"SSAO radius must be positive and finite.",()=>"SSAO intensity must be finite and in [0, 1].",()=>"SSAO normal input must be a single-sample color attachment.",()=>"SSAO currently supports only left-handed builds.",()=>"SSAO requires a single-sample depth attachment; resolve MSAA depth first.",()=>"SSAO normalSpace must be 'view' or 'world'.",()=>"SSAO temporal must be a boolean or reconstruction options.",()=>"SSAO task has been disposed.",()=>"SSAO depth source is not built; record its producer before the AO task.",()=>"SSAO normal/depth attachments must be built with identical dimensions.",()=>"SSAO currently supports perspective cameras with a full-target viewport.",()=>"SSAO camera clip planes must be finite, positive, and ordered.",()=>"SSAO camera FOV must be finite and in (0, pi).",A=>`Unsupported SSAO quality: ${A}`,()=>"SSAO requires positive integer dimensions.",()=>"SSAO dimensions exceed the device's texture limit.",()=>"SSAO GPU owner is disposed or has no bound estimation resources.",()=>"Cannot enable half-resolution rendering on a disposed SSAO task.",()=>"An SSAO working-resolution adapter is already installed.",()=>"Half-pipeline SSAO velocity and source depth must have identical built dimensions.",()=>"SSAO motion pruning requires temporal occlusion-history transport with object velocity.",()=>"Cannot enable motion pruning on a disposed SSAO task.",()=>"SSAO motion pruning requires an object velocity texture in createSsaoTask.",()=>"An SSAO temporal GPU extension is already installed.",()=>"PBR SSAO must use this scene's engine and active camera.",()=>"Cannot enable PBR SSAO on a disposed task or scene.",()=>"A PBR SSAO task cannot be shared between scenes.",()=>"enablePbrSsao accepts only PBR source materials.",()=>"Enable PBR SSAO on new materials before registerScene.",()=>"A different SSAO plugin is already attached to this material.",()=>"PBR SSAO and its consuming pass must use the same camera aspect ratio.",()=>"PBR SSAO sampling state has been disposed.",()=>"SSAO temporal enabled must be a boolean.",()=>"SSAO temporal historySamples must be an integer in [1, 16].",()=>"SSAO temporal resetVersion must be a nonnegative safe integer.",()=>"SSAO temporal resetVersion cannot be incremented further.",()=>"Temporal SSAO currently does not support floating-origin reprojection.",()=>"SSAO temporal velocityHasPreviousDepth must be a boolean.",()=>"Temporal SSAO velocity must be a single-sample signed floating-point RG/RGBA target.",()=>"Temporal SSAO previous-depth velocity requires a floating-point RGBA target.",()=>"Temporal SSAO filter has been disposed.",()=>"Temporal SSAO currently does not support floating-origin reprojection.",()=>"Temporal SSAO velocity and depth must be built with identical dimensions.",()=>"Temporal SSAO requires finite camera matrices.",()=>"Temporal SSAO cannot reproject a singular camera view."];function asA(A,e){const t=lZA[A];return t?t(...e):`Error #${A}`}rA();function uZA(){qPA(asA)}function pZA(A){if(!(A instanceof Error))return String(A);const e=A.lite;if(!Array.isArray(e))return A.message;const t=/^#(\d+)$/.exec(A.message);return t?asA(Number(t[1]),e):A.message}Er();var dZA=(function(A){return A[A.Small=0]="Small",A[A.Medium=1]="Medium",A[A.Large=2]="Large",A[A.ExtraLarge=3]="ExtraLarge",A})({});function fZA(A,e){if(!Number.isInteger(A)||A<0||A>63)throw new RangeError("Mesh-blending group ID must be an integer between 0 and 63.");if(A===0)return 0;if(!Number.isInteger(e)||e<0||e>3)throw new RangeError("Mesh-blending radius class must be an integer between 0 and 3.");return e<<6|A}function q7(A){if(!Number.isInteger(A)||A<0||A>255)throw new RangeError("Mesh-blending tag must be an integer between 0 and 255.");if(A!==0&&(A&63)===0)throw new RangeError("A nonzero mesh-blending tag must contain a group ID between 1 and 63.");return A}function DZA(A){const e=q7(A);return{groupId:e&63,radiusClass:e>>6}}function RU(A,e){let t=A,g=e;const I={};return Object.defineProperties(I,{worldRadius:{enumerable:!0,get:()=>t,set:o=>{if(!Number.isFinite(o)||o<0)throw new RangeError("Mesh-blending world radii must be finite non-negative numbers.");t=o}},minimumProjectedRadius:{enumerable:!0,get:()=>g,set:o=>{if(!Number.isFinite(o)||o<0)throw new RangeError("Mesh-blending minimum projected radii must be finite non-negative numbers.");g=o}}}),I}function EsA(){return Object.freeze([RU(.06,1.5),RU(.1,3),RU(.2,3),RU(.3,5)])}function csA(A){return q7(A.meshBlendingTag??0)}function mU(A,e){if(Array.isArray(e))for(const t of e)A._dependencies.add(t);else A._dependencies.add(e)}var _ZA={r:.2,g:.2,b:.3,a:1};function yZA(A,e){const t={name:A,_parentTask:e,_dependencies:new Set,_renderTarget:null,_renderTargetDepth:null,_renderPassDescriptor:{colorAttachments:[]},_colorAttachment:null,_depthAttachment:null,clearColor:{..._ZA},clear:!0,_executeFunc:null,_beforeExecute:null,_initialize(){const g=t._renderTarget;if(!g)throw new Error(`RenderPass "${t.name}": render target not set`);const I=g._colorView;let o=null;I&&(o={view:I,loadOp:t.clear?"clear":"load",storeOp:"store",clearValue:t.clearColor});const C=t._renderTargetDepth??g,r=C._descriptor.dFormat,n=C._depthView,s=r?r==="depth24plus-stencil8"||r==="depth32float-stencil8"||r==="stencil8":!1;let B=null;n&&(B={view:n,depthClearValue:C._descriptor.depthClearValue??0,depthLoadOp:"clear",depthStoreOp:"store",...s?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}}),t._colorAttachment=o,t._depthAttachment=B,t._renderPassDescriptor={label:t.name,colorAttachments:o?[o]:[],depthStencilAttachment:B??void 0}},_execute(){const g=t._renderTarget;if(!g)return 0;t._beforeExecute?.();const I=t._parentTask.engine,o=t._colorAttachment;o&&(o.clearValue=t.clearColor,o.loadOp=t.clear?"clear":"load",o.view=g._colorView);const C=I._currentEncoder.beginRenderPass(t._renderPassDescriptor);let r=0;return t._executeFunc&&(r=t._executeFunc(C)),C.end(),r},_dispose(){t._renderTarget=null,t._renderTargetDepth=null,t._colorAttachment=null,t._depthAttachment=null,t._renderPassDescriptor={colorAttachments:[]},t._executeFunc=null,t._beforeExecute=null,t._dependencies.clear()}};return e._passes.push(t),t}rA(),yU();function lsA(A){return typeof A=="object"&&A!==null&&"_tasks"in A}function ME(A){if(lsA(A))return A;if("_frameGraph"in A&&lsA(A._frameGraph))return A._frameGraph;m(119)}function hZA(A,e){KnA(ME(A),e)}function wZA(A,e){const t=ME(A),g=t._tasks[0]?.name==="shadow"?1:0;t._tasks.splice(g,0,e)}function SZA(A,e,t){const g=ME(A),I=g._tasks.indexOf(t);I<0?g._tasks.push(e):g._tasks.splice(I,0,e)}function MZA(A,e,t){const g=ME(A),I=g._tasks.indexOf(t);I<0?g._tasks.push(e):g._tasks.splice(I+1,0,e)}function RZA(A,e){const t=ME(A)._tasks;let g=0;for(const o of t)o!==e&&(t[g++]=o);const I=g!==t.length;return t.length=g,I}function mZA(A,e){const t=ME(A)._currentProcessedTask;return t||m(120,e),yZA(e,t)}hI(),yU();function NZA(A,e){const t=A.engine,g=e?.update,I={_kind:"frame-graph-context",name:e?.name??"frame-graph",surface:A,frameGraph:FnA(t),clearColor:e?.clearColor??{r:0,g:0,b:0,a:1},_drawCallsPre:0,_disposed:!1,_update(){I._disposed||g?.(t._currentDelta)},_record(){return I._disposed?0:I.frameGraph.execute()},_resize(){I._disposed||I.frameGraph.build()}};return I}function GZA(A){A._disposed||(A.frameGraph.build(),DQ(A.surface,A))}async function bZA(A){const e=A;e._disposed||(await Promise.all(A.frameGraph._tasks.map(t=>t._preload?.())),!e._disposed&&(A.frameGraph.build(),DQ(A.surface,A)))}function usA(A){AE(A.surface,A)}function FZA(A){const e=A;e._disposed||(usA(A),A.frameGraph.dispose(),e._disposed=!0)}function lI(A){return $H(A.texture,A)}var g1=b((()=>{s3()}));ZA(),cI(),g1(),ki();function psA(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}var kZA="@group(0)@binding(0)var src:texture_depth_2d;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{return textureLoad(src,vec2<i32>(fc.xy),0);}";function KZA(A){return`@group(0)@binding(0)var src:texture_2d<f32>;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{let c=vec2<i32>(fc.xy)*2;let sd=vec2<i32>(textureDimensions(src));let d=sd-vec2<i32>(1,1);let x1=min(c.x+1,d.x);let y1=min(c.y+1,d.y);let a=textureLoad(src,vec2<i32>(c.x,c.y),0).r;let b=textureLoad(src,vec2<i32>(x1,c.y),0).r;let e=textureLoad(src,vec2<i32>(c.x,y1),0).r;let f=textureLoad(src,vec2<i32>(x1,y1),0).r;var r=${A}(${A}(a,b),${A}(e,f));let dd=max(sd/vec2<i32>(2,2),vec2<i32>(1,1));let extraX=(sd.x&1)==1&&i32(fc.x)==dd.x-1;let extraY=(sd.y&1)==1&&i32(fc.y)==dd.y-1;if(extraX){let x2=min(c.x+2,d.x);r=${A}(r,${A}(textureLoad(src,vec2<i32>(x2,c.y),0).r,textureLoad(src,vec2<i32>(x2,y1),0).r));}if(extraY){let y2=min(c.y+2,d.y);r=${A}(r,${A}(textureLoad(src,vec2<i32>(c.x,y2),0).r,textureLoad(src,vec2<i32>(x1,y2),0).r));if(extraX){r=${A}(r,textureLoad(src,vec2<i32>(min(c.x+2,d.x),y2),0).r);}}return r;}`}function vZA(A,e){const t=A._device,g=e.reduce??"max",I=LI(A,{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}),o=t.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d"}}]}),C=t.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,texture:{sampleType:"unfilterable-float",viewDimension:"2d"}}]}),r=(w,S)=>t.createRenderPipeline({layout:t.createPipelineLayout({bindGroupLayouts:[S]}),vertex:{module:t.createShaderModule({code:w}),entryPoint:"vs"},fragment:{module:t.createShaderModule({code:w}),entryPoint:"fs",targets:[{format:"r32float"}]},primitive:{topology:"triangle-list"}}),n=r(kZA,o),s=r(KZA(g),C);let B=Math.max(1,e.width|0),Q=Math.max(1,e.height|0),E=psA(B,Q);function c(){return t.createTexture({label:"depth-pyramid",size:{width:B,height:Q},format:"r32float",usage:_A.RENDER_ATTACHMENT|_A.TEXTURE_BINDING,mipLevelCount:E})}function l(w){const S={texture:w,view:w.createView(),sampler:I,width:B,height:Q,_sampleType:"float"};return Kg(S),S}let u=c(),p=l(u),d,f=[],D=null,_=null;function y(){d=u.createView({baseMipLevel:0,mipLevelCount:1}),f=[];for(let w=1;w<E;w++){const S=u.createView({baseMipLevel:w-1,mipLevelCount:1}),R=u.createView({baseMipLevel:w,mipLevelCount:1});f.push({dst:R,bindGroup:t.createBindGroup({layout:C,entries:[{binding:0,resource:S}]})})}D=null,_=null}return y(),{get texture(){return p},get mipCount(){return E},build(w,S){const R=S??t.createCommandEncoder();(D===null||_!==w)&&(D=t.createBindGroup({layout:o,entries:[{binding:0,resource:w.view}]}),_=w);const M=R.beginRenderPass({label:"depth-pyramid-copy",colorAttachments:[{view:d,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});M.setPipeline(n),M.setBindGroup(0,D),M.draw(3),M.end();for(const N of f){const G=R.beginRenderPass({label:"depth-pyramid-reduce",colorAttachments:[{view:N.dst,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});G.setPipeline(s),G.setBindGroup(0,N.bindGroup),G.draw(3),G.end()}S||t.queue.submit([R.finish()])},resize(w,S){const R=Math.max(1,w|0),M=Math.max(1,S|0);if(R===B&&M===Q)return;B=R,Q=M,E=psA(B,Q);const N=p;u=c(),p=l(u),y(),lI(N)},dispose(){lI(p)}}}function UZA(A,e,t){const{pyramid:g,source:I}=t;return{name:"depth-pyramid",engine:A,scene:e,_passes:[],record(){},execute(){const o=I();return o?(g.build(o,A._currentEncoder),g.mipCount):0},dispose(){g.dispose()}}}function dsA(A,e,t){let g=null;return{name:A.name??"image-processing",engine:e,scene:t,_passes:[],record(){fsA(g),g=LZA(e,A.source)},execute(){if(!g)return 0;const I=t.imageProcessing,o=new CA([I.exposure,I.contrast,I.toneMappingEnabled===!0?1:0,0]);e._device.queue.writeBuffer(g.params,0,o);const C=e._currentEncoder.beginRenderPass({colorAttachments:[{view:e.scRT._colorView,loadOp:"clear",storeOp:"store",clearValue:t.clearColor}]});return C.setPipeline(g.pipeline),C.setBindGroup(0,g.bindGroup),C.draw(3),C.end(),1},dispose(){fsA(g),g=null,this._passes.length=0}}}function LZA(A,e){const t=YZA(e);if(!t)throw new Error("Image processing source has no color texture");const g=A._device,I=(t.sampleCount??1)>1,o=g.createBuffer({size:16,usage:iA.UNIFORM|iA.COPY_DST}),C=g.createBindGroupLayout({entries:[{binding:0,visibility:DA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:I?"unfilterable-float":"float",multisampled:I}}]}),r="struct P{e:f32,c:f32,t:f32,p:f32}@group(0)@binding(0)var<uniform>p:P;@vertex fn vs(@builtin(vertex_index)i:u32)->@builtin(position)vec4f{var a=array<vec2f,3>(vec2f(-1,-3),vec2f(3,1),vec2f(-1,1));return vec4f(a[i],0,1);}fn ip(r:vec4f)->vec4f{var c=r.rgb*p.e;if(p.t>0.5){c=1.0-exp2(-1.590579*c);}c=clamp(pow(max(c,vec3f(0)),vec3f(1/2.2)),vec3f(0),vec3f(1));let h=c*c*(3.0-2.0*c);if(p.c<1.0){c=mix(vec3f(0.5),c,p.c);}else{c=mix(c,h,p.c-1.0);}return vec4f(max(c,vec3f(0)),r.a);}",n=I?"@group(0)@binding(1)var s:texture_multisampled_2d<f32>;":"@group(0)@binding(1)var s:texture_2d<f32>;",s=I?"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);let px=clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1);let n=textureNumSamples(s);var c=vec4f(0);for(var i=0u;i<n;i++){c+=ip(textureLoad(s,px,i));}return c/f32(n);}":"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);return ip(textureLoad(s,clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1),0));}",B=g.createShaderModule({code:`${r}${n}${s}`});return{pipeline:g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[C]}),vertex:{module:B,entryPoint:"vs"},fragment:{module:B,entryPoint:"fs",targets:[{format:A.format}]},primitive:{topology:"triangle-list"}}),bindGroup:g.createBindGroup({layout:C,entries:[{binding:0,resource:{buffer:o}},{binding:1,resource:t.createView()}]}),params:o}}function YZA(A){const e=typeof A=="function"?A():A;return e?"_colorTexture"in e?e._colorTexture:e.texture:null}function fsA(A){A?.params.destroy()}var DsA=b((()=>{VA(),ZA()}));DsA(),rA(),VA(),ZA(),Fg(),ni(),oo();var xZA=(A,e)=>`struct PostProcessVertexOutput{@builtin(position)position:vec4f,@location(0)uv:vec2f${A}}@vertex fn postProcessVertex(@builtin(vertex_index)vertexIndex:u32)->PostProcessVertexOutput{var positions=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));let p=positions[vertexIndex];var out:PostProcessVertexOutput;out.position=vec4f(p,0,1);out.uv=vec2f(p.x*0.5+0.5,0.5-p.y*0.5);${e}return out;}`,JZA="@group(0)@binding(0)var sourceSampler:sampler;@group(0)@binding(1)var sourceTextureSampler:texture_2d<f32>;fn samplePostProcessSource(uv:vec2f)->vec4f{return textureSample(sourceTextureSampler,sourceSampler,uv);}fn readPostProcessSource(uv:vec2f)->vec4f{let dims=vec2f(textureDimensions(sourceTextureSampler));let p=clamp(floor(uv*dims)+vec2f(0.5),vec2f(0.5),dims-vec2f(0.5));return textureSampleLevel(sourceTextureSampler,sourceSampler,p/dims,0);}",HZA="@fragment fn postProcessFragment(input:PostProcessVertexOutput)->@location(0)vec4f{return applyPostProcess(samplePostProcessSource(input.uv),input.uv);}";function qi(A,e,t){const g=A.sourceTexture,I=A.targetTexture?null:ysA(A.name??"post-process",g),o={view:void 0,loadOp:"clear",storeOp:"store"},C={name:A.name??"post-process",engine:e,scene:t,_passes:[],sourceTexture:g,sourceSamplingMode:A.sourceSamplingMode??"linear",targetTexture:A.targetTexture??null,alphaMode:A.alphaMode??0,viewport:A.viewport??null,clear:A.clear??!0,outputTexture:A.targetTexture??I,_shader:A._shader,_internalTarget:I,_internalTargetKey:I?hsA(g):"",_pipeline:null,_bindGroup:null,_bindGroupLayout:null,_pipelineLayout:null,_shaderModule:null,_shaderModuleCode:"",_uniformBuffer:null,_uniformData:null,_renderPassDescriptor:{label:A.name??"post-process",colorAttachments:[o]},_colorAttachment:o,record(){TZA(C),sI(C.outputTexture,e),_sA(C,e)},execute(){VZA(C._colorAttachment,C.outputTexture,C.clear);const r=e._currentEncoder.beginRenderPass(C._renderPassDescriptor);return jZA(r,C.viewport,C.outputTexture),r.setPipeline(C._pipeline),r.setBindGroup(0,C._bindGroup),r.draw(3),r.end(),1},updateUniforms(){MsA(C,e)},_rebuildGpuState(){_sA(C,e)},dispose(){C._passes.length=0,C._uniformBuffer?.destroy(),C._uniformBuffer=null,C._uniformData=null,C._pipeline=null,C._bindGroup=null,C._bindGroupLayout=null,C._pipelineLayout=null,C._shaderModule=null,C._shaderModuleCode="",Bg(C._internalTarget)}};return C}function _sA(A,e){const t=A.sourceTexture;(!t._colorTexture||!t._colorView)&&m(148,A.name),(t._descriptor.samples??1)!==1&&m(149,A.name);const g=A.outputTexture,I=g._descriptor.format;I||m(150,A.name),A._uniformBuffer??=PZA(A,e),A._uniformData??=OZA(A),MsA(A,e);const o=qZA(A,e);A._pipelineLayout??=e._device.createPipelineLayout({label:`${A.name}-pipeline-layout`,bindGroupLayouts:[o]});const C={_colorFormat:I,_sampleCount:g._descriptor.samples??1};A._pipeline=e._device.createRenderPipeline({label:`${A.name}-${ri(C)}-${A.alphaMode}`,layout:A._pipelineLayout,vertex:{module:SsA(A,e),entryPoint:"postProcessVertex"},fragment:{module:SsA(A,e),entryPoint:"postProcessFragment",targets:[{format:I,blend:WZA(A.alphaMode)}]},primitive:{topology:"triangle-list"},multisample:{count:C._sampleCount}});const r=[{binding:0,resource:A.sourceSamplingMode==="nearest"?s9(e):$o(e)},{binding:1,resource:t._colorSamplingView??t._colorView}],n=A._shader.extraTextures??[];A._uniformBuffer&&r.push({binding:wsA(A),resource:{buffer:A._uniformBuffer}});for(let s=0;s<n.length;s++){const B=n[s];B._colorView||m(151,A.name,s),r.push({binding:2+s,resource:B._colorSamplingView??B._colorView})}A._bindGroup=e._device.createBindGroup({label:`${A.name}-bind-group`,layout:o,entries:r})}function TZA(A){const e=A.targetTexture;if(e){A.outputTexture=e;return}const t=hsA(A.sourceTexture);if(A._internalTarget&&A._internalTargetKey===t){A.outputTexture=A._internalTarget;return}A._internalTarget&&Bg(A._internalTarget),A._internalTarget=ysA(A.name,A.sourceTexture),A._internalTargetKey=t,A.outputTexture=A._internalTarget}function ysA(A,e){const t=e._descriptor;return t.format||m(152,A),yI({lbl:`${A}-output`,format:t.format,samples:1,size:t.size})}function hsA(A){const e=A._descriptor,t=e.size,g="canvas"in t?`surface:${t._uniqueId}`:"surface"in t?`surface:${t.surface._uniqueId}@${t.scale}`:`${t.width}x${t.height}`;return`${e.format??"-"}|${e.samples??1}|${g}`}function qZA(A,e){const t=(A._shader.uniformByteLength??0)>0;if(A._bindGroupLayout)return A._bindGroupLayout;const g=[{binding:0,visibility:DA.FRAGMENT,sampler:{type:"filtering"}},{binding:1,visibility:DA.FRAGMENT,texture:{sampleType:"float"}}],I=A._shader.extraTextures??[];for(let o=0;o<I.length;o++)g.push({binding:2+o,visibility:DA.FRAGMENT,texture:{sampleType:"float"}});return t&&g.push({binding:wsA(A),visibility:DA.VERTEX|DA.FRAGMENT,buffer:{type:"uniform"}}),A._bindGroupLayout=e._device.createBindGroupLayout({label:`${A.name}-bind-group-layout`,entries:g}),A._bindGroupLayout}function wsA(A){return A._shader.uniformBinding??2+(A._shader.extraTextures?.length??0)}function SsA(A,e){const t=`${xZA(A._shader.vertexOutputWGSL??"",A._shader.vertexMainWGSL??"")} ${JZA} ${A._shader.extraTextureWGSL??""} ${A._shader.uniformWGSL??""} ${A._shader.fragmentWGSL} ${A._shader.fragmentWrapperWGSL??HZA}`;return(!A._shaderModule||A._shaderModuleCode!==t)&&(A._shaderModuleCode=t,A._shaderModule=e._device.createShaderModule({label:A.name,code:t})),A._shaderModule}function PZA(A,e){const t=RsA(A._shader.uniformByteLength??0);return t===0?null:e._device.createBuffer({label:`${A.name}-uniforms`,size:t,usage:iA.UNIFORM|iA.COPY_DST})}function OZA(A){const e=RsA(A._shader.uniformByteLength??0);return e===0?null:new CA(e/4)}function MsA(A,e){(A._shader.uniformByteLength??0)!==0&&(A._uniformData.fill(0),A._shader.writeUniforms?.(A._uniformData),e._device.queue.writeBuffer(A._uniformBuffer,0,A._uniformData))}function VZA(A,e,t){A.view=e._colorView,A.resolveTarget=void 0,A.loadOp=t?"clear":"load"}function jZA(A,e,t){if(!e)return;const g=Math.floor(e.x*t._width),I=Math.floor((1-e.y-e.height)*t._height),o=Math.ceil((e.x+e.width)*t._width)-g,C=Math.ceil((1-e.y)*t._height)-I;A.setViewport(g,I,o,C,0,1),A.setScissorRect(g,I,o,C)}function WZA(A){switch(A){case 1:return{color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}};case 2:return{color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};case 7:return{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};default:return}}function RsA(A){return Math.ceil(A/16)*16}function zZA(A,e,t){return qi({...A,_shader:A},e,t)}var D1=128;function ZZA(A,e,t){let g=Math.imul(A^t,73244475)^Math.imul(e+t,295559667);return g=Math.imul(g^g>>>16,73244475),g=Math.imul(g^g>>>16,73244475),((g^g>>>16)>>>0)/4294967296}function msA(A,e,t){const I=new Float32Array(16384),o=new Float32Array(16384),C=new Array(16384);for(let r=0;r<D1;r++)for(let n=0;n<D1;n++){const s=r*D1+n;I[s]=ZZA(n,r,t),C[s]=s}for(let r=0;r<D1;r++){const n=r-1&127,s=r+1&127;for(let B=0;B<D1;B++){const Q=B-1&127,E=B+1&127,c=r*D1+B,l=(I[r*D1+Q]+I[r*D1+E]+I[n*D1+B]+I[s*D1+B]+I[n*D1+Q]+I[n*D1+E]+I[s*D1+Q]+I[s*D1+E])*.125;o[c]=I[c]-l}}C.sort((r,n)=>o[r]-o[n]||r-n);for(let r=0;r<16384;r++)A[C[r]*2+e]=Math.floor(r*256/16384)}function XZA(){const A=new Uint8Array(32768);return msA(A,0,1757159915),msA(A,1,795749149),A}function NsA(A){const e=q3;q3=e?t=>e(t)|A(t):A}function GsA(A){return A._gpu.tangentBuffer?1:0}function NU(A,e=!1){const t=A._gpu;let g=GsA(A);return A.vat?(g|=512,A.vat.joints1Buffer&&(g|=4)):A.skeleton&&(g|=2,A.skeleton.joints1Buffer&&(g|=4)),A.morphTargets&&(g|=8),A.thinInstances&&(g|=16,A.thinInstances.colors&&(g|=32)),t.colorBuffer&&(g|=64),t.uv2Buffer&&(g|=128),A._flatNormal&&(g|=bsA),e&&(g|=256),q3&&(g|=q3(A)),g}var bsA,q3,Pi=b((()=>{it(),bsA=1024,q3=null}));function FsA(A,e){const t=A.excludedMeshes?.has(e),g=A.includedOnlyMeshes;if(g?.size)return g.has(e)&&!t;const I=e.id,o=A.includedOnlyMeshIds;return t?!1:o?.size?!!I&&o.has(I):!I||!A.excludedMeshIds?.has(I)}function Z1(A,e,t){const g=t?new gt(t.buffer,t.byteOffset,t.byteLength/4):null;let I=0,o=-1,C=0;for(const r of e){if(C>=Ht)break;r._writeLightUbo&&(FsA(r,A)&&(o=C,g&&(g[P7+I]=C),I++),C++)}if(g){g[16]=I;for(let r=I;r<Ht;r++)g[P7+r]=0}return I===1?o+1:-I}var P7,RE=b((()=>{VA(),EI(),P7=20}));function GU(A,e,t){return e?((A.endsWith("uint")||A.endsWith("sint"))&&m(138,A),A.endsWith("32float")&&!t.features.has("float32-blendable")&&m(139,A),{format:A,blend:e}):{format:A}}function $ZA(A){NI=A}var Mt,sC,ksA,KQ,NI,on=b((()=>{rA(),Mt=(function(A){return A[A.IRRADIANCE=0]="IRRADIANCE",A[A.WORLD_POSITION=1]="WORLD_POSITION",A[A.LOCAL_POSITION=2]="LOCAL_POSITION",A[A.REFLECTIVITY=3]="REFLECTIVITY",A[A.VIEW_DEPTH=4]="VIEW_DEPTH",A[A.NORMALIZED_VIEW_DEPTH=5]="NORMALIZED_VIEW_DEPTH",A[A.SCREENSPACE_DEPTH=6]="SCREENSPACE_DEPTH",A[A.VIEW_NORMAL=7]="VIEW_NORMAL",A[A.WORLD_NORMAL=8]="WORLD_NORMAL",A[A.ALBEDO=9]="ALBEDO",A[A.LINEAR_VELOCITY=10]="LINEAR_VELOCITY",A[A.MESH_BLEND_TAG=11]="MESH_BLEND_TAG",A})({}),sC={r:0,g:0,b:0,a:0},ksA={r:1,g:1,b:1,a:1},KQ=[{name:"Irradiance",defaultFormat:"rgba16float",clearValue:sC},{name:"WorldPosition",defaultFormat:"rgba16float",clearValue:sC},{name:"LocalPosition",defaultFormat:"rgba16float",clearValue:sC},{name:"Reflectivity",defaultFormat:"rgba8unorm",clearValue:sC},{name:"ViewDepth",defaultFormat:"r32float",clearValue:sC},{name:"NormalizedViewDepth",defaultFormat:"r16float",clearValue:ksA},{name:"ScreenspaceDepth",defaultFormat:"r16float",clearValue:sC},{name:"ViewNormal",defaultFormat:"rgba16float",clearValue:sC},{name:"WorldNormal",defaultFormat:"rgba16float",clearValue:sC},{name:"Albedo",defaultFormat:"rgba8unorm",clearValue:sC},{name:"LinearVelocity",defaultFormat:"rgba16float",clearValue:sC},{name:"MeshBlendTag",defaultFormat:"r8uint",clearValue:sC,_validate:()=>{m(140)}}],NI=null}));function O7(A){const e=[];for(const t of[A.baseColorTexture,A.normalTexture,A.ormTexture,A.occlusionTexture,A.emissiveTexture,A.specGlossTexture])t&&e.push(t);for(const t of Es().values())t.textures?.(A,e);return e}var bU=b((()=>{Eg()})),AXA=H({_computePbrMaterialFeatures:()=>mE});function mE(A){let e=(A.emissiveTexture?2:0)|(A.normalTexture?1:0)|(A.alphaBlend===!0||(A._alphaCutOff??0)<=0&&A.alpha<1?64:0)|(A.specGlossTexture?128:0)|(A.doubleSided?256:0);(A.occlusionStrength??1)>0&&(e|=HT),A.enableSpecularAA&&(e|=O9);let t=0;for(const g of Es().values())if(g.detect){const I=g.detect(A);e|=I.f,t|=I.f2}return A._uv2Mask&&(t|=Z9),A.baseColorFactor&&(t|=X9),{features:e,features2:t}}var P3=b((()=>{Eg()}));function eXA(A){O3=A}function tXA(A){kU=A}function gXA(A){V7=A}function KsA(A){const e=KU;KU=e?(t,g,I)=>{e(t,g,I),A(t,g,I)}:A,NE=t=>t,j7=()=>[]}function vsA(A){vU!==A._device&&(V3.clear(),vU=A._device)}function IXA(){V3.clear(),vU=null}function iXA(A,e,t,g,I,o,C="",r=null){vsA(A);const n=r&&O3?O3(r):null,s=`${e}:${t}:${g}:${I}:${C}${n?n._key:""}`,B=V3.get(s);if(B)return B;const Q=A._device,E=Q.createBindGroupLayout(o._meshBGLDescriptor);let c=null;o._shadowBGLDescriptor&&(c=Q.createBindGroupLayout(o._shadowBGLDescriptor));const l={_features:e,_features2:t,_meshFeatures:g,_meshBGL:E,_shadowBGL:c,_composed:o,_pipelines:new Map};return n&&(l._stencil=n._desc),V3.set(s,l),l}function oXA(A,e,t,g){vsA(A);const I=GQ(),o=e._sampleCount>1&&!!I?.(g),C=`${ri(e)}${o?":a2c":""}`,r=t._pipelines.get(C);if(r)return r;const n=A._device,{_features:s,_features2:B,_composed:Q}=t,E=(B&mQ)!==0,c=!E&&(s&64)!==0,l=(s&256)!==0,u=oi(A),p=t._shadowBGL?[u,t._meshBGL,t._shadowBGL]:[u,t._meshBGL],d=I?t._a2cVertModule??=n.createShaderModule({code:Q._vertexWGSL}):n.createShaderModule({code:Q._vertexWGSL}),f=(B&EE)!==0,D=!e._colorFormat&&!f?null:I?t._a2cFragModule??=n.createShaderModule({code:Q._fragmentWGSL}):n.createShaderModule({code:Q._fragmentWGSL}),_=f?null:{format:e._colorFormat,writeMask:RC.ALL};c&&_&&(_.blend={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}});const y=n.createRenderPipeline({layout:n.createPipelineLayout({bindGroupLayouts:p}),vertex:{module:d,entryPoint:"main",buffers:Q._vertexBufferLayouts},...D?{fragment:{module:D,entryPoint:"main",targets:_?[_]:[]}}:{},...e._depthStencilFormat?{depthStencil:{format:e._depthStencilFormat,depthCompare:e._depthCompare??"greater-equal",depthWriteEnabled:f||E||!c,...O3&&t._stencil&&e._depthStencilFormat.includes("stencil")?t._stencil:{}}}:{},multisample:o?{count:e._sampleCount,alphaToCoverageEnabled:!0}:{count:e._sampleCount},primitive:{cullMode:l?"none":"back",...Q._prim}});return t._pipelines.set(C,y),y}function FU(A,e,t,g,I,o,C,r,n,s,B){const Q=A._device,E=e._features,c=e._features2,l=e._meshFeatures,u=(E&1)!==0&&(l&1)!==0,p=(E&1)!==0&&(l&1)===0,d=u||p,f=(E&2)!==0,D=(E&128)!==0,_=(c&mQ)!==0,y=[];let w=0;const S=K=>{y.push({binding:w++,resource:K.view}),y.push({binding:w++,resource:K.sampler})},R={_engine:A,_features:E,_features2:c,_meshFeatures:l,_material:o,_mesh:r,_env:C??V7?.(o)??null,_refractionTexture:n};KU?.(R,s,B);const M=ArA(),N=t._fragmentKey?t._fragmentKey.split("|").filter(K=>K.length>0):[];y.push({binding:w++,resource:{buffer:g}}),y.push({binding:w++,resource:{buffer:I}});for(const K of M)K.phase==="vertex"&&K.bind&&(w=K.bind(R,y,w));S(o.baseColorTexture??kU?.(A)),d&&S(o.normalTexture),S(o.ormTexture??kU?.(A)),(c&2048)!==0&&(l&128)!==0&&o.occlusionTexture&&o.occlusionTexCoord===1&&S(o.occlusionTexture),f&&S(o.emissiveTexture),D&&S(o.specGlossTexture),_&&y.push({binding:w++,resource:{buffer:o._esmShadowParamsUBO}});const G=[];for(const K of N){const F=M.find(v=>v.id===K||K.startsWith(v.id+"-"));!F||F.phase==="vertex"||!F.bind||G.includes(F)||(G.push(F),w=F.bind(R,y,w))}return Q.createBindGroup({layout:e._meshBGL,entries:y})}var O3,kU,V7,KU,NE,j7,V3,vU,vQ=b((()=>{ZA(),Eg(),Pi(),Fg(),ni(),Ci(),bQ(),it(),O3=null,kU=null,V7=null,KU=null,NE=null,j7=null,V3=new Map,vU=null}));function CXA(A){fs=A}var fs,UsA=b((()=>{fs=null}));function LsA(A,e){return A+e-1&~(e-1)}function rXA(A){const e=YsA[A];if(e)return e;const t=/^array<vec4<u32>,\s*(\d+)>$/.exec(A);if(t)return{align:16,size:Number(t[1])*16};throw new Error(`Unknown UBO field type: ${A}`)}function GE(A){const e=new Map,t=[];let g=0;for(const I of A){const o=rXA(I._type);g=LsA(g,o.align),e.set(I._name,g),t.push(`${I._name}: ${I._type},`),g+=o.size}return{_totalBytes:LsA(g,16),_offsets:e,_structBody:t.join(`
2
2
  `)}}var YsA,UU=b((()=>{YsA={f32:{align:4,size:4},u32:{align:4,size:4},i32:{align:4,size:4},"vec2<f32>":{align:8,size:8},"vec3<f32>":{align:16,size:12},"vec4<f32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"mat4x4<f32>":{align:16,size:64}}}));function nXA(A){LU=A}var LU,xsA=b((()=>{LU=null}));function JsA(A,e,t){for(let g=0;g<e.length;g++)A=A.replace(e[g],t[g]);return A}function sXA(A){const e=new Map;for(const o of A){if(e.has(o._id))throw Error();e.set(o._id,{_fragment:o,_remaining:o._dependencies?.length??0,_dependents:[]})}for(const o of A)for(const C of o._dependencies??[]){const r=e.get(C);if(!r)throw Error();r._dependents.push(o._id)}const t=[];for(const[o,C]of e)C._remaining===0&&t.push(o);t.sort();const g=[];let I=0;for(;I<t.length;){const o=t[I++],C=e.get(o);g.push(C._fragment);for(const r of C._dependents){const n=e.get(r);if(--n._remaining===0){let s=I;for(;s<t.length&&t[s]<r;)s++;t.splice(s,0,r)}}}if(g.length!==A.length)throw Error();return g}function HsA(A,e){const t=new Set,g=[];for(const I of[A,e])for(const o of I)t.has(o._name)||(t.add(o._name),g.push(o));return g}function TsA(A,e,t){return A.replace(WsA,(g,I)=>{const o=[];for(const C of e){const r=C[t];r?.[I]&&o.push(r[I])}return o.join(`
3
3
  `)})}function qsA(A,e,t){const g=sXA(e),I=[],o=[],C=[],r=[],n=[];for(const O of g){O._vertexAttributes&&I.push(...O._vertexAttributes),O._varyings&&o.push(...O._varyings),O._helperFunctions&&C.push(O._helperFunctions),O._vertexHelperFunctions&&r.push(O._vertexHelperFunctions);for(const z of O._vertexBuiltins??[])n.push(`@builtin(${z._builtin})${z._name}:${z._type},`)}const s=HsA(A._baseVertexAttributes,I),B=[],Q=[],E=new Map;for(let O=0;O<s.length;O++){const z=s[O],Z=z._stepMode!=="instance"?t?.[z._name]:void 0;B.push(`@location(${O})${z._name}:${z._type},`);let AA=z._bufferGroup?E.get(z._bufferGroup):void 0;AA||(AA={arrayStride:Z?._stride??z._arrayStride,stepMode:z._stepMode??"vertex",attributes:[]},z._bufferGroup?E.set(z._bufferGroup,AA):Q.push(AA)),AA.attributes.push({shaderLocation:O,offset:Z?._offset??z._offset??0,format:z._gpuFormat})}for(const O of E.values())Q.push(O);let c=s.length;for(const O of g)if(O._pipelineVertexBuffers){const z=O._pipelineVertexBuffers(c);Q.push(...z._buffers),c=z._nextLoc}const l="@builtin(position)clipPos:vec4f,"+HsA(A._baseVaryings,o).map((O,z)=>`@location(${z})${O._name}:${O._type},`).join(`
4
4
  `),u=!!(A._baseMaterialUboFields&&A._baseMaterialUboFields.length>0),p=[...A._baseMeshUboFields],d=u?[...A._baseMaterialUboFields]:[];for(const O of g)O._uboFields?.length&&(u?d:p).push(...O._uboFields);const f=GE(p),D=u?GE(d):void 0,_=[{binding:0,visibility:3,buffer:{type:"uniform"}}];u&&_.push({binding:1,visibility:W7,buffer:{type:"uniform"}});const y=[],w=[],S=[];let R=u?2:1,M=0;function N(O){const z=O._group==="shadow",Z=z?M++:R++,AA=z?2:1,BA={binding:Z,visibility:O._visibility},QA=O._type;let sA="",yA;if(LU){const ie=LU(O,BA);ie&&(sA=ie._qualifier,yA=ie._declarationType)}switch(QA._kind){case"uniform-buffer":BA.buffer={type:"uniform"},sA="<uniform>",yA=`${O._name}Uniforms`;break;case"texture":{const ie=QA._textureType==="texture_depth_2d"?"depth":QA._textureType==="texture_2d<u32>"?"uint":"float";BA.texture={sampleType:QA._sampleType??ie,viewDimension:QA._textureType.includes("array")?"2d-array":QA._textureType.includes("cube")?"cube":"2d"},yA=QA._textureType;break}case"sampler":BA.sampler={type:QA._samplerType==="sampler_comparison"?"comparison":QA._samplerType==="sampler_non_filtering"?"non-filtering":"filtering"},yA=QA._samplerType==="sampler_non_filtering"?"sampler":QA._samplerType;break;case"storage-texture":BA.storageTexture={access:QA._gpuAccess,format:QA._format},yA=`texture_storage_2d<${QA._format},${QA._access}>`}(z?y:_).push(BA);const FA=`@group(${AA})@binding(${Z})var${sA} ${O._name}:${yA};`;O._visibility&PsA&&w.push(FA),O._visibility&W7&&S.push(FA)}for(const O of A._baseVertexBindings??[])N(O);for(const O of g)for(const z of O._vertexBindings??[])N(z);for(const O of A._baseBindings??[])N(O);for(const O of jsA)for(const z of g)for(const Z of z._bindings??[])(Z._group??"mesh")===O&&N(Z);const G=g.map(O=>O._id).join("|"),K=B.join(`