@ivoryheart/herdr-world 0.1.0-rc.5

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.
Files changed (72) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +25 -0
  3. package/THIRD_PARTY_NOTICES.md +52 -0
  4. package/UPSTREAM.md +33 -0
  5. package/bin/herdr-world +128 -0
  6. package/docs/world-assets.md +51 -0
  7. package/lib/bridges/linux-x64/herdr-world-bridge +0 -0
  8. package/lib/bridges/macos-arm64/herdr-world-bridge +0 -0
  9. package/lib/bridges/macos-x64/herdr-world-bridge +0 -0
  10. package/lib/herdr-world-launcher.sh +518 -0
  11. package/package.json +36 -0
  12. package/share/herdr-world/web/assets/BufferResource-TmONtVkO.js +311 -0
  13. package/share/herdr-world/web/assets/CanvasPool-C4EP4giG.js +1 -0
  14. package/share/herdr-world/web/assets/FederatedEventTarget-CkoT1sfc.js +1 -0
  15. package/share/herdr-world/web/assets/FilterSystem-Cc8XEqAi.js +173 -0
  16. package/share/herdr-world/web/assets/NoteMarkdownPreview-DSlfOjOc.js +29 -0
  17. package/share/herdr-world/web/assets/SpacesSurface-KQpjWcgW.js +1 -0
  18. package/share/herdr-world/web/assets/WebGLRenderer-COAVtjkI.js +1 -0
  19. package/share/herdr-world/web/assets/WebGPURenderer-DgfOPeWV.js +1 -0
  20. package/share/herdr-world/web/assets/WorldSurface-DvbdAI-_.js +197 -0
  21. package/share/herdr-world/web/assets/__vite-browser-external-2447137e-BvRk9kiK.js +0 -0
  22. package/share/herdr-world/web/assets/browserAll-B8-kqmYE.js +1 -0
  23. package/share/herdr-world/web/assets/chunk-QTnfLwEv.js +1 -0
  24. package/share/herdr-world/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  25. package/share/herdr-world/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  26. package/share/herdr-world/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  27. package/share/herdr-world/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  28. package/share/herdr-world/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  29. package/share/herdr-world/web/assets/getBatchSamplersUniformGroup-D-hqfegN.js +1 -0
  30. package/share/herdr-world/web/assets/ghostty-web-8_X1K5z2.js +13 -0
  31. package/share/herdr-world/web/assets/index-B1fwFDFH.css +1 -0
  32. package/share/herdr-world/web/assets/index-BAVYPHsj.js +17 -0
  33. package/share/herdr-world/web/assets/init-DeL9YIMj.js +1 -0
  34. package/share/herdr-world/web/assets/localUniformBit-BnogyqF-.js +264 -0
  35. package/share/herdr-world/web/assets/web-CkXGA1Hr.js +1 -0
  36. package/share/herdr-world/web/assets/web-DXrm_vsa.js +1 -0
  37. package/share/herdr-world/web/assets/webworkerAll-BFZtmp1G.js +1 -0
  38. package/share/herdr-world/web/herdr-logo-180.png +0 -0
  39. package/share/herdr-world/web/herdr-logo-192.png +0 -0
  40. package/share/herdr-world/web/herdr-logo-512.png +0 -0
  41. package/share/herdr-world/web/herdr-logo-maskable-192.png +0 -0
  42. package/share/herdr-world/web/herdr-logo-maskable-512.png +0 -0
  43. package/share/herdr-world/web/herdr-logo.svg +6 -0
  44. package/share/herdr-world/web/index.html +24 -0
  45. package/share/herdr-world/web/legal/Apache-2.0.txt +190 -0
  46. package/share/herdr-world/web/legal/LICENSE.txt +22 -0
  47. package/share/herdr-world/web/legal/PixiJS-MIT.txt +21 -0
  48. package/share/herdr-world/web/legal/THIRD_PARTY_NOTICES.md +52 -0
  49. package/share/herdr-world/web/legal/UPSTREAM.md +33 -0
  50. package/share/herdr-world/web/legal/manifest.json +33 -0
  51. package/share/herdr-world/web/legal/npm-licenses.txt +1381 -0
  52. package/share/herdr-world/web/legal/world-assets.md +51 -0
  53. package/share/herdr-world/web/manifest.json +42 -0
  54. package/share/herdr-world/web/world/LICENSE-PixiJS.txt +21 -0
  55. package/share/herdr-world/web/world/characters/1-D-1.png +0 -0
  56. package/share/herdr-world/web/world/characters/10-D-1.png +0 -0
  57. package/share/herdr-world/web/world/characters/11-D-1.png +0 -0
  58. package/share/herdr-world/web/world/characters/12-D-1.png +0 -0
  59. package/share/herdr-world/web/world/characters/2-D-1.png +0 -0
  60. package/share/herdr-world/web/world/characters/3-D-1.png +0 -0
  61. package/share/herdr-world/web/world/characters/4-D-1.png +0 -0
  62. package/share/herdr-world/web/world/characters/5-D-1.png +0 -0
  63. package/share/herdr-world/web/world/characters/6-D-1.png +0 -0
  64. package/share/herdr-world/web/world/characters/7-D-1.png +0 -0
  65. package/share/herdr-world/web/world/characters/8-D-1.png +0 -0
  66. package/share/herdr-world/web/world/characters/9-D-1.png +0 -0
  67. package/third_party/dependencies/README.md +22 -0
  68. package/third_party/dependencies/cargo-licenses.html +7696 -0
  69. package/third_party/dependencies/npm-licenses.txt +1381 -0
  70. package/third_party/licenses/Apache-2.0.txt +190 -0
  71. package/third_party/licenses/PixiJS-MIT.txt +21 -0
  72. package/vendor/herdr-compat/VENDOR-MANIFEST.toml +186 -0
@@ -0,0 +1,197 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-B8-kqmYE.js","assets/localUniformBit-BnogyqF-.js","assets/chunk-QTnfLwEv.js","assets/FilterSystem-Cc8XEqAi.js","assets/CanvasPool-C4EP4giG.js","assets/getBatchSamplersUniformGroup-D-hqfegN.js","assets/FederatedEventTarget-CkoT1sfc.js","assets/init-DeL9YIMj.js","assets/webworkerAll-BFZtmp1G.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./chunk-QTnfLwEv.js";import{C as t,D as n,E as r,S as i,T as a,_ as o,a as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,w,x as T,y as ee}from"./index-BAVYPHsj.js";import{A as E,B as te,E as D,F as O,G as ne,K as k,L as A,M as re,N as ie,P as j,S as M,T as N,U as P,V as ae,Y as F,a as I,at as L,b as oe,c as se,ct as ce,d as le,et as ue,f as de,ft as R,g as fe,h as pe,i as z,it as B,j as me,k as V,l as he,n as ge,o as _e,p as ve,pt as H,r as ye,s as be,st as xe,t as Se,u as Ce,w as we,y as Te}from"./localUniformBit-BnogyqF-.js";import{c as U,d as Ee,g as De,u as Oe}from"./FilterSystem-Cc8XEqAi.js";import{n as ke,t as Ae}from"./CanvasPool-C4EP4giG.js";import{t as je}from"./getBatchSamplersUniformGroup-D-hqfegN.js";import{a as Me,c as Ne,d as Pe,f as Fe,g as Ie,h as Le,i as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,r as We,s as Ge,t as Ke,u as qe}from"./BufferResource-TmONtVkO.js";var Je=r(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),W=e(n(),1),Ye=class{init(){let e=new Te({uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uTransformMatrix:{value:new ce,type:`mat3x3<f32>`},uRound:{value:0,type:`f32`}}),t=me(),n=de({name:`graphics`,bits:[le,he(t),ge,be]});this.shader=new z({glProgram:n,resources:{localUniforms:e,batchSamplers:je(t)}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{geometry:a,instructions:o}=i.graphicsContext.getContextRenderData(n);r.groups[0]=i.globalUniforms.bindGroup,i.state.set(e.state),i.shader.bind(r),i.geometry.bind(a,r.glProgram);let s=o.instructions;for(let e=0;e<o.instructionSize;e++){let t=s[e];if(t.size){for(let e=0;e<t.textures.count;e++)i.texture.bind(t.textures.textures[e],e);i.geometry.draw(`triangle-list`,t.size,t.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}};Ye.extension={type:[R.WebGLPipesAdaptor],name:`graphics`};var Xe=class{init(){let e=de({name:`mesh`,bits:[ge,Ie,be]});this._shader=new z({glProgram:e,resources:{uTexture:A.EMPTY.source,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new ce}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r){r=this._shader;let e=t.texture,n=e.source;r.resources.uTexture=n,r.resources.uSampler=n.style,r.resources.textureUniforms.uniforms.uTextureMatrix=e.textureMatrix.mapCoord}else if(!r.glProgram){F(`Mesh shader has no glProgram`,t.shader);return}r.groups[100]=n.globalUniforms.bindGroup,r.groups[101]=e.localUniformsBindGroup,n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}};Xe.extension={type:[R.WebGLPipesAdaptor],name:`mesh`};var Ze=class{constructor(){this._didUpload=!1,this._tempState=M.for2d()}init(e){let t=me(),n=de({name:`batch`,bits:[le,he(t),be]});this._shader=new z({glProgram:n,resources:{batchSamplers:je(t)}}),e.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(e,t){let n=e.renderer;n.shader.bind(this._shader,this._didUpload),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(t,this._shader.glProgram)}execute(e,t){let n=e.renderer;this._didUpload=!0,this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);let r=t.textures.textures;for(let e=0;e<t.textures.count;e++)n.texture.bind(r[e],e);n.geometry.draw(`triangle-list`,t.size,t.start)}destroy(){this._shader.destroy(!0),this._shader=null}};Ze.extension={type:[R.WebGLPipesAdaptor],name:`batch`};var Qe=(e=>(e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e))(Qe||{}),$e=class{constructor(e,t){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}},et=class{constructor(e){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=e}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(e){return this._gpuBuffers[e.uid]||this.createGLBuffer(e)}bind(e){let{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){let{_gl:n}=this;if(this._boundBufferBases[t]!==e){let r=this.getGlBuffer(e);this._boundBufferBases[t]=e,n.bindBufferBase(n.UNIFORM_BUFFER,t,r.buffer)}}bindBufferRange(e,t,n){let{_gl:r}=this;n||=0;let i=this.getGlBuffer(e);r.bindBufferRange(r.UNIFORM_BUFFER,t||0,i.buffer,n*256,256)}updateBuffer(e){let{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);let r=e.data;if(n.byteLength>=e.data.byteLength)t.bufferSubData(n.type,0,r,0,e._updateSize/r.BYTES_PER_ELEMENT);else{let i=e.descriptor.usage&D.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;n.byteLength=r.byteLength,t.bufferData(n.type,r,i)}return n}destroyAll(){let e=this._gl;for(let t in this._gpuBuffers)e.deleteBuffer(this._gpuBuffers[t].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(e,t){let n=this._gpuBuffers[e.uid],r=this._gl;t||r.deleteBuffer(n.buffer),this._gpuBuffers[e.uid]=null}createGLBuffer(e){let{_gl:t}=this,n=Qe.ARRAY_BUFFER;e.descriptor.usage&D.INDEX?n=Qe.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&D.UNIFORM&&(n=Qe.UNIFORM_BUFFER);let r=new $e(t.createBuffer(),n);return this._gpuBuffers[e.uid]=r,e.on(`destroy`,this.onBufferDestroy,this),r}};et.extension={type:[R.WebGLSystem],name:`buffer`};var tt=class e{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(t){if(t={...e.defaultOptions,...t},t.context)this.initFromContext(t.context);else{let e=this._renderer.background.alpha<1,n=t.premultipliedAlpha??!0,r=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:n,antialias:r,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??`default`})}}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof P.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);let t=this._renderer.view.canvas;t.addEventListener(`webglcontextlost`,this.handleContextLost,!1),t.addEventListener(`webglcontextrestored`,this.handleContextRestored,!1)}createContext(e,t){let n,r=this._renderer.view.canvas;if(e===2&&(n=r.getContext(`webgl2`,t)),!n&&(n=r.getContext(`webgl`,t),!n))throw Error(`This browser does not support WebGL. Try using the canvas renderer`);this.gl=n,this.initFromContext(this.gl)}getExtensions(){let{gl:e}=this,t={anisotropicFiltering:e.getExtension(`EXT_texture_filter_anisotropic`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),s3tc:e.getExtension(`WEBGL_compressed_texture_s3tc`),s3tc_sRGB:e.getExtension(`WEBGL_compressed_texture_s3tc_srgb`),etc:e.getExtension(`WEBGL_compressed_texture_etc`),etc1:e.getExtension(`WEBGL_compressed_texture_etc1`),pvrtc:e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`),atc:e.getExtension(`WEBGL_compressed_texture_atc`),astc:e.getExtension(`WEBGL_compressed_texture_astc`),bptc:e.getExtension(`EXT_texture_compression_bptc`),rgtc:e.getExtension(`EXT_texture_compression_rgtc`),loseContext:e.getExtension(`WEBGL_lose_context`)};if(this.webGLVersion===1)this.extensions={...t,drawBuffers:e.getExtension(`WEBGL_draw_buffers`),depthTexture:e.getExtension(`WEBGL_depth_texture`),vertexArrayObject:e.getExtension(`OES_vertex_array_object`)||e.getExtension(`MOZ_OES_vertex_array_object`)||e.getExtension(`WEBKIT_OES_vertex_array_object`),uint32ElementIndex:e.getExtension(`OES_element_index_uint`),floatTexture:e.getExtension(`OES_texture_float`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),textureHalfFloat:e.getExtension(`OES_texture_half_float`),textureHalfFloatLinear:e.getExtension(`OES_texture_half_float_linear`),vertexAttribDivisorANGLE:e.getExtension(`ANGLE_instanced_arrays`),srgb:e.getExtension(`EXT_sRGB`)};else{this.extensions={...t,colorBufferFloat:e.getExtension(`EXT_color_buffer_float`)};let n=e.getExtension(`WEBGL_provoking_vertex`);n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){let e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener(`webglcontextlost`,this.handleContextLost),e.removeEventListener(`webglcontextrestored`,this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){let t=e.getContextAttributes();t&&!t.stencil&&F(`Provided WebGL context does not have a stencil buffer, masks may not render correctly`);let n=this.supports,r=this.webGLVersion===2,i=this.extensions;n.uint32Indices=r||!!i.uint32ElementIndex,n.uniformBufferObject=r,n.vertexArrayObject=r||!!i.vertexArrayObject,n.srgbTextures=r||!!i.srgb,n.nonPowOf2wrapping=r,n.nonPowOf2mipmaps=r,n.msaa=r,n.uint32Indices||F(`Provided WebGL context does not support 32 index buffer, large scenes may not render correctly`)}};tt.extension={type:[R.WebGLSystem],name:`context`},tt.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};var nt=tt,rt=(e=>(e[e.RGBA=6408]=`RGBA`,e[e.RGB=6407]=`RGB`,e[e.RG=33319]=`RG`,e[e.RED=6403]=`RED`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.ALPHA=6406]=`ALPHA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e))(rt||{}),it=(e=>(e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e))(it||{}),G=(e=>(e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.BYTE=5120]=`BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.INT=5124]=`INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.HALF_FLOAT=36193]=`HALF_FLOAT`,e))(G||{}),at={uint8x2:G.UNSIGNED_BYTE,uint8x4:G.UNSIGNED_BYTE,sint8x2:G.BYTE,sint8x4:G.BYTE,unorm8x2:G.UNSIGNED_BYTE,unorm8x4:G.UNSIGNED_BYTE,snorm8x2:G.BYTE,snorm8x4:G.BYTE,uint16x2:G.UNSIGNED_SHORT,uint16x4:G.UNSIGNED_SHORT,sint16x2:G.SHORT,sint16x4:G.SHORT,unorm16x2:G.UNSIGNED_SHORT,unorm16x4:G.UNSIGNED_SHORT,snorm16x2:G.SHORT,snorm16x4:G.SHORT,float16x2:G.HALF_FLOAT,float16x4:G.HALF_FLOAT,float32:G.FLOAT,float32x2:G.FLOAT,float32x3:G.FLOAT,float32x4:G.FLOAT,uint32:G.UNSIGNED_INT,uint32x2:G.UNSIGNED_INT,uint32x3:G.UNSIGNED_INT,uint32x4:G.UNSIGNED_INT,sint32:G.INT,sint32x2:G.INT,sint32x3:G.INT,sint32x4:G.INT};function ot(e){return at[e]??at.float32}var st={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5},ct=class{constructor(e){this._geometryVaoHash=Object.create(null),this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw Error(`[PixiJS] Vertex Array Objects are not supported on this device`);let t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=e=>t.bindVertexArrayOES(e),e.deleteVertexArray=e=>t.deleteVertexArrayOES(e));let n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(e,t,r,i)=>{n.drawArraysInstancedANGLE(e,t,r,i)},e.drawElementsInstanced=(e,t,r,i,a)=>{n.drawElementsInstancedANGLE(e,t,r,i,a)},e.vertexAttribDivisor=(e,t)=>n.vertexAttribDivisorANGLE(e,t)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(e,t){let n=this.gl;this._activeGeometry=e;let r=this.getVao(e,t);this._activeVao!==r&&(this._activeVao=r,n.bindVertexArray(r)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n];t.updateBuffer(r)}}checkCompatibility(e,t){let n=e.attributes,r=t._attributeData;for(let e in r)if(!n[e])throw Error(`shader and geometry incompatible, geometry missing the "${e}" attribute`)}getSignature(e,t){let n=e.attributes,r=t._attributeData,i=[`g`,e.uid];for(let e in n)r[e]&&i.push(e,r[e].location);return i.join(`-`)}getVao(e,t){return this._geometryVaoHash[e.uid]?.[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){let r=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);let a=this.getSignature(e,t);this._geometryVaoHash[e.uid]||(this._geometryVaoHash[e.uid]=Object.create(null),e.on(`destroy`,this.onGeometryDestroy,this));let o=this._geometryVaoHash[e.uid],s=o[a];if(s)return o[t._key]=s,s;ze(e,t._attributeData);let c=e.buffers;s=r.createVertexArray(),r.bindVertexArray(s);for(let e=0;e<c.length;e++){let t=c[e];i.bind(t)}return this.activateVao(e,t),o[t._key]=s,o[a]=s,r.bindVertexArray(null),s}onGeometryDestroy(e,t){let n=this._geometryVaoHash[e.uid],r=this.gl;if(n){if(t)for(let e in n)this._activeVao!==n[e]&&this.unbind(),r.deleteVertexArray(n[e]);this._geometryVaoHash[e.uid]=null}}destroyAll(e=!1){let t=this.gl;for(let n in this._geometryVaoHash){if(e)for(let e in this._geometryVaoHash[n]){let r=this._geometryVaoHash[n];this._activeVao!==r&&this.unbind(),t.deleteVertexArray(r[e])}this._geometryVaoHash[n]=null}}activateVao(e,t){let n=this._renderer.gl,r=this._renderer.buffer,i=e.attributes;e.indexBuffer&&r.bind(e.indexBuffer);let a=null;for(let e in i){let o=i[e],s=o.buffer,c=r.getGlBuffer(s),l=t._attributeData[e];if(l){a!==c&&(r.bind(s),a=c);let e=l.location;n.enableVertexAttribArray(e);let t=pe(o.format),i=ot(o.format);if(l.format?.substring(1,4)===`int`?n.vertexAttribIPointer(e,t.size,i,o.stride,o.offset):n.vertexAttribPointer(e,t.size,i,t.normalised,o.stride,o.offset),o.instance)if(this.hasInstance){let t=o.divisor??1;n.vertexAttribDivisor(e,t)}else throw Error(`geometry error, GPU Instancing is not supported on this device`)}}}draw(e,t,n,r){let{gl:i}=this._renderer,a=this._activeGeometry,o=st[a.topology||e];if(r||=a.instanceCount,a.indexBuffer){let e=a.indexBuffer.data.BYTES_PER_ELEMENT,s=e===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;r>1?i.drawElementsInstanced(o,t||a.indexBuffer.data.length,s,(n||0)*e,r):i.drawElements(o,t||a.indexBuffer.data.length,s,(n||0)*e)}else r>1?i.drawArraysInstanced(o,n||0,t||a.getSize(),r):i.drawArrays(o,n||0,t||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}};ct.extension={type:[R.WebGLSystem],name:`geometry`};var lt=new we({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),ut=class e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(t={}){let{useBackBuffer:n,antialias:r}={...e.defaultOptions,...t};this.useBackBuffer=n,this._antialias=r,this._renderer.context.supports.msaa||(F(`antialiasing, is not supported on when using the back buffer`),this._antialias=!1),this._state=M.for2d();let i=new fe({vertex:`
3
+ attribute vec2 aPosition;
4
+ out vec2 vUv;
5
+
6
+ void main() {
7
+ gl_Position = vec4(aPosition, 0.0, 1.0);
8
+
9
+ vUv = (aPosition + 1.0) / 2.0;
10
+
11
+ // flip dem UVs
12
+ vUv.y = 1.0 - vUv.y;
13
+ }`,fragment:`
14
+ in vec2 vUv;
15
+ out vec4 finalColor;
16
+
17
+ uniform sampler2D uTexture;
18
+
19
+ void main() {
20
+ finalColor = texture(uTexture, vUv);
21
+ }`,name:`big-triangle`});this._bigTriangleShader=new z({glProgram:i,resources:{uTexture:A.WHITE.source}})}renderStart(e){let t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){let t=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=t.colorTexture,e.target=this._getBackBufferTexture(t.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:lt,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new A({source:new te({width:e.width,height:e.height,resolution:e._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(e.width,e.height,e._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&=(this._backBufferTexture.destroy(),null)}};ut.extension={type:[R.WebGLSystem],name:`backBuffer`,priority:1},ut.defaultOptions={useBackBuffer:!1};var dt=ut,ft=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1)))}};ft.extension={type:[R.WebGLSystem],name:`colorMask`};var pt=class{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){let t=this._renderer,{geometry:n,shader:r,state:i,skipSync:a,topology:o,size:s,start:c,instanceCount:l}=e;t.shader.bind(r,a),t.geometry.bind(n,t.shader._activeProgram),i&&t.state.set(i),t.geometry.draw(o,s,c,l??n.instanceCount)}destroy(){this._renderer=null}};pt.extension={type:[R.WebGLSystem],name:`encoder`};var mt=class{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:V.NONE},this._renderTargetStencilState=Object.create(null),e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this._stencilCache.enabled=!1,this._stencilCache.stencilMode=V.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderTargetStencilState[e.uid];t||=this._renderTargetStencilState[e.uid]={stencilMode:V.DISABLED,stencilReference:0},this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let n=this._renderTargetStencilState[this._activeRenderTarget.uid],r=this._gl,i=Ne[e],a=this._stencilCache;if(n.stencilMode=e,n.stencilReference=t,e===V.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,r.disable(r.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,r.enable(r.STENCIL_TEST)),(e!==a.stencilMode||a.stencilReference!==t)&&(a.stencilMode=e,a.stencilReference=t,r.stencilFunc(this._comparisonFuncMapping[i.stencilBack.compare],t,255),r.stencilOp(r.KEEP,r.KEEP,this._stencilOpsMapping[i.stencilBack.passOp]))}};mt.extension={type:[R.WebGLSystem],name:`stencil`};var ht={f32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function gt(e){let t=e.map(e=>({data:e,offset:0,size:0})),n=0,r=0,i=0;for(let e=0;e<t.length;e++){let a=t[e];if(n=ht[a.data.type],!n)throw Error(`Unknown type ${a.data.type}`);if(a.data.size>1&&(n=Math.max(n,16)*a.data.size),a.size=n,r%n!==0&&r<16){let e=r%n%16;r+=e,i+=e}r+n>16?(i=Math.ceil(i/16)*16,a.offset=i,i+=n,r=n):(a.offset=i,r+=n,i+=n)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}function _t(e,t){let n=Math.max(ht[e.data.type]/16,1),r=e.data.value.length/e.data.size,i=(4-r%4)%4;return`
22
+ v = uv.${e.data.name};
23
+ offset += ${t};
24
+
25
+ arrayOffset = offset;
26
+
27
+ t = 0;
28
+
29
+ for(var i=0; i < ${e.data.size*n}; i++)
30
+ {
31
+ for(var j = 0; j < ${r}; j++)
32
+ {
33
+ data[arrayOffset++] = v[t++];
34
+ }
35
+ ${i===0?``:`arrayOffset += ${i};`}
36
+ }
37
+ `}function vt(e){return Me(e,`uboStd40`,_t,We)}var yt=class extends Ge{constructor(){super({createUboElements:gt,generateUboSync:vt})}};yt.extension={type:[R.WebGLSystem],name:`ubo`};var bt=class{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}},xt=class{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ue}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ue}copyToTexture(e,t,n,r,i){let a=this._renderTargetSystem,o=this._renderer,s=a.getGpuRenderTarget(e),c=o.gl;return this.finishRenderPass(e),c.bindFramebuffer(c.FRAMEBUFFER,s.resolveTargetFramebuffer),o.texture.bind(t,0),c.copyTexSubImage2D(c.TEXTURE_2D,0,i.x,i.y,n.x,n.y,r.width,r.height),t}startRenderPass(e,t=!0,n,r){let i=this._renderTargetSystem,a=e.colorTexture,o=i.getGpuRenderTarget(e),s=r.y;e.isRoot&&(s=a.pixelHeight-r.height),e.colorTextures.forEach(e=>{this._renderer.texture.unbind(e)});let c=this._renderer.gl;c.bindFramebuffer(c.FRAMEBUFFER,o.framebuffer);let l=this._viewPortCache;(l.x!==r.x||l.y!==s||l.width!==r.width||l.height!==r.height)&&(l.x=r.x,l.y=s,l.width=r.width,l.height=r.height,c.viewport(r.x,s,r.width,r.height)),!o.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(o),this.clear(e,t,n)}finishRenderPass(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);if(!t.msaa)return;let n=this._renderer.gl;n.bindFramebuffer(n.FRAMEBUFFER,t.resolveTargetFramebuffer),n.bindFramebuffer(n.READ_FRAMEBUFFER,t.framebuffer),n.blitFramebuffer(0,0,t.width,t.height,0,0,t.width,t.height,n.COLOR_BUFFER_BIT,n.NEAREST),n.bindFramebuffer(n.FRAMEBUFFER,t.framebuffer)}initGpuRenderTarget(e){let t=this._renderer,n=t.gl,r=new bt;return e.colorTexture.resource===t.gl.canvas?(r.framebuffer=null,r):(this._initColor(e,r),n.bindFramebuffer(n.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(e){let t=this._renderer.gl;e.framebuffer&&=(t.deleteFramebuffer(e.framebuffer),null),e.resolveTargetFramebuffer&&=(t.deleteFramebuffer(e.resolveTargetFramebuffer),null),e.depthStencilRenderBuffer&&=(t.deleteRenderbuffer(e.depthStencilRenderBuffer),null),e.msaaRenderBuffer.forEach(e=>{t.deleteRenderbuffer(e)}),e.msaaRenderBuffer=null}clear(e,t,n){if(!t)return;let r=this._renderTargetSystem;typeof t==`boolean`&&(t=t?Be.ALL:Be.NONE);let i=this._renderer.gl;if(t&Be.COLOR){n??=r.defaultClearColor;let e=this._clearColorCache,t=n;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3])&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],i.clearColor(t[0],t[1],t[2],t[3]))}i.clear(t)}resizeGpuRenderTarget(e){if(e.isRoot)return;let t=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,t),(e.stencil||e.depth)&&this._resizeStencil(t)}_initColor(e,t){let n=this._renderer,r=n.gl,i=r.createFramebuffer();if(t.resolveTargetFramebuffer=i,r.bindFramebuffer(r.FRAMEBUFFER,i),t.width=e.colorTexture.source.pixelWidth,t.height=e.colorTexture.source.pixelHeight,e.colorTextures.forEach((e,i)=>{let a=e.source;a.antialias&&(n.context.supports.msaa?t.msaa=!0:F(`[RenderTexture] Antialiasing on textures is not supported in WebGL1`)),n.texture.bindSource(a,0);let o=n.texture.getGlSource(a).texture;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,3553,o,0)}),t.msaa){let n=r.createFramebuffer();t.framebuffer=n,r.bindFramebuffer(r.FRAMEBUFFER,n),e.colorTextures.forEach((e,n)=>{let i=r.createRenderbuffer();t.msaaRenderBuffer[n]=i})}else t.framebuffer=i;this._resizeColor(e,t)}_resizeColor(e,t){let n=e.colorTexture.source;if(t.width=n.pixelWidth,t.height=n.pixelHeight,e.colorTextures.forEach((e,t)=>{t!==0&&e.source.resize(n.width,n.height,n._resolution)}),t.msaa){let n=this._renderer,r=n.gl,i=t.framebuffer;r.bindFramebuffer(r.FRAMEBUFFER,i),e.colorTextures.forEach((e,i)=>{let a=e.source;n.texture.bindSource(a,0);let o=n.texture.getGlSource(a).internalFormat,s=t.msaaRenderBuffer[i];r.bindRenderbuffer(r.RENDERBUFFER,s),r.renderbufferStorageMultisample(r.RENDERBUFFER,4,o,a.pixelWidth,a.pixelHeight),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,r.RENDERBUFFER,s)})}}_initStencil(e){if(e.framebuffer===null)return;let t=this._renderer.gl,n=t.createRenderbuffer();e.depthStencilRenderBuffer=n,t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,n),this._resizeStencil(e)}_resizeStencil(e){let t=this._renderer.gl;t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa?t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}},St=class extends Ve{constructor(e){super(e),this.adaptor=new xt,this.adaptor.init(e,this)}};St.extension={type:[R.WebGLSystem],name:`renderTarget`};function Ct(e,t){let n=[],r=[`
38
+ var g = s.groups;
39
+ var sS = r.shader;
40
+ var p = s.glProgram;
41
+ var ugS = r.uniformGroup;
42
+ var resources;
43
+ `],i=!1,a=0,o=0,s=t._getProgramData(e.glProgram);for(let c in e.groups){let l=e.groups[c];n.push(`
44
+ resources = g[${c}].resources;
45
+ `);for(let u in l.resources){let d=l.resources[u];if(d instanceof Te)d.ubo?n.push(`
46
+ sS.bindUniformBlock(
47
+ resources[${u}],
48
+ sS._uniformBindMap[${c}[${u}],
49
+ ${a++}
50
+ );
51
+ `):n.push(`
52
+ ugS.updateUniformGroup(resources[${u}], p, sD);
53
+ `);else if(d instanceof Ke)n.push(`
54
+ sS.bindUniformBlock(
55
+ resources[${u}],
56
+ sS._uniformBindMap[${c}[${u}],
57
+ ${a++}
58
+ );
59
+ `);else if(d instanceof te){let a=e._uniformBindMap[c][u],l=s.uniformData[a];l&&(i||(i=!0,r.push(`
60
+ var tS = r.texture;
61
+ `)),t._gl.uniform1i(l.location,o),n.push(`
62
+ tS.bind(resources[${u}], ${o});
63
+ `),o++)}}}let c=[...r,...n].join(`
64
+ `);return Function(`r`,`s`,`sD`,c)}var wt=class{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}};function Tt(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}function Et(e){let t=Array(e);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Dt(e,t){switch(e){case`float`:return 0;case`vec2`:return new Float32Array(2*t);case`vec3`:return new Float32Array(3*t);case`vec4`:return new Float32Array(4*t);case`int`:case`uint`:case`sampler2D`:case`sampler2DArray`:return 0;case`ivec2`:return new Int32Array(2*t);case`ivec3`:return new Int32Array(3*t);case`ivec4`:return new Int32Array(4*t);case`uvec2`:return new Uint32Array(2*t);case`uvec3`:return new Uint32Array(3*t);case`uvec4`:return new Uint32Array(4*t);case`bool`:return!1;case`bvec2`:return Et(2*t);case`bvec3`:return Et(3*t);case`bvec4`:return Et(4*t);case`mat2`:return new Float32Array([1,0,0,1]);case`mat3`:return new Float32Array([1,0,0,0,1,0,0,0,1]);case`mat4`:return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var Ot=null,kt={FLOAT:`float`,FLOAT_VEC2:`vec2`,FLOAT_VEC3:`vec3`,FLOAT_VEC4:`vec4`,INT:`int`,INT_VEC2:`ivec2`,INT_VEC3:`ivec3`,INT_VEC4:`ivec4`,UNSIGNED_INT:`uint`,UNSIGNED_INT_VEC2:`uvec2`,UNSIGNED_INT_VEC3:`uvec3`,UNSIGNED_INT_VEC4:`uvec4`,BOOL:`bool`,BOOL_VEC2:`bvec2`,BOOL_VEC3:`bvec3`,BOOL_VEC4:`bvec4`,FLOAT_MAT2:`mat2`,FLOAT_MAT3:`mat3`,FLOAT_MAT4:`mat4`,SAMPLER_2D:`sampler2D`,INT_SAMPLER_2D:`sampler2D`,UNSIGNED_INT_SAMPLER_2D:`sampler2D`,SAMPLER_CUBE:`samplerCube`,INT_SAMPLER_CUBE:`samplerCube`,UNSIGNED_INT_SAMPLER_CUBE:`samplerCube`,SAMPLER_2D_ARRAY:`sampler2DArray`,INT_SAMPLER_2D_ARRAY:`sampler2DArray`,UNSIGNED_INT_SAMPLER_2D_ARRAY:`sampler2DArray`},At={float:`float32`,vec2:`float32x2`,vec3:`float32x3`,vec4:`float32x4`,int:`sint32`,ivec2:`sint32x2`,ivec3:`sint32x3`,ivec4:`sint32x4`,uint:`uint32`,uvec2:`uint32x2`,uvec3:`uint32x3`,uvec4:`uint32x4`,bool:`uint32`,bvec2:`uint32x2`,bvec3:`uint32x3`,bvec4:`uint32x4`};function jt(e,t){if(!Ot){let t=Object.keys(kt);Ot={};for(let n=0;n<t.length;++n){let r=t[n];Ot[e[r]]=kt[r]}}return Ot[t]}function Mt(e,t){return At[jt(e,t)]||`float32`}function Nt(e,t,n=!1){let r={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){let i=t.getActiveAttrib(e,n);if(i.name.startsWith(`gl_`))continue;let a=Mt(t,i.type);r[i.name]={location:0,format:a,stride:pe(a).stride,offset:0,instance:!1,start:0}}let a=Object.keys(r);if(n){a.sort((e,t)=>e>t?1:-1);for(let n=0;n<a.length;n++)r[a[n]].location=n,t.bindAttribLocation(e,n,a[n]);t.linkProgram(e)}else for(let n=0;n<a.length;n++)r[a[n]].location=t.getAttribLocation(e,a[n]);return r}function Pt(e,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};let n={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<r;i++){let r=t.getActiveUniformBlockName(e,i);n[r]={name:r,index:t.getUniformBlockIndex(e,r),size:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_DATA_SIZE)}}return n}function Ft(e,t){let n={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<r;i++){let r=t.getActiveUniform(e,i),a=r.name.replace(/\[.*?\]$/,``),o=!!r.name.match(/\[.*?\]$/),s=jt(t,r.type);n[a]={name:a,index:i,type:s,size:r.size,isArray:o,value:Dt(s,r.size)}}return n}function It(e,t){let n=e.getShaderSource(t).split(`
65
+ `).map((e,t)=>`${t}: ${e}`),r=e.getShaderInfoLog(t),i=r.split(`
66
+ `),a={},o=i.map(e=>parseFloat(e.replace(/^ERROR\: 0\:([\d]+)\:.*$/,`$1`))).filter(e=>e&&!a[e]?(a[e]=!0,!0):!1),s=[``];o.forEach(e=>{n[e-1]=`%c${n[e-1]}%c`,s.push(`background: #FF0000; color:#FFFFFF; font-size: 10px`,`font-size: 10px`)}),s[0]=n.join(`
67
+ `),console.error(r),console.groupCollapsed(`click to view full shader code`),console.warn(...s),console.groupEnd()}function Lt(e,t,n,r){e.getProgramParameter(t,e.LINK_STATUS)||(e.getShaderParameter(n,e.COMPILE_STATUS)||It(e,n),e.getShaderParameter(r,e.COMPILE_STATUS)||It(e,r),console.error(`PixiJS Error: Could not initialize shader.`),e.getProgramInfoLog(t)!==``&&console.warn(`PixiJS Warning: gl.getProgramInfoLog()`,e.getProgramInfoLog(t)))}function Rt(e,t){let n=Tt(e,e.VERTEX_SHADER,t.vertex),r=Tt(e,e.FRAGMENT_SHADER,t.fragment),i=e.createProgram();e.attachShader(i,n),e.attachShader(i,r);let a=t.transformFeedbackVaryings;a&&(typeof e.transformFeedbackVaryings==`function`?e.transformFeedbackVaryings(i,a.names,a.bufferMode===`separate`?e.SEPARATE_ATTRIBS:e.INTERLEAVED_ATTRIBS):F(`TransformFeedback is not supported but TransformFeedbackVaryings are given.`)),e.linkProgram(i),e.getProgramParameter(i,e.LINK_STATUS)||Lt(e,i,n,r),t._attributeData=Nt(i,e,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Ft(i,e),t._uniformBlockData=Pt(i,e),e.deleteShader(n),e.deleteShader(r);let o={};for(let n in t._uniformData){let r=t._uniformData[n];o[n]={location:e.getUniformLocation(i,n),value:Dt(r.type,r.size)}}return new wt(i,o)}var zt={textureCount:0,blockIndex:0},Bt=class{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._maxBindings=e.MAX_UNIFORM_BUFFER_BINDINGS?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null,this.maxTextures=me()}bind(e,t){if(this._setProgram(e.glProgram),t)return;zt.textureCount=0,zt.blockIndex=0;let n=this._shaderSyncFunctions[e.glProgram._key];n||=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this),n(this._renderer,e,zt)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,zt)}bindUniformBlock(e,t,n=0){let r=this._renderer.buffer,i=this._getProgramData(this._activeProgram),a=e._bufferResource;a&&this._renderer.ubo.updateUniformGroup(e),r.updateBuffer(e.buffer);let o=this._boundUniformsIdsToIndexHash[e.uid];if(o===void 0){let t=this._nextIndex++%this._maxBindings,n=this._boundIndexToUniformsHash[t];n&&(this._boundUniformsIdsToIndexHash[n.uid]=void 0),o=this._boundUniformsIdsToIndexHash[e.uid]=t,this._boundIndexToUniformsHash[t]=e,a?r.bindBufferRange(e.buffer,t,e.offset):r.bindBufferBase(e.buffer,t)}let s=this._gl,c=this._activeProgram._uniformBlockData[t].index;i.uniformBlockBindings[n]!==o&&(i.uniformBlockBindings[n]=o,s.uniformBlockBinding(i.program,c,o))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;let t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){let t=e._key;return this._programDataHash[t]=Rt(this._gl,e),this._programDataHash[t]}destroy(){for(let e of Object.keys(this._programDataHash))this._programDataHash[e].destroy(),this._programDataHash[e]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(e,t){return Ct(e,t)}};Bt.extension={type:[R.WebGLSystem],name:`shader`};var Vt={f32:`if (cv !== v) {
68
+ cu.value = v;
69
+ gl.uniform1f(location, v);
70
+ }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
71
+ cv[0] = v[0];
72
+ cv[1] = v[1];
73
+ gl.uniform2f(location, v[0], v[1]);
74
+ }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
75
+ cv[0] = v[0];
76
+ cv[1] = v[1];
77
+ cv[2] = v[2];
78
+ gl.uniform3f(location, v[0], v[1], v[2]);
79
+ }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
80
+ cv[0] = v[0];
81
+ cv[1] = v[1];
82
+ cv[2] = v[2];
83
+ cv[3] = v[3];
84
+ gl.uniform4f(location, v[0], v[1], v[2], v[3]);
85
+ }`,i32:`if (cv !== v) {
86
+ cu.value = v;
87
+ gl.uniform1i(location, v);
88
+ }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
89
+ cv[0] = v[0];
90
+ cv[1] = v[1];
91
+ gl.uniform2i(location, v[0], v[1]);
92
+ }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
93
+ cv[0] = v[0];
94
+ cv[1] = v[1];
95
+ cv[2] = v[2];
96
+ gl.uniform3i(location, v[0], v[1], v[2]);
97
+ }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
98
+ cv[0] = v[0];
99
+ cv[1] = v[1];
100
+ cv[2] = v[2];
101
+ cv[3] = v[3];
102
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
103
+ }`,u32:`if (cv !== v) {
104
+ cu.value = v;
105
+ gl.uniform1ui(location, v);
106
+ }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
107
+ cv[0] = v[0];
108
+ cv[1] = v[1];
109
+ gl.uniform2ui(location, v[0], v[1]);
110
+ }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
111
+ cv[0] = v[0];
112
+ cv[1] = v[1];
113
+ cv[2] = v[2];
114
+ gl.uniform3ui(location, v[0], v[1], v[2]);
115
+ }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
116
+ cv[0] = v[0];
117
+ cv[1] = v[1];
118
+ cv[2] = v[2];
119
+ cv[3] = v[3];
120
+ gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
121
+ }`,bool:`if (cv !== v) {
122
+ cu.value = v;
123
+ gl.uniform1i(location, v);
124
+ }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
125
+ cv[0] = v[0];
126
+ cv[1] = v[1];
127
+ gl.uniform2i(location, v[0], v[1]);
128
+ }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
129
+ cv[0] = v[0];
130
+ cv[1] = v[1];
131
+ cv[2] = v[2];
132
+ gl.uniform3i(location, v[0], v[1], v[2]);
133
+ }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
134
+ cv[0] = v[0];
135
+ cv[1] = v[1];
136
+ cv[2] = v[2];
137
+ cv[3] = v[3];
138
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
139
+ }`,"mat2x2<f32>":`gl.uniformMatrix2fv(location, false, v);`,"mat3x3<f32>":`gl.uniformMatrix3fv(location, false, v);`,"mat4x4<f32>":`gl.uniformMatrix4fv(location, false, v);`},Ht={f32:`gl.uniform1fv(location, v);`,"vec2<f32>":`gl.uniform2fv(location, v);`,"vec3<f32>":`gl.uniform3fv(location, v);`,"vec4<f32>":`gl.uniform4fv(location, v);`,"mat2x2<f32>":`gl.uniformMatrix2fv(location, false, v);`,"mat3x3<f32>":`gl.uniformMatrix3fv(location, false, v);`,"mat4x4<f32>":`gl.uniformMatrix4fv(location, false, v);`,i32:`gl.uniform1iv(location, v);`,"vec2<i32>":`gl.uniform2iv(location, v);`,"vec3<i32>":`gl.uniform3iv(location, v);`,"vec4<i32>":`gl.uniform4iv(location, v);`,u32:`gl.uniform1iv(location, v);`,"vec2<u32>":`gl.uniform2iv(location, v);`,"vec3<u32>":`gl.uniform3iv(location, v);`,"vec4<u32>":`gl.uniform4iv(location, v);`,bool:`gl.uniform1iv(location, v);`,"vec2<bool>":`gl.uniform2iv(location, v);`,"vec3<bool>":`gl.uniform3iv(location, v);`,"vec4<bool>":`gl.uniform4iv(location, v);`};function Ut(e,t){let n=[`
140
+ var v = null;
141
+ var cv = null;
142
+ var cu = null;
143
+ var t = 0;
144
+ var gl = renderer.gl;
145
+ var name = null;
146
+ `];for(let r in e.uniforms){if(!t[r]){e.uniforms[r]instanceof Te?e.uniforms[r].ubo?n.push(`
147
+ renderer.shader.bindUniformBlock(uv.${r}, "${r}");
148
+ `):n.push(`
149
+ renderer.shader.updateUniformGroup(uv.${r});
150
+ `):e.uniforms[r]instanceof Ke&&n.push(`
151
+ renderer.shader.bindBufferResource(uv.${r}, "${r}");
152
+ `);continue}let i=e.uniformStructures[r],a=!1;for(let e=0;e<He.length;e++){let t=He[e];if(i.type===t.type&&t.test(i)){n.push(`name = "${r}";`,He[e].uniform),a=!0;break}}if(!a){let e=(i.size===1?Vt:Ht)[i.type].replace(`location`,`ud["${r}"].location`);n.push(`
153
+ cu = ud["${r}"];
154
+ cv = cu.value;
155
+ v = uv["${r}"];
156
+ ${e};`)}}return Function(`ud`,`uv`,`renderer`,`syncData`,n.join(`
157
+ `))}var Wt=class{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,n){let r=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==r.uniformDirtyGroups[e.uid])&&(r.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(r.uniformData,e.uniforms,this._renderer,n))}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){let n=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),r=this._getSignature(e,t._uniformData,`u`);return this._cache[r]||(this._cache[r]=this._generateUniformsSync(e,t._uniformData)),n[t._key]=this._cache[r],n[t._key]}_generateUniformsSync(e,t){return Ut(e,t)}_getSignature(e,t,n){let r=e.uniforms,i=[`${n}-`];for(let e in r)i.push(e),t[e]&&i.push(t[e].type);return i.join(`-`)}destroy(){this._renderer=null,this._cache=null}};Wt.extension={type:[R.WebGLSystem],name:`uniformGroup`};function Gt(e){let t={};if(t.normal=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t.add=[e.ONE,e.ONE],t.multiply=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.screen=[e.ONE,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t[`normal-npm`]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t[`add-npm`]=[e.SRC_ALPHA,e.ONE,e.ONE,e.ONE],t[`screen-npm`]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.erase=[e.ZERO,e.ONE_MINUS_SRC_ALPHA],!(e instanceof P.get().getWebGLRenderingContext()))t.min=[e.ONE,e.ONE,e.ONE,e.ONE,e.MIN,e.MIN],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,e.MAX,e.MAX];else{let n=e.getExtension(`EXT_blend_minmax`);n&&(t.min=[e.ONE,e.ONE,e.ONE,e.ONE,n.MIN_EXT,n.MIN_EXT],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,n.MAX_EXT,n.MAX_EXT])}return t}var Kt=0,qt=1,Jt=2,Yt=3,Xt=4,Zt=5,Qt=class e{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=`none`,this._blendEq=!1,this.map=[],this.map[Kt]=this.setBlend,this.map[qt]=this.setOffset,this.map[Jt]=this.setCullFace,this.map[Yt]=this.setDepthTest,this.map[Xt]=this.setFrontFace,this.map[Zt]=this.setDepthMask,this.checks=[],this.defaultState=M.for2d()}contextChange(e){this.gl=e,this.blendModesMap=Gt(e),this.reset()}set(e){if(e||=this.defaultState,this.stateId!==e.data){let t=this.stateId^e.data,n=0;for(;t;)t&1&&this.map[n].call(this,!!(e.data&1<<n)),t>>=1,n++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e||=this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(t){this._updateCheck(e._checkBlendMode,t),this.gl[t?`enable`:`disable`](this.gl.BLEND)}setOffset(t){this._updateCheck(e._checkPolygonOffset,t),this.gl[t?`enable`:`disable`](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?`enable`:`disable`](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this.gl[e?`enable`:`disable`](this.gl.CULL_FACE)}setFrontFace(e){this.gl.frontFace(this.gl[e?`CW`:`CCW`])}setBlendMode(e){if(this.blendModesMap[e]||(e=`normal`),e===this.blendMode)return;this.blendMode=e;let t=this.blendModesMap[e],n=this.gl;t.length===2?n.blendFunc(t[0],t[1]):n.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,n.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=``,this.setBlendMode(`normal`)}_updateCheck(e,t){let n=this.checks.indexOf(e);t&&n===-1?this.checks.push(e):!t&&n!==-1&&this.checks.splice(n,1)}static _checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static _checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Qt.extension={type:[R.WebGLSystem],name:`state`};var $t=Qt,en=class{constructor(e){this.target=it.TEXTURE_2D,this.texture=e,this.width=-1,this.height=-1,this.type=G.UNSIGNED_BYTE,this.internalFormat=rt.RGBA,this.format=rt.RGBA,this.samplerType=0}},tn={id:`buffer`,upload(e,t,n){t.width===e.width||t.height===e.height?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.width,e.height,t.format,t.type,e.resource):n.texImage2D(t.target,0,t.internalFormat,e.width,e.height,0,t.format,t.type,e.resource),t.width=e.width,t.height=e.height}},nn={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},rn={id:`compressed`,upload(e,t,n){n.pixelStorei(n.UNPACK_ALIGNMENT,4);let r=e.pixelWidth,i=e.pixelHeight,a=!!nn[e.format];for(let o=0;o<e.resource.length;o++){let s=e.resource[o];a?n.compressedTexImage2D(n.TEXTURE_2D,o,t.internalFormat,r,i,0,s):n.texImage2D(n.TEXTURE_2D,o,t.internalFormat,r,i,0,t.format,t.type,s),r=Math.max(r>>1,1),i=Math.max(i>>1,1)}}},an={id:`image`,upload(e,t,n,r){let i=e.alphaMode===`premultiply-alpha-on-upload`;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i);let a=t.width,o=t.height,s=e.pixelWidth,c=e.pixelHeight,l=e.resourceWidth,u=e.resourceHeight;l<s||u<c?((a!==s||o!==c)&&n.texImage2D(t.target,0,t.internalFormat,s,c,0,t.format,t.type,null),r===2?n.texSubImage2D(n.TEXTURE_2D,0,0,0,l,u,t.format,t.type,e.resource):n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.format,t.type,e.resource)):a===s||o===c?n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.format,t.type,e.resource):r===2?n.texImage2D(t.target,0,t.internalFormat,s,c,0,t.format,t.type,e.resource):n.texImage2D(t.target,0,t.internalFormat,t.format,t.type,e.resource),t.width=s,t.height=c}},on={id:`video`,upload(e,t,n,r){if(!e.isValid){n.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}an.upload(e,t,n,r)}},sn={linear:9729,nearest:9728},cn={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},ln={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},un={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function dn(e,t,n,r,i,a,o,s){let c=a;if(!s||e.addressModeU!==`repeat`||e.addressModeV!==`repeat`||e.addressModeW!==`repeat`){let n=ln[o?`clamp-to-edge`:e.addressModeU],r=ln[o?`clamp-to-edge`:e.addressModeV],a=ln[o?`clamp-to-edge`:e.addressModeW];t[i](c,t.TEXTURE_WRAP_S,n),t[i](c,t.TEXTURE_WRAP_T,r),t.TEXTURE_WRAP_R&&t[i](c,t.TEXTURE_WRAP_R,a)}if((!s||e.magFilter!==`linear`)&&t[i](c,t.TEXTURE_MAG_FILTER,sn[e.magFilter]),n){if(!s||e.mipmapFilter!==`linear`){let n=cn[e.minFilter][e.mipmapFilter];t[i](c,t.TEXTURE_MIN_FILTER,n)}}else t[i](c,t.TEXTURE_MIN_FILTER,sn[e.minFilter]);if(r&&e.maxAnisotropy>1){let n=Math.min(e.maxAnisotropy,t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](c,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}e.compare&&t[i](c,t.TEXTURE_COMPARE_FUNC,un[e.compare])}function fn(e){return{r8unorm:e.RED,r8snorm:e.RED,r8uint:e.RED,r8sint:e.RED,r16uint:e.RED,r16sint:e.RED,r16float:e.RED,rg8unorm:e.RG,rg8snorm:e.RG,rg8uint:e.RG,rg8sint:e.RG,r32uint:e.RED,r32sint:e.RED,r32float:e.RED,rg16uint:e.RG,rg16sint:e.RG,rg16float:e.RG,rgba8unorm:e.RGBA,"rgba8unorm-srgb":e.RGBA,rgba8snorm:e.RGBA,rgba8uint:e.RGBA,rgba8sint:e.RGBA,bgra8unorm:e.RGBA,"bgra8unorm-srgb":e.RGBA,rgb9e5ufloat:e.RGB,rgb10a2unorm:e.RGBA,rg11b10ufloat:e.RGB,rg32uint:e.RG,rg32sint:e.RG,rg32float:e.RG,rgba16uint:e.RGBA,rgba16sint:e.RGBA,rgba16float:e.RGBA,rgba32uint:e.RGBA,rgba32sint:e.RGBA,rgba32float:e.RGBA,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT,depth24plus:e.DEPTH_COMPONENT,"depth24plus-stencil8":e.DEPTH_STENCIL,depth32float:e.DEPTH_COMPONENT,"depth32float-stencil8":e.DEPTH_STENCIL}}function pn(e,t){let n={},r=e.RGBA;return e instanceof P.get().getWebGLRenderingContext()?t.srgb&&(n={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(n={"rgba8unorm-srgb":e.SRGB8_ALPHA8,"bgra8unorm-srgb":e.SRGB8_ALPHA8},r=e.RGBA8),{r8unorm:e.R8,r8snorm:e.R8_SNORM,r8uint:e.R8UI,r8sint:e.R8I,r16uint:e.R16UI,r16sint:e.R16I,r16float:e.R16F,rg8unorm:e.RG8,rg8snorm:e.RG8_SNORM,rg8uint:e.RG8UI,rg8sint:e.RG8I,r32uint:e.R32UI,r32sint:e.R32I,r32float:e.R32F,rg16uint:e.RG16UI,rg16sint:e.RG16I,rg16float:e.RG16F,rgba8unorm:e.RGBA,...n,rgba8snorm:e.RGBA8_SNORM,rgba8uint:e.RGBA8UI,rgba8sint:e.RGBA8I,bgra8unorm:r,rgb9e5ufloat:e.RGB9_E5,rgb10a2unorm:e.RGB10_A2,rg11b10ufloat:e.R11F_G11F_B10F,rg32uint:e.RG32UI,rg32sint:e.RG32I,rg32float:e.RG32F,rgba16uint:e.RGBA16UI,rgba16sint:e.RGBA16I,rgba16float:e.RGBA16F,rgba32uint:e.RGBA32UI,rgba32sint:e.RGBA32I,rgba32float:e.RGBA32F,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT16,depth24plus:e.DEPTH_COMPONENT24,"depth24plus-stencil8":e.DEPTH24_STENCIL8,depth32float:e.DEPTH_COMPONENT32F,"depth32float-stencil8":e.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function mn(e){return{r8unorm:e.UNSIGNED_BYTE,r8snorm:e.BYTE,r8uint:e.UNSIGNED_BYTE,r8sint:e.BYTE,r16uint:e.UNSIGNED_SHORT,r16sint:e.SHORT,r16float:e.HALF_FLOAT,rg8unorm:e.UNSIGNED_BYTE,rg8snorm:e.BYTE,rg8uint:e.UNSIGNED_BYTE,rg8sint:e.BYTE,r32uint:e.UNSIGNED_INT,r32sint:e.INT,r32float:e.FLOAT,rg16uint:e.UNSIGNED_SHORT,rg16sint:e.SHORT,rg16float:e.HALF_FLOAT,rgba8unorm:e.UNSIGNED_BYTE,"rgba8unorm-srgb":e.UNSIGNED_BYTE,rgba8snorm:e.BYTE,rgba8uint:e.UNSIGNED_BYTE,rgba8sint:e.BYTE,bgra8unorm:e.UNSIGNED_BYTE,"bgra8unorm-srgb":e.UNSIGNED_BYTE,rgb9e5ufloat:e.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:e.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:e.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:e.UNSIGNED_INT,rg32sint:e.INT,rg32float:e.FLOAT,rgba16uint:e.UNSIGNED_SHORT,rgba16sint:e.SHORT,rgba16float:e.HALF_FLOAT,rgba32uint:e.UNSIGNED_INT,rgba32sint:e.INT,rgba32float:e.FLOAT,stencil8:e.UNSIGNED_BYTE,depth16unorm:e.UNSIGNED_SHORT,depth24plus:e.UNSIGNED_INT,"depth24plus-stencil8":e.UNSIGNED_INT_24_8,depth32float:e.FLOAT,"depth32float-stencil8":e.FLOAT_32_UNSIGNED_INT_24_8_REV}}var hn=4,gn=class{constructor(e){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:an,buffer:tn,video:on,compressed:rn},this._useSeparateSamplers=!1,this._renderer=e}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=pn(e,this._renderer.context.extensions),this._mapFormatToType=mn(e),this._mapFormatToFormat=fn(e)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null);for(let e=0;e<16;e++)this.bind(A.EMPTY,e)}initSource(e){this.bind(e)}bind(e,t=0){let n=e.source;e?(this.bindSource(n,t),this._useSeparateSamplers&&this._bindSampler(n.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){let n=this._gl;if(e._touched=this._renderer.textureGC.count,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||=A.EMPTY.source;let r=this.getGlSource(e);n.bindTexture(r.target,r.texture)}}_bindSampler(e,t=0){let n=this._gl;if(!e){this._boundSamplers[t]=null,n.bindSampler(t,null);return}let r=this._getGlSampler(e);this._boundSamplers[t]!==r&&(this._boundSamplers[t]=r,n.bindSampler(t,r))}unbind(e){let t=e.source,n=this._boundTextures,r=this._gl;for(let e=0;e<n.length;e++)if(n[e]===t){this._activateLocation(e);let i=this.getGlSource(t);r.bindTexture(i.target,null),n[e]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){let t=this._gl,n=new en(t.createTexture());if(n.type=this._mapFormatToType[e.format],n.internalFormat=this._mapFormatToInternalFormat[e.format],n.format=this._mapFormatToFormat[e.format],e.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||e.isPowerOfTwo)){let t=Math.max(e.width,e.height);e.mipLevelCount=Math.floor(Math.log2(t))+1}return this._glTextures[e.uid]=n,this.managedTextures.includes(e)||(e.on(`update`,this.onSourceUpdate,this),e.on(`resize`,this.onSourceUpdate,this),e.on(`styleChange`,this.onStyleChange,this),e.on(`destroy`,this.onSourceDestroy,this),e.on(`unload`,this.onSourceUnload,this),e.on(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.push(e)),this.onSourceUpdate(e),this.updateStyle(e,!1),n}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){let n=this._gl,r=this.getGlSource(e);n.bindTexture(n.TEXTURE_2D,r.texture),this._boundTextures[this._activeTextureLocation]=e,dn(e.style,n,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,`texParameteri`,n.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e){let t=this._glTextures[e.uid];t&&(this.unbind(e),this._glTextures[e.uid]=null,this._gl.deleteTexture(t.texture))}onSourceUpdate(e){let t=this._gl,n=this.getGlSource(e);t.bindTexture(t.TEXTURE_2D,n.texture),this._boundTextures[this._activeTextureLocation]=e,this._uploads[e.uploadMethodId]?this._uploads[e.uploadMethodId].upload(e,n,t,this._renderer.context.webGLVersion):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.pixelWidth,e.pixelHeight,0,t.RGBA,t.UNSIGNED_BYTE,null),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);let n=this.getGlSource(e);this._gl.generateMipmap(n.target)}onSourceDestroy(e){e.off(`destroy`,this.onSourceDestroy,this),e.off(`update`,this.onSourceUpdate,this),e.off(`resize`,this.onSourceUpdate,this),e.off(`unload`,this.onSourceUnload,this),e.off(`styleChange`,this.onStyleChange,this),e.off(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(e),1),this.onSourceUnload(e)}_initSampler(e){let t=this._gl,n=this._gl.createSampler();return this._glSamplers[e._resourceId]=n,dn(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,`samplerParameteri`,n,!1,!0),this._glSamplers[e._resourceId]}_getGlSampler(e){return this._glSamplers[e._resourceId]||this._initSampler(e)}getGlSource(e){return this._glTextures[e.uid]||this._initSource(e)}generateCanvas(e){let{pixels:t,width:n,height:r}=this.getPixels(e),i=P.get().createCanvas();i.width=n,i.height=r;let a=i.getContext(`2d`);if(a){let e=a.createImageData(n,r);e.data.set(t),a.putImageData(e,0,0)}return i}getPixels(e){let t=e.source.resolution,n=e.frame,r=Math.max(Math.round(n.width*t),1),i=Math.max(Math.round(n.height*t),1),a=new Uint8Array(hn*r*i),o=this._renderer,s=o.renderTarget.getRenderTarget(e),c=o.renderTarget.getGpuRenderTarget(s),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,c.resolveTargetFramebuffer),l.readPixels(Math.round(n.x*t),Math.round(n.y*t),r,i,l.RGBA,l.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:r,height:i}}destroy(){this.managedTextures.slice().forEach(e=>this.onSourceDestroy(e)),this.managedTextures=null,this._renderer=null}};gn.extension={type:[R.WebGLSystem],name:`texture`};var _n=[...Pe,yt,dt,nt,et,gn,St,ct,Wt,Bt,pt,$t,mt,ft],vn=[...qe],yn=[Ze,Xe,Ye],bn=[],xn=[],Sn=[];H.handleByNamedList(R.WebGLSystem,bn),H.handleByNamedList(R.WebGLPipes,xn),H.handleByNamedList(R.WebGLPipesAdaptor,Sn),H.add(..._n,...vn,...yn);var Cn=class extends Ue{constructor(){let e={name:`webgl`,type:I.WEBGL,systems:bn,renderPipes:xn,renderPipeAdaptors:Sn};super(e)}},wn=class{init(){let e=new Te({uTransformMatrix:{value:new ce,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}}),t=ve({name:`graphics`,bits:[Ce,se(me()),ye,_e]});this.shader=new z({gpuProgram:t,resources:{localUniforms:e}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{geometry:a,instructions:o}=i.graphicsContext.getContextRenderData(n),s=i.encoder;s.setPipelineFromGeometryProgramAndState(a,r.gpuProgram,e.state),s.setGeometry(a,r.gpuProgram);let c=i.globalUniforms.bindGroup;s.setBindGroup(0,c,r.gpuProgram);let l=i.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);s.setBindGroup(2,l,r.gpuProgram);let u=o.instructions;for(let e=0;e<o.instructionSize;e++){let t=u[e];if(r.groups[1]=t.bindGroup,!t.gpuBindGroup){let e=t.textures;t.bindGroup=ke(e.textures,e.count),t.gpuBindGroup=i.bindGroup.getBindGroup(t.bindGroup,r.gpuProgram,1)}s.setBindGroup(1,t.bindGroup,r.gpuProgram),s.renderPassEncoder.drawIndexed(t.size,1,t.start)}}destroy(){this.shader.destroy(!0),this.shader=null}};wn.extension={type:[R.WebGPUPipesAdaptor],name:`graphics`};var Tn=class{init(){let e=ve({name:`mesh`,bits:[Se,Le,_e]});this._shader=new z({gpuProgram:e,resources:{uTexture:A.EMPTY._source,uSampler:A.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new ce}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r)r=this._shader,r.groups[2]=n.texture.getTextureBindGroup(t.texture);else if(!r.gpuProgram){F(`Mesh shader has no gpuProgram`,t.shader);return}let i=r.gpuProgram;if(i.autoAssignGlobalUniforms&&(r.groups[0]=n.globalUniforms.bindGroup),i.autoAssignLocalUniforms){let t=e.localUniforms;r.groups[1]=n.renderPipes.uniformBatch.getUniformBindGroup(t,!0)}n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}};Tn.extension={type:[R.WebGPUPipesAdaptor],name:`mesh`};var En=M.for2d(),Dn=class{init(){let e=ve({name:`batch`,bits:[Ce,se(me()),_e]});this._shader=new z({gpuProgram:e,groups:{}})}start(e,t){let n=e.renderer,r=n.encoder,i=this._shader.gpuProgram;this._geometry=t,r.setGeometry(t,i),En.blendMode=`normal`,n.pipeline.getPipeline(t,i,En);let a=n.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,a,i)}execute(e,t){let n=this._shader.gpuProgram,r=e.renderer,i=r.encoder;if(!t.bindGroup){let e=t.textures;t.bindGroup=ke(e.textures,e.count)}En.blendMode=t.blendMode;let a=r.bindGroup.getBindGroup(t.bindGroup,n,1),o=r.pipeline.getPipeline(this._geometry,n,En);t.bindGroup._touch(r.textureGC.count),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,a),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}destroy(){this._shader.destroy(!0),this._shader=null}};Dn.extension={type:[R.WebGPUPipesAdaptor],name:`batch`};var On=class{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,n){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,n)}_createBindGroup(e,t,n){let r=this._gpu.device,i=t.layout[n],a=[],o=this._renderer;for(let t in i){let n=e.resources[t]??e.resources[i[t]],r;if(n._resourceType===`uniformGroup`){let e=n;o.ubo.updateUniformGroup(e);let t=e.buffer;r={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if(n._resourceType===`buffer`){let e=n;r={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if(n._resourceType===`bufferResource`){let e=n;r={buffer:o.buffer.getGPUBuffer(e.buffer),offset:e.offset,size:e.size}}else if(n._resourceType===`textureSampler`){let e=n;r=o.texture.getGpuSampler(e)}else if(n._resourceType===`textureSource`){let e=n;r=o.texture.getGpuSource(e).createView({})}a.push({binding:i[t],resource:r})}let s=o.shader.getProgramData(t).bindGroups[n],c=r.createBindGroup({layout:s,entries:a});return this._hash[e._key]=c,c}destroy(){for(let e of Object.keys(this._hash))this._hash[e]=null;this._hash=null,this._renderer=null}};On.extension={type:[R.WebGPUSystem],name:`bindGroup`};var kn=class{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(e){this._gpu=e}getGPUBuffer(e){return this._gpuBuffers[e.uid]||this.createGPUBuffer(e)}updateBuffer(e){let t=this._gpuBuffers[e.uid]||this.createGPUBuffer(e),n=e.data;return e._updateID&&n&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,n.buffer,0,(e._updateSize||n.byteLength)+3&-4)),t}destroyAll(){for(let e in this._gpuBuffers)this._gpuBuffers[e].destroy();this._gpuBuffers={}}createGPUBuffer(e){this._gpuBuffers[e.uid]||(e.on(`update`,this.updateBuffer,this),e.on(`change`,this.onBufferChange,this),e.on(`destroy`,this.onBufferDestroy,this),this._managedBuffers.push(e));let t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&(E(e.data.buffer,t.getMappedRange()),t.unmap()),this._gpuBuffers[e.uid]=t,t}onBufferChange(e){this._gpuBuffers[e.uid].destroy(),e._updateID=0,this._gpuBuffers[e.uid]=this.createGPUBuffer(e)}onBufferDestroy(e){this._managedBuffers.splice(this._managedBuffers.indexOf(e),1),this._destroyBuffer(e)}destroy(){this._managedBuffers.forEach(e=>this._destroyBuffer(e)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(e){this._gpuBuffers[e.uid].destroy(),e.off(`update`,this.updateBuffer,this),e.off(`change`,this.onBufferChange,this),e.off(`destroy`,this.onBufferDestroy,this),this._gpuBuffers[e.uid]=null}};kn.extension={type:[R.WebGPUSystem],name:`buffer`};var An=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}};An.extension={type:[R.WebGPUSystem],name:`colorMask`};var jn=class{constructor(e){this._renderer=e}async init(e){return this._initPromise||=this._createDeviceAndAdaptor(e).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){let t=await P.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),n=[`texture-compression-bc`,`texture-compression-astc`,`texture-compression-etc2`].filter(e=>t.features.has(e));return{adapter:t,device:await t.requestDevice({requiredFeatures:n})}}destroy(){this.gpu=null,this._renderer=null}};jn.extension={type:[R.WebGPUSystem],name:`device`},jn.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var Mn=class{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,n,r){let i=this._renderer.pipeline.getPipeline(e,t,n,r);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;let t=e.data.BYTES_PER_ELEMENT===2?`uint16`:`uint32`;this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,n){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.textureGC.count);let r=this._renderer.bindGroup.getBindGroup(t,n,e);this.renderPassEncoder.setBindGroup(e,r)}setGeometry(e,t){let n=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let t in n)this._setVertexBuffer(t,e.attributes[n[t]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(let n in e.groups){let r=e.groups[n];t||this._syncBindGroup(r),this.setBindGroup(n,r,e.gpuProgram)}}_syncBindGroup(e){for(let t in e.resources){let n=e.resources[t];n.isUniformGroup&&this._renderer.ubo.updateUniformGroup(n)}}draw(e){let{geometry:t,shader:n,state:r,topology:i,size:a,start:o,instanceCount:s,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,r,i),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(a||t.indexBuffer.data.length,s||t.instanceCount,o||0):this.renderPassEncoder.draw(a||t.getSize(),s||t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&=(this.renderPassEncoder.end(),null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){let e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);let t=this._boundPipeline,n={...this._boundVertexBuffer},r=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();let a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(t);for(let e in n)this._setVertexBuffer(e,n[e]);for(let e in i)this.setBindGroup(e,i[e],null);this._setIndexBuffer(r)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}};Mn.extension={type:[R.WebGPUSystem],name:`encoder`,priority:1};var Nn=class{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||=this._renderTargetStencilState[e.uid]={stencilMode:V.DISABLED,stencilReference:0},this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let n=this._renderTargetStencilState[this._activeRenderTarget.uid];n.stencilMode=e,n.stencilReference=t;let r=this._renderer;r.pipeline.setStencilMode(e),r.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}};Nn.extension={type:[R.WebGPUSystem],name:`stencil`};var Pn={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Fn(e){let t=e.map(e=>({data:e,offset:0,size:0})),n=0;for(let e=0;e<t.length;e++){let r=t[e],i=Pn[r.data.type].size,a=Pn[r.data.type].align;if(!Pn[r.data.type])throw Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${r.data.type}`);r.data.size>1&&(i=Math.max(i,a)*r.data.size),n=Math.ceil(n/a)*a,r.size=i,r.offset=n,n+=i}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function In(e,t){let{size:n,align:r}=Pn[e.data.type],i=(r-n)/4;return`
158
+ v = uv.${e.data.name};
159
+ ${t===0?``:`offset += ${t};`}
160
+
161
+ arrayOffset = offset;
162
+
163
+ t = 0;
164
+
165
+ for(var i=0; i < ${e.data.size*(n/4)}; i++)
166
+ {
167
+ for(var j = 0; j < ${n/4}; j++)
168
+ {
169
+ data[arrayOffset++] = v[t++];
170
+ }
171
+ ${i===0?``:`arrayOffset += ${i};`}
172
+ }
173
+ `}function Ln(e){return Me(e,`uboWgsl`,In,Re)}var Rn=class extends Ge{constructor(){super({createUboElements:Fn,generateUboSync:Ln})}};Rn.extension={type:[R.WebGPUSystem],name:`ubo`};var zn=class{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw Error(`UniformBufferBatch: array is too large: ${e*4}`);let t=this.byteIndex,n=t+e*4;if(n=Math.ceil(n/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,n>this.data.length*4)throw Error(`UniformBufferBatch: ubo batch got too big`);return this.byteIndex=n,t}addGroup(e){let t=this.addEmptyGroup(e.length);for(let n=0;n<e.length;n++)this.data[t/4+n]=e[n];return t}destroy(){this._buffer.destroy(),this._buffer=null,this.data=null}},Bn=128,Vn=class{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new zn({minUniformOffsetAlignment:Bn});let t=256/Bn;for(let e=0;e<t;e++){let t=D.UNIFORM|D.COPY_DST;e===0&&(t|=D.COPY_SRC),this._buffers.push(new N({data:this._batchBuffer.data,usage:t}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(let e in this._bindGroupHash)this._bindGroupHash[e]=null;this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);let n=e.buffer.data,r=this._batchBuffer.addEmptyGroup(n.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,r/4),this._bindGroupHash[e.uid]=this._getBindGroup(r/Bn),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);let t=e.buffer.data,n=this._batchBuffer.addGroup(t);return this._getBufferResource(n/Bn)}getArrayBindGroup(e){let t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/Bn)}getArrayBufferResource(e){let t=this._batchBuffer.addGroup(e)/Bn;return this._getBufferResource(t)}_getBufferResource(e){if(!this._bufferResources[e]){let t=this._buffers[e%2];this._bufferResources[e]=new Ke({buffer:t,offset:(e/2|0)*256,size:Bn})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){let t=new re({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){let e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);let n=this._renderer.gpu.device.createCommandEncoder();for(let r=1;r<this._buffers.length;r++){let i=this._buffers[r];n.copyBufferToBuffer(e.getGPUBuffer(t),Bn,e.getGPUBuffer(i),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([n.finish()])}destroy(){for(let e=0;e<this._bindGroups.length;e++)this._bindGroups[e].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}};Vn.extension={type:[R.WebGPUPipes],name:`uniformBatch`};var Hn={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function Un(e,t,n,r,i){return e<<24|t<<16|n<<10|r<<5|i}function Wn(e,t,n,r){return n<<6|e<<3|r<<1|t}var Gn=class{constructor(e){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=e}contextChange(e){this._gpu=e,this.setStencilMode(V.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=+!!e.descriptor.depthStencilAttachment,this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=Ne[e],this._updatePipeHash())}setPipeline(e,t,n,r){let i=this.getPipeline(e,t,n);r.setPipeline(i)}getPipeline(e,t,n,r){e._layoutKey||(ze(e,t.attributeData),this._generateBufferKey(e)),r||=e.topology;let i=Un(e._layoutKey,t._layoutKey,n.data,n._blendModeId,Hn[r]);return this._pipeCache[i]||(this._pipeCache[i]=this._createPipeline(e,t,n,r)),this._pipeCache[i]}_createPipeline(e,t,n,r){let i=this._gpu.device,a=this._createVertexBufferLayouts(e,t),o=this._renderer.state.getColorTargets(n);o[0].writeMask=this._stencilMode===V.RENDERING_MASK_ADD?0:this._colorMask;let s=this._renderer.shader.getProgramData(t).pipeline,c={vertex:{module:this._getModule(t.vertex.source),entryPoint:t.vertex.entryPoint,buffers:a},fragment:{module:this._getModule(t.fragment.source),entryPoint:t.fragment.entryPoint,targets:o},primitive:{topology:r,cullMode:n.cullMode},layout:s,multisample:{count:this._multisampleCount},label:`PIXI Pipeline`};return this._depthStencilAttachment&&(c.depthStencil={...this._stencilState,format:`depth24plus-stencil8`,depthWriteEnabled:n.depthTest,depthCompare:n.depthTest?`less`:`always`}),i.createRenderPipeline(c)}_getModule(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){let t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){let t=[],n=0,r=Object.keys(e.attributes).sort();for(let i=0;i<r.length;i++){let a=e.attributes[r[i]];t[n++]=a.offset,t[n++]=a.format,t[n++]=a.stride,t[n++]=a.instance}return e._layoutKey=oe(t.join(`|`),`geometry`),e._layoutKey}_generateAttributeLocationsKey(e){let t=[],n=0,r=Object.keys(e.attributeData).sort();for(let i=0;i<r.length;i++){let a=e.attributeData[r[i]];t[n++]=a.location}return e._attributeLocationsKey=oe(t.join(`|`),`programAttributes`),e._attributeLocationsKey}getBufferNamesToBind(e,t){let n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[n])return this._bindingNamesCache[n];let r=this._createVertexBufferLayouts(e,t),i=Object.create(null),a=t.attributeData;for(let e=0;e<r.length;e++)for(let t in a)if(a[t].location===e){i[e]=t;break}return this._bindingNamesCache[n]=i,i}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);let n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[n])return this._bufferLayoutsCache[n];let r=[];return e.buffers.forEach(n=>{let i={arrayStride:0,stepMode:`vertex`,attributes:[]},a=i.attributes;for(let r in t.attributeData){let o=e.attributes[r];(o.divisor??1)!==1&&F(`Attribute ${r} has an invalid divisor value of '${o.divisor}'. WebGPU only supports a divisor value of 1`),o.buffer===n&&(i.arrayStride=o.stride,i.stepMode=o.instance?`instance`:`vertex`,a.push({shaderLocation:t.attributeData[r].location,offset:o.offset,format:o.format}))}a.length&&r.push(i)}),this._bufferLayoutsCache[n]=r,r}_updatePipeHash(){let e=Wn(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[e]||(this._pipeStateCaches[e]=Object.create(null)),this._pipeCache=this._pipeStateCaches[e]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}};Gn.extension={type:[R.WebGPUSystem],name:`pipeline`};var Kn=class{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}},qn=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,n,r,i){let a=this._renderer,o=this._getGpuColorTexture(e),s=a.texture.getGpuSource(t.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:n},{texture:s,origin:i},r),t}startRenderPass(e,t=!0,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e);i.descriptor=this.getDescriptor(e,t,n),this._renderer.pipeline.setRenderTarget(i),this._renderer.encoder.beginRenderPass(i),this._renderer.encoder.setViewport(r)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);return t.contexts[0]?t.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(e.colorTextures[0].source)}getDescriptor(e,t,n){typeof t==`boolean`&&(t=t?Be.ALL:Be.NONE);let r=this._renderTargetSystem,i=r.getGpuRenderTarget(e),a=e.colorTextures.map((e,a)=>{let o=i.contexts[a],s,c;s=o?o.getCurrentTexture().createView():this._renderer.texture.getGpuSource(e).createView({mipLevelCount:1}),i.msaaTextures[a]&&(c=s,s=this._renderer.texture.getTextureView(i.msaaTextures[a]));let l=t&Be.COLOR?`clear`:`load`;return n??=r.defaultClearColor,{view:s,resolveTarget:c,clearValue:n,storeOp:`store`,loadOp:l}}),o;if((e.stencil||e.depth)&&!e.depthStencilTexture&&(e.ensureDepthStencilTexture(),e.depthStencilTexture.source.sampleCount=i.msaa?4:1),e.depthStencilTexture){let n=t&Be.STENCIL?`clear`:`load`,r=t&Be.DEPTH?`clear`:`load`;o={view:this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView(),stencilStoreOp:`store`,stencilLoadOp:n,depthClearValue:1,depthLoadOp:r,depthStoreOp:`store`}}return{colorAttachments:a,depthStencilAttachment:o}}clear(e,t=!0,n,r){if(!t)return;let{gpu:i,encoder:a}=this._renderer,o=i.device;if(a.commandEncoder===null){let i=o.createCommandEncoder(),a=this.getDescriptor(e,t,n),s=i.beginRenderPass(a);s.setViewport(r.x,r.y,r.width,r.height,0,1),s.end();let c=i.finish();o.queue.submit([c])}else this.startRenderPass(e,t,n,r)}initGpuRenderTarget(e){e.isRoot=!0;let t=new Kn;return e.colorTextures.forEach((e,n)=>{if(ie.test(e.resource)){let r=e.resource.getContext(`webgpu`),i=e.transparent?`premultiplied`:`opaque`;try{r.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:`bgra8unorm`,alphaMode:i})}catch(e){console.error(e)}t.contexts[n]=r}if(t.msaa=e.source.antialias,e.source.antialias){let e=new te({width:0,height:0,sampleCount:4});t.msaaTextures[n]=e}}),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4)),t}destroyGpuRenderTarget(e){e.contexts.forEach(e=>{e.unconfigure()}),e.msaaTextures.forEach(e=>{e.destroy()}),e.msaaTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);e.depthStencilTexture&&t.msaa&&(e.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorTextures.forEach((e,n)=>{t.msaaTextures[n]?.resize(e.source.width,e.source.height,e.source._resolution)})}},Jn=class extends Ve{constructor(e){super(e),this.adaptor=new qn,this.adaptor.init(e,this)}};Jn.extension={type:[R.WebGPUSystem],name:`renderTarget`};var Yn=class{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e,this.maxTextures=e.device.limits.maxSampledTexturesPerShaderStage}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){let t=this._gpu.device,n=e.gpuLayout.map(e=>t.createBindGroupLayout({entries:e})),r={bindGroupLayouts:n};return this._gpuProgramData[e._layoutKey]={bindGroups:n,pipeline:t.createPipelineLayout(r)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}};Yn.extension={type:[R.WebGPUSystem],name:`shader`};var K={};K.normal={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}},K.add={alpha:{srcFactor:`src-alpha`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one`,operation:`add`}},K.multiply={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`dst`,dstFactor:`one-minus-src-alpha`,operation:`add`}},K.screen={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src`,operation:`add`}},K.overlay={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src`,operation:`add`}},K.none={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`zero`,dstFactor:`zero`,operation:`add`}},K[`normal-npm`]={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one-minus-src-alpha`,operation:`add`}},K[`add-npm`]={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one`,operation:`add`}},K[`screen-npm`]={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one-minus-src`,operation:`add`}},K.erase={alpha:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`zero`,dstFactor:`one-minus-src`,operation:`add`}},K.min={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`min`},color:{srcFactor:`one`,dstFactor:`one`,operation:`min`}},K.max={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`max`},color:{srcFactor:`one`,dstFactor:`one`,operation:`max`}};var Xn=class{constructor(){this.defaultState=new M,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e){return[{format:`bgra8unorm`,writeMask:0,blend:K[e.blendMode]||K.normal}]}destroy(){this.gpu=null}};Xn.extension={type:[R.WebGPUSystem],name:`state`};var Zn={type:`image`,upload(e,t,n){let r=e.resource,i=(e.pixelWidth|0)*(e.pixelHeight|0),a=r.byteLength/i;n.device.queue.writeTexture({texture:t},r,{offset:0,rowsPerImage:e.pixelHeight,bytesPerRow:e.pixelHeight*a},{width:e.pixelWidth,height:e.pixelHeight,depthOrArrayLayers:1})}},Qn={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},$n={blockBytes:4,blockWidth:1,blockHeight:1},er={type:`compressed`,upload(e,t,n){let r=e.pixelWidth,i=e.pixelHeight,a=Qn[e.format]||$n;for(let o=0;o<e.resource.length;o++){let s=e.resource[o],c=Math.ceil(r/a.blockWidth)*a.blockBytes;n.device.queue.writeTexture({texture:t,mipLevel:o},s,{offset:0,bytesPerRow:c},{width:Math.ceil(r/a.blockWidth)*a.blockWidth,height:Math.ceil(i/a.blockHeight)*a.blockHeight,depthOrArrayLayers:1}),r=Math.max(r>>1,1),i=Math.max(i>>1,1)}}},tr={type:`image`,upload(e,t,n){let r=e.resource;if(!r)return;let i=Math.min(t.width,e.resourceWidth||e.pixelWidth),a=Math.min(t.height,e.resourceHeight||e.pixelHeight),o=e.alphaMode===`premultiply-alpha-on-upload`;n.device.queue.copyExternalImageToTexture({source:r},{texture:t,premultipliedAlpha:o},{width:i,height:a})}},nr={type:`video`,upload(e,t,n){tr.upload(e,t,n)}},rr=class{constructor(e){this.device=e,this.sampler=e.createSampler({minFilter:`linear`}),this.pipelines={}}_getMipmapPipeline(e){let t=this.pipelines[e];return t||(this.mipmapShaderModule||=this.device.createShaderModule({code:`
174
+ var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
175
+ vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
176
+
177
+ struct VertexOutput {
178
+ @builtin(position) position : vec4<f32>,
179
+ @location(0) texCoord : vec2<f32>,
180
+ };
181
+
182
+ @vertex
183
+ fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
184
+ var output : VertexOutput;
185
+ output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
186
+ output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
187
+ return output;
188
+ }
189
+
190
+ @group(0) @binding(0) var imgSampler : sampler;
191
+ @group(0) @binding(1) var img : texture_2d<f32>;
192
+
193
+ @fragment
194
+ fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
195
+ return textureSample(img, imgSampler, texCoord);
196
+ }
197
+ `}),t=this.device.createRenderPipeline({layout:`auto`,vertex:{module:this.mipmapShaderModule,entryPoint:`vertexMain`},fragment:{module:this.mipmapShaderModule,entryPoint:`fragmentMain`,targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){let t=this._getMipmapPipeline(e.format);if(e.dimension===`3d`||e.dimension===`1d`)throw Error(`Generating mipmaps for non-2d textures is currently unsupported!`);let n=e,r=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){let t={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};n=this.device.createTexture(t)}let a=this.device.createCommandEncoder({}),o=t.getBindGroupLayout(0);for(let s=0;s<r;++s){let r=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),c=+!!i;for(let i=1;i<e.mipLevelCount;++i){let e=n.createView({baseMipLevel:c++,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),i=a.beginRenderPass({colorAttachments:[{view:e,storeOp:`store`,loadOp:`clear`,clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:r}]});i.setPipeline(t),i.setBindGroup(0,l),i.draw(3,1,0,0),i.end(),r=e}}if(!i){let t={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r};for(let r=1;r<e.mipLevelCount;++r)a.copyTextureToTexture({texture:n,mipLevel:r-1},{texture:e,mipLevel:r},t),t.width=Math.ceil(t.width/2),t.height=Math.ceil(t.height/2)}return this.device.queue.submit([a.finish()]),i||n.destroy(),e}},ir=class{constructor(e){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:tr,buffer:Zn,video:nr,compressed:er},this._renderer=e}contextChange(e){this._gpu=e}initSource(e){if(e.autoGenerateMipmaps){let t=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(t))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;e.uploadMethodId!==`compressed`&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);let n=Qn[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(e.pixelWidth/n.blockWidth)*n.blockWidth,i=Math.ceil(e.pixelHeight/n.blockHeight)*n.blockHeight,a={label:e.label,size:{width:r,height:i},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},o=this._gpu.device.createTexture(a);return this._gpuSources[e.uid]=o,this.managedTextures.includes(e)||(e.on(`update`,this.onSourceUpdate,this),e.on(`resize`,this.onSourceResize,this),e.on(`destroy`,this.onSourceDestroy,this),e.on(`unload`,this.onSourceUnload,this),e.on(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.push(e)),this.onSourceUpdate(e),o}onSourceUpdate(e){let t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onSourceUnload(e){let t=this._gpuSources[e.uid];t&&(this._gpuSources[e.uid]=null,t.destroy())}onUpdateMipmaps(e){this._mipmapGenerator||=new rr(this._gpu.device);let t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceDestroy(e){e.off(`update`,this.onSourceUpdate,this),e.off(`unload`,this.onSourceUnload,this),e.off(`destroy`,this.onSourceDestroy,this),e.off(`resize`,this.onSourceResize,this),e.off(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(e),1),this.onSourceUnload(e)}onSourceResize(e){let t=this._gpuSources[e.uid];t?(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(this._textureViewHash[e.uid]=null,this._bindGroupHash[e.uid]=null,this.onSourceUnload(e),this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){return this._gpuSources[e.uid]||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]??this._createTextureBindGroup(e)}_createTextureBindGroup(e){let t=e.source;return this._bindGroupHash[e.uid]=new re({0:t,1:t.style,2:new Te({uTextureMatrix:{type:`mat3x3<f32>`,value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){let t=e.source;return this._textureViewHash[t.uid]??this._createTextureView(t)}_createTextureView(e){return this._textureViewHash[e.uid]=this.getGpuSource(e).createView(),this._textureViewHash[e.uid]}generateCanvas(e){let t=this._renderer,n=t.gpu.device.createCommandEncoder(),r=P.get().createCanvas();r.width=e.source.pixelWidth,r.height=e.source.pixelHeight;let i=r.getContext(`webgpu`);return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:P.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:`premultiplied`}),n.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:r.width,height:r.height}),t.gpu.device.queue.submit([n.finish()]),r}getPixels(e){let t=this.generateCanvas(e),n=Ae.getOptimalCanvasAndContext(t.width,t.height),r=n.context;r.drawImage(t,0,0);let{width:i,height:a}=t,o=r.getImageData(0,0,i,a),s=new Uint8ClampedArray(o.data.buffer);return Ae.returnCanvasAndContext(n),{pixels:s,width:i,height:a}}destroy(){this.managedTextures.slice().forEach(e=>this.onSourceDestroy(e)),this.managedTextures=null;for(let e of Object.keys(this._bindGroupHash)){let t=Number(e);this._bindGroupHash[t]?.destroy(),this._bindGroupHash[t]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}};ir.extension={type:[R.WebGPUSystem],name:`texture`};var ar=[...Pe,Rn,Mn,jn,kn,ir,Jn,Yn,Xn,Gn,An,Nn,On],or=[...qe,Vn],sr=[Dn,Tn,wn],cr=[],lr=[],ur=[];H.handleByNamedList(R.WebGPUSystem,cr),H.handleByNamedList(R.WebGPUPipes,lr),H.handleByNamedList(R.WebGPUPipesAdaptor,ur),H.add(...ar,...or,...sr);var dr=class extends Ue{constructor(){let e={name:`webgpu`,type:I.WEBGPU,systems:cr,renderPipes:lr,renderPipeAdaptors:ur};super(e)}};function fr(){return pr}function pr(e,t,n){let r=e.gl,i=e.shader,a=i._getProgramData(t.glProgram);for(let o in t.groups){let s=t.groups[o];for(let c in s.resources){let l=s.resources[c];if(l instanceof Te)l.ubo?i.bindUniformBlock(l,t._uniformBindMap[o][c],n.blockIndex++):i.updateUniformGroup(l);else if(l instanceof Ke)i.bindUniformBlock(l,t._uniformBindMap[o][c],n.blockIndex++);else if(l instanceof te){e.texture.bind(l,n.textureCount);let i=t._uniformBindMap[o][c],s=a.uniformData[i];s&&(s.value!==n.textureCount&&r.uniform1i(s.location,n.textureCount),n.textureCount++)}else l instanceof ae}}}var mr=[(e,t,n,r,i)=>{let a=r[e].toArray(!0);t[n]=a[0],t[n+1]=a[1],t[n+2]=a[2],t[n+4]=a[3],t[n+5]=a[4],t[n+6]=a[5],t[n+8]=a[6],t[n+9]=a[7],t[n+10]=a[8]},(e,t,n,r,i)=>{i=r[e],t[n]=i.x,t[n+1]=i.y,t[n+2]=i.width,t[n+3]=i.height},(e,t,n,r,i)=>{i=r[e],t[n]=i.x,t[n+1]=i.y},(e,t,n,r,i)=>{i=r[e],t[n]=i.red,t[n+1]=i.green,t[n+2]=i.blue,t[n+3]=i.alpha},(e,t,n,r,i)=>{i=r[e],t[n]=i.red,t[n+1]=i.green,t[n+2]=i.blue}],hr={f32:(e,t,n,r,i)=>{t[n]=i},i32:(e,t,n,r,i)=>{t[n]=i},"vec2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1]},"vec3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2]},"vec4<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3]},"mat2x2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3]},"mat3x3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+4]=i[3],t[n+5]=i[4],t[n+6]=i[5],t[n+8]=i[6],t[n+9]=i[7],t[n+10]=i[8]},"mat4x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<16;e++)t[n+e]=i[e]},"mat3x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/3|0)*4+e%3]=i[e]},"mat4x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat4x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat3x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/3|0)*4+e%3]=i[e]}},gr={f32:(e,t,n,r,i)=>{t[n]=i},i32:(e,t,n,r,i)=>{t[n]=i},"vec2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1]},"vec3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2]},"vec4<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3]},"mat2x2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+4]=i[2],t[n+5]=i[3]},"mat3x3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+4]=i[3],t[n+5]=i[4],t[n+6]=i[5],t[n+8]=i[6],t[n+9]=i[7],t[n+10]=i[8]},"mat4x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<16;e++)t[n+e]=i[e]},"mat3x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/3|0)*4+e%3]=i[e]},"mat4x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat4x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat3x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/3|0)*4+e%3]=i[e]}};function _r(e){return yr(e,gr,e=>{let t=Math.max(ht[e.data.type]/16,1),n=e.data.value.length/e.data.size,r=(4-n%4)%4;return(i,a,o,s,c)=>{let l=0;for(let i=0;i<e.data.size*t;i++){for(let e=0;e<n;e++)a[o++]=c[l++];o+=r}}})}function vr(e){return yr(e,hr,e=>{let{size:t,align:n}=Pn[e.data.type],r=(t-n)/4;return(n,i,a,o,s)=>{let c=0;for(let n=0;n<e.data.size*(t/4);n++){for(let e=0;e<t/4;e++)i[a++]=s[c++];a+=r}}})}function yr(e,t,n){let r={};for(let i in e){let a=e[i],o=a.data,s=!1;r[o.name]={offset:a.offset/4,func:null};for(let e=0;e<He.length;e++){let t=He[e];if(o.type===t.type&&t.test(o)){r[o.name].func=mr[e],s=!0;break}}s||(o.size===1?r[o.name].func=t[o.type]:r[o.name].func=n(a))}return(e,t,n)=>{for(let i in r)r[i].func(i,t,n+r[i].offset,e,e[i])}}var br={f32(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1f(i[e].location,r))},"vec2<f32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2f(i[e].location,r[0],r[1]))},"vec3<f32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3f(i[e].location,r[0],r[1],r[2]))},"vec4<f32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4f(i[e].location,r[0],r[1],r[2],r[3]))},i32(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1i(i[e].location,r))},"vec2<i32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2i(i[e].location,r[0],r[1]))},"vec3<i32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3i(i[e].location,r[0],r[1],r[2]))},"vec4<i32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4i(i[e].location,r[0],r[1],r[2],r[3]))},u32(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1ui(i[e].location,r))},"vec2<u32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2ui(i[e].location,r[0],r[1]))},"vec3<u32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3ui(i[e].location,r[0],r[1],r[2]))},"vec4<u32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4ui(i[e].location,r[0],r[1],r[2],r[3]))},bool(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1i(i[e].location,r))},"vec2<bool>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2i(i[e].location,r[0],r[1]))},"vec3<bool>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3i(i[e].location,r[0],r[1],r[2]))},"vec4<bool>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4i(i[e].location,r[0],r[1],r[2],r[3]))},"mat2x2<f32>"(e,t,n,r,i,a,o){o.uniformMatrix2fv(i[e].location,!1,r)},"mat3x3<f32>"(e,t,n,r,i,a,o){o.uniformMatrix3fv(i[e].location,!1,r)},"mat4x4<f32>"(e,t,n,r,i,a,o){o.uniformMatrix4fv(i[e].location,!1,r)}},xr={f32(e,t,n,r,i,a,o){o.uniform1fv(i[e].location,r)},"vec2<f32>"(e,t,n,r,i,a,o){o.uniform2fv(i[e].location,r)},"vec3<f32>"(e,t,n,r,i,a,o){o.uniform3fv(i[e].location,r)},"vec4<f32>"(e,t,n,r,i,a,o){o.uniform4fv(i[e].location,r)},"mat2x2<f32>"(e,t,n,r,i,a,o){o.uniformMatrix2fv(i[e].location,!1,r)},"mat3x3<f32>"(e,t,n,r,i,a,o){o.uniformMatrix3fv(i[e].location,!1,r)},"mat4x4<f32>"(e,t,n,r,i,a,o){o.uniformMatrix4fv(i[e].location,!1,r)},i32(e,t,n,r,i,a,o){o.uniform1iv(i[e].location,r)},"vec2<i32>"(e,t,n,r,i,a,o){o.uniform2iv(i[e].location,r)},"vec3<i32>"(e,t,n,r,i,a,o){o.uniform3iv(i[e].location,r)},"vec4<i32>"(e,t,n,r,i,a,o){o.uniform4iv(i[e].location,r)},u32(e,t,n,r,i,a,o){o.uniform1iv(i[e].location,r)},"vec2<u32>"(e,t,n,r,i,a,o){o.uniform2iv(i[e].location,r)},"vec3<u32>"(e,t,n,r,i,a,o){o.uniform3iv(i[e].location,r)},"vec4<u32>"(e,t,n,r,i,a,o){o.uniform4iv(i[e].location,r)},bool(e,t,n,r,i,a,o){o.uniform1iv(i[e].location,r)},"vec2<bool>"(e,t,n,r,i,a,o){o.uniform2iv(i[e].location,r)},"vec3<bool>"(e,t,n,r,i,a,o){o.uniform3iv(i[e].location,r)},"vec4<bool>"(e,t,n,r,i,a,o){o.uniform4iv(i[e].location,r)}},Sr=[(e,t,n,r,i,a,o)=>{o.uniformMatrix3fv(i[e].location,!1,a[e].toArray(!0))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.x||n[1]!==r.y||n[2]!==r.width||n[3]!==r.height)&&(n[0]=r.x,n[1]=r.y,n[2]=r.width,n[3]=r.height,o.uniform4f(i[e].location,r.x,r.y,r.width,r.height))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.x||n[1]!==r.y)&&(n[0]=r.x,n[1]=r.y,o.uniform2f(i[e].location,r.x,r.y))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.red||n[1]!==r.green||n[2]!==r.blue||n[3]!==r.alpha)&&(n[0]=r.red,n[1]=r.green,n[2]=r.blue,n[3]=r.alpha,o.uniform4f(i[e].location,r.red,r.green,r.blue,r.alpha))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.red||n[1]!==r.green||n[2]!==r.blue)&&(n[0]=r.red,n[1]=r.green,n[2]=r.blue,o.uniform3f(i[e].location,r.red,r.green,r.blue))}];function Cr(e,t){let n={};for(let r in e.uniformStructures){if(!t[r])continue;let i=e.uniformStructures[r],a=!1;for(let e=0;e<He.length;e++){let t=He[e];if(i.type===t.type&&t.test(i)){n[r]=Sr[e],a=!0;break}}a||(n[r]=(i.size===1?br:xr)[i.type])}return(e,t,r)=>{let i=r.gl;for(let r in n){let a=t[r],o=e[r],s=e[r].value;n[r](r,o,s,a,e,t,i)}}}function wr(){Object.assign(Ue.prototype,{_unsafeEvalCheck(){}}),Object.assign(Ge.prototype,{_systemCheck(){}}),Object.assign(Wt.prototype,{_generateUniformsSync:Cr}),Object.assign(yt.prototype,{_generateUboSync:_r}),Object.assign(Rn.prototype,{_generateUboSync:vr}),Object.assign(Bt.prototype,{_generateShaderSync:fr})}wr();var Tr={extension:{type:R.Environment,name:`browser`,priority:-1},test:()=>!0,load:async()=>{await ee(()=>import(`./browserAll-B8-kqmYE.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))}},Er={extension:{type:R.Environment,name:`webworker`,priority:0},test:()=>typeof self<`u`&&self.WorkerGlobalScope!==void 0,load:async()=>{await ee(()=>import(`./webworkerAll-BFZtmp1G.js`),__vite__mapDeps([8,3,2,1,4,5,7]))}},Dr;function Or(e){return Dr===void 0&&(Dr=(()=>{let t={stencil:!0,failIfMajorPerformanceCaveat:e??Ue.defaultOptions.failIfMajorPerformanceCaveat};try{if(!P.get().getWebGLRenderingContext())return!1;let e=P.get().createCanvas().getContext(`webgl`,t),n=!!e?.getContextAttributes()?.stencil;if(e){let t=e.getExtension(`WEBGL_lose_context`);t&&t.loseContext()}return e=null,n}catch{return!1}})()),Dr}var kr;async function Ar(e={}){return kr===void 0&&(kr=await(async()=>{let t=P.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(e)).requestDevice(),!0}catch{return!1}})()),kr}var jr=[`webgl`,`webgpu`,`canvas`];async function Mr(e){let t=[];e.preference?(t.push(e.preference),jr.forEach(n=>{n!==e.preference&&t.push(n)})):t=jr.slice();let n,r={};for(let i=0;i<t.length;i++){let a=t[i];if(a===`webgpu`&&await Ar()){let{WebGPURenderer:t}=await ee(async()=>{let{WebGPURenderer:e}=await import(`./WebGPURenderer-DgfOPeWV.js`);return{WebGPURenderer:e}},[]);n=t,r={...e,...e.webgpu};break}else if(a===`webgl`&&Or(e.failIfMajorPerformanceCaveat??Ue.defaultOptions.failIfMajorPerformanceCaveat)){let{WebGLRenderer:t}=await ee(async()=>{let{WebGLRenderer:e}=await import(`./WebGLRenderer-COAVtjkI.js`);return{WebGLRenderer:e}},[]);n=t,r={...e,...e.webgl};break}else if(a===`canvas`)throw r={...e},Error(`CanvasRenderer is not yet implemented`)}if(delete r.webgpu,delete r.webgl,!n)throw Error(`No available renderer for the current environment`);let i=new n;return await i.init(r),i}var Nr=class e{constructor(...e){this.stage=new k,e[0]!==void 0&&B(L,`Application constructor options are deprecated, please use Application.init() instead.`)}async init(t){t={...t},this.renderer=await Mr(t),e._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return B(L,`Application.view is deprecated, please use Application.canvas instead.`),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,n=!1){let r=e._plugins.slice(0);r.reverse(),r.forEach(e=>{e.destroy.call(this)}),this.stage.destroy(n),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Nr._plugins=[];var Pr=Nr;H.handleByList(R.Application,Pr._plugins),H.add(Fe);var Fr=class extends O{constructor(e,t){let{text:n,resolution:r,style:i,anchor:a,width:o,height:s,roundPixels:c,...l}=e;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=n??``,this.style=i,this.resolution=r??null,this.allowChildren=!1,this._anchor=new xe({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o!==void 0&&(this.width=o),s!==void 0&&(this.height=s)}get anchor(){return this._anchor}set anchor(e){typeof e==`number`?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){e||={},this._style?.off(`update`,this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on(`update`,this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&=(this._updateBounds(),!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||={},e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e==`object`?(t=e.height??e.width,e=e.width):t??=e,e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}addBounds(e){let t=this.bounds;e.addFrame(t.minX,t.minY,t.maxX,t.maxY)}containsPoint(e){let t=this.bounds.width,n=this.bounds.height,r=-t*this.anchor.x,i=0;return e.x>=r&&e.x<=r+t&&(i=-n*this.anchor.y,e.y>=i&&e.y<=i+n)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(e=!1){super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e==`boolean`?e:e?.style)&&this._style.destroy(e),this._style=null,this._text=null}};function Ir(e,t){let n=e[0]??{};return(typeof n==`string`||e[1])&&(B(L,`use new ${t}({ text: "hi!", style }) instead`),n={text:n,style:e[1]}),n}var Lr=class extends Fr{constructor(...e){let t=Ir(e,`Text`);super(t,Ee),this.renderPipeId=`text`}_updateBounds(){let e=this._bounds,t=this._anchor,{width:n,height:r}=Oe.measureText(this._text,this._style);e.minX=-t._x*n,e.maxX=e.minX+n,e.minY=-t._y*r,e.maxY=e.minY+r}};De(),H.add(Tr,Er);var Rr=8,zr=s.maxContentItems,Br=s.maxLogicalCanvasWidth,Vr=s.maxLogicalCanvasHeight,q=s.maxExpandedRoomWidth,J=s.maxExpandedRoomHeight,Hr=s.maxLayoutRows;function Ur(e){let t={fixedHeaderChromeWidth:Y(e.style?.fixedHeaderChromeWidth,s.roomHeaderChromeWidth,q),fixedHeaderChromeHeight:Y(e.style?.fixedHeaderChromeHeight,s.roomHeaderChromeHeight,J),overflowMarkerMinWidth:Y(e.style?.overflowMarkerMinWidth,s.overflowMarkerMinWidth,q),overflowMarkerMinHeight:Y(e.style?.overflowMarkerMinHeight,s.overflowMarkerMinHeight,J),overflowMarkerGap:Y(e.style?.overflowMarkerGap,s.overflowMarkerGap,J),roomSafeInset:Y(e.style?.roomSafeInset,s.roomHeaderSafeInset,q)},n=ri(t.fixedHeaderChromeWidth,t.roomSafeInset),r=Math.min(q,Math.max(s.minRoomWidth,n,t.overflowMarkerMinWidth)),i=Math.min(J,Math.max(s.minRoomHeight,t.fixedHeaderChromeHeight+t.overflowMarkerMinHeight+t.overflowMarkerGap)),a=Y(e.maximumExpandedRoomWidth,q,q),o=Y(e.maximumExpandedCanvasWidth,Br,Br),c=Y(e.maximumExpandedRoomHeight,J,J),l=Y(e.maximumExpandedCanvasHeight,Vr,Vr),u=Y(e.minimumLogicalCanvasWidth,s.minOfficeWidth,Br),d=Y(e.minimumLogicalCanvasHeight,s.ceoBandHeight+s.hallwayHeight,Vr),f=Math.min(Br,Math.max(u,r,Y(e.maximumExpandedCanvasWidth,Br,Br))),p=Math.min(Vr,Math.max(d,i,Y(e.maximumExpandedCanvasHeight,Vr,Vr))),m=Math.min(q,f,Math.max(r,Y(e.maximumExpandedRoomWidth,q,q))),h=Math.min(J,p,Math.max(i,Y(e.maximumExpandedRoomHeight,J,J))),g=hi(e.maxContentItems,zr),_=Math.max(1,Math.min(Hr,Y(e.maxLayoutRows,Hr,Hr))),v=e.rooms.map((e,t)=>ci(e,t,m,h)).sort(li).slice(0,s.maxRooms);return{availableViewportWidth:Y(e.availableViewportWidth,0,f),availableViewportHeight:Y(e.availableViewportHeight,0,p),minimumLogicalCanvasWidth:u,minimumLogicalCanvasHeight:d,minimumRoomWidth:r,minimumRoomHeight:i,maximumExpandedCanvasWidth:f,maximumExpandedCanvasHeight:p,maximumExpandedRoomWidth:m,maximumExpandedRoomHeight:h,maxContentItems:g,maxLayoutRows:_,overflowMode:`logical-scroll`,fontKey:e.fontKey??`Inter, ui-sans-serif, system-ui, sans-serif`,fontReady:e.fontReady!==!1,titleMode:e.titleMode===`compact`?`compact`:`expand`,roomAlignment:e.roomAlignment===`center`||e.roomAlignment===`right`?e.roomAlignment:`left`,ceoReceptionCount:Y(e.ceoReceptionCount,0,s.maxReceptionDesks),ceoContentItems:(e.ceoContentItems??[]).map((e,t)=>di(e,t)),ceoContentItemCount:e.ceoContentItems?.length??0,styleCapacityInvalid:n>q||a<n||o<n||a<r||o<r||c<i||l<i,style:t,rooms:v}}function Wr(e){let t=Ur(e),n=pi(fi(t)),r=ui(t),i=t.minimumRoomWidth>t.maximumExpandedRoomWidth||t.styleCapacityInvalid||t.style.fixedHeaderChromeHeight+t.style.overflowMarkerMinHeight+t.style.overflowMarkerGap>t.maximumExpandedRoomHeight,a=Math.min(t.maximumExpandedCanvasWidth,Math.max(t.minimumLogicalCanvasWidth,t.availableViewportWidth,...t.rooms.map(e=>Math.max(Gr(e,t).width,e.headerMinWidth??0,e.headerMinTitleBoxWidth??0,e.contentMinWidth??0,mi(e.contentItems,e.flow,t.maxContentItems)+s.roomPadding*2,e.preferredWidth??0)+24),mi(t.ceoContentItems,`wrap-row`,t.maxContentItems)+s.ceoEdgePadding*2)),o=t.minimumRoomWidth>t.maximumExpandedRoomWidth||t.minimumRoomHeight>t.maximumExpandedRoomHeight;if(i||o){let e=l(t.minimumLogicalCanvasWidth,[],t.roomAlignment,s.ceoBandHeight,0,t.maximumExpandedCanvasHeight),i=ti({...e,totalHeight:Math.min(t.maximumExpandedCanvasHeight,e.totalHeight),fallbackMessage:`Office layout unavailable`},[]);return i.ceoOverflowMarkerRect=ii(ei(i,i.ceoContentRect,-1),t),{inputDigest:n,normalizedInput:r,layout:{...i,overflowMarker:{label:`Office layout unavailable`,required:!0}},roomHeaders:[],rows:[],contentItems:[],omissions:[],omissionSummary:oi(),normalizationErrors:[`invalid-style-capacity`],fallbackMessage:`Office layout unavailable`,accessibleOverflow:{label:`Office layout unavailable`,required:!0},resolvedCanvasWidth:i.officeWidth,resolvedCanvasHeight:i.totalHeight}}let c=S(a,t.ceoReceptionCount,Math.min(t.maximumExpandedCanvasHeight,t.maximumExpandedRoomHeight)),u=$r(t.ceoContentItems,c.ceoContentWidth,t,c.ceoBandHeight),d=l(a,t.rooms.map(e=>({sourceIndex:e.sourceIndex,deskCount:e.deskCount,standingCount:e.standingCount,headerMinWidth:Gr(e,t).width,headerMinTitleBoxWidth:e.headerMinTitleBoxWidth,headerMinHeight:e.headerMinHeight,contentMinWidth:Math.max(e.contentMinWidth??0,mi(e.contentItems,e.flow,t.maxContentItems)+s.roomPadding*2),preferredWidth:Math.min(t.maximumExpandedRoomWidth,Math.max(e.preferredWidth??0,t.minimumRoomWidth)),preferredHeight:Math.min(t.maximumExpandedRoomHeight,Math.max(e.preferredHeight??0,t.minimumRoomHeight)),maximumWidth:t.maximumExpandedRoomWidth,maximumHeight:t.maximumExpandedRoomHeight})),t.roomAlignment,u,t.ceoReceptionCount,Math.min(t.maximumExpandedCanvasHeight,t.maximumExpandedRoomHeight)),f=ai(),p=d.rooms.filter(e=>e.row<t.maxLayoutRows&&e.y+e.height<=t.maximumExpandedCanvasHeight);t.rooms.forEach(e=>{p.some(t=>t.index===e.sourceIndex)||f.add({reason:`canvas-capacity-exhausted`,importance:`required`,id:e.id})});let m=ti({...d,officeWidth:a,totalHeight:Math.min(t.maximumExpandedCanvasHeight,Math.max(d.totalHeight,t.minimumLogicalCanvasHeight)),rooms:p},t.rooms.reduce((e,n)=>(e[n.sourceIndex]=Gr(n,t),e),[])),h=[];t.rooms.forEach(e=>{let n=m.rooms.find(({index:t})=>t===e.sourceIndex);if(!n)return;let r=Xr(e.contentItems??[],t.maxContentItems);r.omitted.forEach(e=>f.add({reason:`content-item-count-cap`,importance:e.importance,id:e.id}));let i=Zr(n,e,r.selected,t);i.items.forEach(e=>h.push(e)),i.omissions.forEach(e=>f.add(e)),(i.requiredOverflow||r.omitted.some(({importance:e})=>e===`required`))&&(n.overflowMarkerRect=ii(n,t))});let g=new Set(m.ceoBlocks.receptions.map(({index:e})=>e));for(let e=0;e<t.ceoReceptionCount;e+=1)g.has(e)||f.add({reason:`canvas-capacity-exhausted`,importance:`required`,id:`reception-${e}`});let _={id:`ceo-office`,role:`ceo`,region:`ceo`,order:0,flow:`wrap-row`,spanPolicy:`multi-row`,title:`CEO Office`,hostTitle:`CEO`,deskCount:0,standingCount:0,contentItems:t.ceoContentItems},v=Xr(t.ceoContentItems,t.maxContentItems);v.omitted.forEach(e=>f.add({reason:`content-item-count-cap`,importance:e.importance,id:e.id}));let y=Zr(ei(m,m.ceoContentRect,-1),_,v.selected,t);y.items.forEach(e=>h.push(e)),y.omissions.forEach(e=>f.add(e)),(y.requiredOverflow||v.omitted.some(({importance:e})=>e===`required`)||g.size<t.ceoReceptionCount)&&(m.ceoOverflowMarkerRect=ii(ei(m,m.ceoContentRect,-1),t));let b=Qr(m),x=f.records(),C=f.summary(),w=C.byImportance.required?{label:`Some required Office content is not shown.`,required:!0}:null,T=w?{...m,overflowMarker:w}:m;return{inputDigest:n,normalizedInput:r,layout:T,roomHeaders:m.rooms.map(e=>e.header??null),rows:b,contentItems:h,omissions:x,omissionSummary:C,normalizationErrors:[],fallbackMessage:null,accessibleOverflow:w,resolvedCanvasWidth:T.officeWidth,resolvedCanvasHeight:T.totalHeight}}function Gr(e,t){let{workspace:n,host:r}=Kr(String(e.title??`ROOM`),String(e.hostTitle??`HOST`),t.titleMode),i=e.visualTitle??n,a=e.visualHostTitle??r,o=t.style.fixedHeaderChromeWidth,c=s.roomHeaderActionWidth,l=s.roomHeaderActionGap,u=s.roomHeaderCloseGap,d=Math.max(ri(o,t.style.roomSafeInset),t.maximumExpandedRoomWidth),f=Math.max(o,d-t.style.roomSafeInset*2-2*(c+l+c+u)),p=Math.max(o,e.headerMinTitleBoxWidth??0,o+bi(i)+bi(a)),m=ri(p,t.style.roomSafeInset),h=!1;if(p>f){h=!0;let e=Math.max(0,f-o),n=Math.floor(e*.52),r=Math.max(0,e-n);i=yi(i,n),a=yi(a,r),p=Math.min(f,o+bi(i)+bi(a)),m=ri(p,t.style.roomSafeInset)}return m=Math.max(m,e.headerMinWidth??0),{workspace:i,host:a,width:Math.min(d,Math.ceil(m)),titleBoxX:0,titleBoxWidth:Math.max(o,Math.ceil(p)),renameX:0,closeX:0,renameWidth:c,closeWidth:c,actionWidth:c,actionGap:l,closeGap:u,height:Math.max(s.roomHeaderHeight,t.style.fixedHeaderChromeHeight),emergencyEllipsis:h}}function Kr(e,t,n){return{workspace:n===`compact`?vi(e,18):e,host:n===`compact`?vi(t,16):t}}var qr=class{revision=0;currentDigest=null;currentLayout=null;renderedRevision=0;publish(e,t){if(t.inputDigest!==e.canonicalDigest)throw Error(`Office layout geometry does not match its input generation.`);if(this.currentLayout&&this.currentDigest===e.canonicalDigest)return this.currentLayout;this.revision+=1,this.currentDigest=e.canonicalDigest;let n={...t.layout,generationId:e.canonicalDigest,layoutRevision:this.revision,inputDigest:e.canonicalDigest,normalizedInput:t.normalizedInput,roomHeaders:t.roomHeaders,rows:t.rows,contentItems:t.contentItems,omissions:t.omissions,omissionSummary:t.omissionSummary,normalizationErrors:t.normalizationErrors,fallbackMessage:t.fallbackMessage,accessibleOverflow:t.accessibleOverflow,resolvedCanvasWidth:t.resolvedCanvasWidth,resolvedCanvasHeight:t.resolvedCanvasHeight};return this.currentLayout=Yr(Jr(n)),this.currentLayout}ackCanvasRendered(e){return!this.currentLayout||e!==this.currentLayout.layoutRevision?!1:(this.renderedRevision=e,!0)}get canvasRenderedRevision(){return this.renderedRevision}isCanvasReady(e){return this.currentLayout?.layoutRevision===e&&this.renderedRevision===e}};function Jr(e){if(Array.isArray(e))return e.map(e=>Jr(e));if(e&&typeof e==`object`){let t={};return Object.entries(e).forEach(([e,n])=>{t[e]=Jr(n)}),t}return e}function Yr(e){return e&&typeof e==`object`&&!Object.isFrozen(e)&&(Object.values(e).forEach(e=>Yr(e)),Object.freeze(e)),e}function Xr(e,t){let n=[...e.map((e,t)=>di(e,t))].sort((e,t)=>{let n=gi(_i(e.importance)?e.importance:`optional`)-gi(_i(t.importance)?t.importance:`optional`);return n===0?e.importance===`required`&&t.importance===`required`?e.order-t.order||e.id.localeCompare(t.id):t.priority-e.priority||e.order-t.order||e.id.localeCompare(t.id):n});return{selected:n.slice(0,t),omitted:n.slice(t)}}function Zr(e,t,n,r){let i=[],a=[],o=e.contentSafeRect.x,s=e.contentSafeRect.y,c=0,l=0,u=0,d=!1,f=t.flow??`wrap-row`;return n.forEach(n=>{let p=_i(n.importance)?n.importance:`optional`;if(!n.valid){a.push({reason:`invalid-content-descriptor`,importance:p,id:n.id}),p===`required`&&(d=!0);return}if(n.minWidth>r.maximumExpandedRoomWidth||n.minHeight>r.maximumExpandedRoomHeight||n.minWidth>e.contentSafeRect.width||n.minHeight>e.contentSafeRect.height){let e=p===`required`?`required-minimum-exceeds-room-cap`:`non-required-minimum-exceeds-room-cap`;a.push({reason:e,importance:p,id:n.id}),p===`required`&&(d=!0);return}let m=e.contentSafeRect.width,h=Math.max(n.minWidth,Math.min(n.preferredWidth,m)),g=Math.max(0,e.contentSafeRect.x+m-o),_=t.spanPolicy===`multi-row`?m:t.spanPolicy===`remaining`&&u>0?Math.max(n.minWidth,Math.min(h,g)):h,v=Math.max(n.minHeight,Math.min(n.preferredHeight,r.maximumExpandedRoomHeight)),y=f===`column`?u>0:f===`wrap-row`||f===`grid`?u>0&&o+_>e.contentSafeRect.x+m:!1,b=t.spanPolicy===`multi-row`&&u>0;if((y||b)&&(l+=1,o=e.contentSafeRect.x,s+=c+8,c=0,u=0),f===`row`&&u>0&&o+_>e.contentSafeRect.x+m){a.push({reason:`canvas-capacity-exhausted`,importance:p,id:n.id}),p===`required`&&(d=!0);return}if(l>=r.maxLayoutRows||s+v>e.contentSafeRect.y+e.contentSafeRect.height){a.push({reason:`canvas-capacity-exhausted`,importance:p,id:n.id}),p===`required`&&(d=!0);return}let x={x:o,y:s,width:_,height:v},S={x:Math.max(e.clipRect.x,x.x),y:Math.max(e.clipRect.y,x.y),width:Math.min(x.width,e.clipRect.x+e.clipRect.width-x.x),height:Math.min(x.height,e.clipRect.y+e.clipRect.height-x.y)};i.push({...x,roomIndex:e.index,id:n.id,kind:n.kind,importance:p,clipRect:S,inkBounds:S}),o+=_+8,c=Math.max(c,v),u+=1}),{items:i,omissions:a,requiredOverflow:d}}function Qr(e){let t=new Map;return e.rooms.forEach(e=>{let n=`${e.row}`,r=t.get(n),i=r?si(r.rect,e.outerRect):e.outerRect;t.set(n,{roomIndex:e.index,index:e.row,rect:i})}),[...t.values()].sort((e,t)=>e.index-t.index)}function $r(e,t,n,r){let i=Xr(e,n.maxContentItems).selected,a=Math.max(1,t-16),o=0,s=0,c=0;return i.forEach(e=>{if(!e.valid||e.minWidth>a||e.minHeight>n.maximumExpandedRoomHeight)return;let t=Math.min(e.preferredWidth,a),r=Math.min(e.preferredHeight,n.maximumExpandedRoomHeight);o>0&&o+t>a&&(s+=c+8,o=0,c=0),o+=t+8,c=Math.max(c,r)}),s+=c,Math.min(n.maximumExpandedCanvasHeight,n.maximumExpandedRoomHeight,Math.max(r,s+56))}function ei(e,t,n){return{index:n,column:0,row:0,x:e.ceoRect.x,y:e.ceoRect.y,width:e.ceoRect.width,height:e.ceoRect.height,deskColumns:0,standingColumns:0,deskRows:0,standingRows:0,outerRect:e.ceoRect,wallRect:e.ceoRect,headerRect:e.ceoRect,contentSafeRect:t,clipRect:e.ceoRect,inkBounds:e.ceoRect,shadowAllowance:0,selectionStrokeAllowance:0}}function ti(e,t){let n=e.rooms.map(e=>({...e,header:t[e.index]?ni(e.headerRect,t[e.index]):e.header}));return{...e,rooms:n}}function ni(e,t){let n=Math.max(0,(e.width-t.titleBoxWidth)/2);return{...t,titleBoxX:n,renameX:n+t.titleBoxWidth+t.actionGap,closeX:Math.max(0,e.width-t.closeWidth)}}function ri(e,t=s.roomHeaderSafeInset){return Math.ceil(Math.max(0,e)+2*(s.roomHeaderActionWidth+s.roomHeaderActionGap+s.roomHeaderActionWidth+s.roomHeaderCloseGap)+Math.max(0,t)*2)}function ii(e,t){let n=Math.min(t.style.overflowMarkerMinWidth,e.contentSafeRect.width),r=Math.min(t.style.overflowMarkerMinHeight,e.contentSafeRect.height);return{x:e.contentSafeRect.x,y:Math.max(e.contentSafeRect.y,e.contentSafeRect.y+e.contentSafeRect.height-r),width:n,height:r}}function ai(){let e=[],t={},n={},r={},i={},a=0;return{add({reason:o,importance:s,id:c}){a+=1,t[o]=(t[o]??0)+1,n[s]=(n[s]??0)+1,c&&(r[o]?.length??0)<Rr&&(r[o]=[...r[o]??[],c]),c&&(i[s]?.length??0)<Rr&&(i[s]=[...i[s]??[],c]),e.filter(e=>e.reason===o&&e.importance===s).length<Rr&&e.push({reason:o,importance:s,id:c})},records(){return e.slice()},summary(){return{total:a,byReason:t,byImportance:n,samples:r,samplesByImportance:i}}}}function oi(){return{total:0,byReason:{},byImportance:{},samples:{},samplesByImportance:{}}}function si(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y),i=Math.max(e.x+e.width,t.x+t.width),a=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:r,width:i-n,height:a-r}}function Y(e,t,n){return Math.max(0,Math.min(n,Math.floor(typeof e==`number`&&Number.isFinite(e)?e:t)))}function ci(e,t,n,r){let i=e.flow===`row`||e.flow===`column`||e.flow===`grid`||e.flow===`wrap-row`?e.flow:void 0,a=e.spanPolicy===`single`||e.spanPolicy===`multi-row`||e.spanPolicy===`remaining`?e.spanPolicy:void 0,o=e.region===`ceo`||e.region===`agent-bar`||e.region===`work`?e.region:void 0;return{id:typeof e.id==`string`&&e.id.trim().length>0?e.id:`room-${t}`,role:typeof e.role==`string`?e.role:void 0,precedence:Y(e.precedence,0,s.maxRooms),region:o,order:Y(e.order,t,s.maxRooms),flow:i,spanPolicy:a,title:String(e.title??`ROOM`),hostTitle:String(e.hostTitle??`HOST`),visualTitle:typeof e.visualTitle==`string`?e.visualTitle:void 0,visualHostTitle:typeof e.visualHostTitle==`string`?e.visualHostTitle:void 0,actions:{rename:!!e.actions?.rename,close:!!e.actions?.close,createSeat:!!e.actions?.createSeat},deskCount:Y(e.deskCount,0,s.desksPerRoom),standingCount:Y(e.standingCount,0,s.standingColumns*2),headerMinWidth:Y(e.headerMinWidth,0,n),headerMinTitleBoxWidth:Y(e.headerMinTitleBoxWidth,0,n),headerMinHeight:Y(e.headerMinHeight,s.roomHeaderHeight,r),contentMinWidth:Y(e.contentMinWidth,0,n),preferredWidth:Y(e.preferredWidth,0,n),preferredHeight:Y(e.preferredHeight,0,r),contentItems:(e.contentItems??[]).map((e,t)=>di(e,t)),contentItemCount:e.contentItems?.length??0,sourceIndex:t}}function li(e,t){let n=e=>e===`ceo`?0:e===`agent-bar`?1:e===`work`?2:3;return n(e.region)-n(t.region)||(e.precedence??0)-(t.precedence??0)||(e.order??0)-(t.order??0)||e.id.localeCompare(t.id)||e.sourceIndex-t.sourceIndex}function ui(e){return{...e,ceoContentItems:Xr(e.ceoContentItems,e.maxContentItems).selected,rooms:e.rooms.map(t=>({...t,contentItems:Xr(t.contentItems,e.maxContentItems).selected}))}}function di(e,t){let n=e.valid!==!1&&typeof e.id==`string`&&e.id.trim().length>0&&typeof e.kind==`string`&&e.kind.trim().length>0&&_i(e.importance)&&typeof e.order==`number`&&Number.isFinite(e.order)&&e.order>=0&&typeof e.minWidth==`number`&&Number.isFinite(e.minWidth)&&e.minWidth>=0&&typeof e.minHeight==`number`&&Number.isFinite(e.minHeight)&&e.minHeight>=0,r=Y(e.minWidth,0,q),i=Y(e.minHeight,0,J);return{id:typeof e.id==`string`&&e.id.trim().length>0?e.id:`item-${t}`,kind:typeof e.kind==`string`&&e.kind.trim().length>0?e.kind:`unknown`,importance:_i(e.importance)?e.importance:`optional`,order:Y(e.order,t,Hr),priority:Y(e.priority,0,Hr),minWidth:r,minHeight:i,preferredWidth:Y(e.preferredWidth,r,q),preferredHeight:Y(e.preferredHeight,i,J),valid:n}}function fi(e){if(e==null)return`null`;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>fi(e)).join(`,`)}]`;if(typeof e==`object`){let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${fi(t[e])}`).join(`,`)}}`}return`null`}function pi(e){let t=14695981039346656037n;for(let n=0;n<e.length;n+=1)t^=BigInt(e.charCodeAt(n)),t=BigInt.asUintN(64,t*1099511628211n);return`office-v1-${t.toString(16).padStart(16,`0`)}`}function mi(e,t,n){let{selected:r}=Xr(e,n),i=r.filter(e=>e.valid);if(i.length===0)return 0;let a=i.map(e=>e.minWidth);return t===`row`?a.reduce((e,t)=>e+t,0)+Math.max(0,a.length-1)*8:Math.max(...a)}function hi(e,t){return Math.max(1,Math.min(zr,typeof e==`number`&&Number.isFinite(e)?Math.floor(e):t))}function gi(e){return e===`required`?0:e===`preferred`?1:2}function _i(e){return e===`required`||e===`preferred`||e===`optional`}function vi(e,t){return yi(e,bi(e.slice(0,t)),t)}function yi(e,t,n=256){let r=[...e];if(t<=0)return``;if(r.length===0||bi(e)<=t)return e;if(bi(`…`)>t)return``;let i=Math.max(1,Math.min(r.length,n));for(;i>1&&bi(`${r.slice(0,i).join(``)}…`)>t;)--i;return bi(`${r[0]}…`)>t?`…`:`${r.slice(0,i).join(``)}…`}function bi(e){return[...e.toUpperCase()].reduce((e,t)=>{let n=t.codePointAt(0)??0;return e+(n>11904||n>=126976?13:t===` `?4:8.1)},0)}function xi({layout:e,projection:t,selectedKey:n,completionSeenKeys:r=new Set,observability:i,visibleRoomIndices:a}){return JSON.stringify({selectedKey:n,completionSeenKeys:[...r].sort(),layout:{officeWidth:e.officeWidth,totalHeight:e.totalHeight,layoutRevision:e.layoutRevision,inputDigest:e.inputDigest??null,rooms:a.map(t=>e.rooms.find(({index:e})=>e===t)??null)},hosts:t.hosts,rooms:a.map(e=>t.rooms[e]??null),receptions:t.receptions,barAgents:t.barAgents,coverage:t.coverage,observability:i?{health:i.health,observedAt:i.observedAt,windowSeconds:i.windowSeconds,models:i.models,totalCostUsd:i.totalCostUsd,totalUsage:i.totalUsage}:null})}var Si=Array.from({length:12},(e,t)=>`/world/characters/${t+1}-D-1.png`),Ci=13,wi=new WeakMap,Ti=new WeakMap,Ei=Object.freeze([{floorA:792096,floorB:659996,wall:1978448,accent:4891608},{floorA:1182752,floorB:1051166,wall:3416410,accent:10120145},{floorA:1577996,floorB:1446410,wall:4601122,accent:14062912},{floorA:793112,floorB:661012,wall:2117693,accent:5355127},{floorA:1707024,floorB:1575438,wall:5317419,accent:13917552},{floorA:1576972,floorB:1445386,wall:4730146,accent:13596996}]),Di=Object.freeze({working:{label:`WORKING`,color:6805184},idle:{label:`IDLE`,color:9280174},blocked:{label:`NEEDS INPUT`,color:15501209},done:{label:`DONE`,color:15779960},unknown:{label:`UNKNOWN`,color:12753629}}),Oi=4;async function ki(e,t,n,r,i,a,c,l,u,d,f,p,m,h,g){if(o(`renderer:create-start`,{rooms:t.rooms.length,agents:t.roster.length,desks:t.deskRoster.length}),window.__HERDR_WORLD_FORCE_RENDERER_FAILURE__)throw Error(`renderer unavailable`);let _=ya();_.mounts+=1,_.activeApplications+=1,_.activeTickers+=1,_.ready=!1;let v=new Pr,y=!1,b=t,x=n,S=r,C=i,w=h,T=g,ee=new qr,E=null,te=0,D=null,O={width:0,height:0},k=null,re=0,ie=0,j=pa(),M=[],N=e.closest(`.world-stage-scroll`),P=window.matchMedia(`(prefers-reduced-motion: reduce)`),ae=P.matches;try{await v.init({width:s.minOfficeWidth,height:640,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:Math.min(2,window.devicePixelRatio||1),roundPixels:!0,preference:`webgl`})}catch(e){throw _.activeApplications=Math.max(0,_.activeApplications-1),_.activeTickers=Math.max(0,_.activeTickers-1),e}if(y)throw v.destroy(!0,{children:!0}),Error(`renderer disposed`);o(`renderer:pixi-ready`);let F=v.canvas;e.replaceChildren(F),F.setAttribute(`aria-hidden`,`true`),F.setAttribute(`data-office-canvas`,`true`),F.style.imageRendering=`auto`,_.canvases=document.querySelectorAll(`canvas[data-office-canvas='true']`).length,_.lastError=null;let I=await Promise.all(Si.map(e=>ba(e).catch(()=>A.EMPTY)));if(o(`renderer:textures-ready`,{textures:I.filter(e=>e!==A.EMPTY).length}),y)throw v.destroy(!0,{children:!0}),xa(I),_.destroys+=1,_.activeApplications=Math.max(0,_.activeApplications-1),_.activeTickers=Math.max(0,_.activeTickers-1),Error(`renderer disposed`);let L=e=>{y||a(e)},oe=e=>{y||c(e)},se=e=>{y||l(e)},ce=e=>{let t=v.renderer.events.rootBoundary.hitTest(e.offsetX,e.offsetY);for(;t&&!t.label;)t=t.parent;if(!t?.label){f(null);return}f({key:t.label,clientX:e.clientX,clientY:e.clientY})},le=()=>f(null);v.canvas.addEventListener(`pointermove`,ce),v.canvas.addEventListener(`pointerleave`,le);let ue=e=>{let t=Ti.get(L);if(!t)return;let n=Math.hypot(e.offsetX-t.x,e.offsetY-t.y)<=12,r=window.performance.now()-t.at<=1e3;wi.delete(L),Ti.delete(L),n&&r&&t.activate(t.key)};v.canvas.addEventListener(`dblclick`,ue),_.activeListeners+=3;let de=e=>{if(y)return;let t=N?.scrollTop??0,n=Math.min(e.totalHeight,Math.max(1,N?.clientHeight??e.totalHeight)),r=(Math.max(s.minRoomHeight,...e.rooms.map(({height:e})=>e))+Math.max(s.roomGap,s.roomRowGap))*Oi,i=e.rooms.filter(e=>e.y+e.height>=t-r&&e.y<=t+n+r),a=xi({layout:e,projection:b,selectedKey:x,completionSeenKeys:S,observability:C,visibleRoomIndices:i.map(({index:e})=>e)});if(a===k){_.sceneSkips+=1;return}k=a,_.sceneRenders+=1,M.splice(0),v.stage.removeChildren().forEach(e=>e.destroy({children:!0})),Ni(v.stage,e),Pi(v.stage,e,b,C,x,I,M,L,oe),Bi(v.stage,e),i.forEach(e=>{let t=b.rooms[e.index];t&&qi(v.stage,t,e,b,x,S,I,M,L,oe,se,u,d)}),Vi(v.stage,e),_.ready||o(`renderer:scene-ready`,{rooms:e.rooms.length,officeWidth:e.officeWidth}),_.ready=!0,_.reducedMotion=ae,_.animation={characters:M.filter(({kind:e})=>e===`character`).length,monitors:M.filter(({kind:e})=>e===`monitor`).length,statuses:M.filter(({kind:e})=>e===`status`).length},_.completionMarkers=b.rooms.reduce((e,t)=>e+t.desks.reduce((e,t)=>e+t.completionAgentKeys.filter(e=>!S.has(e)).length,0),0)},R=()=>{v.stage.position.y=-(N?.scrollTop??0),E&&de(E)};N&&(N.addEventListener(`scroll`,R,{passive:!0}),_.activeListeners+=1);let fe=e=>{ie=e,v.ticker.addOnce(()=>{y||ie!==e||E?.layoutRevision!==e||ee.ackCanvasRendered(e)&&m(e)},void 0,ne.UTILITY)},pe=(t=e.clientWidth)=>{if(y)return;let n=N?.clientWidth??e.clientWidth,r=Math.floor(n||t||0),i=b.rooms.map(e=>{let t=b.hosts.find(({key:t})=>t===e.hostKey),n=e.accessibleLabel??e.displayLabel,r=t?.accessibleLabel??t?.displayLabel??`host`,i=ma(n,r,T);return{id:e.key,role:`work`,region:`work`,title:n,hostTitle:r,visualTitle:i.workspace,visualHostTitle:i.host,headerMinTitleBoxWidth:i.titleBoxWidth,headerMinWidth:i.roomWidth,deskCount:e.desks.length+(u(e.key)&&e.desks.length<s.desksPerRoom?1:0),standingCount:e.roomAgents.filter(({placement:e})=>e===`standing`).length,actions:{rename:!0,close:!0,createSeat:u(e.key)}}}),a=Wr({availableViewportWidth:r,availableViewportHeight:N?.clientHeight??0,titleMode:T,roomAlignment:w,ceoReceptionCount:b.receptions.length,fontKey:`Inter, ui-sans-serif, system-ui, sans-serif`,fontReady:j,rooms:i}),o=ee.publish({canonicalDigest:a.inputDigest},a),c=Math.min(o.totalHeight,Math.max(1,N?.clientHeight??o.totalHeight));E=o,_.publishedLayout=o,p(o),te=o.officeWidth,(O.width!==o.officeWidth||O.height!==c)&&(v.renderer.resize(o.officeWidth,c),O={width:o.officeWidth,height:c}),e.style.width=`${o.officeWidth}px`,e.style.height=`${o.totalHeight}px`,v.stage.position.y=-(N?.scrollTop??0),de(o),fe(o.layoutRevision),_.layout={officeWidth:o.officeWidth,totalHeight:o.totalHeight,rooms:o.rooms.length,characterHeight:s.characterHeight,ceoBandHeight:o.ceoBandHeight,viewportHeight:c}},z=()=>{if(_.frames+=1,re+=1,!ae)for(let e of M){let t=Math.sin(re*.075+e.phase);e.kind===`character`?e.node.y=e.baseY+t*2:e.kind===`monitor`?e.node.alpha=e.baseAlpha+(t+1)*.15:e.node.alpha=.82+(t+1)*.09}};v.ticker.add(z);let B=document.fonts,me=()=>{y||(j=pa(),k=null,pe(te||e.clientWidth))};B?.addEventListener(`loadingdone`,me),B&&(B.ready.then(me),_.activeListeners+=1);let V=e=>{if(ae=e.matches,_.reducedMotion=ae,ae)for(let e of M)e.kind===`character`?e.node.y=e.baseY:e.node.alpha=e.baseAlpha};P.addEventListener(`change`,V),_.activeListeners+=1;let he=new ResizeObserver(e=>{let t=Math.max(s.minOfficeWidth,Math.floor(e[0]?.contentRect.width||0));Math.abs(t-te)<=10||(D!==null&&window.clearTimeout(D),D=window.setTimeout(()=>{D=null,pe(t)},80))});he.observe(N??e),_.activeObservers+=1;try{pe()}catch(e){throw he.disconnect(),P.removeEventListener(`change`,V),B?.removeEventListener(`loadingdone`,me),N?.removeEventListener(`scroll`,R),v.canvas.removeEventListener(`pointermove`,ce),v.canvas.removeEventListener(`pointerleave`,le),v.canvas.removeEventListener(`dblclick`,ue),wi.delete(L),Ti.delete(L),v.ticker.remove(z),v.destroy(!0,{children:!0}),xa(I),_.activeApplications=Math.max(0,_.activeApplications-1),_.activeTickers=Math.max(0,_.activeTickers-1),_.activeObservers=Math.max(0,_.activeObservers-1),_.activeListeners=Math.max(0,_.activeListeners-(N?6:5)),e}return{update(t,n,r=S,i=C,a=w,o=T){(a!==w||o!==T)&&(w=a,T=o,k=null),b=t,x=n,S=r,C=i,pe(te||e.clientWidth)},getAnchors(e,t){return E?Ai(b,E,e,t):{agent:null,workbench:null}},destroy(){if(y)return;y=!0;let t=e.contains(F);D!==null&&window.clearTimeout(D),he.disconnect(),P.removeEventListener(`change`,V),B?.removeEventListener(`loadingdone`,me),N?.removeEventListener(`scroll`,R),v.canvas.removeEventListener(`pointermove`,ce),v.canvas.removeEventListener(`pointerleave`,le),v.canvas.removeEventListener(`dblclick`,ue),wi.delete(L),Ti.delete(L),v.ticker.remove(z),v.destroy(!0,{children:!0}),xa(I),t&&e.replaceChildren(),e.style.removeProperty(`width`),e.style.removeProperty(`height`),_.destroys+=1,_.activeApplications=Math.max(0,_.activeApplications-1),_.activeTickers=Math.max(0,_.activeTickers-1),_.activeObservers=Math.max(0,_.activeObservers-1),_.activeListeners=Math.max(0,_.activeListeners-(N?6:5)),_.canvases=document.querySelectorAll(`canvas[data-office-canvas='true']`).length,_.ready=!1,_.publishedLayout=null,p(null)}}}function Ai(e,t,n,r){let i=n?e.roster.find(({agent:e})=>e.key===n)??null:null,a=r?e.deskRoster.find(({desk:e})=>e.key===r)?.desk??null:null,o=!i&&n?e.deskRoster.find(({desk:e})=>e.key===n)?.desk??null:null,s=i?.agent.deskKey?e.deskRoster.find(({desk:e})=>e.key===i.agent.deskKey)?.desk??null:null;return{agent:i?Mi(e,t,i.agent.key):null,workbench:ji(e,t,a??s??o)}}function ji(e,t,n){if(!n)return null;let r=e.rooms.findIndex(({key:e})=>e===n.roomKey),i=e.rooms[r],a=t.rooms.find(({index:e})=>e===r);if(!i||!a)return null;let o=i.desks.findIndex(({key:e})=>e===n.key);if(o<0)return null;let s=b(a,o);return{x:s.x,y:s.deskY+10}}function Mi(e,t,n){let r=e.roster.find(({agent:e})=>e.key===n);if(!r)return null;let i=r.agent;if(i.destination===`reception`){let r=e.receptions.findIndex(e=>e.hostKey===i.hostKey),a=e.receptions[r],o=t.ceoBlocks.receptions[r];if(!a||!o)return null;let s=a.waitingAgents.findIndex(({key:e})=>e===n);if(s<0)return null;let l=c(o,s);return{x:l.x,y:l.characterFeetY-42}}if(i.destination===`bar`){let r=e.barAgents.findIndex(({key:e})=>e===n);if(r<0)return null;let i=_(t.ceoBlocks,r);return{x:i.x,y:i.characterFeetY-42}}let a=e.rooms.findIndex(({key:e})=>e===i.roomKey),o=e.rooms[a],s=t.rooms.find(({index:e})=>e===a);if(!o||!s)return null;if(i.placement===`seated`){let e=o.desks.findIndex(({occupantAgentKey:e})=>e===n);if(e>=0){let t=b(s,e);return{x:t.x,y:t.characterFeetY-42}}}let l=o.roomAgents.filter(({placement:e})=>e===`standing`).findIndex(({key:e})=>e===n);if(l>=0){let e=u(s,l);return{x:e.x,y:e.characterFeetY-42}}return null}function Ni(e,t){let n=new U;n.roundRect(0,0,t.officeWidth,t.totalHeight,6).fill(921116);for(let e=0;e<14;e+=1)n.rect(2,2+(t.totalHeight-4)*(e/14),t.officeWidth-4,t.totalHeight/14+1).fill({color:Q(1381674,592148,e/13),alpha:.9});n.roundRect(2,2,t.officeWidth-4,t.totalHeight-4,5).stroke({width:2,color:2763336,alpha:.8}),e.addChild(n)}function Pi(e,t,n,r,i,a,o,s,c){let l=new k;if(t.fallbackMessage){t.ceoOverflowMarkerRect&&Ji(l,t.ceoOverflowMarkerRect,15779960),e.addChild(l);return}let u=t.ceoBlocks,d=t.ceoRect.x+t.ceoRect.width,f=new U;da(f,4,4,d-4,t.ceoRect.height,1250088,921117),f.roundRect(4,4,d-4,t.ceoRect.height,4).stroke({width:2,color:9269557,alpha:.8}),l.addChild(f),Fi(l,d,4,Math.max(0,t.agentBarRect.x-d),t.ceoRect.height);let p=new k;p.position.x=u.ceoOriginX,p.scale.x=u.ceoScale,fa(p,u.ceoContentWidth/2-88,8,`CEO OFFICE`,7755548,176,void 0,void 0,void 0,13),Ii(p,a,u.localCeoX),Ri(p,r,u.localOtelBoardX),Li(p,n,u.localBoardX);let m=u.localReceptions;if(n.receptions.forEach((e,t)=>{let r=m[t];r&&zi(p,e,n,r,i,a,o,s,c)}),n.coverage.omittedReceptionDesks>0){let e=Z(`+${n.coverage.omittedReceptionDesks} host desks in roster`,{size:10,color:14140308,anchor:{x:1,y:0}});e.position.set(u.ceoContentWidth-18,13),p.addChild(e)}l.addChild(p),t.ceoOverflowMarkerRect&&Ji(l,t.ceoOverflowMarkerRect,15779960),ea(l,u,n,i,a,o,s,c),e.addChild(l)}function Fi(e,t,n,r,i){let a=new U;a.rect(t,n,r,i).fill(2434359),a.rect(t,n,1,i).fill({color:7104912,alpha:.35}),a.rect(t+r-1,n,1,i).fill({color:7104912,alpha:.35});for(let e=n+14;e<n+i-8;e+=18)a.rect(t+r/2,e,1,6).fill({color:7828634,alpha:.38});e.addChild(a)}function Ii(e,t,n){let r=s.ceoDeskWidth,i=n+r/2,a=Z(`YOU · CEO`,{size:11,color:16180146,anchor:.5});a.position.set(i,48),e.addChild(a),sa(e,i,136,9203253);let o=new k;o.position.set(i,148),oa(o,t[0]??A.EMPTY),e.addChild(o),ca(e,i,136,9203253);let c=new U;c.roundRect(n,130,r,44,5).fill(4798248),c.roundRect(n+4,134,r-8,36,4).fill(7361076),c.roundRect(n+50,138,60,25,3).fill(1581105),c.roundRect(n+57,144,46,13,2).fill(3501214),c.rect(n+4,168,r-8,2).fill({color:12819029,alpha:.72}),e.addChild(c)}function Li(e,t,n){let{ceoBoardY:r,ceoBoardWidth:i,ceoBoardHeight:a}=s,o=new U;o.roundRect(n+4,r+5,i,a,5).fill({color:0,alpha:.34}),o.roundRect(n,r,i,a,5).fill(5585701),o.roundRect(n+4,r+4,i-8,a-8,3).fill(1516831),o.roundRect(n+4,r+4,i-8,a-8,3).stroke({width:1,color:10188098,alpha:.78}),o.rect(n+10,r+18,i-20,1).fill({color:14215368,alpha:.2}),o.rect(n+8,r+a-10,i-16,2).fill({color:9399868,alpha:.58}),e.addChild(o);let c=Z(`WORKFORCE`,{size:12,color:14873041,anchor:.5});c.position.set(n+i/2,r+12),e.addChild(c);let l=[[`HOSTS`,t.coverage.observedHosts],[`SPACES`,t.coverage.observedWorkspaces],[`AGENTS`,t.coverage.observedAgents],[`WORKING`,t.coverage.status.working],[`INPUT`,t.coverage.status.blocked],[`STALE`,t.coverage.staleHosts]],u=(i-20)/3;l.forEach(([t,i],a)=>{let o=a%3,s=Math.floor(a/3),c=n+10+u*(o+.5),l=r+52+s*44,d=Z(String(i),{size:20,color:t===`STALE`&&typeof i==`number`&&i>0?16756922:15854013,anchor:.5});d.position.set(c,l),e.addChild(d);let f=Z(t,{size:11,color:11126948,anchor:.5});f.position.set(c,l+13),e.addChild(f)})}function Ri(e,t,n){let{ceoBoardY:r,ceoOtelBoardWidth:i,ceoBoardHeight:a}=s,o=new U;o.roundRect(n+4,r+5,i,a,5).fill({color:0,alpha:.34}),o.roundRect(n,r,i,a,5).fill(5585701),o.roundRect(n+4,r+4,i-8,a-8,3).fill(1516831),o.roundRect(n+4,r+4,i-8,a-8,3).stroke({width:1,color:10188098,alpha:.78}),o.rect(n+10,r+34,i-20,1).fill({color:14215368,alpha:.2}),o.rect(n+8,r+a-10,i-16,2).fill({color:9399868,alpha:.58}),e.addChild(o);let c=Z(`ECONOMY`,{size:12,color:14873041,anchor:.5});c.position.set(n+i/2,r+12),e.addChild(c);let l=Z(`MODEL`,{size:11,color:11126948,anchor:{x:0,y:.5},weight:`700`});l.position.set(n+12,r+26),e.addChild(l);let u=n+100,d=new U;d.circle(u-4,r+25,5).fill({color:13940332,alpha:.62}),d.circle(u+3,r+24,5).fill({color:13940332,alpha:.82}),d.circle(u,r+28,5).fill(15854013),d.circle(u,r+28,2).fill({color:9071421,alpha:.8}),e.addChild(d);let f=Z(`$$$`,{size:12,color:11126948,anchor:{x:1,y:.5},weight:`700`});if(f.position.set(n+i-12,r+26),e.addChild(f),t.health!==`available`||t.models.length===0){let a=Z(t.health===`degraded`?`DEGRADED`:`NO DATA`,{size:14,color:t.health===`degraded`?16756922:14140308,anchor:.5});a.position.set(n+i/2,r+78),e.addChild(a);return}t.models.slice(0,4).forEach((t,a)=>{let o=r+48+a*22,s=Z(g(t.model),{size:11,color:15789285,anchor:{x:0,y:.5}});s.position.set(n+12,o),e.addChild(s);let c=Z(y(p(t.usage)),{size:12,color:15854013,anchor:.5});c.position.set(u,o),e.addChild(c);let l=Z(x(t.costUsd,t.costKind),{size:12,color:15854013,anchor:{x:1,y:.5}});l.position.set(n+i-12,o),e.addChild(l)}),o.rect(n+10,r+a-31,i-20,1).fill({color:14215368,alpha:.2});let m=Z(`TOTAL`,{size:11,color:11126948,anchor:{x:0,y:.5},weight:`700`});m.position.set(n+12,r+a-20),e.addChild(m);let h=Z(y(t.totalUsage),{size:12,color:15854013,anchor:.5,weight:`700`});h.position.set(u,r+a-20),e.addChild(h);let _=t.models.some(({costKind:e})=>e!==null&&e!==`reported`)?`estimated`:null,v=Z(x(t.totalCostUsd,_),{size:12,color:15854013,anchor:{x:1,y:.5},weight:`700`});v.position.set(n+i-12,r+a-20),e.addChild(v)}function zi(e,t,n,r,i,a,o,l,u){let d=n.hosts.find(({key:e})=>e===t.hostKey);if(!d)return;let f=va(d),p=r.x+r.width/2,h=new U;if(h.rect(r.x,r.y,r.width,r.height).fill({color:i===d.key?f:0,alpha:i===d.key?.08:.001}),X(h,d.key,l),e.addChild(h),r.index>0){let t=new U;t.rect(r.x-r.gapBefore/2,r.y+8,1,r.height-20).fill({color:7828634,alpha:.22}),e.addChild(t)}let g=t.waitingAgents,_=m(r),v=Array.from({length:4},(t,n)=>{let i=c(r,n),a=i.characterFeetY-s.characterHeight*.18;return sa(e,i.x,a,f),{anchor:i,chairY:a}});Array.from({length:4},(e,t)=>_.x+_.width*((t+.5)/4)).forEach(t=>{let n=_.y+_.height+10;sa(e,t,n,f),ca(e,t,n,f)}),g.forEach((t,n)=>{let{anchor:r,chairY:s}=v[n],c=Z(_a(t.displayLabel,12),{size:8,color:15920625,anchor:.5});c.position.set(r.x,r.nameY),X(c,t.key,l,u),e.addChild(c);let d=aa(e,a[t.characterIndex]??A.EMPTY,r.x,r.characterFeetY,!1,t.stale,o,t.key,l,i,u);d.alpha=t.stale?.56:1,ca(e,r.x,s,f)}),v.slice(g.length).forEach(({anchor:t,chairY:n})=>{ca(e,t.x,n,f)});let y=new U;y.ellipse(_.x+_.width/2,_.y+_.height+3,Math.max(1,_.width*.38),5).fill({color:0,alpha:.24}),y.roundRect(_.x,_.y,_.width,_.height,16).fill(4863270),y.roundRect(_.x+4,_.y+4,_.width-8,_.height-8,13).fill(7754807),y.roundRect(_.x+_.width*.32,_.y+8,_.width*.36,7,3).fill(2960178),y.roundRect(_.x+6,_.y+6,_.width-12,_.height-12,11).stroke({width:1,color:f,alpha:.68}),X(y,d.key,l),e.addChild(y);let b=Z(_a(d.displayLabel,20),{size:10,color:16049856,anchor:.5});if(b.position.set(p,_.y+_.height/2),e.addChild(b),t.overflowCount>0){let n=Z(`+${t.overflowCount} waiting in roster`,{size:8,color:15779960,anchor:.5});n.position.set(p,_.y+_.height-7),e.addChild(n)}}function Bi(e,t){let n=new U,r=t.ceoBandHeight;n.rect(4,r,t.officeWidth-8,s.hallwayHeight).fill(2434359),n.rect(4,r,t.officeWidth-8,1).fill({color:7104912,alpha:.35});for(let e=20;e<t.officeWidth-20;e+=18)n.rect(e,r+16,7,1).fill({color:7828634,alpha:.38});e.addChild(n)}function Vi(e,t){let n=new U,r=new Map;t.rooms.forEach(e=>{let t=r.get(e.row)??[];t.push(e),r.set(e.row,t)});let i=[...r.values()].map(e=>e.sort((e,t)=>e.x-t.x)).sort((e,t)=>e[0].y-t[0].y);i.forEach(e=>{e.slice(0,-1).forEach((t,r)=>{let i=e[r+1],a=i.x-(t.x+t.width);a>0&&Fi(n,t.x+t.width,t.y,a,Math.min(t.height,i.height))})}),i.slice(0,-1).forEach((e,r)=>{let a=i[r+1],o=Math.max(...e.map(({y:e,height:t})=>e+t)),s=Math.min(...a.map(({y:e})=>e));s>o&&Hi(n,4,o,t.officeWidth-8,s-o)}),e.addChild(n)}function Hi(e,t,n,r,i){if(!(r<=0||i<=0)){e.rect(t,n,r,i).fill(2434359),e.rect(t,n,r,1).fill({color:7104912,alpha:.35}),e.rect(t,n+i-1,r,1).fill({color:7104912,alpha:.35});for(let a=t+14;a<t+r-8;a+=18)e.rect(a,n+i/2,7,1).fill({color:7828634,alpha:.38})}}function Ui(e){let t=new Set(e.roomAgents.filter(({semanticStatus:e})=>e!==`idle`).map(({key:e})=>e));return e.roomAgents.some(({semanticStatus:e})=>e!==`idle`)||e.desks.some(({occupantAgentKey:e})=>!!(e&&t.has(e)))}function Wi(e,t,n,r,i,a,o,c){let l=s.roomHeaderActionWidth,u=Math.max(0,r.headerRect.width-2*(l+s.roomHeaderActionGap+l+s.roomHeaderCloseGap)),d=Math.max(0,(r.headerRect.width-u)/2),f=r.header??{workspace:_a(t.displayLabel,18),host:_a(n.displayLabel,16),width:r.headerRect.width,titleBoxX:d,titleBoxWidth:u,renameX:d+u+s.roomHeaderActionGap,closeX:Math.max(0,r.headerRect.width-l),renameWidth:l,closeWidth:l,actionWidth:l,actionGap:s.roomHeaderActionGap,closeGap:s.roomHeaderCloseGap,height:r.headerRect.height,emergencyEllipsis:!1},p=r.headerRect.x+f.titleBoxX,m=r.headerRect.y,h=Z(f.workspace.toUpperCase(),{size:Ci,color:16777215,anchor:{x:0,y:.5}}),g=Z(f.host.toUpperCase(),{size:Ci,color:16111762,anchor:{x:0,y:.5}}),_=Z(`-`,{size:Ci,color:15787718,anchor:.5}),v=Z(`-`,{size:Ci,color:15787718,anchor:.5}),y=Math.min(Math.max(0,r.headerRect.width-f.titleBoxX),Math.max(0,f.titleBoxWidth)),b=new U;b.roundRect(p,m,y,Math.min(22,r.headerRect.height),4).fill(a===t.key?i:Q(i,1185058,.5)),b.roundRect(p,m,y,Math.min(22,r.headerRect.height),4).stroke({width:a===t.key?2:1,color:Q(i,16777215,.35),alpha:.84}),X(b,t.key,o,c),e.addChild(b);let x=p+10;Gi(e,x,m+3,16180146,t.key,o,c),x+=16,_.position.set(x+_.width/2,m+11),X(_,t.key,o,c),e.addChild(_),x+=_.width,h.position.set(x,m+11),X(h,t.key,o,c),e.addChild(h),x+=h.width+12,Ki(e,x,m+4,15003903,t.key,o,c),x+=20,v.position.set(x+v.width/2,m+11),X(v,t.key,o,c),e.addChild(v),x+=v.width,g.position.set(x,m+11),X(g,t.key,o,c),e.addChild(g)}function Gi(e,t,n,r,i,a,o){let s=new U;s.roundRect(t+2,n,12,16,2).fill({color:r,alpha:.94}),s.rect(t+4,n+4,7,1).fill(6311477),s.rect(t+4,n+7,7,1).fill(6311477),s.rect(t+4,n+10,5,1).fill(6311477),s.rect(t,n+3,2,10).fill(Q(r,790554,.35)),X(s,i,a,o),e.addChild(s)}function Ki(e,t,n,r,i,a,o){let s=new U;s.roundRect(t,n,17,11,2).fill({color:r,alpha:.94}),s.roundRect(t+3,n+3,11,5,1).fill(3426910),s.rect(t+7,n+11,3,3).fill(r),s.rect(t+4,n+14,9,1).fill(r),X(s,i,a,o),e.addChild(s)}function qi(e,t,n,r,i,a,o,c,l,u,d,f,p){let m=r.hosts.find(({key:e})=>e===t.hostKey);if(!m)return;let h=Ei[m.deterministicSkin.themeIndex%Ei.length],g=Ui(t),_=t.desks.some(e=>e.completionAgentKeys.some(e=>!a.has(e))),v=t.desks.some(e=>e.completionAgentKeys.includes(i??``)),y=i===t.key||v,b=new k,x=new U,S=g?Q(h.floorA,6115640,.34):h.floorA,C=g?Q(h.floorB,4471338,.32):h.floorB;da(x,n.wallRect.x,n.wallRect.y,n.wallRect.width,n.wallRect.height,S,C),x.rect(n.wallRect.x,n.wallRect.y,n.wallRect.width,Math.min(34,n.wallRect.height)).fill({color:h.wall,alpha:.76}),x.roundRect(n.x+3,n.y+3,Math.max(0,n.width-6),Math.max(0,n.height-6),4).stroke({width:y||_?2:1,color:y?16777215:_?15779960:h.accent,alpha:y||_?.92:.78}),X(x,t.key,l,d),b.addChild(x),Wi(b,t,m,n,h.accent,i,l,d),n.overflowMarkerRect&&Ji(b,n.overflowMarkerRect,h.accent),ua(b,n.x+14,n.y+n.height-18,h.accent),ua(b,n.x+n.width-16,n.y+n.height-18,h.accent);let w=new Map(t.roomAgents.map(e=>[e.key,e]));t.desks.forEach((e,t)=>{Zi(b,e,e.occupantAgentKey?w.get(e.occupantAgentKey):void 0,n,t,h.accent,i,a,o,c,l,u)}),t.roomAgents.filter(({placement:e})=>e===`standing`).forEach((e,t)=>{$i(b,e,n,t,i,o,c,l,u)}),f(t.key)&&(t.desks.length<s.desksPerRoom?Yi(b,t,n,t.desks.length,h.accent,p):Xi(b,n,h.accent));let T=[];if(t.omittedDeskCount>0&&T.push(`+${t.omittedDeskCount} desks`),t.omittedAgentCount>0&&T.push(`+${t.omittedAgentCount} agents`),T.length>0){let e=Z(`${T.join(` · `)} in roster`,{size:9,color:14147306,anchor:{x:1,y:0}});e.position.set(n.x+n.width-18,n.y+n.height-18),b.addChild(e)}if(t.stale){b.alpha=.68;let e=new U;e.rect(n.x,n.y,n.width,n.height).fill({color:8070965,alpha:.08}),b.addChild(e)}e.addChild(b)}function Ji(e,t,n){if(t.width<=0||t.height<=0)return;let r=new U;r.roundRect(t.x,t.y,t.width,t.height,3).fill({color:1777707,alpha:.96}).stroke({width:1,color:n,alpha:.86}),e.addChild(r);let i=Z(`MORE`,{size:7,color:15779960,anchor:.5});i.position.set(t.x+t.width/2,t.y+t.height/2),e.addChild(i)}function Yi(e,t,n,r,i,a){let o=b(n,r),s=new k;s.label=t.key,s.eventMode=`static`,s.cursor=`pointer`,s.on(`pointertap`,e=>{e.stopPropagation(),a(t.key)});let c=new U;c.label=t.key,c.eventMode=`static`,c.roundRect(o.x-25,o.deskY,50,27,5).fill({color:i,alpha:.1}).stroke({width:1,color:i,alpha:.8}),s.addChild(c);let l=Z(`+`,{size:19,color:16049856,anchor:.5,weight:`700`});l.eventMode=`none`,l.position.set(o.x,o.deskY+13),s.addChild(l);let u=Z(`NEW SEAT`,{size:7,color:11126948,anchor:.5});u.eventMode=`none`,u.position.set(o.x,o.nameY+7),s.addChild(u),e.addChild(s)}function Xi(e,t,n){let r=t.x+t.width/2,i=t.y+t.height-40,a=new U;a.roundRect(r-25,i,50,27,5).fill({color:n,alpha:.04}).stroke({width:1,color:n,alpha:.38}),e.addChild(a);let o=Z(`+`,{size:19,color:10261631,anchor:.5});o.alpha=.62,o.position.set(r,i+13),e.addChild(o);let s=Z(`ROOM FULL`,{size:7,color:9344394,anchor:.5});s.position.set(r,i+35),e.addChild(s)}function Zi(e,t,n,r,i,a,o,c,l,u,d,f){let p=b(r,i),m=o===t.key||o===n?.key||t.completionAgentKeys.includes(o??``),h=Z(_a(t.displayLabel,18),{size:9,color:m?16777215:14477043,anchor:.5}),g=Math.max(58,Math.min(p.stationSpan-6,h.width+14)),_=new U;_.roundRect(p.x-g/2,p.nameY,g,16,4).fill({color:m?a:1845046,alpha:.96}),_.roundRect(p.x-g/2,p.nameY,g,16,4).stroke({width:m?2:1,color:a,alpha:.82}),X(_,t.key,d),e.addChild(_),h.position.set(p.x,p.nameY+8),X(h,t.key,d),e.addChild(h);let v=p.characterFeetY-s.characterHeight*.18;if(sa(e,p.x,v,a),n){let t=n.stale?{label:`STALE`,color:7964314}:Di[n.semanticStatus],r=Z(`${_a(n.displayLabel,14)} · ${t.label}`,{size:9,color:1120034,anchor:.5}),i=Math.max(54,Math.min(p.stationSpan-4,r.width+10)),s=new U;s.roundRect(p.x-i/2,p.nameY+18,i,15,3).fill({color:t.color,alpha:.96}),X(s,n.key,d,f),e.addChild(s),r.position.set(p.x,p.nameY+25.5),X(r,n.key,d,f),e.addChild(r),n.semanticStatus===`working`&&!n.stale&&u.push({kind:`status`,node:s,baseAlpha:1,phase:u.length*7});let c=aa(e,l[n.characterIndex]??A.EMPTY,p.x,p.characterFeetY,n.semanticStatus===`working`,n.stale,u,n.key,d,m?n.key:o,f);c.alpha=n.stale?.56:1,ca(e,p.x,v,a)}else{ca(e,p.x,v,a);let t=Z(`EMPTY`,{size:8,color:8359329,anchor:.5});t.position.set(p.x,p.nameY+25),e.addChild(t)}X(la(e,p.x-s.deskWidth/2,p.deskY,a,n?.semanticStatus===`working`&&!n.stale,u,m),t.key,d),t.completionAgentKeys.some(e=>!c.has(e))&&Qi(e,t,p,c,d,f)}function Qi(e,t,n,r,i,a){let o=t.completionAgentKeys.filter(e=>!r.has(e)),s=o[0];if(!s)return;let c=o.length,l=new k;l.position.set(n.x+17,n.deskY-16),l.alpha=c>0?1:.48;let u=new U;if(u.roundRect(-10,-7,18,13,2).fill(15918013),u.roundRect(-7,-10,18,13,2).fill(16774352),u.rect(-3,-6,9,1).fill(11701592),u.rect(-3,-3,7,1).fill(11701592),u.rect(-3,0,9,1).fill(11701592),u.poly([4,3,8,0,8,4]).fill(7846025),u.moveTo(4,2).lineTo(5.5,3.5).lineTo(8,.5).stroke({width:1.6,color:3108939,alpha:1}),l.addChild(u),c>1){let e=Z(`+${c-1}`,{size:7,color:2432018,anchor:.5}),t=new U;t.circle(11,-9,7).fill(15779960),l.addChild(t),e.position.set(11,-9),l.addChild(e)}X(l,s,i,a),e.addChild(l)}function $i(e,t,n,r,i,a,o,s,c){let l=u(n,r),d=t.stale?{label:`STALE`,color:7964314}:Di[t.semanticStatus],f=Z(_a(t.displayLabel,13),{size:9,color:15922424,anchor:.5});f.position.set(l.x,l.nameY+6),X(f,t.key,s,c),e.addChild(f);let p=Z(d.label,{size:7,color:d.color,anchor:.5});p.position.set(l.x,l.nameY+18),X(p,t.key,s,c),e.addChild(p);let m=aa(e,a[t.characterIndex]??A.EMPTY,l.x,l.characterFeetY,t.semanticStatus===`working`,t.stale,o,t.key,s,i,c);m.alpha=t.stale?.56:1}function ea(e,t,n,r,i,a,o,c){let l=t.agentBarX,u=t.agentBarWidth,d=t.agentBarHeight,f=new k,p=new U;da(p,l,4,u,d,1512463,1118221),p.roundRect(l,4,u,d,4).stroke({width:2,color:11898952,alpha:.72}),f.addChild(p),fa(f,l+u/2-58,12,`AGENT BAR`,10583351,116,void 0,void 0,void 0,10);let m=l+10,h=Math.min(76,u*.25),g=d-86,v=_(t,0),y=m+h+10,b=Math.max(0,l+u-10-y),x=4+d-s.agentBarCounterBottomClearance,S=v.capacity,C=n.barAgents.slice(0,S);ta(f,m,46,h,g,C.length),C.forEach((e,n)=>{let s=_(t,n),l=s.x,u=s.rowY,d=e.stale?{label:`STALE`,color:7964314}:Di[e.semanticStatus],p=Z(_a(e.displayLabel,10),{size:8,color:15789285,anchor:.5});p.position.set(l,u+1),X(p,e.key,o,c),f.addChild(p);let m=Z(d.label,{size:6,color:d.color,anchor:.5});m.position.set(l,u+12),X(m,e.key,o,c),f.addChild(m);let h=s.characterFeetY,g=aa(f,i[e.characterIndex]??A.EMPTY,l,h,!1,e.stale,a,e.key,o,r,c);g.alpha=e.stale?.56:1}),ia(f,y,x,b,C.map((e,n)=>_(t,n).x)),ra(f,y,4+d,b);let w=n.coverage.omittedBarAgents+Math.max(0,n.barAgents.length-S);if(w>0){let e=Z(`+${w} more`,{size:8,color:15060888,anchor:{x:1,y:0}});e.position.set(l+u-10,16),f.addChild(e)}e.addChild(f)}function ta(e,t,n,r,i,a){let o=new U;o.roundRect(t+3,n+4,r,i,4).fill({color:0,alpha:.28}),o.roundRect(t,n,r,i,4).fill(5585701),o.roundRect(t+4,n+4,r-8,i-8,2).fill(1516831),o.roundRect(t+4,n+4,r-8,i-8,2).stroke({width:1,color:10188098,alpha:.72}),e.addChild(o);let s=Z(`PARTY`,{size:11,color:15914895,anchor:.5});s.position.set(t+r/2,n+17),e.addChild(s);let c=Z(String(a),{size:26,color:15854013,anchor:.5});c.position.set(t+r/2,n+i/2-4),e.addChild(c),na(e,t,n,r,i)}function na(e,t,n,r,i){let a=new U;[[10,25,14850918],[r-14,23,9419224],[16,58,10473132],[r-20,68,14460103],[10,i-32,15974526],[r-14,i-30,14850918]].forEach(([e,r,i],o)=>{o%2==0?a.rect(t+e,n+r,3,7).fill(i):a.circle(t+e,n+r,2.5).fill(i)});let o=t+r/2-4,s=n+i-30;a.roundRect(o-6,s,12,9,3).stroke({width:1.5,color:15847834,alpha:.9}),a.rect(o-1,s+9,2,9).fill(15847834),a.rect(o-7,s+18,14,2).fill(15847834),e.addChild(a)}function ra(e,t,n,r){let i=new U,a=n-30,o=a+18,s=Math.max(0,r-16);i.rect(t+8,o,s,3).fill({color:5979179,alpha:.72}),i.rect(t+8,o+3,s,1).fill({color:13674616,alpha:.36}),e.addChild(i);let c=new U,l=Math.max(3,Math.min(12,Math.floor(r/42)));for(let e=0;e<l;e+=1){let n=t+14+(s-12)*e/Math.max(1,l-1),r=a,i=[13856343,8042948,14066254,12092630][e%4];c.roundRect(n-4,r,8,13,2).fill({color:i,alpha:.86}).stroke({width:1,color:15847834,alpha:.78}),c.rect(n-2,r-4,4,4).fill(15847834)}e.addChild(c)}function ia(e,t,n,r,i){let a=new U;a.roundRect(t+3,n+6,r,34,8).fill({color:0,alpha:.28}),a.roundRect(t,n,r,32,7).fill(4993314),a.roundRect(t+4,n+4,r-8,9,4).fill(9132853),a.rect(t+8,n+7,r-16,2).fill({color:13674616,alpha:.54}),a.roundRect(t+8,n+16,r-16,12,4).fill(3679005);for(let e=t+24;e<t+r-18;e+=52)a.rect(e,n+19,1,7).fill({color:11565381,alpha:.4});for(let e=t+24;e<t+r-20;e+=74)a.circle(e,n+10,3).fill(13674616),a.rect(e-1,n+9,2,7).fill(5979179);e.addChild(a);let o=new U;i.forEach((e,t)=>{let r=n-9,i=[13856343,8042948,14066254,12092630][t%4];o.roundRect(e-5,r,10,8,2).fill({color:i,alpha:.9}).stroke({width:1,color:15847834,alpha:.9}),o.rect(e-1,r+8,2,7).fill(15847834),o.rect(e-6,r+15,12,2).fill(15847834)}),e.addChild(o)}function aa(e,t,n,r,i,a,o,c,l,u,d){let f=new k;f.position.set(n,r),f.hitArea=new ue(-30,-s.characterHeight-8,60,s.characterHeight+18),oa(f,t);let p=new U;if(p.rect(-30,-s.characterHeight-8,60,s.characterHeight+18).fill({color:16777215,alpha:1e-4}),X(p,c,l,d),f.addChild(p),u===c){let e=new U;e.ellipse(0,-2,25,8).stroke({width:2,color:16777215,alpha:.9}),f.addChildAt(e,0)}return X(f,c,l,d),i&&!a&&o.push({kind:`character`,node:f,baseY:r,phase:o.length*7}),e.addChild(f),f}function oa(e,t){if(t!==A.EMPTY){let n=new j(t);n.anchor.set(.5,1),n.scale.set(s.characterHeight/Math.max(1,t.height)),n.roundPixels=!0,e.addChild(n)}else{let t=Z(`◆`,{size:22,color:11845374,anchor:.5});t.position.y=-22,e.addChild(t)}}function sa(e,t,n,r){let i=new U,a=Q(r,724246,.3),o=Q(r,2106426,.38);i.ellipse(t,n+13,28,7).fill({color:0,alpha:.24}),i.rect(t-2,n+1,4,11).fill(a),i.rect(t-13,n+10,26,3).fill(a),i.circle(t-13,n+13,3).fill(a),i.circle(t+13,n+13,3).fill(a),i.ellipse(t,n,27,11).fill(o),i.roundRect(t-20,n-31,40,22,7).fill(a),i.roundRect(t-16,n-28,32,15,5).fill(o),i.roundRect(t-13,n-25,26,3,2).fill({color:r,alpha:.48}),e.addChild(i)}function ca(e,t,n,r){let i=new U,a=Q(r,921632,.18);i.roundRect(t-20,n-14,6,17,3).fill(a),i.roundRect(t+14,n-14,6,17,3).fill(a),e.addChild(i)}function la(e,t,n,r,i,a,o=!1){let s=new U;if(s.ellipse(t+24,n+30,30,6).fill({color:0,alpha:.22}),s.roundRect(t,n,48,26,3).fill(7756600),s.roundRect(t+2,n+2,44,22,2).fill(11438941),s.roundRect(t+14,n+10,21,13,2).fill(Q(r,1054498,.7)),s.roundRect(t+16,n+12,17,8,1).fill(i?3440006:1515825),s.rect(t+1,n+24,46,2).fill({color:r,alpha:.78}),o&&s.roundRect(t-3,n-3,54,32,5).stroke({width:2,color:16777215,alpha:.92}),e.addChild(s),i){let r=new U;r.roundRect(t+16,n+12,17,8,1).fill({color:13238260,alpha:.18}),r.eventMode=`none`,e.addChild(r),a.push({kind:`monitor`,node:r,baseAlpha:.18,phase:a.length*7})}return s}function ua(e,t,n,r){let i=new U;i.roundRect(t-6,n,12,8,2).fill(10902598),i.circle(t,n-4,7).fill(Q(r,5215599,.7)),i.circle(t-5,n-7,4).fill(6003832),i.circle(t+5,n-7,4).fill(6924933),e.addChild(i)}function da(e,t,n,r,i,a,o){for(let c=0;c<i;c+=s.tile)for(let i=0;i<r;i+=s.tile)e.rect(t+i,n+c,s.tile,s.tile).fill((i+c)/s.tile%2==0?a:o)}function fa(e,t,n,r,i,a,o,s,c,l=10){let u=new U;u.roundRect(t,n,a,19,4).fill(i),u.roundRect(t,n,a,19,4).stroke({width:1,color:Q(i,16777215,.32),alpha:.72}),o&&s&&X(u,o,s,c),e.addChild(u);let d=Z(r,{size:l,color:16777215,anchor:.5});d.position.set(t+a/2,n+9.5),o&&s&&X(d,o,s,c),e.addChild(d)}function X(e,t,n,r){e.label=t,e.eventMode=`static`,e.cursor=`pointer`,e.on(`pointertap`,e=>{if(e.stopPropagation(),o(`renderer:pointertap`,{key:t,detail:e.detail,hasActivation:!!r}),e.detail===0){wi.delete(n),Ti.delete(n),n(t);return}let i=window.performance.now(),a=wi.get(n),s=a?.key===t&&(e.detail===2||i-a.at<=500);if(n(t),s){wi.delete(n),Ti.delete(n),r?.(t);return}wi.set(n,{key:t,at:i,x:e.global.x,y:e.global.y,activate:r});let c=Ti.get(n);r&&(!c||i-c.at>1e3)&&Ti.set(n,{key:t,at:i,x:e.global.x,y:e.global.y,activate:r})})}function Z(e,t={}){let n=new Lr({text:e,resolution:4,style:new Ee({fontSize:t.size??9,fill:t.color??16777215,fontWeight:t.weight??`600`,fontFamily:`Inter, ui-sans-serif, system-ui, sans-serif`,dropShadow:{alpha:.24,distance:1,color:0}})});return typeof t.anchor==`number`?n.anchor.set(t.anchor):t.anchor&&n.anchor.set(t.anchor.x,t.anchor.y),n}function pa(){let e=document.fonts;return!e||e.status===`loaded`&&e.check(`600 ${Ci}px Inter`)}function ma(e,t,n){let r=Kr(e,t,n),i=ha(`-`),a=26+i+12+20+i+10,o=Math.max(0,s.maxExpandedRoomWidth-2*s.roomHeaderSafeInset-2*(s.roomHeaderActionWidth+s.roomHeaderActionGap+s.roomHeaderActionWidth+s.roomHeaderCloseGap)),c=r.workspace,l=r.host;if(a+ha(c)+ha(l)>o){let e=Math.max(0,o-a),t=Math.floor(e*.52);c=ga(c,t),l=ga(l,Math.max(0,e-t))}let u=Math.ceil(a+ha(c)+ha(l));return{titleBoxWidth:u,roomWidth:ri(u),workspace:c,host:l}}function ha(e){let t=new Lr({text:e.toUpperCase(),resolution:4,style:new Ee({fontSize:Ci,fill:16777215,fontWeight:`600`,fontFamily:`Inter, ui-sans-serif, system-ui, sans-serif`,dropShadow:{alpha:.24,distance:1,color:0}})}),n=t.width;return t.destroy(),n}function ga(e,t){if(t<=0)return``;if(ha(e)<=t)return e;if(ha(`…`)>t)return``;let n=[...e],r=n.length;for(;r>0&&ha(`${n.slice(0,r).join(``)}…`)>t;)--r;return r>0?`${n.slice(0,r).join(``)}…`:`…`}function _a(e,t){let n=[...e];return n.length<=t?e:`${n.slice(0,Math.max(1,t-1)).join(``)}…`}function va(e){return Ei[e.deterministicSkin.themeIndex%Ei.length].accent}function Q(e,t,n){let r=Math.max(0,Math.min(1,n)),i=e>>16&255,a=e>>8&255,o=e&255,s=t>>16&255,c=t>>8&255,l=t&255;return Math.round(i+(s-i)*r)<<16|Math.round(a+(c-a)*r)<<8|Math.round(o+(l-o)*r)}function ya(){return window.__HERDR_WORLD_RENDERER__||(window.__HERDR_WORLD_RENDERER__={mounts:0,destroys:0,activeApplications:0,activeTickers:0,activeObservers:0,activeListeners:0,canvases:0,frames:0,sceneRenders:0,sceneSkips:0,ready:!1,reducedMotion:!1,lastError:null,animation:{characters:0,monitors:0,statuses:0},layout:null,publishedLayout:null,completionMarkers:0}),window.__HERDR_WORLD_RENDERER__}async function ba(e){let t=new Image;if(t.decoding=`async`,t.src=e,typeof t.decode==`function`?await t.decode():await new Promise((e,n)=>{t.addEventListener(`load`,()=>e(),{once:!0}),t.addEventListener(`error`,()=>n(Error(`character asset unavailable`)),{once:!0})}),typeof globalThis.createImageBitmap==`function`)return A.from(await globalThis.createImageBitmap(t));let n=document.createElement(`canvas`);n.width=t.naturalWidth||t.width,n.height=t.naturalHeight||t.height;let r=n.getContext(`2d`);if(!r)throw Error(`character asset canvas unavailable`);return r.drawImage(t,0,0),new A({source:new ie({resource:n})})}function xa(e){for(let t of e)t!==A.EMPTY&&t.destroy(!0)}var $=C();function Sa({projection:e,selectedKey:t,completionSeenKeys:n,observability:r,conversationTargets:i,onSelect:a,onActivateAgent:s,onActivateRoom:c,canCreateSeat:l,onNewSeat:u,onHover:d,onAnchorChange:f,onSelectedAnchorChange:p,onLayoutChange:m,onCanvasRendered:h,roomAlignment:g,longRoomTitleMode:_,children:v}){let y=(0,W.useRef)(null),b=(0,W.useRef)(null),x=(0,W.useRef)({projection:e,selectedKey:t,completionSeenKeys:n,observability:r,conversationTargets:i,onSelect:a,onActivateAgent:s,onActivateRoom:c,canCreateSeat:l,onNewSeat:u,onHover:d,onAnchorChange:f,onSelectedAnchorChange:p,onLayoutChange:m,onCanvasRendered:h,roomAlignment:g,longRoomTitleMode:_}),[S,C]=(0,W.useState)(!1);x.current={projection:e,selectedKey:t,completionSeenKeys:n,observability:r,conversationTargets:i,onSelect:a,onActivateAgent:s,onActivateRoom:c,canCreateSeat:l,onNewSeat:u,onHover:d,onAnchorChange:f,onSelectedAnchorChange:p,onLayoutChange:m,onCanvasRendered:h,roomAlignment:g,longRoomTitleMode:_};let w=()=>{let e=x.current.onAnchorChange,t=x.current.onSelectedAnchorChange;if(!e&&!t)return;let n=b.current,r=y.current,i=r?.closest(`.world-stage-scroll`),a=r?.querySelector(`canvas[data-office-canvas='true']`);if(!i||!a||!n){e?.(null),t?.(null);return}let o=a.getBoundingClientRect(),s=i.getBoundingClientRect(),c=e=>{if(!e)return null;let t=o.left+e.x,n=o.top+e.y-i.scrollTop,r=t>=s.left&&t<=s.right&&n>=s.top&&n<=s.bottom,a=t<s.left?s.left-t:t>s.right?t-s.right:0,c=n<s.top?s.top-n:n>s.bottom?n-s.bottom:0,l=r?null:a>c?t<s.left?`left`:`right`:n<s.top?`top`:`bottom`;return{x:l===`left`?s.left+10:l===`right`?s.right-10:t,y:l===`top`?s.top+10:l===`bottom`?s.bottom-10:n,visible:r,edge:l}},l={};for(let e of x.current.conversationTargets){let t=n.getAnchors(e.selectedKey,e.targetKey);t&&(l[e.id]={agent:c(t.agent),workbench:c(t.workbench)})}e?.(l);let u=n.getAnchors(x.current.selectedKey,null);t?.(c(u.agent??u.workbench))},T=(0,W.useRef)(w);return T.current=w,(0,W.useEffect)(()=>{let e=y.current;if(!e)return;let t=!1;return o(`renderer:mount-request`,{rooms:x.current.projection.rooms.length,agents:x.current.projection.roster.length,desks:x.current.projection.deskRoster.length}),ki(e,x.current.projection,x.current.selectedKey,x.current.completionSeenKeys,x.current.observability,e=>x.current.onSelect(e),e=>x.current.onActivateAgent(e),e=>x.current.onActivateRoom(e),e=>x.current.canCreateSeat(e),e=>x.current.onNewSeat(e),e=>x.current.onHover?.(e),e=>x.current.onLayoutChange?.(e),e=>x.current.onCanvasRendered?.(e),x.current.roomAlignment,x.current.longRoomTitleMode).then(e=>{if(t){e.destroy();return}b.current=e,o(`renderer:ready`,{rooms:x.current.projection.rooms.length,agents:x.current.projection.roster.length,desks:x.current.projection.deskRoster.length});let n=x.current;e.update(n.projection,n.selectedKey,n.completionSeenKeys,n.observability,n.roomAlignment,n.longRoomTitleMode),window.requestAnimationFrame(()=>T.current())}).catch(e=>{t||(o(`renderer:error`,{error:e instanceof Error?e.message:String(e)}),window.__HERDR_WORLD_RENDERER__&&(window.__HERDR_WORLD_RENDERER__.lastError=e instanceof Error?e.message.slice(0,160):`renderer initialization failed`),C(!0))}),()=>{t=!0,o(`renderer:destroy`),b.current?.destroy(),b.current=null}},[]),(0,W.useEffect)(()=>{b.current?.update(e,t,n,r,g,_),window.requestAnimationFrame(()=>T.current())},[n,i,_,r,e,g,t]),(0,W.useEffect)(()=>{let e=y.current?.closest(`.world-stage-scroll`);if(!e)return;let t=()=>window.requestAnimationFrame(()=>T.current());return e.addEventListener(`scroll`,t,{passive:!0}),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t),window.removeEventListener(`resize`,t)}},[]),(0,$.jsxs)(`div`,{className:`world-canvas-shell`,children:[S?(0,$.jsxs)(`div`,{className:`world-renderer-fallback`,role:`status`,children:[(0,$.jsx)(`strong`,{children:`Visual scene unavailable`}),(0,$.jsx)(`span`,{children:`The complete roster and inspector remain available.`})]}):null,(0,$.jsx)(`div`,{ref:y,className:`world-canvas-host`,"data-renderer":S?`unavailable`:`pixi`,hidden:S}),v]})}function Ca(e,t){let n=Da(e*.72,560,960,e),r=Da(t*.6,340,560,t);return wa({left:(e-n)/2,top:(t-r)/2,width:n,height:r},e,t)}function wa(e,t,n){let r=Math.max(0,t-24),i=Math.max(0,n-24),a=Math.min(560,r),o=Math.min(340,i),s=ka(Oa(e.width,a),a,r),c=ka(Oa(e.height,o),o,i),l=Math.max(12,t-12-s),u=Math.max(12,n-12-c);return{left:ka(Oa(e.left,12),12,l),top:ka(Oa(e.top,12),12,u),width:s,height:c}}function Ta(e,t,n,r,i){return wa({...e,left:e.left+t,top:e.top+n},r,i)}function Ea(e,t,n,r,i){return wa({...e,width:e.width+t,height:e.height+n},r,i)}function Da(e,t,n,r){let i=Math.max(0,r-24);return ka(e,Math.min(t,i),Math.min(n,i))}function Oa(e,t){return Number.isFinite(e)?e:t}function ka(e,t,n){return Math.max(t,Math.min(n,e))}var Aa=`herdrWeb.worldView.v1`,ja=1e4;function Ma(){return{geometry:{},order:[],scrollTop:0}}function Na(e=za()){if(!e)return Ma();try{let t=e.getItem(Aa);return t?Fa(JSON.parse(t)):Ma()}catch{return Ma()}}function Pa(e,t=za()){if(t)try{t.setItem(Aa,JSON.stringify(Fa(e)))}catch{}}function Fa(e){if(!e||typeof e!=`object`||Array.isArray(e))return Ma();let t=e,n={};if(t.geometry&&typeof t.geometry==`object`&&!Array.isArray(t.geometry))for(let[e,r]of Object.entries(t.geometry)){let t=Ia(r);if(t&&(n[e.slice(0,160)]=t),Object.keys(n).length>=5)break}return{geometry:n,order:Array.isArray(t.order)?Ra(t.order).slice(0,5):[],scrollTop:typeof t.scrollTop==`number`&&Number.isFinite(t.scrollTop)?Math.max(0,Math.min(ja,t.scrollTop)):0}}function Ia(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return[t.left,t.top,t.width,t.height].every(e=>typeof e==`number`&&Number.isFinite(e))?{left:La(t.left),top:La(t.top),width:La(t.width),height:La(t.height)}:null}function La(e){return Math.max(0,Math.min(ja,e))}function Ra(e){let t=new Set,n=[];for(let r of e)typeof r!=`string`||!r||t.has(r)||(t.add(r),n.push(r.slice(0,160)));return n}function za(){try{return globalThis.localStorage??null}catch{return null}}var Ba={projection:{version:1,generatedAt:0,hosts:[],rooms:[],receptions:[],barAgents:[],roomRoster:[],deskRoster:[],roster:[],unresolved:[],coverage:{configuredHosts:0,observedHosts:0,compatibleHosts:0,connectingHosts:0,staleHosts:0,incompatibleHosts:0,disabledHosts:0,observedWorkspaces:0,observedDesks:0,observedAgents:0,status:{working:0,idle:0,blocked:0,done:0,unknown:0},omittedRooms:0,omittedDesks:0,omittedRoomAgents:0,omittedReceptionDesks:0,omittedWaitingAgents:0,omittedBarAgents:0},presentationBounds:{...h,totalRooms:0,renderedRooms:0,totalDesks:0,renderedDesks:0,totalRoomAgents:0,renderedRoomAgents:0,totalReceptionDesks:0,renderedReceptionDesks:0,totalWaitingAgents:0,renderedWaitingAgents:0,totalBarAgents:0,renderedBarAgents:0}},selectedKey:null,observability:{health:`unavailable`,providerId:null,sourceCount:0,configuredSourceCount:0,failedSourceCount:0,observedAt:0,windowSeconds:null,models:[],totalCostUsd:null,totalUsage:0},completionSeenKeys:new Set,onSelect:()=>{},compact:!1,onBackToSidebar:()=>{},onToggleSidebar:()=>{},onOpenInSpaces:()=>{},handoffStatus:null,conversationBubbles:[],onCloseConversation:()=>{},onFocusConversation:()=>{},agentActivityTransitions:new Map,roomAlignment:`left`,longRoomTitleMode:`expand`,canCreateSeat:()=>!1,onNewSeat:()=>{},canCreateRoom:()=>!1,onCreateRoom:()=>{},canRenameRoom:()=>!1,onRenameRoom:()=>{},canCloseRoom:()=>!1,onCloseRoom:()=>{}};function Va({context:e}){let t=Ga(e)?e:Ba;return(0,$.jsx)(Ha,{projection:t.projection,context:t,onActivateAgent:e=>{let n=t.projection.roster.find(t=>t.agent.key===e)?.agent;n&&(t.onSelect(e),t.onOpenInSpaces(f(n)))},onActivateRoom:e=>{let n=t.projection.roomRoster.find(t=>t.key===e);n&&(t.onSelect(e),t.onOpenInSpaces(d(n)))}})}function Ha({projection:e,context:t,onActivateAgent:n,onActivateRoom:r}){let o=(0,W.useRef)(null),c=(0,W.useRef)(null),l=(0,W.useRef)({}),[u]=(0,W.useState)(Na),d=(0,W.useRef)(u),f=(0,W.useRef)(!1),p=(0,W.useRef)(null),[m,h]=(0,W.useState)({}),[g,_]=(0,W.useState)(null),[y,b]=(0,W.useState)(0),[x,S]=(0,W.useState)({width:0,height:0}),[C,T]=(0,W.useState)({}),[ee,E]=(0,W.useState)({}),[te,D]=(0,W.useState)(null),[O,ne]=(0,W.useState)(()=>d.current.order),[k,A]=(0,W.useState)(null),[re,ie]=(0,W.useState)(null),j=(0,W.useRef)({}),M=(0,W.useRef)(null),N=(0,W.useRef)(null),P=(0,W.useCallback)(()=>{d.current={geometry:{...d.current.geometry,...j.current},order:O.filter(Boolean).slice(0,5),scrollTop:Math.max(0,o.current?.scrollTop??d.current.scrollTop)},Pa(d.current)},[O]),ae=(0,W.useCallback)(()=>{p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{p.current=null,P()},120)},[P]),F=t.conversationBubbles.map(({id:e})=>e),I=F.join(`|`),L=e.rooms.find(({key:e})=>e===t.selectedKey)?.key??e.deskRoster.find(({desk:e})=>e.key===t.selectedKey)?.desk.roomKey??e.roster.find(({agent:e})=>e.key===t.selectedKey)?.agent.roomKey??null,oe=g?.agentBarRect,se=!!(g&&!g.fallbackMessage&&g.layoutRevision>0&&g.layoutRevision===y),ce=e=>{if(!e){A(null);return}let t=c.current;if(!t)return;let n=t.getBoundingClientRect();A({...e,left:e.clientX-n.left,top:e.clientY-n.top})},le=e=>{if(!e){ie(null);return}let t=c.current;if(!t)return;let n=t.getBoundingClientRect();ie({...e,left:e.x-n.left,top:e.y-n.top})};(0,W.useEffect)(()=>()=>{M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]);let ue=()=>{M.current===null&&(M.current=window.requestAnimationFrame(()=>{M.current=null,E({...j.current})}))},de=(e,n)=>{let r=c.current;if(!r||t.compact)return;let i=wa(n,r.clientWidth,r.clientHeight),a=j.current[e];a&&a.left===i.left&&a.top===i.top&&a.width===i.width&&a.height===i.height||(j.current={...j.current,[e]:i},ue())},R=e=>{let t=c.current,n=l.current[e];if(!t||!n)return null;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect();return wa({left:i.left-r.left,top:i.top-r.top,width:i.width,height:i.height},t.clientWidth,t.clientHeight)},fe=(e,t)=>{t?l.current[e]=t:delete l.current[e]},pe=()=>{let e=c.current;if(!e||t.compact||e.clientWidth<=0||e.clientHeight<=0)return;let n={};for(let[r,i]of t.conversationBubbles.entries()){let t=j.current[i.id];if(t){n[i.id]=wa(t,e.clientWidth,e.clientHeight);continue}let a=Ca(e.clientWidth,e.clientHeight);n[i.id]=wa({...a,left:a.left+r*34,top:a.top+r*28},e.clientWidth,e.clientHeight)}(Object.keys(j.current).length!==Object.keys(n).length||Object.entries(n).some(([e,t])=>{let n=j.current[e];return!n||n.left!==t.left||n.top!==t.top||n.width!==t.width||n.height!==t.height}))&&(j.current=n,E(n))};(0,W.useEffect)(()=>{let e=c.current;if(!e)return;let n=()=>{let n=e.getBoundingClientRect(),r={width:e.clientWidth,height:e.clientHeight};S(e=>e.width===r.width&&e.height===r.height?e:r),pe();let i={};for(let e of t.conversationBubbles){let t=l.current[e.id];t&&(i[e.id]=t.getBoundingClientRect())}T(i),n.width<=0||n.height};n();let r=new ResizeObserver(n);r.observe(e);for(let e of t.conversationBubbles){let t=l.current[e.id];t&&r.observe(t)}return window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[t.compact,I]),(0,W.useEffect)(()=>{if(t.compact||f.current)return;let e=o.current;if(!e)return;let n=()=>{e.scrollTop=d.current.scrollTop,f.current=!0},r=window.requestAnimationFrame(()=>{n(),window.requestAnimationFrame(n)});return()=>window.cancelAnimationFrame(r)},[t.compact,e.generatedAt]),(0,W.useEffect)(()=>{if(t.compact)return;let e=o.current;if(!e)return;let n=()=>ae();return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t.compact,ae]),(0,W.useLayoutEffect)(()=>{let e={};for(let n of t.conversationBubbles){let t=l.current[n.id];t&&(e[n.id]=t.getBoundingClientRect())}T(e)},[t.conversationBubbles,ee]),(0,W.useEffect)(()=>{let e=new Set(F);if(t.compact)j.current={},E({});else{let e=Object.fromEntries(F.flatMap(e=>{let t=j.current[e]??d.current.geometry[e];return t?[[e,t]]:[]}));j.current=e,E(e)}h(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),T(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t)))),ne(t=>[...(t.length>0?t:d.current.order).filter(t=>e.has(t)),...F.filter(e=>!(t.length>0?t:d.current.order).includes(e))]),F.length===0&&(N.current=null,D(null))},[t.compact,I]),(0,W.useEffect)(()=>{t.compact||P()},[t.compact,ee,O,P]),(0,W.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`)return;let n=e.target instanceof Element?e.target:null,r=document.activeElement;if(n?.closest(`.world-conversation-terminal`)||r instanceof Element&&r.closest(`.world-conversation-terminal`))return;let i=[...O].reverse().find(e=>F.includes(e));i&&(e.preventDefault(),e.stopPropagation(),t.onCloseConversation(i))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[t,O,I]);let z=e=>{ne(t=>[...t.filter(t=>t!==e),e]),t.onFocusConversation(e)},B=(e,n)=>{if(t.compact||n.button!==0)return;z(e);let r=n.target instanceof Element?n.target:null,i=r?.closest(`[data-world-conversation-resize='true']`),a=r?.closest(`.world-conversation-header`);if(!i&&!a||a&&r?.closest(`button, a, input, textarea, select`))return;let o=j.current[e]??R(e),s=l.current[e];!o||!s||(n.preventDefault(),n.stopPropagation(),s.setPointerCapture(n.pointerId),N.current={id:e,mode:i?`resizing`:`moving`,pointerId:n.pointerId,startX:n.clientX,startY:n.clientY,geometry:o},D({id:e,mode:i?`resizing`:`moving`}))},me=e=>{let t=N.current;if(!t||t.pointerId!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let n=c.current;if(!n)return;let r=e.clientX-t.startX,i=e.clientY-t.startY;de(t.id,t.mode===`moving`?Ta(t.geometry,r,i,n.clientWidth,n.clientHeight):Ea(t.geometry,r,i,n.clientWidth,n.clientHeight))},V=e=>{let t=N.current;if(!t||t.pointerId!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget;n?.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),N.current=null,D(null)},he=(e,n)=>{if(t.compact||![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(n.key))return;let r=n.target instanceof Element?n.target:null,i=!!r?.closest(`.world-conversation-header`),a=!!r?.closest(`[data-world-conversation-resize='true']`);if(!i&&!a||!a&&r?.closest(`button, a, input, textarea, select`))return;let o=c.current;O[O.length-1]!==e&&z(e);let s=j.current[e]??R(e);if(!o||!s)return;n.preventDefault();let l=n.shiftKey?48:16,u=n.key===`ArrowRight`?l:n.key===`ArrowLeft`?-l:0,d=n.key===`ArrowDown`?l:n.key===`ArrowUp`?-l:0;de(e,a?Ea(s,u,d,o.clientWidth,o.clientHeight):Ta(s,u,d,o.clientWidth,o.clientHeight))},ge=(()=>{let e=c.current;if(!e||t.conversationBubbles.length===0||x.width<=0||x.height<=0)return null;let n=e.getBoundingClientRect(),r=t.conversationBubbles.flatMap(e=>{let t=C[e.id],r=m[e.id];if(!t||!r)return[];let i=t.left-n.left,a=t.right-n.left,o=t.top-n.top,s=t.bottom-n.top,c=(i+a)/2;return[`workbench`,`agent`].flatMap(t=>{let l=r[t];if(!l)return[];let u=l.x-n.left,d=l.y-n.top,f=u<=c?i:a,p=d+(t===`workbench`?-10:10),m=Math.max(o+22,Math.min(s-22,p)),h=u+(f-u)*.55,g=`M ${u.toFixed(1)} ${d.toFixed(1)} C ${h.toFixed(1)} ${d.toFixed(1)}, ${h.toFixed(1)} ${m.toFixed(1)}, ${f.toFixed(1)} ${m.toFixed(1)}`;return[{id:`${e.id}:${t}`,windowId:e.id,kind:t,path:g,targetX:u,targetY:d,offscreen:l.edge}]})});return r.length===0?null:(0,$.jsx)(`svg`,{className:`world-conversation-connector`,"aria-hidden":`true`,width:x.width,height:x.height,viewBox:`0 0 ${x.width} ${x.height}`,preserveAspectRatio:`none`,children:r.map(({id:e,windowId:t,kind:n,path:r,targetX:i,targetY:a,offscreen:o})=>(0,$.jsxs)(`g`,{"data-anchor":n,"data-window-id":t,"data-offscreen":o??void 0,children:[(0,$.jsx)(`path`,{"data-anchor":n,"data-window-id":t,"data-offscreen":o??void 0,d:r}),(0,$.jsx)(`circle`,{"data-anchor":n,"data-window-id":t,"data-offscreen":o??void 0,cx:i,cy:a,r:`4`})]},e))})})();return(0,$.jsxs)(`div`,{ref:c,className:`world-stage-shell`,children:[(0,$.jsxs)(`header`,{className:`stage-bar world-stage-bar`,children:[(0,$.jsx)(`button`,{className:`icon-btn`,type:`button`,"aria-label":t.compact?`Back to Herdr sidebar`:`Toggle sidebar`,title:t.compact?`Back to sidebar`:`Toggle sidebar`,onClick:t.compact?t.onBackToSidebar:t.onToggleSidebar,children:t.compact?(0,$.jsx)(a,{size:20}):(0,$.jsx)(w,{size:18})}),(0,$.jsxs)(`div`,{className:`stage-id`,children:[(0,$.jsx)(`span`,{className:`stage-title`,children:`Pixel Office`}),(0,$.jsx)(`span`,{className:`stage-sub`,children:`Shared Herdr state · live board in CEO Office`})]}),(0,$.jsx)(`button`,{className:`icon-btn`,type:`button`,"aria-label":`Reset office view`,title:`Reset view`,onClick:()=>o.current?.scrollTo({top:0,left:0,behavior:`auto`}),children:(0,$.jsx)(i,{size:16})})]}),(0,$.jsx)(`div`,{ref:o,className:`world-stage-scroll`,role:`region`,"aria-label":`Scrollable Pixel Office scene`,tabIndex:0,children:(0,$.jsxs)(Sa,{projection:e,observability:t.observability,selectedKey:t.selectedKey,completionSeenKeys:t.completionSeenKeys,conversationTargets:t.conversationBubbles.map(e=>({id:e.id,selectedKey:e.selectedKey,targetKey:e.targetKey})),onSelect:t.onSelect,onActivateAgent:n,onActivateRoom:r,canCreateSeat:t.canCreateSeat,onNewSeat:t.onNewSeat,onLayoutChange:_,onCanvasRendered:b,roomAlignment:t.roomAlignment,longRoomTitleMode:t.longRoomTitleMode,onHover:ce,onAnchorChange:e=>h(e??{}),onSelectedAnchorChange:le,children:[(0,$.jsx)(Ka,{className:`world-canvas-agent-bar`,projection:e,selectedKey:t.selectedKey,barWidth:oe?.width??s.agentBarPreferredWidth,barHeight:oe?.height??s.ceoBandHeight-4,left:oe?.x,top:oe?.y,interactive:se,onSelect:t.onSelect,onActivateAgent:n}),g?(0,$.jsx)(Wa,{layout:g,projection:e,selectedRoomKey:L,context:t,canvasRenderedRevision:y}):null]})}),t.selectedKey&&re?(0,$.jsx)(Ua,{callout:v(e,t.selectedKey),left:re.left,top:re.top,persistent:!0}):null,k&&!(k.key===t.selectedKey&&v(e,k.key)?.summary)?(0,$.jsx)(Ua,{callout:v(e,k.key),left:k.left,top:k.top}):null,ge,t.conversationBubbles.map(e=>{let n=ee[e.id],r=O.indexOf(e.id),i=te?.id===e.id?te.mode:void 0;return(0,$.jsxs)(`div`,{ref:t=>fe(e.id,t),className:`world-conversation-slot`,"data-window-id":e.id,"data-positioned":n?`true`:`false`,"data-active":r===O.length-1?`true`:void 0,"data-interaction":i,"aria-busy":i!==void 0,style:n&&!t.compact?{left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,zIndex:20+Math.max(0,r)}:void 0,onPointerDown:t=>{z(e.id),B(e.id,t)},onPointerMove:me,onPointerUp:V,onPointerCancel:V,onKeyDown:t=>he(e.id,t),children:[e.content,t.compact?null:(0,$.jsx)(`button`,{type:`button`,className:`world-conversation-resize`,"data-world-conversation-resize":`true`,"aria-label":`Resize agent conversation`,title:`Resize conversation`,onPointerDown:t=>B(e.id,t)})]},e.id)})]})}function Ua({callout:e,left:t,top:n,persistent:r=!1}){return e?(0,$.jsxs)(`div`,{className:`world-canvas-callout${r?` world-canvas-callout-persistent`:``}`,"data-kind":e.kind,"data-status":e.status??void 0,style:{left:`${t}px`,top:`${n}px`},role:r?`status`:`tooltip`,"aria-live":r?`polite`:void 0,children:[(0,$.jsx)(`strong`,{children:e.title}),e.summary?(0,$.jsx)(`span`,{className:`world-canvas-callout-summary`,children:e.summary}):null,(0,$.jsx)(`span`,{children:e.detail})]}):null}function Wa({layout:e,projection:n,selectedRoomKey:r,context:i,canvasRenderedRevision:a}){let o=e.layoutRevision>0&&e.layoutRevision===a,c=e.rooms.reduce((e,t)=>Math.max(e,t.y+t.height),e.roomStartY);return(0,$.jsxs)(`div`,{className:`world-room-actions-overlay`,"aria-label":`Office room actions`,children:[e.overflowMarker?(0,$.jsx)(`div`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:e.overflowMarker.label}):null,n.rooms.map((t,n)=>{let r=e.rooms.find(({index:e})=>e===n);if(!r)return null;let a=o,c=r.header;return(0,$.jsxs)(`div`,{className:`world-room-actions${a?``:` world-room-actions-stale`}`,"aria-hidden":!a,style:{left:`${r.headerRect.x}px`,top:`${r.headerRect.y}px`,width:`${r.headerRect.width}px`,height:`${r.headerRect.height}px`},children:[(0,$.jsx)(`button`,{className:`world-room-overlay-action world-room-overlay-action-rename`,type:`button`,"aria-label":`Rename room ${t.accessibleLabel??t.displayLabel}`,title:`Rename ${t.accessibleLabel??t.displayLabel}`,disabled:!a||!i.canRenameRoom(t.key),style:{left:`${c?.renameX??Math.max(0,r.headerRect.width-52)}px`,top:`2px`},onClick:()=>i.onRenameRoom(t.key),children:(0,$.jsx)(Je,{size:12,"aria-hidden":`true`})}),(0,$.jsx)(`button`,{className:`world-room-overlay-action world-room-overlay-action-danger`,type:`button`,"aria-label":`Close room ${t.accessibleLabel??t.displayLabel}`,title:`Close ${t.accessibleLabel??t.displayLabel}`,disabled:!a||!i.canCloseRoom(t.key),style:{left:`${c?.closeX??Math.max(0,r.headerRect.width-s.roomHeaderActionWidth)}px`,top:`2px`},onClick:()=>i.onCloseRoom(t.key),children:(0,$.jsx)(T,{size:12,"aria-hidden":`true`})})]},t.key)}),n.rooms.map((t,n)=>{let r=e.rooms.find(({index:e})=>e===n);if(!r||!i.canCreateSeat(t.key))return null;let a=t.desks.length>=s.desksPerRoom,c=a?{x:r.x+r.width/2,deskY:r.y+r.height-40}:b(r,t.desks.length);return(0,$.jsx)(`button`,{className:`world-new-seat-canvas-action${a?` world-new-seat-canvas-action-full`:``}`,type:`button`,"aria-label":a?`${t.accessibleLabel??t.displayLabel} room full`:`New seat in ${t.accessibleLabel??t.displayLabel}`,title:a?`${t.accessibleLabel??t.displayLabel} is full`:`Start a new seat in ${t.accessibleLabel??t.displayLabel}`,disabled:!o||a,style:{left:`${c.x-25}px`,top:`${c.deskY}px`},onClick:()=>i.onNewSeat(t.key)},`${t.key}:new-seat`)}),(0,$.jsx)(`div`,{className:`sr-only`,"aria-label":`Office room names`,children:n.rooms.map(e=>{let t=n.hosts.find(({key:t})=>t===e.hostKey);return(0,$.jsxs)(`span`,{children:[e.accessibleLabel??e.displayLabel,` — `,t?.accessibleLabel??t?.displayLabel??`host unavailable`]},`${e.key}:semantic-name`)})}),i.canCreateRoom(r??void 0)?(0,$.jsxs)(`button`,{className:`world-new-room-canvas-action`,type:`button`,"aria-label":`New room`,title:`Create a new Herdr workspace`,disabled:!o,style:{left:`${e.officeWidth/2-28}px`,top:`${c+8}px`},onClick:()=>i.onCreateRoom(r??void 0),children:[(0,$.jsx)(t,{size:24,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`NEW ROOM`})]}):null]})}function Ga(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.onSelect==`function`&&typeof t.onBackToSidebar==`function`&&typeof t.onToggleSidebar==`function`&&typeof t.onOpenInSpaces==`function`&&(t.roomAlignment===`left`||t.roomAlignment===`center`||t.roomAlignment===`right`)&&(t.longRoomTitleMode===`expand`||t.longRoomTitleMode===`compact`)&&typeof t.canCreateSeat==`function`&&typeof t.onNewSeat==`function`&&typeof t.canCreateRoom==`function`&&typeof t.onCreateRoom==`function`&&typeof t.canRenameRoom==`function`&&typeof t.onRenameRoom==`function`&&typeof t.canCloseRoom==`function`&&typeof t.onCloseRoom==`function`&&!!t.projection}function Ka({className:e,projection:t,selectedKey:n,barWidth:r,barHeight:i,left:a,top:o,interactive:s,onSelect:c,onActivateAgent:l}){let u=t.barAgents.filter(({semanticStatus:e})=>e===`idle`).length,d=t.barAgents.filter(({semanticStatus:e})=>e===`blocked`).length,f=t.coverage.omittedBarAgents,p=Math.max(3,Math.floor(Math.max(0,r-106)/56)),m=Math.max(2,Math.floor(Math.max(1,i-102)/56));return(0,$.jsxs)(`section`,{className:`world-office-overview${e?` ${e}`:``}`,"aria-label":`Agent Bar`,"aria-hidden":!s,style:{width:`${r}px`,height:`${i}px`,...a===void 0?{}:{left:`${a}px`,right:`auto`},...o===void 0?{}:{top:`${o}px`},visibility:s?`visible`:`hidden`},children:[(0,$.jsxs)(`div`,{className:`world-overview-heading`,children:[(0,$.jsx)(`strong`,{children:`Agent Bar`}),(0,$.jsxs)(`span`,{children:[t.barAgents.length,` visible · `,u,` idle · `,d,` needs input`]})]}),(0,$.jsxs)(`ul`,{className:`world-agent-bar`,"aria-label":`Agent Bar`,style:{gridTemplateColumns:`repeat(${p}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${m}, minmax(0, 1fr))`},children:[t.barAgents.length===0?(0,$.jsx)(`li`,{className:`world-agent-bar-empty`,children:`No completed or waiting agents`}):t.barAgents.map(e=>{let t=e.stale?`stale`:e.semanticStatus,r=e.stale?`STALE`:e.stateLabels[e.semanticStatus]??e.semanticStatus.toUpperCase();return(0,$.jsx)(`li`,{className:`world-agent-bar-item-shell`,children:(0,$.jsxs)(`button`,{className:`world-agent-bar-item`,type:`button`,"aria-pressed":n===e.key,"data-status":t,disabled:!s,title:e.taskSummary??`${e.displayLabel} · ${r}`,onClick:()=>c(e.key),onDoubleClick:()=>l(e.key),children:[(0,$.jsx)(`img`,{className:`world-agent-bar-avatar`,src:`/world/characters/${e.characterIndex+1}-D-1.png`,alt:``,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`world-agent-bar-name`,children:e.displayLabel}),(0,$.jsx)(`span`,{className:`world-agent-bar-state`,children:r})]})},e.key)}),f>0?(0,$.jsxs)(`li`,{className:`world-agent-bar-overflow`,children:[`+`,f,` more in roster`]}):null]})]})}export{Va as default,Cn as n,dr as t};