shaders 2.0.650 → 2.0.652
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +16 -9
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.js +1 -1
- package/package.json +1 -1
package/dist/vue/index.js
CHANGED
|
@@ -393,7 +393,7 @@ struct ${e} {
|
|
|
393
393
|
${t}
|
|
394
394
|
};`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`,o=this._getWGSLStruct(a,t);return`${o}
|
|
395
395
|
@binding( ${r} ) @group( ${i} )
|
|
396
|
-
var<${n}> ${e} : ${a};`}},cj=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture===null?e.depth&&e.stencil?t=I.Depth24PlusStencil8:e.depth&&(t=I.Depth24Plus):t=this.getTextureFormatGPU(e.depthTexture),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,r=n?1:t;return{samples:t,primarySamples:r,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return fA.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return fA.LineList;if(e.isLine)return fA.LineStrip;if(e.isMesh)return fA.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=2**Math.floor(Math.log2(e)),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===st)return I.BGRA8Unorm;if(e===mt)return I.RGBA16Float;throw Error(`Unsupported outputType`)}};const lj=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),uj=new Map([[Aa,[`float16`]]]),dj=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var fj=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=this._isTypedArray(o),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=s?1:o.BYTES_PER_ELEMENT;for(let t=0,n=c.length;t<n;t++){let n=c[t],l,u;if(i._force3to4BytesAlignment===!0){let t=Math.floor(n.start/3),r=Math.ceil(n.count/3);l=t*4*e,u=r*4*e}else l=n.start*e,u=n.count*e;let d=l*(s?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?MA.Instance:MA.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?MA.Instance:MA.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)),i=r.buffer,a=i.size,o=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),s=n.createCommandEncoder({label:`readback_encoder_${e.name}`});s.copyBufferToBuffer(i,0,o,0,a);let c=s.finish();n.queue.submit([c]),await o.mapAsync(GPUMapMode.READ);let l=o.getMappedRange(),u=new e.array.constructor(l.slice(0));return o.unmap(),u.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=dj.get(r);else{let e=uj.get(i)||lj.get(r),o=e[n?1:0];if(o){let e=r.BYTES_PER_ELEMENT*t,n=Math.floor((e+3)/4)*4,i=n/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${o}x${i}`}}return a||console.error(`THREE.WebGPUAttributeUtils: Vertex format not supported yet.`),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},pj=class{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,n=t.device,r=[],i=0;for(let n of e.bindings){let e={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let t={};n.isStorageBuffer&&(n.visibility&4&&(n.access===vc.READ_WRITE||n.access===vc.WRITE_ONLY)?t.type=TA.Storage:t.type=TA.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=DA.NonFiltering):r.type=DA.Comparison),e.sampler=r}else if(n.isSampledTexture&&n.texture.isVideoTexture)e.externalTexture={};else if(n.isSampledTexture&&n.store){let t={};t.format=this.backend.get(n.texture).texture.format;let r=n.access;r===vc.READ_WRITE?t.access=EA.ReadWrite:r===vc.WRITE_ONLY?t.access=EA.WriteOnly:t.access=EA.ReadOnly,e.storageTexture=t}else if(n.isSampledTexture){let r={},{primarySamples:i}=t.utils.getTextureSampleData(n.texture);if(i>1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=OA.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=OA.UnfilterableFloat:r.sampleType=OA.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=OA.SInt:e===ft?r.sampleType=OA.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=OA.Float:r.sampleType=OA.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=AA.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=AA.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=AA.ThreeD),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){let{backend:i,bindGroupLayoutCache:a}=this,o=i.get(e),s=a.get(e.bindingsReference);s===void 0&&(s=this.createBindingsLayout(e),a.set(e.bindingsReference,s));let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,s),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c,o.layout=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroupIndex(e,t){let n=this.backend,r=n.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],o=r.createBuffer({label:`bindingCameraIndex_`+a,size:16,usage:i});r.queue.writeBuffer(o,0,e,0);let s=[{binding:0,resource:{buffer:o}}];return r.createBindGroup({label:`bindGroupCameraIndex_`+a,layout:t,entries:s})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=r.createBuffer({label:`bindingBuffer_`+t.name,size:n,usage:i});e.buffer=a}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t);if(e.buffer===void 0){let r=t.attribute;e.buffer=n.get(r).buffer}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(o=e[r],o===void 0){let i=jA.All,a;a=t.isSampledCubeTexture?AA.Cube:t.isSampledTexture3D?AA.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?AA.TwoDArray:AA.TwoD,o=e[r]=e.texture.createView({aspect:i,dimension:a,mipLevelCount:n})}}a.push({binding:i,resource:o})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}},mj=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){let n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let e=c.get(t);f.push(e.layout)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==ae&&(r.blending!==oe||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures;for(let e=0;e<t.length;e++){let n=u.getTextureFormatGPU(t[e]);_.push({format:n,blend:m,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),ee=this._getSampleCount(e.context),te={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:ee,alphaToCoverageEnabled:r.alphaToCoverage&&ee>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},ne={},re=e.context.depth,ie=e.context.stencil;if((re===!0||ie===!0)&&(re===!0&&(ne.format=S,ne.depthWriteEnabled=r.depthWrite,ne.depthCompare=x),ie===!0&&(ne.stencilFront=h,ne.stencilBack={},ne.stencilReadMask=r.stencilFuncMask,ne.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(ne.depthBias=r.polygonOffsetUnits,ne.depthBiasSlopeScale=r.polygonOffsetFactor,ne.depthBiasClamp=0),te.depthStencil=ne),t===null)d.pipeline=l.createRenderPipeline(te);else{let e=new Promise(e=>{l.createRenderPipelineAsync(te).then(t=>{d.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let n=this.backend,{utils:r,device:i}=n,a=r.getCurrentDepthStencilFormat(e),o=r.getCurrentColorFormat(e),s=this._getSampleCount(e),c={label:t,colorFormats:[o],depthStencilFormat:a,sampleCount:s};return i.createRenderBundleEncoder(c)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let t=n.get(e);o.push(t.layout)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===ue){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:SA.Add},n={srcFactor:i,dstFactor:a,operation:SA.Add}};if(i)switch(r){case oe:a(xA.One,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.One,xA.One,xA.One,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.SrcAlpha);break}else switch(r){case oe:a(xA.SrcAlpha,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.SrcAlpha,xA.One,xA.SrcAlpha,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error(`THREE.WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case ge:t=xA.Zero;break;case _e:t=xA.One;break;case ve:t=xA.Src;break;case ye:t=xA.OneMinusSrc;break;case be:t=xA.SrcAlpha;break;case xe:t=xA.OneMinusSrcAlpha;break;case we:t=xA.Dst;break;case Te:t=xA.OneMinusDst;break;case Se:t=xA.DstAlpha;break;case Ce:t=xA.OneMinusDstAlpha;break;case Ee:t=xA.SrcAlphaSaturated;break;case qb:t=xA.Constant;break;case Jb:t=xA.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case Dn:t=pA.Never;break;case Pn:t=pA.Always;break;case On:t=pA.Less;break;case An:t=pA.LessEqual;break;case kn:t=pA.Equal;break;case Nn:t=pA.GreaterEqual;break;case jn:t=pA.Greater;break;case Mn:t=pA.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case bn:t=wA.Keep;break;case yn:t=wA.Zero;break;case xn:t=wA.Replace;break;case En:t=wA.Invert;break;case Sn:t=wA.IncrementClamp;break;case Cn:t=wA.DecrementClamp;break;case wn:t=wA.IncrementWrap;break;case Tn:t=wA.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=SA.Add;break;case fe:t=SA.Subtract;break;case pe:t=SA.ReverseSubtract;break;case me:t=SA.Min;break;case he:t=SA.Max;break;default:console.error(`THREE.WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?vA.Uint16:vA.Uint32),n.side){case ne:r.frontFace=gA.CCW,r.cullMode=_A.Back;break;case re:r.frontFace=gA.CCW,r.cullMode=_A.Front;break;case ie:r.frontFace=gA.CCW,r.cullMode=_A.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?CA.All:CA.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=pA.Always;else{let n=e.depthFunc;switch(n){case De:t=pA.Never;break;case Oe:t=pA.Always;break;case ke:t=pA.Less;break;case Ae:t=pA.LessEqual;break;case je:t=pA.Equal;break;case Me:t=pA.GreaterEqual;break;case Ne:t=pA.Greater;break;case Pe:t=pA.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},hj=class extends cA{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return jr(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{let e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o=0;for(let[,t]of e){let e=a[t],n=a[t+1],r=Number(n-e)/1e6;o+=r}return this.resultBuffer.unmap(),this.lastValue=o,o}catch(e){return console.error(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){console.error(`Error unmapping buffer:`,e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},gj=class extends Wk{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new cj(this),this.attributeUtils=new fj(this),this.bindingUtils=new pj(this),this.pipelineUtils=new mj(this),this.textureUtils=new HA(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?`compatibility`:void 0},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(NA),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;n.lost.then(t=>{let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)});let r=t.context===void 0?e.domElement.getContext(`webgpu`):t.context;this.device=n,this.context=r;let i=t.alpha?`premultiplied`:`opaque`;this.trackTimestamp=this.trackTimestamp&&this.hasFeature(NA.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return Kn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let t=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;if(i===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples){i={},r.descriptors=i;let e=()=>{n.removeEventListener(`dispose`,e),this.delete(n)};n.hasEventListener(`dispose`,e)===!1&&n.addEventListener(`dispose`,e)}let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:AA.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=AA.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:AA.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=AA.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};e.depthTexture.isArrayTexture&&(n.dimension=AA.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=n.dimensions}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||hA.Load,storeOp:t.storeOp||mA.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:hA.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=hA.Clear):r.loadOp=hA.Load,r.storeOp=mA.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=hA.Clear):t.loadOp=hA.Load,t.storeOp=mA.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=hA.Clear):o.depthLoadOp=hA.Load,o.depthStoreOp=mA.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=hA.Clear):o.stencilLoadOp=hA.Load,o.stencilStoreOp=mA.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(n),t.bundleSets.push(i)}t.currentPass=null}else{let n=s.beginRenderPass(a);if(t.currentPass=n,e.viewport&&this.updateViewport(e),e.scissor){let{x:t,y:r,width:i,height:a}=e.scissorValue;n.setScissorRect(t,r,i,a)}}t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:AA.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||hA.Clear,depthStoreOp:i.depthStoreOp||mA.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=hA.Clear):t.depthLoadOp=hA.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=hA.Clear):t.stencilLoadOp=hA.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=hA.Clear,e.storeOp=mA.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?hA.Clear:hA.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?hA.Clear:hA.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=mA.Store),u&&(i.stencilLoadOp=n?hA.Clear:hA.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=mA.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=hA.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=mA.Store):(s.depthLoadOp=hA.Load,s.depthStoreOp=mA.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=hA.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=mA.Store):(s.stencilLoadOp=hA.Load,s.stencilStoreOp=mA.Store));let d=i.createCommandEncoder({label:`clear`}),f=d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s});f.end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(e,n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r){let{passEncoderGPU:i}=this.get(e),a=this.get(r).pipeline;this.pipelineUtils.setPipeline(i,a);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);i.setBindGroup(e,r.group)}let o=this.device.limits.maxComputeWorkgroupsPerDimension,s=this.get(t);s.dispatchSize===void 0&&(s.dispatchSize={x:0,y:1,z:1});let{dispatchSize:c}=s;t.dispatchCount>o?(c.x=Math.min(t.dispatchCount,o),c.y=Math.ceil(t.dispatchCount/o)):c.x=t.dispatchCount,i.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a).pipeline,l=e.getIndex(),u=l!==null,d=e.getDrawParameters();if(d===null)return;let f=(t,n)=>{this.pipelineUtils.setPipeline(t,c),n.pipeline=c;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(u===!0&&n.index!==l){let e=this.get(l).buffer,r=l.array instanceof Uint16Array?vA.Uint16:vA.Uint32;t.setIndexBuffer(e,r),n.index=l}let d=e.getVertexBuffers();for(let e=0,r=d.length;e<r;e++){let r=d[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},p=(r,i)=>{if(f(r,i),n.isBatchedMesh===!0){let e=n._multiDrawStarts,i=n._multiDrawCounts,a=n._multiDrawCount,o=n._multiDrawInstances;o!==null&&jr(`THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);for(let s=0;s<a;s++){let a=o?o[s]:1,c=a>1?0:s;u===!0?r.drawIndexed(i[s],a,e[s]/l.array.BYTES_PER_ELEMENT,0,c):r.draw(i[s],a,e[s],c),t.update(n,i[s],a)}}else if(u===!0){let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndexedIndirect(e,0)}else r.drawIndexed(i,a,o,0,0);t.update(n,i,a)}else{let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndirect(e,0)}else r.draw(i,a,o,0);t.update(n,i,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let r=this.bindingUtils.createBindGroupIndex(i,e.layout);n.push(r)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),p(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}p(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;let n=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[n]||(this.timestampQueryPool[n]=new hj(this.device,n,2048));let r=this.timestampQueryPool[n],i=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new sj(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass,i=r.finish();this.get(t).bundleGPU=i,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){let n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){console.error(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=hA.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=hA.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=hA.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:n,width:i,height:a}=t.scissorValue;r.currentPass.setScissorRect(e,n,i,a)}}else this.device.queue.submit([o.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}},_j=class extends Ts{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},vj=class extends Ts{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},yj=class extends YO{constructor(){super(),this.addMaterial(xv,`MeshPhongMaterial`),this.addMaterial(_b,`MeshStandardMaterial`),this.addMaterial(yb,`MeshPhysicalMaterial`),this.addMaterial(Cb,`MeshToonMaterial`),this.addMaterial(dv,`MeshBasicMaterial`),this.addMaterial(yv,`MeshLambertMaterial`),this.addMaterial(X_,`MeshNormalMaterial`),this.addMaterial(Db,`MeshMatcapMaterial`),this.addMaterial(V_,`LineBasicMaterial`),this.addMaterial(U_,`LineDashedMaterial`),this.addMaterial(Nb,`PointsMaterial`),this.addMaterial(jb,`SpriteMaterial`),this.addMaterial(Ib,`ShadowMaterial`),this.addLight(YT,As),this.addLight(bO,Ns),this.addLight(wO,Fs),this.addLight(TO,Ts),this.addLight(kO,Ps),this.addLight(AO,ys),this.addLight(jO,Ls),this.addLight(EO,_j),this.addLight(OO,vj),this.addToneMapping(zC,ze),this.addToneMapping(BC,Be),this.addToneMapping(VC,Ve),this.addToneMapping(UC,He),this.addToneMapping(qC,Ue),this.addToneMapping(JC,We)}},bj=class extends vk{constructor(e={}){let t;e.forceWebGL?t=dA:(t=gj,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new dA(e)));let n=new t(e);super(n,e),this.library=new yj,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},xj={};_(xj,{BRDF_GGX:()=>Sj,BRDF_Lambert:()=>Cj,BasicShadowFilter:()=>wj,Break:()=>Tj,Const:()=>Fte,Continue:()=>Ej,DFGApprox:()=>Dj,D_GGX:()=>Oj,Discard:()=>kj,EPSILON:()=>Aj,F_Schlick:()=>jj,Fn:()=>Mj,INFINITY:()=>Nj,If:()=>Pj,Loop:()=>Ij,NodeAccess:()=>Bj,NodeShaderStage:()=>Lj,NodeType:()=>Rj,NodeUpdateType:()=>zj,PCFShadowFilter:()=>Vj,PCFSoftShadowFilter:()=>Hj,PI:()=>Uj,PI2:()=>Wj,Return:()=>Gj,Schlick_to_F0:()=>Kj,ScriptableNodeResources:()=>qj,ShaderNode:()=>Jj,Switch:()=>Fj,TBNViewMatrix:()=>Yj,VSMShadowFilter:()=>Xj,V_GGX_SmithCorrelated:()=>Zj,Var:()=>PP,abs:()=>Qj,acesFilmicToneMapping:()=>$j,acos:()=>eM,add:()=>tM,addNodeElement:()=>nM,agxToneMapping:()=>rM,all:()=>iM,alphaT:()=>aM,and:()=>oM,anisotropy:()=>sM,anisotropyB:()=>cM,anisotropyT:()=>lM,any:()=>uM,append:()=>mee,array:()=>hee,arrayBuffer:()=>gee,asin:()=>_ee,assign:()=>vee,atan:()=>yee,atan2:()=>bee,atomicAdd:()=>xee,atomicAnd:()=>See,atomicFunc:()=>Cee,atomicLoad:()=>Aee,atomicMax:()=>wee,atomicMin:()=>Tee,atomicOr:()=>Eee,atomicStore:()=>Dee,atomicSub:()=>Oee,atomicXor:()=>kee,attenuationColor:()=>jee,attenuationDistance:()=>Mee,attribute:()=>Nee,attributeArray:()=>Pee,backgroundBlurriness:()=>Fee,backgroundIntensity:()=>Iee,backgroundRotation:()=>Lee,batch:()=>Ree,billboarding:()=>zee,bitAnd:()=>Bee,bitNot:()=>Vee,bitOr:()=>Hee,bitXor:()=>Uee,bitangentGeometry:()=>Wee,bitangentLocal:()=>Gee,bitangentView:()=>Kee,bitangentWorld:()=>qee,bitcast:()=>Jee,blendBurn:()=>Yee,blendColor:()=>Xee,blendDodge:()=>Zee,blendOverlay:()=>Qee,blendScreen:()=>$ee,blur:()=>ete,bool:()=>tte,buffer:()=>nte,bufferAttribute:()=>rte,bumpMap:()=>ite,burn:()=>ate,bvec2:()=>ote,bvec3:()=>ste,bvec4:()=>cte,bypass:()=>lte,cache:()=>ute,call:()=>dte,cameraFar:()=>fte,cameraIndex:()=>pte,cameraNear:()=>mte,cameraNormalMatrix:()=>hte,cameraPosition:()=>gte,cameraProjectionMatrix:()=>_te,cameraProjectionMatrixInverse:()=>vte,cameraViewMatrix:()=>yte,cameraWorldMatrix:()=>bte,cbrt:()=>xte,cdl:()=>Ste,ceil:()=>Cte,checker:()=>wte,cineonToneMapping:()=>Tte,clamp:()=>dM,clearcoat:()=>Ete,clearcoatRoughness:()=>Dte,code:()=>Ote,color:()=>kte,colorSpaceToWorking:()=>Ate,colorToDirection:()=>jte,compute:()=>Mte,computeSkinning:()=>Nte,cond:()=>Pte,context:()=>Ite,convert:()=>Lte,convertColorSpace:()=>Rte,convertToTexture:()=>zte,cos:()=>fM,cross:()=>Bte,cubeTexture:()=>Vte,dFdx:()=>Hte,dFdy:()=>Ute,dashSize:()=>Wte,debug:()=>Gte,decrement:()=>Kte,decrementBefore:()=>qte,defaultBuildStages:()=>Jte,defaultShaderStages:()=>Yte,defined:()=>Xte,degrees:()=>Zte,deltaTime:()=>Qte,densityFog:()=>$te,densityFogFactor:()=>ene,depth:()=>tne,depthPass:()=>nne,difference:()=>rne,diffuseColor:()=>ine,directPointLight:()=>ane,directionToColor:()=>one,dispersion:()=>sne,distance:()=>cne,div:()=>lne,dodge:()=>une,dot:()=>pM,drawIndex:()=>dne,dynamicBufferAttribute:()=>fne,element:()=>pne,emissive:()=>mne,equal:()=>hne,equals:()=>gne,equirectUV:()=>_ne,exp:()=>vne,exp2:()=>yne,expression:()=>bne,faceDirection:()=>xne,faceForward:()=>Sne,faceforward:()=>Cne,float:()=>mM,floor:()=>wne,fog:()=>Tne,fract:()=>hM,frameGroup:()=>Ene,frameId:()=>Dne,frontFacing:()=>One,fwidth:()=>gM,gain:()=>kne,gapSize:()=>Ane,getConstNodeType:()=>jne,getCurrentStack:()=>Mne,getDirection:()=>Nne,getDistanceAttenuation:()=>Pne,getGeometryRoughness:()=>Fne,getNormalFromDepth:()=>Ine,getParallaxCorrectNormal:()=>Lne,getRoughness:()=>Rne,getScreenPosition:()=>zne,getShIrradianceAt:()=>Bne,getShadowMaterial:()=>Une,getShadowRenderObjectFunction:()=>Wne,getTextureIndex:()=>Vne,getViewPosition:()=>Hne,globalId:()=>Ire,glsl:()=>Gne,glslFn:()=>Kne,grayscale:()=>qne,greaterThan:()=>Jne,greaterThanEqual:()=>Yne,hash:()=>Xne,highpModelNormalViewMatrix:()=>Zne,highpModelViewMatrix:()=>Qne,hue:()=>$ne,increment:()=>ere,incrementBefore:()=>tre,instance:()=>nre,instanceIndex:()=>rre,instancedArray:()=>ire,instancedBufferAttribute:()=>are,instancedDynamicBufferAttribute:()=>ore,instancedMesh:()=>sre,int:()=>cre,inverseSqrt:()=>lre,inversesqrt:()=>ure,invocationLocalIndex:()=>dre,invocationSubgroupIndex:()=>fre,ior:()=>pre,iridescence:()=>mre,iridescenceIOR:()=>hre,iridescenceThickness:()=>gre,ivec2:()=>_re,ivec3:()=>vre,ivec4:()=>yre,js:()=>bre,label:()=>xre,length:()=>Sre,lengthSq:()=>Cre,lessThan:()=>wre,lessThanEqual:()=>Tre,lightPosition:()=>Ere,lightProjectionUV:()=>joe,lightShadowMatrix:()=>Dre,lightTargetDirection:()=>Ore,lightTargetPosition:()=>kre,lightViewPosition:()=>Are,lightingContext:()=>jre,lights:()=>Mre,linearDepth:()=>Nre,linearToneMapping:()=>Pre,localId:()=>Fre,log:()=>Lre,log2:()=>Rre,logarithmicDepthToViewZ:()=>zre,loop:()=>Bre,luminance:()=>Vre,mat2:()=>Ure,mat3:()=>Wre,mat4:()=>Gre,matcapUV:()=>Kre,materialAO:()=>qre,materialAlphaTest:()=>Jre,materialAnisotropy:()=>Yre,materialAnisotropyVector:()=>Xre,materialAttenuationColor:()=>Zre,materialAttenuationDistance:()=>Qre,materialClearcoat:()=>$re,materialClearcoatNormal:()=>eie,materialClearcoatRoughness:()=>tie,materialColor:()=>nie,materialDispersion:()=>rie,materialEmissive:()=>iie,materialIOR:()=>aie,materialIridescence:()=>oie,materialIridescenceIOR:()=>sie,materialIridescenceThickness:()=>cie,materialLightMap:()=>lie,materialLineDashOffset:()=>uie,materialLineDashSize:()=>die,materialLineGapSize:()=>fie,materialLineScale:()=>pie,materialLineWidth:()=>mie,materialMetalness:()=>hie,materialNormal:()=>gie,materialOpacity:()=>_ie,materialPointSize:()=>vie,materialReference:()=>yie,materialReflectivity:()=>bie,materialRefractionRatio:()=>xie,materialRotation:()=>Sie,materialRoughness:()=>Cie,materialSheen:()=>wie,materialSheenRoughness:()=>Tie,materialShininess:()=>Eie,materialSpecular:()=>Die,materialSpecularColor:()=>Oie,materialSpecularIntensity:()=>kie,materialSpecularStrength:()=>Aie,materialThickness:()=>jie,materialTransmission:()=>Mie,max:()=>_M,maxMipLevel:()=>Nie,mediumpModelViewMatrix:()=>Hre,metalness:()=>Pie,min:()=>Fie,mix:()=>vM,mixElement:()=>Iie,mod:()=>Lie,modInt:()=>Rie,modelDirection:()=>zie,modelNormalMatrix:()=>Bie,modelPosition:()=>Vie,modelRadius:()=>Hie,modelScale:()=>Uie,modelViewMatrix:()=>Wie,modelViewPosition:()=>Gie,modelViewProjection:()=>Kie,modelWorldMatrix:()=>qie,modelWorldMatrixInverse:()=>Jie,morphReference:()=>Yie,mrt:()=>Xie,mul:()=>yM,mx_aastep:()=>Zie,mx_cell_noise_float:()=>Qie,mx_contrast:()=>$ie,mx_fractal_noise_float:()=>eae,mx_fractal_noise_vec2:()=>tae,mx_fractal_noise_vec3:()=>nae,mx_fractal_noise_vec4:()=>rae,mx_hsvtorgb:()=>iae,mx_noise_float:()=>aae,mx_noise_vec3:()=>oae,mx_noise_vec4:()=>sae,mx_ramplr:()=>cae,mx_ramptb:()=>lae,mx_rgbtohsv:()=>uae,mx_safepower:()=>dae,mx_splitlr:()=>fae,mx_splittb:()=>pae,mx_srgb_texture_to_lin_rec709:()=>mae,mx_transform_uv:()=>hae,mx_worley_noise_float:()=>gae,mx_worley_noise_vec2:()=>_ae,mx_worley_noise_vec3:()=>vae,namespace:()=>yae,negate:()=>bae,neutralToneMapping:()=>xae,nodeArray:()=>Sae,nodeImmutable:()=>Cae,nodeObject:()=>wae,nodeObjects:()=>Tae,nodeProxy:()=>Eae,normalFlat:()=>Dae,normalGeometry:()=>Oae,normalLocal:()=>kae,normalMap:()=>Aae,normalView:()=>jae,normalWorld:()=>Mae,normalize:()=>Nae,not:()=>Pae,notEqual:()=>Fae,numWorkgroups:()=>Iae,objectDirection:()=>Lae,objectGroup:()=>Rae,objectPosition:()=>zae,objectRadius:()=>Bae,objectScale:()=>Vae,objectViewPosition:()=>Hae,objectWorldMatrix:()=>Uae,oneMinus:()=>Wae,or:()=>Gae,orthographicDepthToViewZ:()=>Kae,oscSawtooth:()=>qae,oscSine:()=>Jae,oscSquare:()=>Yae,oscTriangle:()=>Xae,output:()=>Zae,outputStruct:()=>Qae,overlay:()=>$ae,overloadingFn:()=>eoe,parabola:()=>toe,parallaxDirection:()=>noe,parallaxUV:()=>roe,parameter:()=>ioe,pass:()=>aoe,passTexture:()=>ooe,pcurve:()=>soe,perspectiveDepthToViewZ:()=>coe,pmremTexture:()=>loe,pointShadow:()=>rN,pointUV:()=>uoe,pointWidth:()=>doe,positionGeometry:()=>foe,positionLocal:()=>poe,positionPrevious:()=>moe,positionView:()=>hoe,positionViewDirection:()=>goe,positionWorld:()=>_oe,positionWorldDirection:()=>voe,posterize:()=>yoe,pow:()=>bM,pow2:()=>boe,pow3:()=>xoe,pow4:()=>Soe,premult:()=>Coe,property:()=>woe,radians:()=>Toe,rand:()=>Eoe,range:()=>Doe,rangeFog:()=>Ooe,rangeFogFactor:()=>koe,reciprocal:()=>Aoe,reference:()=>Moe,referenceBuffer:()=>xM,reflect:()=>SM,reflectVector:()=>CM,reflectView:()=>wM,reflector:()=>TM,refract:()=>EM,refractVector:()=>DM,refractView:()=>OM,reinhardToneMapping:()=>kM,remainder:()=>AM,remap:()=>jM,remapClamp:()=>MM,renderGroup:()=>NM,renderOutput:()=>PM,rendererReference:()=>FM,rotate:()=>IM,rotateUV:()=>LM,roughness:()=>RM,round:()=>zM,rtt:()=>BM,sRGBTransferEOTF:()=>VM,sRGBTransferOETF:()=>HM,sampler:()=>UM,samplerComparison:()=>WM,saturate:()=>GM,saturation:()=>KM,screen:()=>qM,screenCoordinate:()=>JM,screenSize:()=>YM,screenUV:()=>XM,scriptable:()=>ZM,scriptableValue:()=>QM,select:()=>$M,setCurrentStack:()=>eN,shaderStages:()=>tN,shadow:()=>nN,shadowPositionWorld:()=>iN,shapeCircle:()=>oN,sharedUniformGroup:()=>aN,sheen:()=>sN,sheenRoughness:()=>cN,shiftLeft:()=>lN,shiftRight:()=>uN,shininess:()=>dN,sign:()=>fN,sin:()=>pN,sinc:()=>mN,skinning:()=>hN,smoothstep:()=>gN,smoothstepElement:()=>_N,specularColor:()=>vN,specularF90:()=>yN,spherizeUV:()=>bN,split:()=>xN,spritesheetUV:()=>SN,sqrt:()=>CN,stack:()=>wN,step:()=>TN,storage:()=>EN,storageBarrier:()=>DN,storageObject:()=>ON,storageTexture:()=>kN,string:()=>AN,struct:()=>jN,sub:()=>MN,subgroupIndex:()=>NN,subgroupSize:()=>PN,tan:()=>FN,tangentGeometry:()=>IN,tangentLocal:()=>LN,tangentView:()=>RN,tangentWorld:()=>zN,temp:()=>BN,texture:()=>VN,texture3D:()=>HN,textureBarrier:()=>UN,textureBicubic:()=>WN,textureCubeUV:()=>GN,textureLoad:()=>KN,textureSize:()=>qN,textureStore:()=>JN,thickness:()=>YN,time:()=>XN,timerDelta:()=>ZN,timerGlobal:()=>QN,timerLocal:()=>$N,toneMapping:()=>eP,toneMappingExposure:()=>tP,toonOutlinePass:()=>nP,transformDirection:()=>rP,transformNormal:()=>iP,transformNormalToView:()=>aP,transformedBentNormalView:()=>oP,transformedBitangentView:()=>sP,transformedBitangentWorld:()=>cP,transformedClearcoatNormalView:()=>lP,transformedNormalView:()=>uP,transformedNormalWorld:()=>dP,transformedTangentView:()=>fP,transformedTangentWorld:()=>pP,transmission:()=>mP,transpose:()=>hP,triNoise3D:()=>gP,triplanarTexture:()=>_P,triplanarTextures:()=>vP,trunc:()=>yP,tslFn:()=>bP,uint:()=>xP,uniform:()=>SP,uniformArray:()=>wP,uniformCubeTexture:()=>CP,uniformGroup:()=>TP,uniformTexture:()=>EP,uniforms:()=>DP,unpremult:()=>OP,userData:()=>kP,uv:()=>AP,uvec2:()=>jP,uvec3:()=>MP,uvec4:()=>NP,varying:()=>FP,varyingProperty:()=>IP,vec2:()=>LP,vec3:()=>RP,vec4:()=>zP,vectorComponents:()=>BP,velocity:()=>VP,vertexColor:()=>HP,vertexIndex:()=>UP,vibrance:()=>WP,viewZToLogarithmicDepth:()=>GP,viewZToOrthographicDepth:()=>KP,viewZToPerspectiveDepth:()=>qP,viewport:()=>JP,viewportBottomLeft:()=>YP,viewportCoordinate:()=>XP,viewportDepthTexture:()=>ZP,viewportLinearDepth:()=>QP,viewportMipTexture:()=>$P,viewportResolution:()=>eF,viewportSafeUV:()=>tF,viewportSharedTexture:()=>nF,viewportSize:()=>rF,viewportTexture:()=>iF,viewportTopLeft:()=>aF,viewportUV:()=>oF,wgsl:()=>sF,wgslFn:()=>cF,workgroupArray:()=>lF,workgroupBarrier:()=>uF,workgroupId:()=>dF,workingToColorSpace:()=>fF,xor:()=>pF});const Sj=F.BRDF_GGX,Cj=F.BRDF_Lambert,wj=F.BasicShadowFilter,Tj=F.Break,Ej=F.Continue,Dj=F.DFGApprox,Oj=F.D_GGX,kj=F.Discard,Aj=F.EPSILON,jj=F.F_Schlick,Mj=F.Fn,Nj=F.INFINITY,Pj=F.If,Fj=F.Switch,Ij=F.Loop,Lj=F.NodeShaderStage,Rj=F.NodeType,zj=F.NodeUpdateType,Bj=F.NodeAccess,Vj=F.PCFShadowFilter,Hj=F.PCFSoftShadowFilter,Uj=F.PI,Wj=F.PI2,Gj=F.Return,Kj=F.Schlick_to_F0,qj=F.ScriptableNodeResources,Jj=F.ShaderNode,Yj=F.TBNViewMatrix,Xj=F.VSMShadowFilter,Zj=F.V_GGX_SmithCorrelated,Qj=F.abs,$j=F.acesFilmicToneMapping,eM=F.acos,tM=F.add,nM=F.addNodeElement,rM=F.agxToneMapping,iM=F.all,aM=F.alphaT,oM=F.and,sM=F.anisotropy,cM=F.anisotropyB,lM=F.anisotropyT,uM=F.any,mee=F.append,hee=F.array,gee=F.arrayBuffer,_ee=F.asin,vee=F.assign,yee=F.atan,bee=F.atan2,xee=F.atomicAdd,See=F.atomicAnd,Cee=F.atomicFunc,wee=F.atomicMax,Tee=F.atomicMin,Eee=F.atomicOr,Dee=F.atomicStore,Oee=F.atomicSub,kee=F.atomicXor,Aee=F.atomicLoad,jee=F.attenuationColor,Mee=F.attenuationDistance,Nee=F.attribute,Pee=F.attributeArray,Fee=F.backgroundBlurriness,Iee=F.backgroundIntensity,Lee=F.backgroundRotation,Ree=F.batch,zee=F.billboarding,Bee=F.bitAnd,Vee=F.bitNot,Hee=F.bitOr,Uee=F.bitXor,Wee=F.bitangentGeometry,Gee=F.bitangentLocal,Kee=F.bitangentView,qee=F.bitangentWorld,Jee=F.bitcast,Yee=F.blendBurn,Xee=F.blendColor,Zee=F.blendDodge,Qee=F.blendOverlay,$ee=F.blendScreen,ete=F.blur,tte=F.bool,nte=F.buffer,rte=F.bufferAttribute,ite=F.bumpMap,ate=F.burn,ote=F.bvec2,ste=F.bvec3,cte=F.bvec4,lte=F.bypass,ute=F.cache,dte=F.call,fte=F.cameraFar,pte=F.cameraIndex,mte=F.cameraNear,hte=F.cameraNormalMatrix,gte=F.cameraPosition,_te=F.cameraProjectionMatrix,vte=F.cameraProjectionMatrixInverse,yte=F.cameraViewMatrix,bte=F.cameraWorldMatrix,xte=F.cbrt,Ste=F.cdl,Cte=F.ceil,wte=F.checker,Tte=F.cineonToneMapping,dM=F.clamp,Ete=F.clearcoat,Dte=F.clearcoatRoughness,Ote=F.code,kte=F.color,Ate=F.colorSpaceToWorking,jte=F.colorToDirection,Mte=F.compute,Nte=F.computeSkinning,Pte=F.cond,Fte=F.Const,Ite=F.context,Lte=F.convert,Rte=F.convertColorSpace,zte=F.convertToTexture,fM=F.cos,Bte=F.cross,Vte=F.cubeTexture,Hte=F.dFdx,Ute=F.dFdy,Wte=F.dashSize,Gte=F.debug,Kte=F.decrement,qte=F.decrementBefore,Jte=F.defaultBuildStages,Yte=F.defaultShaderStages,Xte=F.defined,Zte=F.degrees,Qte=F.deltaTime,$te=F.densityFog,ene=F.densityFogFactor,tne=F.depth,nne=F.depthPass,rne=F.difference,ine=F.diffuseColor,ane=F.directPointLight,one=F.directionToColor,sne=F.dispersion,cne=F.distance,lne=F.div,une=F.dodge,pM=F.dot,dne=F.drawIndex,fne=F.dynamicBufferAttribute,pne=F.element,mne=F.emissive,hne=F.equal,gne=F.equals,_ne=F.equirectUV,vne=F.exp,yne=F.exp2,bne=F.expression,xne=F.faceDirection,Sne=F.faceForward,Cne=F.faceforward,mM=F.float,wne=F.floor,Tne=F.fog,hM=F.fract,Ene=F.frameGroup,Dne=F.frameId,One=F.frontFacing,gM=F.fwidth,kne=F.gain,Ane=F.gapSize,jne=F.getConstNodeType,Mne=F.getCurrentStack,Nne=F.getDirection,Pne=F.getDistanceAttenuation,Fne=F.getGeometryRoughness,Ine=F.getNormalFromDepth,Lne=F.getParallaxCorrectNormal,Rne=F.getRoughness,zne=F.getScreenPosition,Bne=F.getShIrradianceAt,Vne=F.getTextureIndex,Hne=F.getViewPosition,Une=F.getShadowMaterial,Wne=F.getShadowRenderObjectFunction,Gne=F.glsl,Kne=F.glslFn,qne=F.grayscale,Jne=F.greaterThan,Yne=F.greaterThanEqual,Xne=F.hash,Zne=F.highpModelNormalViewMatrix,Qne=F.highpModelViewMatrix,$ne=F.hue,ere=F.increment,tre=F.incrementBefore,nre=F.instance,rre=F.instanceIndex,ire=F.instancedArray,are=F.instancedBufferAttribute,ore=F.instancedDynamicBufferAttribute,sre=F.instancedMesh,cre=F.int,lre=F.inverseSqrt,ure=F.inversesqrt,dre=F.invocationLocalIndex,fre=F.invocationSubgroupIndex,pre=F.ior,mre=F.iridescence,hre=F.iridescenceIOR,gre=F.iridescenceThickness,_re=F.ivec2,vre=F.ivec3,yre=F.ivec4,bre=F.js,xre=F.label,Sre=F.length,Cre=F.lengthSq,wre=F.lessThan,Tre=F.lessThanEqual,Ere=F.lightPosition,Dre=F.lightShadowMatrix,Ore=F.lightTargetDirection,kre=F.lightTargetPosition,Are=F.lightViewPosition,jre=F.lightingContext,Mre=F.lights,Nre=F.linearDepth,Pre=F.linearToneMapping,Fre=F.localId,Ire=F.globalId,Lre=F.log,Rre=F.log2,zre=F.logarithmicDepthToViewZ,Bre=F.loop,Vre=F.luminance,Hre=F.mediumpModelViewMatrix,Ure=F.mat2,Wre=F.mat3,Gre=F.mat4,Kre=F.matcapUV,qre=F.materialAO,Jre=F.materialAlphaTest,Yre=F.materialAnisotropy,Xre=F.materialAnisotropyVector,Zre=F.materialAttenuationColor,Qre=F.materialAttenuationDistance,$re=F.materialClearcoat,eie=F.materialClearcoatNormal,tie=F.materialClearcoatRoughness,nie=F.materialColor,rie=F.materialDispersion,iie=F.materialEmissive,aie=F.materialIOR,oie=F.materialIridescence,sie=F.materialIridescenceIOR,cie=F.materialIridescenceThickness,lie=F.materialLightMap,uie=F.materialLineDashOffset,die=F.materialLineDashSize,fie=F.materialLineGapSize,pie=F.materialLineScale,mie=F.materialLineWidth,hie=F.materialMetalness,gie=F.materialNormal,_ie=F.materialOpacity,vie=F.materialPointSize,yie=F.materialReference,bie=F.materialReflectivity,xie=F.materialRefractionRatio,Sie=F.materialRotation,Cie=F.materialRoughness,wie=F.materialSheen,Tie=F.materialSheenRoughness,Eie=F.materialShininess,Die=F.materialSpecular,Oie=F.materialSpecularColor,kie=F.materialSpecularIntensity,Aie=F.materialSpecularStrength,jie=F.materialThickness,Mie=F.materialTransmission,_M=F.max,Nie=F.maxMipLevel,Pie=F.metalness,Fie=F.min,vM=F.mix,Iie=F.mixElement,Lie=F.mod,Rie=F.modInt,zie=F.modelDirection,Bie=F.modelNormalMatrix,Vie=F.modelPosition,Hie=F.modelRadius,Uie=F.modelScale,Wie=F.modelViewMatrix,Gie=F.modelViewPosition,Kie=F.modelViewProjection,qie=F.modelWorldMatrix,Jie=F.modelWorldMatrixInverse,Yie=F.morphReference,Xie=F.mrt,yM=F.mul,Zie=F.mx_aastep,Qie=F.mx_cell_noise_float,$ie=F.mx_contrast,eae=F.mx_fractal_noise_float,tae=F.mx_fractal_noise_vec2,nae=F.mx_fractal_noise_vec3,rae=F.mx_fractal_noise_vec4,iae=F.mx_hsvtorgb,aae=F.mx_noise_float,oae=F.mx_noise_vec3,sae=F.mx_noise_vec4,cae=F.mx_ramplr,lae=F.mx_ramptb,uae=F.mx_rgbtohsv,dae=F.mx_safepower,fae=F.mx_splitlr,pae=F.mx_splittb,mae=F.mx_srgb_texture_to_lin_rec709,hae=F.mx_transform_uv,gae=F.mx_worley_noise_float,_ae=F.mx_worley_noise_vec2,vae=F.mx_worley_noise_vec3,yae=F.namespace,bae=F.negate,xae=F.neutralToneMapping,Sae=F.nodeArray,Cae=F.nodeImmutable,wae=F.nodeObject,Tae=F.nodeObjects,Eae=F.nodeProxy,Dae=F.normalFlat,Oae=F.normalGeometry,kae=F.normalLocal,Aae=F.normalMap,jae=F.normalView,Mae=F.normalWorld,Nae=F.normalize,Pae=F.not,Fae=F.notEqual,Iae=F.numWorkgroups,Lae=F.objectDirection,Rae=F.objectGroup,zae=F.objectPosition,Bae=F.objectRadius,Vae=F.objectScale,Hae=F.objectViewPosition,Uae=F.objectWorldMatrix,Wae=F.oneMinus,Gae=F.or,Kae=F.orthographicDepthToViewZ,qae=F.oscSawtooth,Jae=F.oscSine,Yae=F.oscSquare,Xae=F.oscTriangle,Zae=F.output,Qae=F.outputStruct,$ae=F.overlay,eoe=F.overloadingFn,toe=F.parabola,noe=F.parallaxDirection,roe=F.parallaxUV,ioe=F.parameter,aoe=F.pass,ooe=F.passTexture,soe=F.pcurve,coe=F.perspectiveDepthToViewZ,loe=F.pmremTexture,uoe=F.pointUV,doe=F.pointWidth,foe=F.positionGeometry,poe=F.positionLocal,moe=F.positionPrevious,hoe=F.positionView,goe=F.positionViewDirection,_oe=F.positionWorld,voe=F.positionWorldDirection,yoe=F.posterize,bM=F.pow,boe=F.pow2,xoe=F.pow3,Soe=F.pow4,Coe=F.premult,woe=F.property,Toe=F.radians,Eoe=F.rand,Doe=F.range,Ooe=F.rangeFog,koe=F.rangeFogFactor,Aoe=F.reciprocal,joe=F.lightProjectionUV,Moe=F.reference,xM=F.referenceBuffer,SM=F.reflect,CM=F.reflectVector,wM=F.reflectView,TM=F.reflector,EM=F.refract,DM=F.refractVector,OM=F.refractView,kM=F.reinhardToneMapping,AM=F.remainder,jM=F.remap,MM=F.remapClamp,NM=F.renderGroup,PM=F.renderOutput,FM=F.rendererReference,IM=F.rotate,LM=F.rotateUV,RM=F.roughness,zM=F.round,BM=F.rtt,VM=F.sRGBTransferEOTF,HM=F.sRGBTransferOETF,UM=F.sampler,WM=F.samplerComparison,GM=F.saturate,KM=F.saturation,qM=F.screen,JM=F.screenCoordinate,YM=F.screenSize,XM=F.screenUV,ZM=F.scriptable,QM=F.scriptableValue,$M=F.select,eN=F.setCurrentStack,tN=F.shaderStages,nN=F.shadow,rN=F.pointShadow,iN=F.shadowPositionWorld,aN=F.sharedUniformGroup,oN=F.shapeCircle,sN=F.sheen,cN=F.sheenRoughness,lN=F.shiftLeft,uN=F.shiftRight,dN=F.shininess,fN=F.sign,pN=F.sin,mN=F.sinc,hN=F.skinning,gN=F.smoothstep,_N=F.smoothstepElement,vN=F.specularColor,yN=F.specularF90,bN=F.spherizeUV,xN=F.split,SN=F.spritesheetUV,CN=F.sqrt,wN=F.stack,TN=F.step,EN=F.storage,DN=F.storageBarrier,ON=F.storageObject,kN=F.storageTexture,AN=F.string,jN=F.struct,MN=F.sub,NN=F.subgroupIndex,PN=F.subgroupSize,FN=F.tan,IN=F.tangentGeometry,LN=F.tangentLocal,RN=F.tangentView,zN=F.tangentWorld,BN=F.temp,VN=F.texture,HN=F.texture3D,UN=F.textureBarrier,WN=F.textureBicubic,GN=F.textureCubeUV,KN=F.textureLoad,qN=F.textureSize,JN=F.textureStore,YN=F.thickness,XN=F.time,ZN=F.timerDelta,QN=F.timerGlobal,$N=F.timerLocal,eP=F.toneMapping,tP=F.toneMappingExposure,nP=F.toonOutlinePass,rP=F.transformDirection,iP=F.transformNormal,aP=F.transformNormalToView,oP=F.transformedBentNormalView,sP=F.transformedBitangentView,cP=F.transformedBitangentWorld,lP=F.transformedClearcoatNormalView,uP=F.transformedNormalView,dP=F.transformedNormalWorld,fP=F.transformedTangentView,pP=F.transformedTangentWorld,mP=F.transmission,hP=F.transpose,gP=F.triNoise3D,_P=F.triplanarTexture,vP=F.triplanarTextures,yP=F.trunc,bP=F.tslFn,xP=F.uint,SP=F.uniform,CP=F.uniformCubeTexture,wP=F.uniformArray,TP=F.uniformGroup,EP=F.uniformTexture,DP=F.uniforms,OP=F.unpremult,kP=F.userData,AP=F.uv,jP=F.uvec2,MP=F.uvec3,NP=F.uvec4,PP=F.Var,FP=F.varying,IP=F.varyingProperty,LP=F.vec2,RP=F.vec3,zP=F.vec4,BP=F.vectorComponents,VP=F.velocity,HP=F.vertexColor,UP=F.vertexIndex,WP=F.vibrance,GP=F.viewZToLogarithmicDepth,KP=F.viewZToOrthographicDepth,qP=F.viewZToPerspectiveDepth,JP=F.viewport,YP=F.viewportBottomLeft,XP=F.viewportCoordinate,ZP=F.viewportDepthTexture,QP=F.viewportLinearDepth,$P=F.viewportMipTexture,eF=F.viewportResolution,tF=F.viewportSafeUV,nF=F.viewportSharedTexture,rF=F.viewportSize,iF=F.viewportTexture,aF=F.viewportTopLeft,oF=F.viewportUV,sF=F.wgsl,cF=F.wgslFn,lF=F.workgroupArray,uF=F.workgroupBarrier,dF=F.workgroupId,fF=F.workingToColorSpace,pF=F.xor;function mF(e,t,n=1){let r=e.rgb,i=t.rgb,a=yM(r,i),o=yM(t.a,n),s=vM(r,a,o),c=_M(e.a,yM(t.a,n));return zP(s,c)}function hF(e,t,n=1){let r=yM(t.a,n),i=tM(r,yM(e.a,MN(1,r))),a=tM(yM(t.rgb,r),yM(e.rgb,yM(e.a,MN(1,r))));return zP(a,i)}const gF={normal:hF,multiply:mF};function _F(e,t,n=`normal`,r=1){let i=gF[n]||gF.normal;return i(e,t,r)}function vF(e,t){let n=yM(e.a,t.a);return zP(e.rgb,n)}function yF(e,t){let n=MN(1,t.a),r=yM(e.a,n);return zP(e.rgb,r)}function bF(e,t){let n=RP(.2126,.7152,.0722),r=pM(t.rgb,n),i=yM(e.a,r);return zP(e.rgb,i)}function xF(e,t){let n=RP(.2126,.7152,.0722),r=pM(t.rgb,n),i=MN(1,r),a=yM(e.a,i);return zP(e.rgb,a)}const SF={alpha:vF,alphaInverted:yF,luminance:bF,luminanceInverted:xF};function CF(e,t,n=`alpha`){let r=SF[n]||SF.alpha;return r(e,t)}const wF={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let TF=!1;const EF=()=>{try{if(wF!==void 0){let{MODE:e,DEV:t}=wF;return t||e===`development`}if(typeof window<`u`&&window.location){let e=window.location.hostname;return e===`localhost`||e===`127.0.0.1`||e.endsWith(`.local`)||e.includes(`dev.`)||e.startsWith(`dev-`)}return!1}catch{return!1}};function DF(){let e=`renderer_${Math.random().toString(36).substring(2,11)}`,t=null,n,r,i,a,o,s={nodes:new Map,rootId:null,idToNodeId:new Map},c=null,l=null,u=null,d=!1,f=!1,p=!1,m=null,h=!1,g=!0,_=0,v=0,y=0,b=0,x=8,S=.5,ee=.5,te=!1,ne=!1,re=!1,ie=[],ae=!1,oe=[],se=!1,ce=()=>{var e,t,n;return(e=t=(n=window).matchMedia)?.call(n,`(prefers-reduced-motion: reduce)`).matches??!1},le=(e,t)=>{if(e===_&&t===v)return;let i=performance.now();if(i-y<x)return;_=e,v=t,y=i,n.setSize(e,t,!1);let o=e/t,c=2,l=c*o;r.left=-l/2,r.right=l/2,r.top=c/2,r.bottom=-c/2,r.updateProjectionMatrix(),a.scale.set(l,c,1),s.rootId&&p&&fe(),we().catch(console.warn)},ue=e=>{if(!n||!r||!a)return;let t=e[0];if(!t)return;let{width:i,height:o}=t.contentRect,s=Math.round(i),c=Math.round(o);le(s,c)},de=e=>{let t=e[0];t&&(h=t.isIntersecting,h?(o&&d&&s.rootId&&fe(),g&&Te()):Ee())},fe=()=>{if(!s.rootId||!o||ne)return;let e=s.nodes.get(s.rootId);if(e){ne=!0;try{let e=_e(s.rootId);e&&o&&(o.fragmentNode=e,o.needsUpdate=!0)}catch(e){console.error(`Error composing shader tree:`,e)}finally{ne=!1}h&&we().catch(console.warn)}},pe=e=>{let t=[];return s.nodes.forEach(n=>{n.parentId===e&&t.push(n)}),t},me=e=>{for(let[t,n]of s.nodes.entries())if(n.metadata.id===e)return t;return null},he=(e,t,n,r)=>{var i,a;if(!(i=a=t.metadata.mask)?.source)return e;let o=t.metadata.mask.source,s=me(o);if(!s)return e;if(r.has(s))return console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`),e;let c=new Set(r);c.add(n);let l=_e(s,c),u=t.metadata.mask.type||`alpha`;return CF(e,l,u)},ge=e=>{var t,n;let r=s.nodes.get(e);if(!r||!r.metadata.id)return!1;let i=r.metadata.id;for(let e of s.nodes.values())if((t=n=e.metadata.mask)?.source===i)return!0;return!1},_e=(e,n=new Set)=>{let r=s.nodes.get(e);if(!r)return zP(0,0,0,0);let i=e=>{r.cleanupCallbacks.push(e)},a=e=>{r.beforeRenderCallbacks.push(e)},o=e=>{r.afterRenderCallbacks.push(e)},c=pe(e);if(c.length===0){let s=r.fragmentNodeFunc({uniforms:r.uniforms??{},childNode:void 0,onCleanup:i,onBeforeRender:a,onAfterRender:o,canvas:t});return he(s,r,e,n)}else{let s=[...c].sort((e,t)=>e.metadata.renderOrder-t.metadata.renderOrder),l=r.parentId===null;if(l){let c;for(let e of s){let t=e.metadata.opacity??(ge(e.id)?0:1);if(t===0&&!ge(e.id))continue;let r=_e(e.id,n),i;i=e.metadata.opacity===void 0?ge(e.id)?0:1:e.metadata.opacity,c=c===void 0?i===1?_F(zP(1,1,1,0),r,`normal`,1):_F(zP(1,1,1,0),r,e.metadata.blendMode,i):_F(c,r,e.metadata.blendMode,i)}let l=r.fragmentNodeFunc({uniforms:r.uniforms??{},childNode:c,onCleanup:i,onBeforeRender:a,onAfterRender:o,canvas:t});return he(l,r,e,n)}else{let c;for(let e of s){let t=_e(e.id,n),r=e.metadata.opacity??(ge(e.id)?0:1);if(r===0&&!ge(e.id))continue;let i;i=e.metadata.opacity===void 0?ge(e.id)?0:1:e.metadata.opacity,c=c===void 0?i===1?_F(zP(1,1,1,0),t,`normal`,1):_F(zP(1,1,1,0),t,e.metadata.blendMode,i):_F(c,t,e.metadata.blendMode,i)}let l=r.fragmentNodeFunc({uniforms:r.uniforms??{},childNode:c,onCleanup:i,onBeforeRender:a,onAfterRender:o,canvas:t});return he(l,r,e,n)}}},ve=(e,t,n,r,i={})=>{let a=0;if(n!==null){let e=Array.from(s.nodes.values()).filter(e=>e.parentId===n);e.length>0&&(a=Math.max(...e.map(e=>e.metadata.renderOrder))+1)}let c={id:e,fragmentNodeFunc:t,parentId:n,metadata:{blendMode:r?.blendMode||`normal`,opacity:r?.opacity,id:r?.id,mask:r?.mask,renderOrder:r?.renderOrder===void 0?a:r?.renderOrder},uniforms:i,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};s.nodes.set(e,c),n===null&&(s.rootId=e),o&&d&&(ie.includes(e)||ie.push(e),ae||(ae=!0,queueMicrotask(()=>{ae=!1,ie=[],fe()})))},ye=(e,t,n)=>{let r=s.nodes.get(e);if(!r||!r.uniforms){console.warn(`Node or uniforms not found for ID: ${e}`);return}let i=r.uniforms[t];if(!i||!i.uniform){console.warn(`Uniform ${t} not found in node: ${e}`);return}i.uniform.value=n,h&&we()},be=(e,t)=>{var n,r,i,a,c,l,u,f;let p=s.nodes.get(e);if(!p)return;let m=!1;t.blendMode!==void 0&&p.metadata.blendMode!==t.blendMode&&(p.metadata.blendMode=t.blendMode,m=!0),t.opacity!==void 0&&p.metadata.opacity!==t.opacity&&(p.metadata.opacity=t.opacity,m=!0),t.renderOrder!==void 0&&p.metadata.renderOrder!==t.renderOrder&&(p.metadata.renderOrder=t.renderOrder,m=!0),t.id!==void 0&&p.metadata.id!==t.id&&(p.metadata.id=t.id,m=!0),t.mask!==void 0&&((n=c=p.metadata.mask)?.source!==(r=l=t.mask)?.source||(i=u=p.metadata.mask)?.type!==(a=f=t.mask)?.type)&&(p.metadata.mask=t.mask,m=!0),m&&o&&d?(oe.includes(e)||oe.push(e),se||(se=!0,queueMicrotask(()=>{se=!1,oe=[],fe()}))):h&&we()},xe=e=>{if(!s.nodes.has(e))return;let t=s.nodes.get(e);if(t&&t.cleanupCallbacks.length>0)for(let n of t.cleanupCallbacks)try{n()}catch(t){console.error(`Error executing cleanup callback for node ${e}:`,t)}let n=pe(e);for(let e of n)xe(e.id);s.rootId===e&&(s.rootId=null),s.nodes.delete(e),o&&d&&fe()},Se=e=>{let t={deltaTime:e,pointer:{x:S,y:ee},pointerActive:te,dimensions:{width:_,height:v}};for(let e of s.nodes.values())if(e.beforeRenderCallbacks.length>0)for(let n of e.beforeRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing before render callback for node ${e.id}:`,t)}},Ce=e=>{let t={deltaTime:e,pointer:{x:S,y:ee},pointerActive:te,dimensions:{width:_,height:v}};for(let e of s.nodes.values())if(e.afterRenderCallbacks.length>0)for(let n of e.afterRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing after render callback for node ${e.id}:`,t)}},we=async()=>{if(!d||!n||!i||!r||!o)return;let e=performance.now(),t=b>0?(e-b)/1e3:.016,a=Math.min(t,.1);b=e,Se(a);try{if(ne)return;n instanceof bj?await n.renderAsync(i,r).then(()=>{d&&Ce(a)}).catch(e=>{console.error(`WebGPU render error:`,e)}):(n.render(i,r),Ce(a))}catch(e){console.error(`Render frame error:`,e)}},Te=()=>{if(c||!g||!h)return;let e=()=>{c=requestAnimationFrame(e),we().catch(console.warn)};e()},Ee=()=>{c&&(cancelAnimationFrame(c),c=null)},De=n=>{if(!t){console.log(`[${e}] No canvas element in updatePointerCoords`);return}let r,i;if(`touches`in n){if(n.touches.length===0)return;r=n.touches[0].clientX,i=n.touches[0].clientY}else r=n.clientX,i=n.clientY;let a=t.getBoundingClientRect(),o=(r-a.left)/a.width,s=(i-a.top)/a.height;S=o,ee=s},Oe=e=>{De(e)},ke=e=>{De(e)},Ae=()=>{te=!1,we().catch(console.warn)},je=()=>{te=!1,we().catch(console.warn)},Me=()=>{te=!0,we().catch(console.warn)},Ne=()=>{te=!0,we().catch(console.warn)},Pe=async({canvas:s})=>{if(d||f)return;f=!0,m=new AbortController;let c=m;try{if(t=s,i=new bo,i.background=null,r=new js(-1,1,1,-1,.1,10),r.position.z=1,r.lookAt(0,0,0),re||(window.addEventListener(`mousemove`,Oe),window.addEventListener(`touchmove`,ke),window.addEventListener(`mouseup`,Ae),window.addEventListener(`touchend`,je),s.addEventListener(`mousedown`,Me),s.addEventListener(`touchstart`,Ne),re=!0,console.log(`[${e}] Added event listeners`)),c.signal.aborted)return;try{if(n=new bj({canvas:s,antialias:!0,alpha:!0,depth:!1,powerPreference:`high-performance`}),await n.init(),c.signal.aborted){n.dispose();return}}catch(e){if(c.signal.aborted)return;console.error(`[Shaders] WebGPU initialization error:`,e);return}if(c.signal.aborted){n&&n.dispose();return}n.setPixelRatio(Math.min(window.devicePixelRatio,2)),n.outputColorSpace=hn,o=new dv({transparent:!0}),o.fragmentNode=zP(0,0,0,0);let f=new Ho(2,2);a=new Za(f,o),i.add(a),l=new ResizeObserver(ue),l.observe(s),u=new IntersectionObserver(de,{threshold:0}),u.observe(s),g=!ce();let{width:m,height:_}=s.getBoundingClientRect();le(Math.round(m),Math.round(_)),p=!0,await we(),g&&h&&Te(),c.signal.aborted||(d=!0)}catch(e){console.error(`[Shaders] Initialization error:`,e)}finally{f=!1,m===c&&(m=null)}},Fe=()=>{!EF()||TF||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),TF=!0)},Ie=()=>{if(console.log(`[${e}] Cleanup called`),m&&m.abort(),l&&(l.disconnect(),l=null),u&&(u.disconnect(),u=null),re&&(console.log(`[${e}] Removing event listeners`),t&&(t.removeEventListener(`mousedown`,Me),t.removeEventListener(`touchstart`,Ne)),window&&(window.removeEventListener(`mousemove`,Oe),window.removeEventListener(`touchmove`,ke),window.removeEventListener(`mouseup`,Ae),window.removeEventListener(`touchend`,je)),re=!1),Ee(),s.nodes.clear(),s.rootId=null,s.idToNodeId.clear(),ie=[],ae=!1,oe=[],se=!1,a&&(i&&i.remove(a),a.geometry&&a.geometry.dispose(),a.material instanceof va&&a.material.dispose()),n&&typeof n.dispose==`function`)try{n.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}t=null,n=null,r=null,i=null,a=null,o=null,d=!1,f=!1,p=!1,m=null,_=0,v=0,h=!1,g=!0,S=.5,ee=.5,te=!1};return{initialize:Pe,cleanup:Ie,registerNode:ve,removeNode:xe,updateUniformValue:ye,updateNodeMetadata:be,showLicenseWarning:Fe}}const{uniform:OF}=xj;function kF(e,t,n){let r={};return Object.entries(e.props).forEach(([e,i])=>{let a=t[e],o=a;i.transform&&(o=i.transform(a)),r[e]={uniform:OF(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:AF,fract:jF,sin:MF,dot:NF}=xj,PF=e=>jF(MF(NF(e,AF(12.12345,78.12345))).mul(40000.12345)),Noe=(e=.03)=>t=>PF(t).mul(e).mul(.10012345),{vec2:FF}=xj,Poe=(e=FF(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=xj,c=r*1.618033988749895,l=r*2.718281828459045,u=(Math.sin(r)+2)*5,d=(Math.cos(r)+2)*5,f=i(a(e.x.mul(n).mul(u).add(s.mul(.1)).add(c)),o(e.y.mul(n).mul(u).add(s.mul(.1)).add(l))),p=i(a(e.y.mul(n).mul(d).add(s.mul(.05)).add(l)),o(e.x.mul(n).mul(d).add(s.mul(.05)).add(c))),m=f.add(p).mul(t);return e.add(m)},Foe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=xj,c=a(a(e.r,e.g),e.b),l=o(n,n+r,c).mul(i).mul(1),u=e.rgb.add(t.rgb.mul(l));return s(u,e.a)},Ioe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=xj,c=s(),l=c.x.sub(.5).sub(a(r)).mul(2),u=c.y.sub(.5).add(a(i)).mul(2),d=l.mul(l).add(u.mul(u)).sqrt();return a(1).sub(o(a(1).sub(a(t)),a(1).sub(a(t)).add(a(n)),d.mul(a(1).add(a(n)))))},IF=`177`,LF=0,RF=3,zF=0,BF=1,VF=0,HF=1,UF=100,WF=204,GF=205,KF=3,qF=0,JF=0,YF=300,XF=301,ZF=302,QF=306,$F=1e3,eI=1001,tI=1002,nI=1003,rI=1006,iI=1008,aI=1008,oI=1009,sI=1013,cI=1014,lI=1015,uI=1016,dI=1023,fI=1026,pI=1027,mI=1028,hI=1030,gI=2300,_I=2301,vI=2302,yI=2400,bI=2401,xI=2402,SI=0,CI=1,wI=``,TI=`srgb`,EI=`srgb-linear`,DI=`linear`,OI=`srgb`,kI=7680,AI=519,jI=512,MI=513,NI=514,PI=515,FI=516,II=517,LI=518,RI=519,zI=35044,BI=35048,VI=2e3,HI=2001;var UI=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const WI=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let GI=1234567;const KI=Math.PI/180,qI=180/Math.PI;function JI(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=WI[e&255]+WI[e>>8&255]+WI[e>>16&255]+WI[e>>24&255]+`-`+WI[t&255]+WI[t>>8&255]+`-`+WI[t>>16&15|64]+WI[t>>24&255]+`-`+WI[n&63|128]+WI[n>>8&255]+`-`+WI[n>>16&255]+WI[n>>24&255]+WI[r&255]+WI[r>>8&255]+WI[r>>16&255]+WI[r>>24&255];return i.toLowerCase()}function YI(e,t,n){return Math.max(t,Math.min(n,e))}function XI(e,t){return(e%t+t)%t}function ZI(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function QI(e,t,n){return e===t?0:(n-e)/(t-e)}function $I(e,t,n){return(1-n)*e+n*t}function eL(e,t,n,r){return $I(e,t,1-Math.exp(-n*r))}function tL(e,t=1){return t-Math.abs(XI(e,t*2)-t)}function nL(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function rL(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function iL(e,t){return e+Math.floor(Math.random()*(t-e+1))}function aL(e,t){return e+Math.random()*(t-e)}function oL(e){return e*(.5-Math.random())}function sL(e){e!==void 0&&(GI=e);let t=GI+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function cL(e){return e*KI}function lL(e){return e*qI}function uL(e){return(e&e-1)==0&&e!==0}function dL(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function fL(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function pL(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function mL(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function hL(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const gL={DEG2RAD:KI,RAD2DEG:qI,generateUUID:JI,clamp:YI,euclideanModulo:XI,mapLinear:ZI,inverseLerp:QI,lerp:$I,damp:eL,pingpong:tL,smoothstep:nL,smootherstep:rL,randInt:iL,randFloat:aL,randFloatSpread:oL,seededRandom:sL,degToRad:cL,radToDeg:lL,isPowerOfTwo:uL,ceilPowerOfTwo:dL,floorPowerOfTwo:fL,setQuaternionFromProperEuler:pL,normalize:hL,denormalize:mL};var _L=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=YI(this.x,e.x,t.x),this.y=YI(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=YI(this.x,e,t),this.y=YI(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(YI(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(YI(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},vL=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(YI(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},L=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(bL.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(bL.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=YI(this.x,e.x,t.x),this.y=YI(this.y,e.y,t.y),this.z=YI(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=YI(this.x,e,t),this.y=YI(this.y,e,t),this.z=YI(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(YI(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return yL.copy(this).projectOnVector(e),this.sub(yL)}reflect(e){return this.sub(yL.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(YI(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const yL=new L,bL=new vL;var xL=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(SL.makeScale(e,t)),this}rotate(e){return this.premultiply(SL.makeRotation(-e)),this}translate(e,t){return this.premultiply(SL.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const SL=new xL;function CL(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function wL(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}const TL={};function EL(e){e in TL||(TL[e]=!0,console.warn(e))}const DL=new xL().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),OL=new xL().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function kL(){let e={enabled:!0,workingColorSpace:EI,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===OI&&(e.r=jL(e.r),e.g=jL(e.g),e.b=jL(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===OI&&(e.r=ML(e.r),e.g=ML(e.g),e.b=ML(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===wI?DI:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return EL(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return EL(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[EI]:{primaries:t,whitePoint:r,transfer:DI,toXYZ:DL,fromXYZ:OL,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:TI},outputColorSpaceConfig:{drawingBufferColorSpace:TI}},[TI]:{primaries:t,whitePoint:r,transfer:OI,toXYZ:DL,fromXYZ:OL,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:TI}}}),e}const AL=kL();function jL(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function ML(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let NL;var PL=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{NL===void 0&&(NL=wL(`canvas`)),NL.width=e.width,NL.height=e.height;let t=NL.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=NL}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=wL(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=jL(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(jL(t[e]/255)*255):t[e]=jL(t[e]);return{data:t,width:e.width,height:e.height}}else return console.warn(`THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}};let FL=0;var IL=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:FL++}),this.uuid=JI(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(LL(r[t].image)):e.push(LL(r[t]))}else e=LL(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function LL(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?PL.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let RL=0;const zL=new L;var BL=class e extends UI{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=eI,i=eI,a=rI,o=iI,s=dI,c=oI,l=e.DEFAULT_ANISOTROPY,u=wI){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:RL++}),this.uuid=JI(),this.name=``,this.source=new IL(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new _L(0,0),this.repeat=new _L(1,1),this.center=new _L(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xL,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(zL).x}get height(){return this.source.getSize(zL).y}get depth(){return this.source.getSize(zL).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==YF)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case $F:e.x-=Math.floor(e.x);break;case eI:e.x=e.x<0?0:1;break;case tI:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case $F:e.y-=Math.floor(e.y);break;case eI:e.y=e.y<0?0:1;break;case tI:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};BL.DEFAULT_IMAGE=null,BL.DEFAULT_MAPPING=YF,BL.DEFAULT_ANISOTROPY=1;var VL=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=YI(this.x,e.x,t.x),this.y=YI(this.y,e.y,t.y),this.z=YI(this.z,e.z,t.z),this.w=YI(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=YI(this.x,e,t),this.y=YI(this.y,e,t),this.z=YI(this.z,e,t),this.w=YI(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(YI(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},HL=class extends UI{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rI,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new VL(0,0,e,t),this.scissorTest=!1,this.viewport=new VL(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new BL(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:rI,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new IL(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},UL=class extends BL{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=nI,this.minFilter=nI,this.wrapR=eI,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},WL=class{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(KL.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(KL.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=KL.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,KL):KL.fromBufferAttribute(r,t),KL.applyMatrix4(e.matrixWorld),this.expandByPoint(KL);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),qL.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),qL.copy(e.boundingBox)),qL.applyMatrix4(e.matrixWorld),this.union(qL)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,KL),KL.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eR),tR.subVectors(this.max,eR),JL.subVectors(e.a,eR),YL.subVectors(e.b,eR),XL.subVectors(e.c,eR),ZL.subVectors(YL,JL),QL.subVectors(XL,YL),$L.subVectors(JL,XL);let t=[0,-ZL.z,ZL.y,0,-QL.z,QL.y,0,-$L.z,$L.y,ZL.z,0,-ZL.x,QL.z,0,-QL.x,$L.z,0,-$L.x,-ZL.y,ZL.x,0,-QL.y,QL.x,0,-$L.y,$L.x,0];return!iR(t,JL,YL,XL,tR)||(t=[1,0,0,0,1,0,0,0,1],!iR(t,JL,YL,XL,tR))?!1:(nR.crossVectors(ZL,QL),t=[nR.x,nR.y,nR.z],iR(t,JL,YL,XL,tR))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,KL).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(KL).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(GL[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),GL[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),GL[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),GL[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),GL[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),GL[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),GL[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),GL[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(GL),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const GL=[new L,new L,new L,new L,new L,new L,new L,new L],KL=new L,qL=new WL,JL=new L,YL=new L,XL=new L,ZL=new L,QL=new L,$L=new L,eR=new L,tR=new L,nR=new L,rR=new L;function iR(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){rR.fromArray(e,a);let o=i.x*Math.abs(rR.x)+i.y*Math.abs(rR.y)+i.z*Math.abs(rR.z),s=t.dot(rR),c=n.dot(rR),l=r.dot(rR);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const aR=new WL,oR=new L,sR=new L;var cR=class{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?aR.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;oR.subVectors(e,this.center);let t=oR.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(oR,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(sR.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oR.copy(e.center).add(sR)),this.expandByPoint(oR.copy(e.center).sub(sR))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const lR=new L,uR=new L,dR=new L,fR=new L,pR=new L,mR=new L,hR=new L;var gR=class{constructor(e=new L,t=new L(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,lR)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=lR.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(lR.copy(this.origin).addScaledVector(this.direction,t),lR.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){uR.copy(e).add(t).multiplyScalar(.5),dR.copy(t).sub(e).normalize(),fR.copy(this.origin).sub(uR);let i=e.distanceTo(t)*.5,a=-this.direction.dot(dR),o=fR.dot(this.direction),s=-fR.dot(dR),c=fR.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(uR).addScaledVector(dR,d),f}intersectSphere(e,t){lR.subVectors(e.center,this.origin);let n=lR.dot(this.direction),r=lR.dot(lR)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,lR)!==null}intersectTriangle(e,t,n,r,i){pR.subVectors(t,e),mR.subVectors(n,e),hR.crossVectors(pR,mR);let a=this.direction.dot(hR),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fR.subVectors(this.origin,e);let s=o*this.direction.dot(mR.crossVectors(fR,mR));if(s<0)return null;let c=o*this.direction.dot(pR.cross(fR));if(c<0||s+c>a)return null;let l=-o*fR.dot(hR);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},_R=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/vR.setFromMatrixColumn(e,0).length(),i=1/vR.setFromMatrixColumn(e,1).length(),a=1/vR.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(bR,e,xR)}lookAt(e,t,n){let r=this.elements;return wR.subVectors(e,t),wR.lengthSq()===0&&(wR.z=1),wR.normalize(),SR.crossVectors(n,wR),SR.lengthSq()===0&&(Math.abs(n.z)===1?wR.x+=1e-4:wR.z+=1e-4,wR.normalize(),SR.crossVectors(n,wR)),SR.normalize(),CR.crossVectors(wR,SR),r[0]=SR.x,r[4]=CR.x,r[8]=wR.x,r[1]=SR.y,r[5]=CR.y,r[9]=wR.y,r[2]=SR.z,r[6]=CR.z,r[10]=wR.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=vR.set(r[0],r[1],r[2]).length(),a=vR.set(r[4],r[5],r[6]).length(),o=vR.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],yR.copy(this);let c=1/i,l=1/a,u=1/o;return yR.elements[0]*=c,yR.elements[1]*=c,yR.elements[2]*=c,yR.elements[4]*=l,yR.elements[5]*=l,yR.elements[6]*=l,yR.elements[8]*=u,yR.elements[9]*=u,yR.elements[10]*=u,t.setFromRotationMatrix(yR),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=VI){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===VI)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===HI)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=VI){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===VI)p=(a+i)*u,m=-2*u;else if(o===HI)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const vR=new L,yR=new _R,bR=new L(0,0,0),xR=new L(1,1,1),SR=new L,CR=new L,wR=new L,TR=new _R,ER=new vL;var DR=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(YI(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-YI(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(YI(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-YI(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(YI(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-YI(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return TR.makeRotationFromQuaternion(e),this.setFromRotationMatrix(TR,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ER.setFromEuler(this),this.setFromQuaternion(ER,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};DR.DEFAULT_ORDER=`XYZ`;var OR=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}};let kR=0;const AR=new L,jR=new vL,MR=new _R,NR=new L,PR=new L,FR=new L,IR=new vL,LR=new L(1,0,0),RR=new L(0,1,0),zR=new L(0,0,1),BR={type:`added`},VR={type:`removed`},HR={type:`childadded`,child:null},UR={type:`childremoved`,child:null};var WR=class e extends UI{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:kR++}),this.uuid=JI(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new L,n=new DR,r=new vL,i=new L(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new _R},normalMatrix:{value:new xL}}),this.matrix=new _R,this.matrixWorld=new _R,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new OR,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return jR.setFromAxisAngle(e,t),this.quaternion.multiply(jR),this}rotateOnWorldAxis(e,t){return jR.setFromAxisAngle(e,t),this.quaternion.premultiply(jR),this}rotateX(e){return this.rotateOnAxis(LR,e)}rotateY(e){return this.rotateOnAxis(RR,e)}rotateZ(e){return this.rotateOnAxis(zR,e)}translateOnAxis(e,t){return AR.copy(e).applyQuaternion(this.quaternion),this.position.add(AR.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(LR,e)}translateY(e){return this.translateOnAxis(RR,e)}translateZ(e){return this.translateOnAxis(zR,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(MR.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?NR.copy(e):NR.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),PR.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?MR.lookAt(PR,NR,this.up):MR.lookAt(NR,PR,this.up),this.quaternion.setFromRotationMatrix(MR),r&&(MR.extractRotation(r.matrixWorld),jR.setFromRotationMatrix(MR),this.quaternion.premultiply(jR.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error(`THREE.Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(BR),HR.child=e,this.dispatchEvent(HR),HR.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(VR),UR.child=e,this.dispatchEvent(UR),UR.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),MR.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),MR.multiply(e.parent.matrixWorld)),e.applyMatrix4(MR),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(BR),HR.child=e,this.dispatchEvent(HR),HR.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(PR,e,FR),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(PR,IR,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};WR.DEFAULT_UP=new L(0,1,0),WR.DEFAULT_MATRIX_AUTO_UPDATE=!0,WR.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const GR=new L,KR=new L,qR=new L,JR=new L,YR=new L,XR=new L,ZR=new L,QR=new L,$R=new L,ez=new L,tz=new VL,nz=new VL,rz=new VL;var iz=class e{constructor(e=new L,t=new L,n=new L){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),GR.subVectors(e,t),r.cross(GR);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){GR.subVectors(r,t),KR.subVectors(n,t),qR.subVectors(e,t);let a=GR.dot(GR),o=GR.dot(KR),s=GR.dot(qR),c=KR.dot(KR),l=KR.dot(qR),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,JR)===null?!1:JR.x>=0&&JR.y>=0&&JR.x+JR.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,JR)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,JR.x),s.addScaledVector(a,JR.y),s.addScaledVector(o,JR.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return tz.setScalar(0),nz.setScalar(0),rz.setScalar(0),tz.fromBufferAttribute(e,t),nz.fromBufferAttribute(e,n),rz.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(tz,i.x),a.addScaledVector(nz,i.y),a.addScaledVector(rz,i.z),a}static isFrontFacing(e,t,n,r){return GR.subVectors(n,t),KR.subVectors(e,t),GR.cross(KR).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return GR.subVectors(this.c,this.b),KR.subVectors(this.a,this.b),GR.cross(KR).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;YR.subVectors(r,n),XR.subVectors(i,n),QR.subVectors(e,n);let s=YR.dot(QR),c=XR.dot(QR);if(s<=0&&c<=0)return t.copy(n);$R.subVectors(e,r);let l=YR.dot($R),u=XR.dot($R);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(YR,a);ez.subVectors(e,i);let f=YR.dot(ez),p=XR.dot(ez);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(XR,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return ZR.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(ZR,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(YR,a).addScaledVector(XR,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const az={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},oz={h:0,s:0,l:0},sz={h:0,s:0,l:0};function cz(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var lz=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=TI){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,AL.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=AL.workingColorSpace){return this.r=e,this.g=t,this.b=n,AL.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=AL.workingColorSpace){if(e=XI(e,1),t=YI(t,0,1),n=YI(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=cz(i,r,e+1/3),this.g=cz(i,r,e),this.b=cz(i,r,e-1/3)}return AL.colorSpaceToWorking(this,r),this}setStyle(e,t=TI){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=TI){let n=az[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=jL(e.r),this.g=jL(e.g),this.b=jL(e.b),this}copyLinearToSRGB(e){return this.r=ML(e.r),this.g=ML(e.g),this.b=ML(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=TI){return AL.workingToColorSpace(uz.copy(this),e),Math.round(YI(uz.r*255,0,255))*65536+Math.round(YI(uz.g*255,0,255))*256+Math.round(YI(uz.b*255,0,255))}getHexString(e=TI){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=AL.workingColorSpace){AL.workingToColorSpace(uz.copy(this),t);let n=uz.r,r=uz.g,i=uz.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=AL.workingColorSpace){return AL.workingToColorSpace(uz.copy(this),t),e.r=uz.r,e.g=uz.g,e.b=uz.b,e}getStyle(e=TI){AL.workingToColorSpace(uz.copy(this),e);let t=uz.r,n=uz.g,r=uz.b;return e===TI?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(oz),this.setHSL(oz.h+e,oz.s+t,oz.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(oz),e.getHSL(sz);let n=$I(oz.h,sz.h,t),r=$I(oz.s,sz.s,t),i=$I(oz.l,sz.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const uz=new lz;lz.NAMES=az;let dz=0;var fz=class extends UI{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:dz++}),this.uuid=JI(),this.name=``,this.type=`Material`,this.blending=HF,this.side=zF,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=WF,this.blendDst=GF,this.blendEquation=UF,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new lz(0,0,0),this.blendAlpha=0,this.depthFunc=KF,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AI,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kI,this.stencilZFail=kI,this.stencilZPass=kI,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==HF&&(n.blending=this.blending),this.side!==zF&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==WF&&(n.blendSrc=this.blendSrc),this.blendDst!==GF&&(n.blendDst=this.blendDst),this.blendEquation!==UF&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==KF&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==AI&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kI&&(n.stencilFail=this.stencilFail),this.stencilZFail!==kI&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==kI&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},pz=class extends fz{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new lz(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new DR,this.combine=qF,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const mz=new L,hz=new _L;let gz=0;var _z=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:gz++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=zI,this.updateRanges=[],this.gpuType=lI,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)hz.fromBufferAttribute(this,t),hz.applyMatrix3(e),this.setXY(t,hz.x,hz.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.applyMatrix3(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.applyMatrix4(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.applyNormalMatrix(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.transformDirection(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=mL(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=hL(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=mL(t,this.array)),t}setX(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=mL(t,this.array)),t}setY(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=mL(t,this.array)),t}setZ(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=mL(t,this.array)),t}setW(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array),i=hL(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==zI&&(e.usage=this.usage),e}},vz=class extends _z{constructor(e,t,n){super(new Uint16Array(e),t,n)}},yz=class extends _z{constructor(e,t,n){super(new Uint32Array(e),t,n)}},bz=class extends _z{constructor(e,t,n){super(new Float32Array(e),t,n)}};let xz=0;const Sz=new _R,Cz=new WR,wz=new L,Tz=new WL,Ez=new WL,Dz=new L;var Oz=class e extends UI{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:xz++}),this.uuid=JI(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(CL(e)?yz:vz)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new xL().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Sz.makeRotationFromQuaternion(e),this.applyMatrix4(Sz),this}rotateX(e){return Sz.makeRotationX(e),this.applyMatrix4(Sz),this}rotateY(e){return Sz.makeRotationY(e),this.applyMatrix4(Sz),this}rotateZ(e){return Sz.makeRotationZ(e),this.applyMatrix4(Sz),this}translate(e,t,n){return Sz.makeTranslation(e,t,n),this.applyMatrix4(Sz),this}scale(e,t,n){return Sz.makeScale(e,t,n),this.applyMatrix4(Sz),this}lookAt(e){return Cz.lookAt(e),Cz.updateMatrix(),this.applyMatrix4(Cz.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wz).negate(),this.translate(wz.x,wz.y,wz.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new bz(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new WL);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Tz.setFromBufferAttribute(n),this.morphTargetsRelative?(Dz.addVectors(this.boundingBox.min,Tz.min),this.boundingBox.expandByPoint(Dz),Dz.addVectors(this.boundingBox.max,Tz.max),this.boundingBox.expandByPoint(Dz)):(this.boundingBox.expandByPoint(Tz.min),this.boundingBox.expandByPoint(Tz.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(`THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cR);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new L,1/0);return}if(e){let n=this.boundingSphere.center;if(Tz.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ez.setFromBufferAttribute(n),this.morphTargetsRelative?(Dz.addVectors(Tz.min,Ez.min),Tz.expandByPoint(Dz),Dz.addVectors(Tz.max,Ez.max),Tz.expandByPoint(Dz)):(Tz.expandByPoint(Ez.min),Tz.expandByPoint(Ez.max))}Tz.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Dz.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Dz));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Dz.fromBufferAttribute(a,t),o&&(wz.fromBufferAttribute(e,t),Dz.add(wz)),r=Math.max(r,n.distanceToSquared(Dz))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error(`THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new _z(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new L,s[e]=new L;let c=new L,l=new L,u=new L,d=new _L,f=new _L,p=new _L,m=new L,h=new L;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new L,y=new L,b=new L,x=new L;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new _z(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new L,i=new L,a=new L,o=new L,s=new L,c=new L,l=new L,u=new L;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Dz.fromBufferAttribute(e,t),Dz.normalize(),e.setXYZ(t,Dz.x,Dz.y,Dz.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new _z(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const kz=new _R,Az=new gR,jz=new cR,Mz=new L,Nz=new L,Pz=new L,Fz=new L,Iz=new L,Lz=new L,Rz=new L,zz=new L;var Bz=class extends WR{constructor(e=new Oz,t=new pz){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Lz.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Iz.fromBufferAttribute(s,e),a?Lz.addScaledVector(Iz,r):Lz.addScaledVector(Iz.sub(t),r))}t.add(Lz)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),jz.copy(n.boundingSphere),jz.applyMatrix4(i),Az.copy(e.ray).recast(e.near),!(jz.containsPoint(Az.origin)===!1&&(Az.intersectSphere(jz,Mz)===null||Az.origin.distanceToSquared(Mz)>(e.far-e.near)**2))&&(kz.copy(i).invert(),Az.copy(e.ray).applyMatrix4(kz),!(n.boundingBox!==null&&Az.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Az)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Hz(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Hz(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Hz(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Hz(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function Vz(e,t,n,r,i,a,o,s){let c;if(c=t.side===BF?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===zF,s),c===null)return null;zz.copy(s),zz.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(zz);return l<n.near||l>n.far?null:{distance:l,point:zz.clone(),object:e}}function Hz(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Nz),e.getVertexPosition(c,Pz),e.getVertexPosition(l,Fz);let u=Vz(e,t,n,r,Nz,Pz,Fz,Rz);if(u){let e=new L;iz.getBarycoord(Rz,Nz,Pz,Fz,e),i&&(u.uv=iz.getInterpolatedAttribute(i,s,c,l,e,new _L)),a&&(u.uv1=iz.getInterpolatedAttribute(a,s,c,l,e,new _L)),o&&(u.normal=iz.getInterpolatedAttribute(o,s,c,l,e,new L),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new L,materialIndex:0};iz.getNormal(Nz,Pz,Fz,t.normal),u.face=t,u.barycoord=e}return u}var Uz=class e extends Oz{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new bz(c,3)),this.setAttribute(`normal`,new bz(l,3)),this.setAttribute(`uv`,new bz(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new L;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Wz=class extends WR{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new _R,this.projectionMatrix=new _R,this.projectionMatrixInverse=new _R,this.coordinateSystem=VI}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const Gz=new L,Kz=new _L,qz=new _L;var Jz=class extends Wz{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=qI*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(KI*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return qI*2*Math.atan(Math.tan(KI*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Gz.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Gz.x,Gz.y).multiplyScalar(-e/Gz.z),Gz.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Gz.x,Gz.y).multiplyScalar(-e/Gz.z)}getViewSize(e,t){return this.getViewBounds(e,Kz,qz),t.subVectors(qz,Kz)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(KI*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Yz=class extends BL{constructor(e=[],t=XF,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Xz=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=zI,this.updateRanges=[],this.version=0,this.uuid=JI()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=JI()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=JI()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const Zz=new L;var Qz=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Zz.fromBufferAttribute(this,t),Zz.applyMatrix4(e),this.setXYZ(t,Zz.x,Zz.y,Zz.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Zz.fromBufferAttribute(this,t),Zz.applyNormalMatrix(e),this.setXYZ(t,Zz.x,Zz.y,Zz.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Zz.fromBufferAttribute(this,t),Zz.transformDirection(e),this.setXYZ(t,Zz.x,Zz.y,Zz.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=mL(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=hL(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=mL(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=mL(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=mL(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=mL(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array),i=hL(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new _z(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},$z=class extends BL{constructor(e=null,t=1,n=1,r,i,a,o,s,c=nI,l=nI,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},eB=class extends _z{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const tB=new L,nB=new L,rB=new xL;var iB=class{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=tB.subVectors(n,t).cross(nB.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(tB),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||rB.getNormalMatrix(e),r=this.coplanarPoint(tB).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},aB=class extends BL{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=nI,this.minFilter=nI,this.generateMipmaps=!1,this.needsUpdate=!0}},oB=class extends BL{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},sB=class extends BL{constructor(e,t,n=cI,r,i,a,o=nI,s=nI,c,l=fI,u=1){if(l!==fI&&l!==pI)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new IL(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};function cB(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function lB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var uB=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},dB=class extends uB{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yI,endingEnd:yI}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case bI:i=e,o=2*t-n;break;case xI:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case bI:a=e,s=2*n-t;break;case xI:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},fB=class extends uB{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},pB=class extends uB{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},mB=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=cB(t,this.TimeBufferType),this.values=cB(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:cB(e.times,Array),values:cB(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new pB(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new fB(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new dB(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case gI:t=this.InterpolantFactoryMethodDiscrete;break;case _I:t=this.InterpolantFactoryMethodLinear;break;case vI:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return gI;case this.InterpolantFactoryMethodLinear:return _I;case this.InterpolantFactoryMethodSmooth:return vI}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&lB(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===vI,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};mB.prototype.ValueTypeName=``,mB.prototype.TimeBufferType=Float32Array,mB.prototype.ValueBufferType=Float32Array,mB.prototype.DefaultInterpolation=_I;var hB=class extends mB{constructor(e,t,n){super(e,t,n)}};hB.prototype.ValueTypeName=`bool`,hB.prototype.ValueBufferType=Array,hB.prototype.DefaultInterpolation=gI,hB.prototype.InterpolantFactoryMethodLinear=void 0,hB.prototype.InterpolantFactoryMethodSmooth=void 0;var gB=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}};gB.prototype.ValueTypeName=`color`;var _B=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}};_B.prototype.ValueTypeName=`number`;var vB=class extends uB{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)vL.slerpFlat(i,0,a,c-o,a,c,s);return i}},yB=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new vB(this.times,this.values,this.getValueSize(),e)}};yB.prototype.ValueTypeName=`quaternion`,yB.prototype.InterpolantFactoryMethodSmooth=void 0;var bB=class extends mB{constructor(e,t,n){super(e,t,n)}};bB.prototype.ValueTypeName=`string`,bB.prototype.ValueBufferType=Array,bB.prototype.DefaultInterpolation=gI,bB.prototype.InterpolantFactoryMethodLinear=void 0,bB.prototype.InterpolantFactoryMethodSmooth=void 0;var xB=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}};xB.prototype.ValueTypeName=`vector`;const SB={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};var CB=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const wB=new CB;var TB=class{constructor(e){this.manager=e===void 0?wB:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};TB.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var EB=class extends TB{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=SB.get(e);if(a!==void 0)return i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a;let o=wL(`img`);function s(){l(),SB.add(e,this),t&&t(this),i.manager.itemEnd(e)}function c(t){l(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.slice(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(e),o.src=e,o}},DB=class extends TB{constructor(e){super(e)}load(e,t,n,r){let i=new BL,a=new EB(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){i.image=e,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}},OB=class extends Wz{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const kB=`\\[\\]\\.:\\/`,AB=RegExp(`[`+kB+`]`,`g`),jB=`[^`+kB+`]`,MB=`[^`+kB.replace(`\\.`,``)+`]`,NB=/((?:WC+[\/:])*)/.source.replace(`WC`,jB),PB=/(WCOD+)?/.source.replace(`WCOD`,MB),FB=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,jB),IB=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,jB),LB=RegExp(`^`+NB+PB+FB+IB+`$`),RB=[`material`,`materials`,`bones`,`map`];var zB=class{constructor(e,t,n){let r=n||BB.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},BB=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(AB,``)}static parseTrackName(e){let t=LB.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);RB.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};BB.Composite=zB,BB.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},BB.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},BB.prototype.GetterByBindingType=[BB.prototype._getValue_direct,BB.prototype._getValue_array,BB.prototype._getValue_arrayElement,BB.prototype._getValue_toArray],BB.prototype.SetterByBindingTypeAndVersioning=[[BB.prototype._setValue_direct,BB.prototype._setValue_direct_setNeedsUpdate,BB.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[BB.prototype._setValue_array,BB.prototype._setValue_array_setNeedsUpdate,BB.prototype._setValue_array_setMatrixWorldNeedsUpdate],[BB.prototype._setValue_arrayElement,BB.prototype._setValue_arrayElement_setNeedsUpdate,BB.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[BB.prototype._setValue_fromArray,BB.prototype._setValue_fromArray_setNeedsUpdate,BB.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Loe=new Float32Array(1);var VB=class extends Xz{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},HB=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:IF}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=IF);const UB={name:`ASCII`,props:{characters:{default:`@%#*+=-:.`,description:`Characters to use for ASCII effect (light to dark)`,ui:{type:`text`,label:`Characters`}},cellSize:{default:30,description:`Size of each ASCII character cell in pixels`,ui:{type:`range`,min:8,max:100,step:1,label:`Cell Size`}},fontFamily:{default:`jetbrains mono`,description:`Font family for characters`,ui:{type:`select`,options:[{label:`JetBrains Mono`,value:`jetbrains mono`},{label:`Courier New`,value:`courier new`},{label:`Monaco`,value:`monaco`},{label:`Consolas`,value:`consolas`}],label:`Font Family`}}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,onBeforeRender:r,canvas:i})=>{let{vec2:a,vec3:o,vec4:s,floor:c,fract:l,dot:u,screenUV:d,convertToTexture:f,texture:p}=xj;if(!t)return s(0,0,0,0);let m=Math.round(i.clientWidth),h=Math.round(i.clientHeight),g=f(t,m,h),_=(e,t,n)=>{let r=e.length,i=Math.max(2,Math.ceil(Math.sqrt(r))),a=Math.max(8,t-4),o=document.createElement(`canvas`);o.width=i*t,o.height=i*t;let s=o.getContext(`2d`);s.fillStyle=`#000000`,s.fillRect(0,0,o.width,o.height),s.fillStyle=`#ffffff`,s.font=`${a}px ${n}`,s.textAlign=`center`,s.textBaseline=`middle`;for(let n=0;n<r;n++){let r=e[n],a=Math.floor(n/i),o=n%i,c=o*t+t/2,l=a*t+t/2;s.fillText(r,c,l)}return console.log(`Atlas created: ${r} chars, ${i}x${i} grid, ${o.width}x${o.height}px`),console.log(`Characters: "${e}"`),{canvas:o,atlasSize:i,cellSize:t,charCount:r}},v=_(e.characters.uniform.value,e.cellSize.uniform.value,e.fontFamily.uniform.value),y=new oB(v.canvas);y.minFilter=nI,y.magFilter=nI,y.generateMipmaps=!1;let b=p(y),x=e.characters.uniform.value,S=e.cellSize.uniform.value,ee=e.fontFamily.uniform.value,te=()=>{let t=e.characters.uniform.value,n=e.cellSize.uniform.value,r=e.fontFamily.uniform.value;(t!==x||n!==S||r!==ee)&&(v=_(t,n,r),y.image=v.canvas,y.needsUpdate=!0,x=t,S=n,ee=r)};r(()=>{te()}),n(()=>{y.dispose()});let ne=e.cellSize.uniform,re=a(m,h).div(ne),ie=d.mul(re),ae=c(ie),oe=l(ie),se=ae.add(a(.5)).div(re),ce=g.sample(se),le=u(ce.rgb,o(.299,.587,.114)),ue=v.charCount,de=le.mul(.8).add(.1),fe=de.mul(ue),pe=c(fe.min(ue-1e-4)),me=v.atlasSize,he=pe.mod(me),ge=c(pe.div(me)),_e=1/me,ve=a(oe.x,oe.y.sub(1).mul(-1)),ye=a(he,ge).mul(_e).add(ve.mul(_e)),be=b.sample(ye);return s(be.rgb.mul(ce.rgb),ce.a)}};var WB=r({__name:`Ascii`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},characters:{},cellSize:{},fontFamily:{}},{blendMode:`normal`,...Object.entries(UB.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${UB.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(UB.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(UB.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(UB,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,UB.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),GB=WB,KB=function(exports){"use strict";function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({}),qB,JB;function YB(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>{let n=0;if(!Array.isArray(e)){for(let r of t)n+=e*r;return n}for(let r=0;r<e.length;r++)n+=e[r]*(t[r]||0);return n}));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}function XB(e){return ZB(e)===`string`}function ZB(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function QB(e,{precision:t,unit:n}){return $B(e)?`none`:tV(e,t)+(n??``)}function $B(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function eV(e){return $B(e)?0:e}function tV(e,t){if(e===0)return 0;let n=~~e,r=0;n&&t&&(r=~~Math.log10(Math.abs(n))+1);let i=10**(t-r);return Math.floor(e*i+.5)/i}const nV={deg:1,grad:.9,rad:180/Math.PI,turn:360};function rV(e){if(!e)return;e=e.trim();let t=/^([a-z]+)\((.+?)\)$/i,n=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,a=e.match(t);if(a){let e=[];return a[2].replace(i,(t,i)=>{let a=i.match(r),o=i;if(a){let e=a[0],t=o.slice(0,-e.length);e===`%`?(o=new Number(t/100),o.type=`<percentage>`):(o=new Number(t*nV[e]),o.type=`<angle>`,o.unit=e)}else n.test(o)?(o=new Number(o),o.type=`<number>`):o===`none`&&(o=new Number(NaN),o.none=!0);t.startsWith(`/`)&&(o=o instanceof Number?o:new Number(o),o.alpha=!0),typeof o==`object`&&o instanceof Number&&(o.raw=i),e.push(o)}),{name:a[1].toLowerCase(),rawName:a[1],rawArgs:a[2],args:e}}}function iV(e){return e[e.length-1]}function aV(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function oV(e,t,n){return(n-e)/(t-e)}function sV(e,t,n){return aV(t[0],t[1],oV(e[0],e[1],n))}function cV(e){return e.map(e=>e.split(`|`).map(e=>{e=e.trim();let t=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))}function lV(e,t,n){return Math.max(Math.min(n,t),e)}function uV(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function dV(e,t){return uV(Math.abs(e)**t,e)}function fV(e,t){return t===0?0:e/t}function pV(e,t,n=0,r=e.length){for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}var mV=Object.freeze({__proto__:null,bisectLeft:pV,clamp:lV,copySign:uV,interpolate:aV,interpolateInv:oV,isNone:$B,isString:XB,last:iV,mapRange:sV,multiplyMatrices:YB,parseCoordGrammar:cV,parseFunction:rV,serializeNumber:QB,skipNone:eV,spow:dV,toPrecision:tV,type:ZB,zdiv:fV}),hV=class{add(e,t,n){if(typeof arguments[0]!=`string`){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?`unshift`:`push`](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}};const gV=new hV;var _V={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((qB=globalThis)==null||(qB=qB.process)==null||(qB=qB.env)==null||(qB=qB.NODE_ENV)==null?void 0:qB.toLowerCase())!==`test`,warn:function(e){var t,n;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(n=t.warn)==null||n.call(t,e))}};const vV={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function yV(e){return Array.isArray(e)?e:vV[e]}function bV(e,t,n,r={}){if(e=yV(e),t=yV(t),!e||!t)throw TypeError(`Missing white point to convert ${e?``:`from`}${!e&&!t?`/`:``}${t?``:`to`}`);if(e===t)return n;let i={W1:e,W2:t,XYZ:n,options:r};if(gV.run(`chromatic-adaptation-start`,i),i.M||(i.W1===vV.D65&&i.W2===vV.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===vV.D50&&i.W2===vV.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),gV.run(`chromatic-adaptation-end`,i),i.M)return YB(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const xV=new Set([`<number>`,`<percentage>`,`<angle>`]);function SV(e,t,n,r){let i=Object.entries(e.coords).map(([e,i],a)=>{let o=t.coordGrammar[a],s=r[a],c=s?.type,l;if(l=s.none?o.find(e=>xV.has(e)):o.find(e=>e==c),!l){let t=i.name||e;throw TypeError(`${c??s.raw} not allowed for ${t} in ${n}()`)}let u=l.range;c===`<percentage>`&&(u||=[0,1]);let d=i.range||i.refRange;return u&&d&&(r[a]=sV(u,d,r[a])),l});return i}function CV(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(gV.run(`parse-start`,i),i.color)return i.color;if(i.parsed=rV(i.str),i.parsed){let e=i.parsed.name;if(e===`color`){let e=i.parsed.args.shift(),n=e.startsWith(`--`)?e.substring(2):`--${e}`,r=[e,n],c=i.parsed.rawArgs.indexOf(`/`)>0?i.parsed.args.pop():1;for(let n of EV.all){let s=n.getFormat(`color`);if(s){var a,o;if(r.includes(s.id)||(a=o=s.ids)?.filter(e=>r.includes(e)).length){let r=Object.keys(n.coords).map((e,t)=>i.parsed.args[t]||0),a;return s.coordGrammar&&(a=SV(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&_V.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith(`--`)&&!s.id.startsWith(`--`)&&_V.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:n.id,coords:r,alpha:c}}}}let l=``,u=e in EV.registry?e:n;if(u in EV.registry){var s;let e=(s=EV.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;e&&(l=`Did you mean color(${e})?`)}throw TypeError(`Cannot parse color(${e}). `+(l||`Missing a plugin?`))}else for(let n of EV.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||iV(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=SV(n,r,e,o)),t&&Object.assign(t,{formatId:r.name,types:s}),{spaceId:n.id,coords:o,alpha:a}}}}else for(let e of EV.all)for(let n in e.formats){let r=e.formats[n];if(r.type!==`custom`||r.test&&!r.test(i.str))continue;let a=r.parse(i.str);if(a)return a.alpha??=1,t&&(t.formatId=n),a}throw TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function wV(e){if(Array.isArray(e))return e.map(wV);if(!e)throw TypeError(`Empty color reference`);XB(e)&&(e=CV(e));let t=e.space||e.spaceId;return t instanceof EV||(e.space=EV.get(t)),e.alpha===void 0&&(e.alpha=1),e}const TV=75e-6;var EV=(JB=class e{constructor(t){var n,r;this.id=t.id,this.name=t.name,this.base=t.base?e.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let i=t.coords??this.base.coords;for(let e in i)`name`in i[e]||(i[e].name=e);this.coords=i;let a=t.white??this.base.white??`D65`;for(let e in this.white=yV(a),this.formats=t.formats??{},this.formats){let t=this.formats[e];t.type||=`function`,t.name||=e}(n=r=this.formats.color)?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace===`self`?this:e.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=t.referred,Object.defineProperty(this,`path`,{value:DV(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),gV.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=TV}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let n=Object.values(this.coords);return e.every((e,r)=>{let i=n[r];if(i.type!==`angle`&&i.range){if(Number.isNaN(e))return!0;let[n,r]=i.range;return(n===void 0||e>=n-t)&&(r===void 0||e<=r+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!(`range`in e))}get cssId(){var e;return((e=this.formats)==null||(e=e.color)==null?void 0:e.id)||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type===`angle`)return!0;return!1}getFormat(e){if(typeof e==`object`)return e=OV(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=OV(t,this),t):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(t,n){if(arguments.length===1){let e=wV(t);[t,n]=[e.space,e.coords]}if(t=e.get(t),this.equals(t))return n;n=n.map(e=>Number.isNaN(e)?0:e);let r=this.path,i=t.path,a,o;for(let e=0;e<r.length&&r[e].equals(i[e]);e++)a=r[e],o=e;if(!a)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let e=r.length-1;e>o;e--)n=r[e].toBase(n);for(let e=o+1;e<i.length;e++)n=i[e].fromBase(n);return n}from(t,n){if(arguments.length===1){let e=wV(t);[t,n]=[e.space,e.coords]}return t=e.get(t),t.to(this,n)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let n=this.coords[t],r=n.range||n.refRange;e.push(r?.min??0)}return e}static get all(){return[...new Set(Object.values(e.registry))]}static register(e,t){if(arguments.length===1&&(t=arguments[0],e=t.id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,arguments.length===1&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(t,...n){if(!t||t instanceof e)return t;let r=ZB(t);if(r===`string`){let n=e.registry[t.toLowerCase()];if(!n)throw TypeError(`No color space found with id = "${t}"`);return n}if(n.length)return e.get(...n);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,n){let r=ZB(t),i,a;if(r===`string`?t.includes(`.`)?[i,a]=t.split(`.`):[i,a]=[,t]:Array.isArray(t)?[i,a]=t:(i=t.space,a=t.coordId),i=e.get(i),i||=n,!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(r=ZB(a),r===`number`||r===`string`&&a>=0){let e=Object.entries(i.coords)[a];if(e)return{space:i,id:e[0],index:a,...e[1]}}i=e.get(i);let o=a.toLowerCase(),s=0;for(let e in i.coords){var c,l;let t=i.coords[e];if(e.toLowerCase()===o||(c=l=t.name)?.toLowerCase()===o)return{space:i,id:e,index:s,...t};s++}throw TypeError(`No "${a}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(`, `)}`)}},KB.defineProperty(JB,`registry`,{}),KB.defineProperty(JB,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),JB);function DV(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function OV(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=cV(e.coords);let n=Object.entries(t).map(([t,n],r)=>{let i=e.coordGrammar[r][0],a=n.range||n.refRange,o=i.range,s=``;return i==`<percentage>`?(o=[0,100],s=`%`):i==`<angle>`&&(s=`deg`),{fromRange:a,toRange:o,suffix:s}});e.serializeCoords=(e,t)=>e.map((e,r)=>{let{fromRange:i,toRange:a,suffix:o}=n[r];return i&&a&&(e=sV(i,a,e)),e=QB(e,{precision:t,unit:o}),e})}return e}var kV=new EV({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{name:`X`},y:{name:`Y`},z:{name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),AV=class extends EV{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=kV,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=YB(e.toXYZ_M,t);return this.white!==this.base.white&&(n=bV(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=bV(this.base.white,this.white,t),YB(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function jV(e,t){return e=wV(e),!t||e.space.equals(t)?e.coords.slice():(t=EV.get(t),t.from(e))}function MV(e,t){e=wV(e);let{space:n,index:r}=EV.resolveCoord(t,e.space),i=jV(e,n);return i[r]}function NV(e,t,n){return e=wV(e),t=EV.get(t),e.coords=t.to(e.space,n),e}NV.returns=`color`;function PV(e,t,n){if(e=wV(e),arguments.length===2&&ZB(arguments[1])===`object`){let t=arguments[1];for(let n in t)PV(e,n,t[n])}else{typeof n==`function`&&(n=n(MV(e,t)));let{space:r,index:i}=EV.resolveCoord(t,e.space),a=jV(e,r);a[i]=n,NV(e,r,a)}return e}PV.returns=`color`;var FV=new EV({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:kV,fromBase:e=>bV(kV.white,`D50`,e),toBase:e=>bV(`D50`,kV.white,e)});const IV=216/24389,LV=24/116,RV=24389/27;let zV=vV.D50;var BV=new EV({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:zV,base:FV,fromBase(e){let t=e.map((e,t)=>e/zV[t]),n=t.map(e=>e>IV?Math.cbrt(e):(RV*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>LV?t[0]**3:(116*t[0]-16)/RV,e[0]>8?((e[0]+16)/116)**3:e[0]/RV,t[2]>LV?t[2]**3:(116*t[2]-16)/RV];return n.map((e,t)=>e*zV[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function VV(e){return(e%360+360)%360}function HV(e,t){if(e===`raw`)return t;let[n,r]=t.map(VV),i=r-n;return e===`increasing`?i<0&&(r+=360):e===`decreasing`?i>0&&(n+=360):e===`longer`?-180<i&&i<180&&(i>0?n+=360:r+=360):e===`shorter`&&(i>180?n+=360:i<-180&&(r+=360)),[n,r]}var UV=new EV({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:BV,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{lch:{coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const WV=25**7,GV=Math.PI,KV=180/GV,qV=GV/180;function JV(e){let t=e*e,n=t*t*t*e;return n}function YV(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=wV([e,t]);let[a,o,s]=BV.from(e),c=UV.from(BV,[a,o,s])[1],[l,u,d]=BV.from(t),f=UV.from(BV,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=JV(p),h=.5*(1-Math.sqrt(m/(m+WV))),g=(1+h)*o,_=(1+h)*u,v=Math.sqrt(g**2+s**2),y=Math.sqrt(_**2+d**2),b=g===0&&s===0?0:Math.atan2(s,g),x=_===0&&d===0?0:Math.atan2(d,_);b<0&&(b+=2*GV),x<0&&(x+=2*GV),b*=KV,x*=KV;let S=l-a,ee=y-v,te=x-b,ne=b+x,re=Math.abs(te),ie;v*y===0?ie=0:re<=180?ie=te:te>180?ie=te-360:te<-180?ie=te+360:_V.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*qV/2),oe=(a+l)/2,se=(v+y)/2,ce=JV(se),le;le=v*y===0?ne:re<=180?ne/2:ne<360?(ne+360)/2:(ne-360)/2;let ue=(oe-50)**2,de=1+.015*ue/Math.sqrt(20+ue),fe=1+.045*se,pe=1;pe-=.17*Math.cos((le-30)*qV),pe+=.24*Math.cos(2*le*qV),pe+=.32*Math.cos((3*le+6)*qV),pe-=.2*Math.cos((4*le-63)*qV);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+WV)),_e=-1*Math.sin(2*he*qV)*ge,ve=(S/(n*de))**2;return ve+=(ee/(r*fe))**2,ve+=(ae/(i*me))**2,ve+=_e*(ee/(r*fe))*(ae/(i*me)),Math.sqrt(ve)}const XV=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],ZV=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],QV=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],$V=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var eH=new EV({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:kV,fromBase(e){let t=YB(XV,e),n=t.map(e=>Math.cbrt(e));return YB(QV,n)},toBase(e){let t=YB($V,e),n=t.map(e=>e**3);return YB(ZV,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function tH(e,t){[e,t]=wV([e,t]);let[n,r,i]=eH.from(e),[a,o,s]=eH.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const nH=75e-6;function rH(e,t,{epsilon:n=nH}={}){e=wV(e),t||=e.space,t=EV.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function iH(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function aH(e,t,n=`lab`){n=EV.get(n);let r=n.from(e),i=n.from(t);return Math.sqrt(r.reduce((e,t,n)=>{let r=i[n];return isNaN(t)||isNaN(r)?e:e+(r-t)**2},0))}function oH(e,t){return aH(e,t,`lab`)}const sH=Math.PI,cH=sH/180;function lH(e,t,{l:n=2,c:r=1}={}){[e,t]=wV([e,t]);let[i,a,o]=BV.from(e),[,s,c]=UV.from(BV,[i,a,o]),[l,u,d]=BV.from(t),f=UV.from(BV,[l,u,d])[1];s<0&&(s=0),f<0&&(f=0);let p=i-l,m=s-f,h=a-u,g=o-d,_=h**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let y=.0638*s/(1+.0131*s)+.638,b;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*cH)):.36+Math.abs(.4*Math.cos((c+35)*cH));let x=s**4,S=Math.sqrt(x/(x+1900)),ee=y*(S*b+1-S),te=(p/(n*v))**2;return te+=(m/(r*y))**2,te+=_/ee**2,Math.sqrt(te)}const uH=203;var dH=new EV({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:kV,fromBase(e){return e.map(e=>Math.max(e*uH,0))},toBase(e){return e.map(e=>Math.max(e/uH,0))}});const fH=1.15,pH=.66,mH=2610/2**14,hH=2**14/2610,gH=3424/2**12,_H=2413/2**7,vH=2392/2**7,yH=1.7*2523/2**5,bH=2**5/(1.7*2523),xH=-.56,SH=16295499532821565e-27,CH=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],wH=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],TH=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],EH=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var DH=new EV({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:dH,fromBase(e){let[t,n,r]=e,i=fH*t-(fH-1)*r,a=pH*n-(pH-1)*t,o=YB(CH,[i,a,r]),s=o.map(function(e){let t=gH+_H*(e/1e4)**mH,n=1+vH*(e/1e4)**mH;return(t/n)**yH}),[c,l,u]=YB(TH,s),d=(1+xH)*c/(1+xH*c)-SH;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+SH)/(1+xH-xH*(t+SH)),a=YB(EH,[i,n,r]),o=a.map(function(e){let t=gH-e**bH,n=vH*e**bH-_H,r=1e4*(t/n)**hH;return r}),[s,c,l]=YB(wH,o),u=(s+(fH-1)*l)/fH,d=(c+(pH-1)*u)/pH;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),OH=new EV({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,1],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:DH,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){return[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]}});function kH(e,t){[e,t]=wV([e,t]);let[n,r,i]=OH.from(e),[a,o,s]=OH.from(t),c=n-a,l=r-o;Number.isNaN(i)&&Number.isNaN(s)?(i=0,s=0):Number.isNaN(i)?i=s:Number.isNaN(s)&&(s=i);let u=i-s,d=2*Math.sqrt(r*o)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(c**2+l**2+d**2)}const AH=3424/4096,jH=2413/128,MH=2392/128,NH=2610/16384,PH=2523/32,FH=16384/2610,IH=32/2523,LH=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],RH=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],zH=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],BH=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var VH=new EV({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:dH,fromBase(e){let t=YB(LH,e);return HH(t)},toBase(e){let t=UH(e);return YB(BH,t)}});function HH(e){let t=e.map(function(e){let t=AH+jH*(e/1e4)**NH,n=1+MH*(e/1e4)**NH;return(t/n)**PH});return YB(RH,t)}function UH(e){let t=YB(zH,e),n=t.map(function(e){let t=Math.max(e**IH-AH,0),n=jH-MH*e**IH;return 1e4*(t/n)**FH});return n}function WH(e,t){[e,t]=wV([e,t]);let[n,r,i]=VH.from(e),[a,o,s]=VH.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const GH=vV.D65,KH=.42,qH=1/KH,JH=2*Math.PI,YH=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],XH=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],ZH=[[460,451,288],[460,-891,-261],[460,-220,-6300]],QH={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},$H={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},eU=180/Math.PI,tU=Math.PI/180;function nU(e,t){let n=e.map(e=>{let n=dV(t*Math.abs(e)*.01,KH);return 400*uV(n,e)/(n+27.13)});return n}function rU(e,t){let n=100/t*27.13**qH;return e.map(e=>{let t=Math.abs(e);return uV(n*dV(t/(400-t),qH),e)})}function iU(e){let t=VV(e);t<=$H.h[0]&&(t+=360);let n=pV($H.h,t)-1,[r,i]=$H.h.slice(n,n+2),[a,o]=$H.e.slice(n,n+2),s=$H.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function aU(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=$H.h.slice(n,n+2),[a,o]=$H.e.slice(n,n+2);return VV((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function oU(e,t,n,r,i){let a={};a.discounting=i,a.refWhite=e,a.surround=r;let o=e.map(e=>e*100);a.la=t,a.yb=n;let s=o[1],c=YB(YH,o);r=QH[a.surround];let l=r[0];a.c=r[1],a.nc=r[2];let u=1/(5*a.la+1),d=u**4;a.fl=d*a.la+.1*(1-d)*(1-d)*Math.cbrt(5*a.la),a.flRoot=a.fl**.25,a.n=a.yb/s,a.z=1.48+Math.sqrt(a.n),a.nbb=.725*a.n**-.2,a.ncb=a.nbb;let f=i?1:Math.max(Math.min(l*(1-1/3.6*Math.exp((-a.la-42)/92)),1),0);a.dRgb=c.map(e=>aV(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=nU(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const sU=oU(GH,64/Math.PI*.2,20,`average`,!1);function cU(e,t){if(!(e.J!==void 0^e.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(e.C!==void 0^e.M!==void 0^e.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(e.h!==void 0^e.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(e.J===0||e.Q===0)return[0,0,0];let n=0;n=e.h===void 0?aU(e.H)*tU:VV(e.h)*tU;let r=Math.cos(n),i=Math.sin(n),a=0;e.J===void 0?e.Q!==void 0&&(a=.25*t.c*e.Q/((t.aW+4)*t.flRoot)):a=dV(e.J,1/2)*.1;let o=0;e.C===void 0?e.M===void 0?e.s!==void 0&&(o=4e-4*e.s**2*(t.aW+4)/t.c):o=e.M/t.flRoot/a:o=e.C/a;let s=dV(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*dV(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*fV(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=rU(YB(ZH,[d,p,m]).map(e=>e*1/1403),t.fl);return YB(XH,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function lU(e,t){let n=e.map(e=>e*100),r=nU(YB(YH,n).map((e,n)=>e*t.dRgb[n]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%JH+JH)%JH,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*fV(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=dV(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=dV(u/t.aW,.5*t.c*t.z),f=100*dV(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=VV(o*eU),_=iU(g),v=50*dV(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var uU=new EV({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:kV,fromBase(e){let t=lU(e,sU);return[t.J,t.M,t.h]},toBase(e){return cU({J:e[0],M:e[1],h:e[2]},sU)}});const dU=vV.D65,fU=216/24389,pU=24389/27;function mU(e){let t=e>fU?Math.cbrt(e):(pU*e+16)/116;return 116*t-16}function hU(e){return e>8?((e+16)/116)**3:e/pU}function gU(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=hU(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let c=2e-12,l=15,u=0,d=1/0;for(;u<=l;){a=cU({J:o,C:r,h:n},t);let e=Math.abs(a[1]-s);if(e<d){if(e<=c)return a;d=e}o-=(a[1]-s)*o/(2*a[1]),u+=1}return cU({J:o,C:r,h:n},t)}function _U(e,t){let n=mU(e[1]);if(n===0)return[0,0,0];let r=lU(e,vU);return[VV(r.h),r.C,n]}const vU=oU(dU,200/Math.PI*hU(50),hU(50)*100,`average`,!1);var yU=new EV({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:kV,fromBase(e){return _U(e)},toBase(e){return gU(e,vU)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const bU=Math.PI/180,xU=[1,.007,.0228];function SU(e){e[1]<0&&(e=yU.fromBase(yU.toBase(e)));let t=Math.log(Math.max(1+xU[2]*e[1]*vU.flRoot,1))/xU[2],n=e[0]*bU,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function CU(e,t){[e,t]=wV([e,t]);let[n,r,i]=SU(yU.from(e)),[a,o,s]=SU(yU.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var wU={deltaE76:oH,deltaECMC:lH,deltaE2000:YV,deltaEJz:kH,deltaEITP:WH,deltaEOK:tH,deltaEHCT:CU};function TU(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const EU={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function DU(e,{method:t=_V.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=wV(e),XB(arguments[1])?n=arguments[1]:n||=e.space,n=EV.get(n),rH(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=kU(e,{space:n});else{if(t!==`clip`&&!rH(e,n)){Object.prototype.hasOwnProperty.call(EU,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=EU[t]);let s=YV;if(r!==``){for(let e in wU)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=wU[e];break}}let c=DU(AU(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=EV.resolveCoord(a.channel),n=MV(AU(e,t.space),t.id);if($B(n)&&(n=0),n>=a.max)return AU({space:`xyz-d65`,coords:vV.D65},e.space);if(n<=a.min)return AU({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=EV.resolveCoord(t),c=r.space,l=r.id,u=AU(e,c);u.coords.forEach((e,t)=>{$B(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=TU(i),m=f,h=MV(u,l);for(;h-m>p;){let e=iH(u);e=DU(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=MV(u,l):h=MV(u,l),PV(u,l,(m+h)/2)}o=AU(u,n)}else o=c}else o=AU(e,n);if(t===`clip`||!rH(o,n,{epsilon:0})){let e=Object.values(n.coords).map(e=>e.range||[]);o.coords=o.coords.map((t,n)=>{let[r,i]=e[n];return r!==void 0&&(t=Math.max(r,t)),i!==void 0&&(t=Math.min(t,i)),t})}}return n!==e.space&&(o=AU(o,e.space)),e.coords=o.coords,e}DU.returns=`color`;const OU={WHITE:{space:eH,coords:[1,0,0]},BLACK:{space:eH,coords:[0,0,0]}};function kU(e,{space:t}={}){let n=.02,r=1e-4;e=wV(e),t||=e.space,t=EV.get(t);let i=EV.get(`oklch`);if(t.isUnbounded)return AU(e,t);let a=AU(e,i),o=a.coords[0];if(o>=1){let n=AU(OU.WHITE,t);return n.alpha=e.alpha,AU(n,t)}if(o<=0){let n=AU(OU.BLACK,t);return n.alpha=e.alpha,AU(n,t)}if(rH(a,t,{epsilon:0}))return AU(a,t);function s(e){let n=AU(e,t),r=Object.values(t.coords);return n.coords=n.coords.map((e,t)=>{if(`range`in r[t]){let[n,i]=r[t].range;return lV(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=iH(a),f=s(d),p=tH(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&rH(d,t,{epsilon:0}))c=e;else if(f=s(d),p=tH(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function AU(e,t,{inGamut:n}={}){e=wV(e),t=EV.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=DU(i,n===!0?void 0:n)),i}AU.returns=`color`;function jU(e,{precision:t=_V.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=wV(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??EV.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!rH(e)&&(s=DU(iH(e),r===!0?void 0:r).coords),n.type===`custom`)if(i.precision=t,n.serialize)a=n.serialize(s,e.alpha,i);else throw TypeError(`format ${o} can only be used to parse colors, not for serialization`);else{let r=n.name||`color`;n.serializeCoords?s=n.serializeCoords(s,t):t!==null&&(s=s.map(e=>QB(e,{precision:t})));let i=[...s];if(r===`color`){var c,l;let t=n.id||(c=l=n.ids)?.[0]||e.space.id;i.unshift(t)}let o=e.alpha;t!==null&&(o=QB(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const MU=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],NU=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var PU=new AV({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:MU,fromXYZ_M:NU});const FU=1.09929682680944,IU=.018053968510807;var LU=new AV({id:`rec2020`,name:`REC.2020`,base:PU,toBase(e){return e.map(function(e){return e<IU*4.5?e/4.5:((e+FU-1)/FU)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=IU?FU*e**.45-(FU-1):4.5*e})}});const RU=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],zU=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var BU=new AV({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:RU,fromXYZ_M:zU});const VU=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],HU=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var UU=new AV({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:VU,fromXYZ_M:HU}),WU={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let GU=[,,,].fill(`<percentage> | <number>[0, 255]`),KU=[,,,].fill(`<number>[0, 255]`);var qU=new AV({id:`srgb`,name:`sRGB`,base:UU,fromBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),formats:{rgb:{coords:GU},rgb_number:{name:`rgb`,commas:!0,coords:KU,noAlpha:!0},color:{},rgba:{coords:GU,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:KU},hex:{type:`custom`,toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,`$&$&`));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:`srgb`,coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:n=!0}={})=>{t<1&&e.push(t),e=e.map(e=>Math.round(e*255));let r=n&&e.every(e=>e%17==0),i=e.map(e=>r?(e/17).toString(16):e.toString(16).padStart(2,`0`)).join(``);return`#`+i}},keyword:{type:`custom`,test:e=>/^[a-z]+$/i.test(e),parse(e){e=e.toLowerCase();let t={spaceId:`srgb`,coords:null,alpha:1};if(e===`transparent`?(t.coords=WU.black,t.alpha=0):t.coords=WU[e],t.coords)return t}}}}),JU=new AV({id:`p3`,cssId:`display-p3`,name:`P3`,base:BU,fromBase:qU.fromBase,toBase:qU.toBase});_V.display_space=qU;let YU;if(typeof CSS<`u`&&CSS.supports)for(let e of[BV,LU,JU]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=jU(n);if(CSS.supports(`color`,r)){_V.display_space=e;break}}function XU(e,{space:t=_V.display_space,...n}={}){let r=jU(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!_V.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some($B)||$B(e.alpha);if(a&&!(YU??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=iH(e),i.coords=i.coords.map(eV),i.alpha=eV(i.alpha),r=jU(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=AU(i,t),r=new String(jU(i,n)),r.color=i}return r}function ZU(e,t){return e=wV(e),t=wV(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function QU(e){return MV(e,[kV,`y`])}function $U(e,t){PV(e,[kV,`y`],t)}function eW(e){Object.defineProperty(e.prototype,`luminance`,{get(){return QU(this)},set(e){$U(this,e)}})}var tW=Object.freeze({__proto__:null,getLuminance:QU,register:eW,setLuminance:$U});function nW(e,t){e=wV(e),t=wV(t);let n=Math.max(QU(e),0),r=Math.max(QU(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const rW=.56,iW=.57,aW=.62,oW=.65,sW=.022,cW=1.414,lW=.1,uW=5e-4,dW=1.14,fW=.027,pW=1.14;function mW(e){return e>=sW?e:e+(sW-e)**cW}function hW(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function gW(e,t){t=wV(t),e=wV(e);let n,r,i,a,o,s;t=AU(t,`srgb`),[a,o,s]=t.coords;let c=hW(a)*.2126729+hW(o)*.7151522+hW(s)*.072175;e=AU(e,`srgb`),[a,o,s]=e.coords;let l=hW(a)*.2126729+hW(o)*.7151522+hW(s)*.072175,u=mW(c),d=mW(l),f=d>u;return Math.abs(d-u)<uW?r=0:f?(n=d**rW-u**iW,r=n*dW):(n=d**oW-u**aW,r=n*pW),i=Math.abs(r)<lW?0:r>0?r-fW:r+fW,i*100}function _W(e,t){e=wV(e),t=wV(t);let n=Math.max(QU(e),0),r=Math.max(QU(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const vW=5e4;function yW(e,t){e=wV(e),t=wV(t);let n=Math.max(QU(e),0),r=Math.max(QU(t),0);return r>n&&([n,r]=[r,n]),r===0?vW:(n-r)/r}function bW(e,t){e=wV(e),t=wV(t);let n=MV(e,[BV,`l`]),r=MV(t,[BV,`l`]);return Math.abs(n-r)}const xW=216/24389,SW=24/116,CW=24389/27;let wW=vV.D65;var TW=new EV({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:wW,base:kV,fromBase(e){let t=e.map((e,t)=>e/wW[t]),n=t.map(e=>e>xW?Math.cbrt(e):(CW*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>SW?t[0]**3:(116*t[0]-16)/CW,e[0]>8?((e[0]+16)/116)**3:e[0]/CW,t[2]>SW?t[2]**3:(116*t[2]-16)/CW];return n.map((e,t)=>e*wW[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const EW=5**.5*.5+.5;function DW(e,t){e=wV(e),t=wV(t);let n=MV(e,[TW,`l`]),r=MV(t,[TW,`l`]),i=Math.abs(n**+EW-r**+EW),a=i**(1/EW)*Math.SQRT2-40;return a<7.5?0:a}var OW=Object.freeze({__proto__:null,contrastAPCA:gW,contrastDeltaPhi:DW,contrastLstar:bW,contrastMichelson:_W,contrastWCAG21:nW,contrastWeber:yW});function kW(e,t,n={}){XB(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(OW).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=wV(e),t=wV(t),OW)if(`contrast`+r.toLowerCase()===n.toLowerCase())return OW[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function AW(e){let[t,n,r]=jV(e,kV),i=t+15*n+3*r;return[4*t/i,9*n/i]}function jW(e){let[t,n,r]=jV(e,kV),i=t+n+r;return[t/i,n/i]}function MW(e){Object.defineProperty(e.prototype,`uv`,{get(){return AW(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return jW(this)}})}var NW=Object.freeze({__proto__:null,register:MW,uv:AW,xy:jW});function PW(e,t,n={}){XB(n)&&(n={method:n});let{method:r=_V.deltaE,...i}=n;for(let n in wU)if(`deltae`+r.toLowerCase()===n.toLowerCase())return wU[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function FW(e,t=.25){let n=EV.get(`oklch`,`lch`),r=[n,`l`];return PV(e,r,e=>e*(1+t))}function IW(e,t=.25){let n=EV.get(`oklch`,`lch`),r=[n,`l`];return PV(e,r,e=>e*(1-t))}var LW=Object.freeze({__proto__:null,darken:IW,lighten:FW});function RW(e,t,n=.5,r={}){[e,t]=[wV(e),wV(t)],ZB(n)===`object`&&([n,r]=[.5,n]);let i=BW(e,t,r);return i(n)}function zW(e,t,n={}){let r;VW(e)&&([r,n]=[e,t],[e,t]=r.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:a,steps:o=2,maxSteps:s=1e3,...c}=n;r||([e,t]=[wV(e),wV(t)],r=BW(e,t,c));let l=PW(e,t),u=i>0?Math.max(o,Math.ceil(l/i)+1):o,d=[];if(s!==void 0&&(u=Math.min(u,s)),u===1)d=[{p:.5,color:r(.5)}];else{let e=1/(u-1);d=Array.from({length:u},(t,n)=>{let i=n*e;return{p:i,color:r(i)}})}if(i>0){let e=d.reduce((e,t,n)=>{if(n===0)return 0;let r=PW(t.color,d[n-1].color,a);return Math.max(e,r)},0);for(;e>i;){e=0;for(let t=1;t<d.length&&d.length<s;t++){let n=d[t-1],i=d[t],a=(i.p+n.p)/2,o=r(a);e=Math.max(e,PW(o,n.color),PW(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function BW(e,t,n={}){if(VW(e)){let[n,r]=[e,t];return BW(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=wV(e),t=wV(t),e=iH(e),t=iH(t);let s={colors:[e,t],options:n};if(r=r?EV.get(r):EV.registry[_V.interpolationSpace]||e.space,i=i?EV.get(i):r,e=AU(e,r),t=AU(t,r),e=DU(e),t=DU(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[MV(e,a),MV(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=HV(i,[o,s]),PV(e,a,o),PV(t,a,s)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(n=>{n=a?a(n):n;let s=e.coords.map((e,r)=>{let i=t.coords[r];return aV(e,i,n)}),c=aV(e.alpha,t.alpha,n),l={space:r,coords:s,alpha:c};return o&&(l.coords=l.coords.map(e=>e/c)),i!==r&&(l=AU(l,i)),l},{rangeArgs:s})}function VW(e){return ZB(e)===`function`&&!!e.rangeArgs}_V.interpolationSpace=`lab`;function HW(e){e.defineFunction(`mix`,RW,{returns:`color`}),e.defineFunction(`range`,BW,{returns:`function<color>`}),e.defineFunction(`steps`,zW,{returns:`array<color>`})}var UW=Object.freeze({__proto__:null,isRange:VW,mix:RW,range:BW,register:HW,steps:zW}),WW=new EV({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:qU,fromBase:e=>{let t=Math.max(...e),n=Math.min(...e),[r,i,a]=e,[o,s,c]=[NaN,0,(n+t)/2],l=t-n;if(l!==0){switch(s=c===0||c===1?0:(t-c)/Math.min(c,1-c),t){case r:o=(i-a)/l+(i<a?6:0);break;case i:o=(a-r)/l+2;break;case a:o=(r-i)/l+4}o*=60}return s<0&&(o+=180,s=Math.abs(s)),o>=360&&(o-=360),[o,s*100,c*100]},toBase:e=>{let[t,n,r]=e;t%=360,t<0&&(t+=360),n/=100,r/=100;function i(e){let i=(e+t/30)%12,a=n*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsla:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commas:!0,lastAlpha:!0}}}),GW=new EV({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:WW,fromBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r+n*Math.min(r,1-r);return[t,i===0?0:200*(1-r/i),100*i]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r*(1-n/2);return[t,i===0||i===1?0:(r-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),KW=new EV({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:GW,fromBase(e){let[t,n,r]=e;return[t,r*(100-n)/100,100-r]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=n+r;if(i>=1){let e=n/i;return[t,0,e*100]}let a=1-r,o=a===0?0:1-n/a;return[t,o*100,a*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const qW=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],JW=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var YW=new AV({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:qW,fromXYZ_M:JW}),XW=new AV({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:YW,toBase:e=>e.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:e=>e.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const ZW=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],QW=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var $W=new AV({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:FV,toXYZ_M:ZW,fromXYZ_M:QW});const eG=1/512,tG=16/512;var nG=new AV({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:$W,toBase(e){return e.map(e=>e<tG?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=eG?e**(1/1.8):16*e)}}),rG=new EV({id:`oklch`,name:`Oklch`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:eH,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){let[t,n,r]=e,i,a;return isNaN(r)?(i=0,a=0):(i=n*Math.cos(r*Math.PI/180),a=n*Math.sin(r*Math.PI/180)),[t,i,a]},formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>[0,1]`,`<number> | <angle>`]}}});let iG=vV.D65;const aG=216/24389,oG=24389/27,[sG,cG]=AW({space:kV,coords:iG});var lG=new EV({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:iG,base:kV,fromBase(e){let t=[eV(e[0]),eV(e[1]),eV(e[2])],n=t[1],[r,i]=AW({space:kV,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=aG?oG*n:116*Math.cbrt(n)-16;return[a,13*a*(r-sG),13*a*(i-cG)]},toBase(e){let[t,n,r]=e;if(t===0||$B(t))return[0,0,0];n=eV(n),r=eV(r);let i=n/(13*t)+sG,a=r/(13*t)+cG,o=t<=8?t/oG:((t+16)/116)**3;return[o*(9*i/(4*a)),o,o*((12-3*i-20*a)/(4*a))]},formats:{color:{id:`--luv`,coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),uG=new EV({id:`lchuv`,name:`LChuv`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,220],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:lG,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{color:{id:`--lchuv`,coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const dG=216/24389,fG=24389/27,pG=HU[0][0],mG=HU[0][1],hG=HU[0][2],gG=HU[1][0],_G=HU[1][1],vG=HU[1][2],yG=HU[2][0],bG=HU[2][1],xG=HU[2][2];function SG(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function CG(e){let t=(e+16)**3/1560896,n=t>dG?t:e/fG,r=n*(284517*pG-94839*hG),i=n*(838422*hG+769860*mG+731718*pG),a=n*(632260*hG-126452*mG),o=n*(284517*gG-94839*vG),s=n*(838422*vG+769860*_G+731718*gG),c=n*(632260*vG-126452*_G),l=n*(284517*yG-94839*xG),u=n*(838422*xG+769860*bG+731718*yG),d=n*(632260*xG-126452*bG);return{r0s:r/a,r0i:i*e/a,r1s:r/(a+126452),r1i:(i-769860)*e/(a+126452),g0s:o/c,g0i:s*e/c,g1s:o/(c+126452),g1i:(s-769860)*e/(c+126452),b0s:l/d,b0i:u*e/d,b1s:l/(d+126452),b1i:(u-769860)*e/(d+126452)}}function wG(e,t){let n=t/360*Math.PI*2,r=SG(e.r0s,e.r0i,n),i=SG(e.r1s,e.r1i,n),a=SG(e.g0s,e.g0i,n),o=SG(e.g1s,e.g1i,n),s=SG(e.b0s,e.b0i,n),c=SG(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var TG=new EV({id:`hsluv`,name:`HSLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:uG,gamutSpace:qU,fromBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=CG(t),a=wG(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=CG(r),a=wG(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});HU[0][0],HU[0][1],HU[0][2],HU[1][0],HU[1][1],HU[1][2],HU[2][0],HU[2][1],HU[2][2];function EG(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function DG(e){let t=EG(e.r0s,e.r0i),n=EG(e.r1s,e.r1i),r=EG(e.g0s,e.g0i),i=EG(e.g1s,e.g1i),a=EG(e.b0s,e.b0i),o=EG(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var OG=new EV({id:`hpluv`,name:`HPLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:uG,gamutSpace:`self`,fromBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=CG(t),r=DG(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=CG(r),t=DG(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const kG=203,AG=2610/2**14,jG=2**14/2610,MG=2523/2**5,NG=2**5/2523,PG=3424/2**12,FG=2413/2**7,IG=2392/2**7;var LG=new AV({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:PU,toBase(e){return e.map(function(e){let t=(Math.max(e**NG-PG,0)/(FG-IG*e**NG))**jG;return t*1e4/kG})},fromBase(e){return e.map(function(e){let t=Math.max(e*kG/1e4,0),n=PG+FG*t**AG,r=1+IG*t**AG;return(n/r)**MG})}});const RG=.17883277,zG=.28466892,BG=.55991073,VG=3.7743;var HG=new AV({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:PU,toBase(e){return e.map(function(e){return e<=.5?e**2/3*VG:(Math.exp((e-BG)/RG)+zG)/12*VG})},fromBase(e){return e.map(function(e){return e/=VG,e<=1/12?Math.sqrt(3*e):RG*Math.log(12*e-zG)+BG})}});const UG={};gV.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=GG(e.W1,e.W2,e.options.method))}),gV.add(`chromatic-adaptation-end`,e=>{e.M||=GG(e.W1,e.W2,e.options.method)});function WG({id:e,toCone_M:t,fromCone_M:n}){UG[e]=arguments[0]}function GG(e,t,n=`Bradford`){let r=UG[n],[i,a,o]=YB(r.toCone_M,e),[s,c,l]=YB(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=YB(u,r.toCone_M),f=YB(r.fromCone_M,d);return f}WG({id:`von Kries`,toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),WG({id:`Bradford`,toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),WG({id:`CAT02`,toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),WG({id:`CAT16`,toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(vV,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),vV.ACES=[.32168/.33767,1,.34065/.33767];const KG=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],qG=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var JG=new AV({id:`acescg`,cssId:`--acescg`,name:`ACEScg`,coords:{r:{range:[0,65504],name:`Red`},g:{range:[0,65504],name:`Green`},b:{range:[0,65504],name:`Blue`}},referred:`scene`,white:vV.ACES,toXYZ_M:KG,fromXYZ_M:qG});const YG=2**-16,XG=-.35828683,ZG=(Math.log2(65504)+9.72)/17.52;var QG=new AV({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[XG,ZG],name:`Red`},g:{range:[XG,ZG],name:`Green`},b:{range:[XG,ZG],name:`Blue`}},referred:`scene`,base:JG,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-YG)*2:e<ZG?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(YG)+9.72)/17.52:e<YG?(Math.log2(YG+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),$G=Object.freeze({__proto__:null,A98RGB:XW,A98RGB_Linear:YW,ACEScc:QG,ACEScg:JG,CAM16_JMh:uU,HCT:yU,HPLuv:OG,HSL:WW,HSLuv:TG,HSV:GW,HWB:KW,ICTCP:VH,JzCzHz:OH,Jzazbz:DH,LCH:UV,LCHuv:uG,Lab:BV,Lab_D65:TW,Luv:lG,OKLCH:rG,OKLab:eH,P3:JU,P3_Linear:BU,ProPhoto:nG,ProPhoto_Linear:$W,REC_2020:LU,REC_2020_Linear:PU,REC_2100_HLG:HG,REC_2100_PQ:LG,XYZ_ABS_D65:dH,XYZ_D50:FV,XYZ_D65:kV,sRGB:qU,sRGB_Linear:UU}),eK=class e{constructor(...e){let t;e.length===1&&(t=wV(e[0]));let n,r,i;t?(n=t.space||t.spaceId,r=t.coords,i=t.alpha):[n,r,i]=e,Object.defineProperty(this,`space`,{value:EV.get(n),writable:!1,enumerable:!0,configurable:!0}),this.coords=r?r.slice():[0,0,0],this.alpha=i>1||i===void 0?1:i<0?0:i;for(let e=0;e<this.coords.length;e++)this.coords[e]===`NaN`&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new e(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let n=XU(this,...t);return n.color=new e(n.color),n}static get(t,...n){return t instanceof e?t:new e(t,...n)}static defineFunction(t,n,r=n){let{instance:i=!0,returns:a}=r,o=function(...t){let r=n(...t);if(a===`color`)r=e.get(r);else if(a===`function<color>`){let t=r;r=function(...n){let r=t(...n);return e.get(r)},Object.assign(r,t)}else a===`array<color>`&&(r=r.map(t=>e.get(t)));return r};t in e||(e[t]=o),i&&(e.prototype[t]=function(...e){return o(this,...e)})}static defineFunctions(t){for(let n in t)e.defineFunction(n,t[n],t[n])}static extend(exports){if(exports.register)exports.register(e);else for(let n in exports)e.defineFunction(n,exports[n])}};eK.defineFunctions({get:MV,getAll:jV,set:PV,setAll:NV,to:AU,equals:ZU,inGamut:rH,toGamut:DU,distance:aH,toString:jU}),Object.assign(eK,{util:mV,hooks:gV,WHITES:vV,Space:EV,spaces:EV.registry,parse:CV,defaults:_V});for(let e of Object.keys($G))EV.register($G[e]);for(let e in EV.registry)tK(e,EV.registry[e]);gV.add(`colorspace-init-end`,e=>{var t,n;tK(e.id,e),(t=n=e.aliases)?.forEach(t=>{tK(t,e)})});function tK(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(eK.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return EV.resolveCoord([t,n]),!0}catch{}return Reflect.has(e,n)},get:(e,n,r)=>{if(n&&typeof n!=`symbol`&&!(n in e)){let{index:r}=EV.resolveCoord([t,n]);if(r>=0)return e[r]}return Reflect.get(e,n,r)},set:(n,r,i,a)=>{if(r&&typeof r!=`symbol`&&!(r in n)||r>=0){let{index:a}=EV.resolveCoord([t,r]);if(a>=0)return n[a]=i,this.setAll(e,n),!0}return Reflect.set(n,r,i,a)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}eK.extend(wU),eK.extend({deltaE:PW}),Object.assign(eK,{deltaEMethods:wU}),eK.extend(LW),eK.extend({contrast:kW}),eK.extend(NW),eK.extend(tW),eK.extend(UW),eK.extend(OW);const{vec2:nK,vec4:rK}=xj,iK=e=>{let t=new eK(e);return rK(...t.to(`p3-linear`).coords,t.alpha).value},aK=e=>{let t=.5,n=.5,r=(e,t=!1)=>{if(typeof e==`number`)return e;let n=e.toLowerCase().trim();if(t){if(n===`top`)return 0;if(n===`bottom`)return 1;if(n===`center`)return .5}else{if(n===`left`)return 0;if(n===`right`)return 1;if(n===`center`)return .5}return console.warn(`Invalid position value: ${e}. Defaulting to center.`),.5};if(typeof e==`string`){let r=e.toLowerCase().trim().split(/\s+/);r.includes(`left`)?t=0:r.includes(`right`)?t=1:(r.includes(`center`)||r.length===1&&(r[0]===`top`||r[0]===`bottom`))&&(t=.5),r.includes(`top`)?n=0:r.includes(`bottom`)?n=1:(r.includes(`center`)||r.length===1&&(r[0]===`left`||r[0]===`right`))&&(n=.5),r.length===1&&r[0]===`center`&&(t=.5,n=.5)}else typeof e==`object`&&e?(t=r(e.x,!1),n=r(e.y,!0)):console.warn(`Invalid position value provided: ${e}. Defaulting to center.`);return nK(t,1-n).value},oK=e=>{if(typeof e==`number`)return(e%360+360)%360;let t=e.toLowerCase().trim();switch(t){case`to right`:return 0;case`to bottom`:return 90;case`to left`:return 180;case`to top`:return 270;case`to bottom right`:case`to right bottom`:return 45;case`to bottom left`:case`to left bottom`:return 135;case`to top left`:case`to left top`:return 225;case`to top right`:case`to right top`:return 315;case`from left`:return 0;case`from top`:return 90;case`from right`:return 180;case`from bottom`:return 270;case`from top left`:return 45;case`from top right`:return 135;case`from bottom right`:return 225;case`from bottom left`:return 315;default:let n=t.match(/^(-?\d*\.?\d+)(deg|rad|turn)?$/);if(n){let[,e,t=`deg`]=n,r=parseFloat(e);switch(t){case`deg`:return(r%360+360)%360;case`rad`:return(r*180/Math.PI%360+360)%360;case`turn`:return(r*360%360+360)%360;default:return(r%360+360)%360}}return console.warn(`Invalid angle value: ${e}. Defaulting to 0 degrees.`),0}},sK={name:`Checkerboard`,props:{colorA:{default:`#cccccc`,transform:iK,description:`First color of the checkerboard pattern`,ui:{type:`color`,label:`Color A`}},colorB:{default:`#999999`,transform:iK,description:`Second color of the checkerboard pattern`,ui:{type:`color`,label:`Color B`}},cells:{default:8,description:`Number of cells along the shortest canvas edge (creates square cells)`,ui:{type:`range`,min:1,max:50,step:1,label:`Cells`}}},fragmentNode:({uniforms:e})=>{let{vec2:t,mix:n,floor:r,mod:i,screenUV:a,viewportSize:o}=xj,s=o.x.div(o.y),c=t(a.x.mul(s),a.y.oneMinus()),l=e.cells.uniform,u=c.mul(l),d=r(u),f=i(d.x.add(d.y),2);return n(e.colorA.uniform,e.colorB.uniform,f)}};var cK=r({__name:`Checkerboard`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},colorA:{},colorB:{},cells:{}},{blendMode:`normal`,...Object.entries(sK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${sK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(sK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(sK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(sK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,sK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),lK=cK;const uK={name:`Circle`,props:{color:{default:`#ffffff`,transform:iK,description:`The color of the circle`,ui:{type:`color`,label:`Color`}},radius:{default:1,description:`The radius of the circle. A value of one (1) is sets the circle to fit the canvas.`,ui:{type:`range`,min:0,max:2,step:.01,label:`Radius`}},softness:{default:0,description:`Edge softness. Lower values like zero (0) are sharp, higher values like one (1) are softer.`,ui:{type:`range`,min:0,max:1,step:.01,label:`Softness`}},center:{default:{x:.5,y:.5},transform:aK,description:`The center point of the circle`,ui:{type:`text`,label:`Center Position`}}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,screenUV:o,viewportSize:s}=xj,c=s.x.div(s.y),l=t(o.x.mul(c),o.y),u=t(e.center.uniform.x.mul(c),e.center.uniform.y.oneMinus()),d=r(l.sub(u)),f=e.softness.uniform,p=e.radius.uniform.mul(.5),m=a(p,p.sub(f),d);return i(n(e.color.uniform.rgb,0),e.color.uniform,m)}};var dK=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},radius:{},softness:{},center:{}},{blendMode:`normal`,...Object.entries(uK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${uK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(uK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(uK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(uK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,uK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),fK=dK;const pK={name:`DotGrid`,props:{color:{default:`#ffffff`,description:`The color of the dot`,transform:iK,ui:{type:`color`,label:`Color`}},density:{default:100,description:`The number of dots on the longest canvas edge`,ui:{type:`range`,min:10,max:500,step:10,label:`Density`}},dotSize:{default:.3,description:`The size of each dot, zero (0) being invisible, one (1) filled the grid with no gaps`,ui:{type:`range`,min:0,max:1,step:.01,label:`Dot Size`}},twinkle:{default:0,description:`Intensity of the twinkle effect (0 = off, 1 = full twinkle)`,ui:{type:`range`,min:0,max:1,step:.01,label:`Twinkle`}}},fragmentNode:({uniforms:e})=>{let{screenUV:t,vec4:n,vec3:r,vec2:i,smoothstep:a,length:o,floor:s,float:c,viewportSize:l,time:u,sin:d,mix:f}=xj,p=t,m=e.density.uniform,h=e.dotSize.uniform,g=e.color.uniform,_=e.twinkle.uniform,v=l,y=v.x.div(v.y),b=i(p.x.mul(y),p.y.oneMinus()),x=b.mul(m),S=x.sub(s(x)),ee=o(S.sub(.5)),te=o(gM(b.mul(m))),ne=c(1).sub(a(h.mul(.5),h.mul(.5).add(te.mul(.5)),ee)),re=s(x),ie=re.x.mul(12.9898).add(re.y.mul(78.233)).sin().mul(43758.5453).fract(),ae=u.mul(2).add(ie.mul(6.28318)),oe=d(ae).mul(.5).add(.5),se=f(c(1),oe,_),ce=ne.mul(se),le=r(g).mul(ce);return n(le,ce)}};var mK=r({__name:`DotGrid`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},density:{},dotSize:{},twinkle:{}},{blendMode:`normal`,...Object.entries(pK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${pK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(pK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(pK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(pK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,pK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),hK=mK;const gK={name:`FilmGrain`,props:{intensity:{default:.25,description:`Grain intensity (0-1)`,ui:{type:`range`,min:0,max:1,step:.01,label:`Intensity`}},power:{default:.645,description:`Controls blending based on brightness`,ui:{type:`range`,min:0,max:2,step:.01,label:`Power`}},speed:{default:.5,description:`Animation speed of grain noise`,ui:{type:`range`,min:0,max:3,step:.1,label:`Speed`}}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||zP(0,0,0,0),r=AP(),i=e=>hM(pN(pM(e,LP(12.9898,78.233))).mul(43758.5453)),a=e=>pM(e,zP(.299,.587,.114,0)),o=i(r).add(XN.mul(e.speed.uniform)),s=hM(pN(o.mul(43758.5453))),c=vM(mM(.5),mM(.75),s).mul(e.intensity.uniform),l=bM(a(n),e.power.uniform),u=n.mul(c),d=dM(l,0,1),f=vM(u,n,d);return zP(f.x,f.y,f.z,n.w)}};var _K=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},power:{},speed:{}},{blendMode:`normal`,...Object.entries(gK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${gK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(gK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(gK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(gK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,gK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),vK=_K;const yK=new WeakMap,bK={name:`glassTiles`,props:{intensity:{default:1,description:`The intensity of the glass tiles effect`,ui:{type:`range`,min:0,max:5,step:.1,label:`Intensity`}},tileCount:{default:100,description:`Number of tiles across the shortest dimension`,ui:{type:`range`,min:1,max:200,step:1,label:`Tile Count`}}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,canvas:r})=>{let{vec2:i,vec4:a,floor:o,mul:s,div:c,sub:l,add:u,convertToTexture:d,screenUV:f,uniform:p}=xj;if(!t)return console.error(`You must pass a child component into the Glass Tiles shader.`),a(0);let m=d(t),h=p(1),g=()=>{r&&(h.value=r.clientWidth/r.clientHeight)};g();let _=yK.get(r);_||(_=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;m.setSize(n*i,r*i),g()}),_.observe(r),yK.set(r,_)),n(()=>{let e=yK.get(r);e&&(e.disconnect(),yK.delete(r))});let v=f,y=e.intensity.uniform,b=e.tileCount.uniform,x=i(h.greaterThanEqual(1).select(s(b,h),b),h.lessThan(1).select(c(b,h),b)),S=c(o(s(v,x)),x),ee=l(v,S),te=i(.5,.5),ne=s(y,.025),re=c(ee,c(i(1),x)),ie=l(re,te),ae=s(ie,ne),oe=u(ee,ae),se=u(oe,S);return a(m.sample(se))}};var xK=r({__name:`GlassTiles`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},tileCount:{}},{blendMode:`normal`,...Object.entries(bK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${bK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(bK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(bK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(bK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,bK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),SK=xK;const CK={VERTEX:`vertex`,FRAGMENT:`fragment`},wK={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},TK=[`fragment`,`vertex`],Roe=[...TK,`compute`],EK=[`x`,`y`,`z`,`w`],DK=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let OK=1234567;const kK=Math.PI/180,AK=180/Math.PI;function jK(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=DK[e&255]+DK[e>>8&255]+DK[e>>16&255]+DK[e>>24&255]+`-`+DK[t&255]+DK[t>>8&255]+`-`+DK[t>>16&15|64]+DK[t>>24&255]+`-`+DK[n&63|128]+DK[n>>8&255]+`-`+DK[n>>16&255]+DK[n>>24&255]+DK[r&255]+DK[r>>8&255]+DK[r>>16&255]+DK[r>>24&255];return i.toLowerCase()}function MK(e,t,n){return Math.max(t,Math.min(n,e))}function NK(e,t){return(e%t+t)%t}function PK(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function FK(e,t,n){return e===t?0:(n-e)/(t-e)}function IK(e,t,n){return(1-n)*e+n*t}function LK(e,t,n,r){return IK(e,t,1-Math.exp(-n*r))}function RK(e,t=1){return t-Math.abs(NK(e,t*2)-t)}function zK(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function BK(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function VK(e,t){return e+Math.floor(Math.random()*(t-e+1))}function HK(e,t){return e+Math.random()*(t-e)}function UK(e){return e*(.5-Math.random())}function WK(e){e!==void 0&&(OK=e);let t=OK+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function GK(e){return e*kK}function KK(e){return e*AK}function qK(e){return(e&e-1)==0&&e!==0}function JK(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function YK(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function XK(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function ZK(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function QK(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const $K={DEG2RAD:kK,RAD2DEG:AK,generateUUID:jK,clamp:MK,euclideanModulo:NK,mapLinear:PK,inverseLerp:FK,lerp:IK,damp:LK,pingpong:RK,smoothstep:zK,smootherstep:BK,randInt:VK,randFloat:HK,randFloatSpread:UK,seededRandom:WK,degToRad:GK,radToDeg:KK,isPowerOfTwo:qK,ceilPowerOfTwo:JK,floorPowerOfTwo:YK,setQuaternionFromProperEuler:XK,normalize:QK,denormalize:ZK},eq=0,tq=1015,nq=``,rq=`srgb`,iq=`srgb-linear`,aq=`linear`,oq=`srgb`,sq=35044,cq=2e3,lq=2001;var uq=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(dq.makeScale(e,t)),this}rotate(e){return this.premultiply(dq.makeRotation(-e)),this}translate(e,t){return this.premultiply(dq.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const dq=new uq,fq={};function pq(e){e in fq||(fq[e]=!0,console.warn(e))}const mq=new uq().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),hq=new uq().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function gq(){let e={enabled:!0,workingColorSpace:iq,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===oq&&(e.r=vq(e.r),e.g=vq(e.g),e.b=vq(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===oq&&(e.r=yq(e.r),e.g=yq(e.g),e.b=yq(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===nq?aq:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return pq(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return pq(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[iq]:{primaries:t,whitePoint:r,transfer:aq,toXYZ:mq,fromXYZ:hq,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:rq},outputColorSpaceConfig:{drawingBufferColorSpace:rq}},[rq]:{primaries:t,whitePoint:r,transfer:oq,toXYZ:mq,fromXYZ:hq,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:rq}}}),e}const _q=gq();function vq(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function yq(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}const bq={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},xq={h:0,s:0,l:0},Sq={h:0,s:0,l:0};function Cq(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var wq=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=rq){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,_q.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=_q.workingColorSpace){return this.r=e,this.g=t,this.b=n,_q.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=_q.workingColorSpace){if(e=NK(e,1),t=MK(t,0,1),n=MK(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Cq(i,r,e+1/3),this.g=Cq(i,r,e),this.b=Cq(i,r,e-1/3)}return _q.colorSpaceToWorking(this,r),this}setStyle(e,t=rq){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=rq){let n=bq[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=vq(e.r),this.g=vq(e.g),this.b=vq(e.b),this}copyLinearToSRGB(e){return this.r=yq(e.r),this.g=yq(e.g),this.b=yq(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=rq){return _q.workingToColorSpace(Tq.copy(this),e),Math.round(MK(Tq.r*255,0,255))*65536+Math.round(MK(Tq.g*255,0,255))*256+Math.round(MK(Tq.b*255,0,255))}getHexString(e=rq){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=_q.workingColorSpace){_q.workingToColorSpace(Tq.copy(this),t);let n=Tq.r,r=Tq.g,i=Tq.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=_q.workingColorSpace){return _q.workingToColorSpace(Tq.copy(this),t),e.r=Tq.r,e.g=Tq.g,e.b=Tq.b,e}getStyle(e=rq){_q.workingToColorSpace(Tq.copy(this),e);let t=Tq.r,n=Tq.g,r=Tq.b;return e===rq?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(xq),this.setHSL(xq.h+e,xq.s+t,xq.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(xq),e.getHSL(Sq);let n=IK(xq.h,Sq.h,t),r=IK(xq.s,Sq.s,t),i=IK(xq.l,Sq.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Tq=new wq;wq.NAMES=bq;var Eq=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},Dq=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(MK(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Oq=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Aq.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Aq.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=MK(this.x,e.x,t.x),this.y=MK(this.y,e.y,t.y),this.z=MK(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=MK(this.x,e,t),this.y=MK(this.y,e,t),this.z=MK(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MK(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return kq.copy(this).projectOnVector(e),this.sub(kq)}reflect(e){return this.sub(kq.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(MK(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const kq=new Oq,Aq=new Dq;var jq=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/Mq.setFromMatrixColumn(e,0).length(),i=1/Mq.setFromMatrixColumn(e,1).length(),a=1/Mq.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Pq,e,Fq)}lookAt(e,t,n){let r=this.elements;return Rq.subVectors(e,t),Rq.lengthSq()===0&&(Rq.z=1),Rq.normalize(),Iq.crossVectors(n,Rq),Iq.lengthSq()===0&&(Math.abs(n.z)===1?Rq.x+=1e-4:Rq.z+=1e-4,Rq.normalize(),Iq.crossVectors(n,Rq)),Iq.normalize(),Lq.crossVectors(Rq,Iq),r[0]=Iq.x,r[4]=Lq.x,r[8]=Rq.x,r[1]=Iq.y,r[5]=Lq.y,r[9]=Rq.y,r[2]=Iq.z,r[6]=Lq.z,r[10]=Rq.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=Mq.set(r[0],r[1],r[2]).length(),a=Mq.set(r[4],r[5],r[6]).length(),o=Mq.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],Nq.copy(this);let c=1/i,l=1/a,u=1/o;return Nq.elements[0]*=c,Nq.elements[1]*=c,Nq.elements[2]*=c,Nq.elements[4]*=l,Nq.elements[5]*=l,Nq.elements[6]*=l,Nq.elements[8]*=u,Nq.elements[9]*=u,Nq.elements[10]*=u,t.setFromRotationMatrix(Nq),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=cq){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===cq)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===lq)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=cq){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===cq)p=(a+i)*u,m=-2*u;else if(o===lq)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const Mq=new Oq,Nq=new jq,Pq=new Oq(0,0,0),Fq=new Oq(1,1,1),Iq=new Oq,Lq=new Oq,Rq=new Oq;var zq=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=MK(this.x,e.x,t.x),this.y=MK(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=MK(this.x,e,t),this.y=MK(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MK(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(MK(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Bq=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=MK(this.x,e.x,t.x),this.y=MK(this.y,e.y,t.y),this.z=MK(this.z,e.z,t.z),this.w=MK(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=MK(this.x,e,t),this.y=MK(this.y,e,t),this.z=MK(this.z,e,t),this.w=MK(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MK(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function Vq(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const Hq=(...e)=>Vq(e);function Uq(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of Wq(e))n.push(Vq(r.slice(0,-4)),i.getCacheKey(t));return Vq(n)}function*Wq(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function Gq(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function Kq(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new wq(...t):n===`vec2`?new zq(...t):n===`vec3`?new Oq(...t):n===`vec4`?new Bq(...t):n===`mat2`?new Eq(...t):n===`mat3`?new uq(...t):n===`mat4`?new jq(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?Jq(t[0]):null}function qq(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function Jq(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Yq=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const Xq={analyze:`setup`,generate:`analyze`};let Zq=0;var Qq=class extends Yq{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=wK.NONE,this.updateBeforeType=wK.NONE,this.updateAfterType=wK.NONE,this.uuid=$K.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:Zq++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,wK.FRAME)}onRenderUpdate(e){return this.onUpdate(e,wK.RENDER)}onObjectUpdate(e){return this.onUpdate(e,wK.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of Wq(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Hq(Uq(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=Xq[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Wq(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},$q=Qq,eJ=class extends $q{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},tJ=eJ,nJ=class extends $q{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},rJ=nJ,iJ=class extends $q{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},aJ=iJ,oJ=class extends tJ{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},sJ=oJ;const cJ=EK.join(``);var lJ=class extends $q{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(EK.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===cJ.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},uJ=lJ,dJ=class extends tJ{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=EK[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},fJ=dJ,pJ=class extends tJ{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=EK[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},mJ=pJ,hJ=class extends $q{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Gq(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Gq(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=qq(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Kq(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}},gJ=hJ;const _J=/float|u?int/;var vJ=class extends gJ{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return _J.test(n)&&_J.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},yJ=vJ,bJ=class extends $q{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}},xJ=bJ;let SJ=null;const CJ=new Map;function R(e,t){if(CJ.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);CJ.set(e,t)}const wJ=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),TJ=e=>wJ(e).split(``).sort().join(``),EJ={setup(e,t){let n=t.shift();return e(ZJ(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(SJ.assign(n,...e),n);if(CJ.has(t)){let r=CJ.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&CJ.has(t.slice(0,t.length-6))){let r=CJ.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=wJ(t),XJ(new uJ(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=TJ(t.slice(3).toLowerCase()),n=>XJ(new fJ(e,t,XJ(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=TJ(t.slice(4).toLowerCase()),()=>XJ(new mJ(XJ(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),XJ(new uJ(e,t));else if(/^\d+$/.test(t)===!0)return XJ(new rJ(n,new yJ(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>XJ(new xJ(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},DJ=new WeakMap,OJ=new WeakMap,kJ=function(e,t=null){let n=Gq(e);if(n===`node`){let t=DJ.get(e);return t===void 0&&(t=new Proxy(e,EJ),DJ.set(e,t),DJ.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return XJ(GJ(e,t));else if(n===`shader`)return eY(e);return e},AJ=function(e,t=null){for(let n in e)e[n]=XJ(e[n],t);return e},jJ=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=XJ(e[r],t);return e},MJ=function(e,t=null,n=null,r=null){let i=e=>XJ(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...QJ(l(t)))):n===null?a=(...n)=>i(new e(t,...QJ(l(n)))):(n=XJ(n),a=(...r)=>i(new e(t,...QJ(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a};var NJ=class extends $q{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=OJ.get(e.constructor);r===void 0&&(r=new WeakMap,OJ.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=XJ(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=XJ(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=XJ(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},PJ=class extends $q{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return ZJ(e),XJ(new NJ(this,e))}setup(){return this.call()}};const FJ=[!1,!0],IJ=[0,1,2,3],LJ=[-1,-2],RJ=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],zJ=new Map;for(let e of FJ)zJ.set(e,new yJ(e));const BJ=new Map;for(let e of IJ)BJ.set(e,new yJ(e,`uint`));const VJ=new Map([...BJ].map(e=>new yJ(e.value,`int`)));for(let e of LJ)VJ.set(e,new yJ(e,`int`));const HJ=new Map([...VJ].map(e=>new yJ(e.value)));for(let e of RJ)HJ.set(e,new yJ(e));for(let e of RJ)HJ.set(-e,new yJ(-e));const UJ={bool:zJ,uint:BJ,ints:VJ,float:HJ},WJ=new Map([...zJ,...HJ]),GJ=(e,t)=>WJ.has(e)?WJ.get(e):e.isNode===!0?e:new yJ(e,t),KJ=e=>{try{return e.getNodeType()}catch{return}},qJ=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[Kq(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return XJ(t.get(n[0]));if(n.length===1){let t=GJ(n[0],e);return KJ(t)===e?XJ(t):XJ(new aJ(t,e))}let r=n.map(e=>GJ(e));return XJ(new sJ(r,e))}},JJ=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function YJ(e,t){return new Proxy(new PJ(e,t),EJ)}const XJ=(e,t=null)=>kJ(e,t),ZJ=(e,t=null)=>new AJ(e,t),QJ=(e,t=null)=>new jJ(e,t),z=(...e)=>new MJ(...e);let $J=0;const eY=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new YJ(e,n),i=(...e)=>{let t;ZJ(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ $J++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i};function tY(e){return SJ&&SJ.add(e),e}R(`toStack`,tY);const nY=new qJ(`color`),rY=new qJ(`float`,UJ.float),iY=new qJ(`int`,UJ.ints),aY=new qJ(`uint`,UJ.uint),oY=new qJ(`bool`,UJ.bool),sY=new qJ(`vec2`),cY=new qJ(`ivec2`),lY=new qJ(`uvec2`),uY=new qJ(`bvec2`),dY=new qJ(`vec3`),fY=new qJ(`ivec3`),pY=new qJ(`uvec3`),mY=new qJ(`bvec3`),hY=new qJ(`vec4`),gY=new qJ(`ivec4`),_Y=new qJ(`uvec4`),vY=new qJ(`bvec4`),yY=new qJ(`mat2`),bY=new qJ(`mat3`),xY=new qJ(`mat4`);R(`toColor`,nY),R(`toFloat`,rY),R(`toInt`,iY),R(`toUint`,aY),R(`toBool`,oY),R(`toVec2`,sY),R(`toIVec2`,cY),R(`toUVec2`,lY),R(`toBVec2`,uY),R(`toVec3`,dY),R(`toIVec3`,fY),R(`toUVec3`,pY),R(`toBVec3`,mY),R(`toVec4`,hY),R(`toIVec4`,gY),R(`toUVec4`,_Y),R(`toBVec4`,vY),R(`toMat2`,yY),R(`toMat3`,bY),R(`toMat4`,xY);const SY=z(rJ).setParameterLength(2),CY=(e,t)=>XJ(new aJ(XJ(e),t));R(`element`,SY),R(`convert`,CY),R(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),tY(e)));const wY={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var TY=class e extends tJ{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(wY[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===cq;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const EY=z(TY,`+`).setParameterLength(2,1/0).setName(`add`),DY=z(TY,`-`).setParameterLength(2,1/0).setName(`sub`),OY=z(TY,`*`).setParameterLength(2,1/0).setName(`mul`),kY=z(TY,`/`).setParameterLength(2,1/0).setName(`div`),AY=z(TY,`%`).setParameterLength(2).setName(`mod`),jY=z(TY,`==`).setParameterLength(2).setName(`equal`),MY=z(TY,`!=`).setParameterLength(2).setName(`notEqual`),NY=z(TY,`<`).setParameterLength(2).setName(`lessThan`),PY=z(TY,`>`).setParameterLength(2).setName(`greaterThan`),FY=z(TY,`<=`).setParameterLength(2).setName(`lessThanEqual`),IY=z(TY,`>=`).setParameterLength(2).setName(`greaterThanEqual`),LY=z(TY,`&&`).setParameterLength(2,1/0).setName(`and`),RY=z(TY,`||`).setParameterLength(2,1/0).setName(`or`),zY=z(TY,`!`).setParameterLength(1).setName(`not`),BY=z(TY,`^^`).setParameterLength(2).setName(`xor`),VY=z(TY,`&`).setParameterLength(2).setName(`bitAnd`),HY=z(TY,`~`).setParameterLength(2).setName(`bitNot`),UY=z(TY,`|`).setParameterLength(2).setName(`bitOr`),WY=z(TY,`^`).setParameterLength(2).setName(`bitXor`),GY=z(TY,`<<`).setParameterLength(2).setName(`shiftLeft`),KY=z(TY,`>>`).setParameterLength(2).setName(`shiftRight`),qY=eY(([e])=>(e.addAssign(1),e)),JY=eY(([e])=>(e.subAssign(1),e)),YY=eY(([e])=>{let t=iY(e).toConst();return e.addAssign(1),t}),XY=eY(([e])=>{let t=iY(e).toConst();return e.subAssign(1),t});R(`add`,EY),R(`sub`,DY),R(`mul`,OY),R(`div`,kY),R(`mod`,AY),R(`equal`,jY),R(`notEqual`,MY),R(`lessThan`,NY),R(`greaterThan`,PY),R(`lessThanEqual`,FY),R(`greaterThanEqual`,IY),R(`and`,LY),R(`or`,RY),R(`not`,zY),R(`xor`,BY),R(`bitAnd`,VY),R(`bitNot`,HY),R(`bitOr`,UY),R(`bitXor`,WY),R(`shiftLeft`,GY),R(`shiftRight`,KY),R(`incrementBefore`,qY),R(`decrementBefore`,JY),R(`increment`,YY),R(`decrement`,XY);const ZY=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),AY(e,t)),QY=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),AY(iY(e),iY(t)));R(`remainder`,ZY),R(`modInt`,QY);var B=class e extends tJ{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=DY(1,n);else if(i===e.RECIPROCAL)a=kY(1,n);else if(i===e.DIFFERENCE)a=bX(DY(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=hY(dY(i),0):e=hY(dY(e),0);let o=OY(e,i).xyz;a=fX(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===cq&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===cq&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===lq&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};B.ALL=`all`,B.ANY=`any`,B.RADIANS=`radians`,B.DEGREES=`degrees`,B.EXP=`exp`,B.EXP2=`exp2`,B.LOG=`log`,B.LOG2=`log2`,B.SQRT=`sqrt`,B.INVERSE_SQRT=`inversesqrt`,B.FLOOR=`floor`,B.CEIL=`ceil`,B.NORMALIZE=`normalize`,B.FRACT=`fract`,B.SIN=`sin`,B.COS=`cos`,B.TAN=`tan`,B.ASIN=`asin`,B.ACOS=`acos`,B.ATAN=`atan`,B.ABS=`abs`,B.SIGN=`sign`,B.LENGTH=`length`,B.NEGATE=`negate`,B.ONE_MINUS=`oneMinus`,B.DFDX=`dFdx`,B.DFDY=`dFdy`,B.ROUND=`round`,B.RECIPROCAL=`reciprocal`,B.TRUNC=`trunc`,B.FWIDTH=`fwidth`,B.TRANSPOSE=`transpose`,B.BITCAST=`bitcast`,B.EQUALS=`equals`,B.MIN=`min`,B.MAX=`max`,B.STEP=`step`,B.REFLECT=`reflect`,B.DISTANCE=`distance`,B.DIFFERENCE=`difference`,B.DOT=`dot`,B.CROSS=`cross`,B.POW=`pow`,B.TRANSFORM_DIRECTION=`transformDirection`,B.MIX=`mix`,B.CLAMP=`clamp`,B.REFRACT=`refract`,B.SMOOTHSTEP=`smoothstep`,B.FACEFORWARD=`faceforward`;const $Y=rY(Math.PI),zoe=rY(Math.PI*2),eX=z(B,B.ALL).setParameterLength(1),tX=z(B,B.ANY).setParameterLength(1),nX=z(B,B.RADIANS).setParameterLength(1),rX=z(B,B.DEGREES).setParameterLength(1),iX=z(B,B.EXP).setParameterLength(1),aX=z(B,B.EXP2).setParameterLength(1),oX=z(B,B.LOG).setParameterLength(1),sX=z(B,B.LOG2).setParameterLength(1),cX=z(B,B.SQRT).setParameterLength(1),lX=z(B,B.INVERSE_SQRT).setParameterLength(1),uX=z(B,B.FLOOR).setParameterLength(1),dX=z(B,B.CEIL).setParameterLength(1),fX=z(B,B.NORMALIZE).setParameterLength(1),pX=z(B,B.FRACT).setParameterLength(1),mX=z(B,B.SIN).setParameterLength(1),hX=z(B,B.COS).setParameterLength(1),gX=z(B,B.TAN).setParameterLength(1),_X=z(B,B.ASIN).setParameterLength(1),vX=z(B,B.ACOS).setParameterLength(1),yX=z(B,B.ATAN).setParameterLength(1,2),bX=z(B,B.ABS).setParameterLength(1),xX=z(B,B.SIGN).setParameterLength(1),SX=z(B,B.LENGTH).setParameterLength(1),CX=z(B,B.NEGATE).setParameterLength(1),wX=z(B,B.ONE_MINUS).setParameterLength(1),TX=z(B,B.DFDX).setParameterLength(1),EX=z(B,B.DFDY).setParameterLength(1),DX=z(B,B.ROUND).setParameterLength(1),OX=z(B,B.RECIPROCAL).setParameterLength(1),kX=z(B,B.TRUNC).setParameterLength(1),AX=z(B,B.FWIDTH).setParameterLength(1),jX=z(B,B.TRANSPOSE).setParameterLength(1),MX=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),jY(e,t)),NX=z(B,B.MIN).setParameterLength(2,1/0),PX=z(B,B.MAX).setParameterLength(2,1/0),FX=z(B,B.STEP).setParameterLength(2),IX=z(B,B.REFLECT).setParameterLength(2),LX=z(B,B.DISTANCE).setParameterLength(2),RX=z(B,B.DIFFERENCE).setParameterLength(2),zX=z(B,B.DOT).setParameterLength(2),BX=z(B,B.CROSS).setParameterLength(2),VX=z(B,B.POW).setParameterLength(2),HX=z(B,B.POW,2).setParameterLength(1),UX=z(B,B.POW,3).setParameterLength(1),WX=z(B,B.POW,4).setParameterLength(1),GX=z(B,B.TRANSFORM_DIRECTION).setParameterLength(2),KX=e=>OY(xX(e),VX(bX(e),1/3)),qX=e=>zX(e,e),JX=z(B,B.MIX).setParameterLength(3),YX=(e,t=0,n=1)=>XJ(new B(B.CLAMP,XJ(e),XJ(t),XJ(n))),XX=e=>YX(e),ZX=z(B,B.REFRACT).setParameterLength(3),QX=z(B,B.SMOOTHSTEP).setParameterLength(3),$X=z(B,B.FACEFORWARD).setParameterLength(3),eZ=eY(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=zX(e.xy,sY(t,n)),a=AY(i,$Y);return pX(mX(a).mul(r))}),tZ=(e,t,n)=>JX(t,n,e),nZ=(e,t,n)=>QX(t,n,e),rZ=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),yX(e,t));R(`all`,eX),R(`any`,tX),R(`equals`,MX),R(`radians`,nX),R(`degrees`,rX),R(`exp`,iX),R(`exp2`,aX),R(`log`,oX),R(`log2`,sX),R(`sqrt`,cX),R(`inverseSqrt`,lX),R(`floor`,uX),R(`ceil`,dX),R(`normalize`,fX),R(`fract`,pX),R(`sin`,mX),R(`cos`,hX),R(`tan`,gX),R(`asin`,_X),R(`acos`,vX),R(`atan`,yX),R(`abs`,bX),R(`sign`,xX),R(`length`,SX),R(`lengthSq`,qX),R(`negate`,CX),R(`oneMinus`,wX),R(`dFdx`,TX),R(`dFdy`,EX),R(`round`,DX),R(`reciprocal`,OX),R(`trunc`,kX),R(`fwidth`,AX),R(`atan2`,rZ),R(`min`,NX),R(`max`,PX),R(`step`,FX),R(`reflect`,IX),R(`distance`,LX),R(`dot`,zX),R(`cross`,BX),R(`pow`,VX),R(`pow2`,HX),R(`pow3`,UX),R(`pow4`,WX),R(`transformDirection`,GX),R(`mix`,tZ),R(`clamp`,YX),R(`refract`,ZX),R(`smoothstep`,nZ),R(`faceForward`,$X),R(`difference`,RX),R(`saturate`,XX),R(`cbrt`,KX),R(`transpose`,jX),R(`rand`,eZ);var iZ=class extends tJ{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const aZ=(...e)=>{let t;if(e.length===1){let n=e[0];t=new iZ(null,n.length,n)}else{let n=e[0],r=e[1];t=new iZ(n,r)}return XJ(t)};R(`toArray`,(e,t)=>aZ(Array(t).fill(e)));var oZ=class extends $q{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const sZ=e=>new oZ(e),cZ=(e,t=0)=>new oZ(e,!0,t),lZ=cZ(`render`),uZ=sZ(`object`);var dZ=class extends gJ{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=uZ}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const fZ=(e,t)=>{let n=JJ(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return XJ(new dZ(r,n))};var pZ=class extends $q{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const mZ=(e,t)=>XJ(new pZ(e,t));var hZ=class extends tJ{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=EK.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const gZ=z(hZ).setParameterLength(2);R(`assign`,gZ);var _Z=class extends tJ{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(rY(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(rY(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const vZ=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?QJ(t):ZJ(t[0]),XJ(new _Z(XJ(e),t)));R(`call`,vZ);var yZ=class extends $q{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?mZ(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
396
|
+
var<${n}> ${e} : ${a};`}},cj=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture===null?e.depth&&e.stencil?t=I.Depth24PlusStencil8:e.depth&&(t=I.Depth24Plus):t=this.getTextureFormatGPU(e.depthTexture),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,r=n?1:t;return{samples:t,primarySamples:r,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return fA.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return fA.LineList;if(e.isLine)return fA.LineStrip;if(e.isMesh)return fA.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=2**Math.floor(Math.log2(e)),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===st)return I.BGRA8Unorm;if(e===mt)return I.RGBA16Float;throw Error(`Unsupported outputType`)}};const lj=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),uj=new Map([[Aa,[`float16`]]]),dj=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var fj=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=this._isTypedArray(o),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=s?1:o.BYTES_PER_ELEMENT;for(let t=0,n=c.length;t<n;t++){let n=c[t],l,u;if(i._force3to4BytesAlignment===!0){let t=Math.floor(n.start/3),r=Math.ceil(n.count/3);l=t*4*e,u=r*4*e}else l=n.start*e,u=n.count*e;let d=l*(s?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?MA.Instance:MA.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?MA.Instance:MA.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)),i=r.buffer,a=i.size,o=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),s=n.createCommandEncoder({label:`readback_encoder_${e.name}`});s.copyBufferToBuffer(i,0,o,0,a);let c=s.finish();n.queue.submit([c]),await o.mapAsync(GPUMapMode.READ);let l=o.getMappedRange(),u=new e.array.constructor(l.slice(0));return o.unmap(),u.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=dj.get(r);else{let e=uj.get(i)||lj.get(r),o=e[n?1:0];if(o){let e=r.BYTES_PER_ELEMENT*t,n=Math.floor((e+3)/4)*4,i=n/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${o}x${i}`}}return a||console.error(`THREE.WebGPUAttributeUtils: Vertex format not supported yet.`),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},pj=class{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,n=t.device,r=[],i=0;for(let n of e.bindings){let e={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let t={};n.isStorageBuffer&&(n.visibility&4&&(n.access===vc.READ_WRITE||n.access===vc.WRITE_ONLY)?t.type=TA.Storage:t.type=TA.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=DA.NonFiltering):r.type=DA.Comparison),e.sampler=r}else if(n.isSampledTexture&&n.texture.isVideoTexture)e.externalTexture={};else if(n.isSampledTexture&&n.store){let t={};t.format=this.backend.get(n.texture).texture.format;let r=n.access;r===vc.READ_WRITE?t.access=EA.ReadWrite:r===vc.WRITE_ONLY?t.access=EA.WriteOnly:t.access=EA.ReadOnly,e.storageTexture=t}else if(n.isSampledTexture){let r={},{primarySamples:i}=t.utils.getTextureSampleData(n.texture);if(i>1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=OA.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=OA.UnfilterableFloat:r.sampleType=OA.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=OA.SInt:e===ft?r.sampleType=OA.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=OA.Float:r.sampleType=OA.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=AA.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=AA.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=AA.ThreeD),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){let{backend:i,bindGroupLayoutCache:a}=this,o=i.get(e),s=a.get(e.bindingsReference);s===void 0&&(s=this.createBindingsLayout(e),a.set(e.bindingsReference,s));let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,s),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c,o.layout=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroupIndex(e,t){let n=this.backend,r=n.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],o=r.createBuffer({label:`bindingCameraIndex_`+a,size:16,usage:i});r.queue.writeBuffer(o,0,e,0);let s=[{binding:0,resource:{buffer:o}}];return r.createBindGroup({label:`bindGroupCameraIndex_`+a,layout:t,entries:s})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=r.createBuffer({label:`bindingBuffer_`+t.name,size:n,usage:i});e.buffer=a}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t);if(e.buffer===void 0){let r=t.attribute;e.buffer=n.get(r).buffer}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(o=e[r],o===void 0){let i=jA.All,a;a=t.isSampledCubeTexture?AA.Cube:t.isSampledTexture3D?AA.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?AA.TwoDArray:AA.TwoD,o=e[r]=e.texture.createView({aspect:i,dimension:a,mipLevelCount:n})}}a.push({binding:i,resource:o})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}},mj=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){let n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let e=c.get(t);f.push(e.layout)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==ae&&(r.blending!==oe||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures;for(let e=0;e<t.length;e++){let n=u.getTextureFormatGPU(t[e]);_.push({format:n,blend:m,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),ee=this._getSampleCount(e.context),te={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:ee,alphaToCoverageEnabled:r.alphaToCoverage&&ee>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},ne={},re=e.context.depth,ie=e.context.stencil;if((re===!0||ie===!0)&&(re===!0&&(ne.format=S,ne.depthWriteEnabled=r.depthWrite,ne.depthCompare=x),ie===!0&&(ne.stencilFront=h,ne.stencilBack={},ne.stencilReadMask=r.stencilFuncMask,ne.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(ne.depthBias=r.polygonOffsetUnits,ne.depthBiasSlopeScale=r.polygonOffsetFactor,ne.depthBiasClamp=0),te.depthStencil=ne),t===null)d.pipeline=l.createRenderPipeline(te);else{let e=new Promise(e=>{l.createRenderPipelineAsync(te).then(t=>{d.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let n=this.backend,{utils:r,device:i}=n,a=r.getCurrentDepthStencilFormat(e),o=r.getCurrentColorFormat(e),s=this._getSampleCount(e),c={label:t,colorFormats:[o],depthStencilFormat:a,sampleCount:s};return i.createRenderBundleEncoder(c)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let t=n.get(e);o.push(t.layout)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===ue){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:SA.Add},n={srcFactor:i,dstFactor:a,operation:SA.Add}};if(i)switch(r){case oe:a(xA.One,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.One,xA.One,xA.One,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.SrcAlpha);break}else switch(r){case oe:a(xA.SrcAlpha,xA.OneMinusSrcAlpha,xA.One,xA.OneMinusSrcAlpha);break;case se:a(xA.SrcAlpha,xA.One,xA.SrcAlpha,xA.One);break;case ce:a(xA.Zero,xA.OneMinusSrc,xA.Zero,xA.One);break;case le:a(xA.Zero,xA.Src,xA.Zero,xA.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error(`THREE.WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case ge:t=xA.Zero;break;case _e:t=xA.One;break;case ve:t=xA.Src;break;case ye:t=xA.OneMinusSrc;break;case be:t=xA.SrcAlpha;break;case xe:t=xA.OneMinusSrcAlpha;break;case we:t=xA.Dst;break;case Te:t=xA.OneMinusDst;break;case Se:t=xA.DstAlpha;break;case Ce:t=xA.OneMinusDstAlpha;break;case Ee:t=xA.SrcAlphaSaturated;break;case qb:t=xA.Constant;break;case Jb:t=xA.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case Dn:t=pA.Never;break;case Pn:t=pA.Always;break;case On:t=pA.Less;break;case An:t=pA.LessEqual;break;case kn:t=pA.Equal;break;case Nn:t=pA.GreaterEqual;break;case jn:t=pA.Greater;break;case Mn:t=pA.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case bn:t=wA.Keep;break;case yn:t=wA.Zero;break;case xn:t=wA.Replace;break;case En:t=wA.Invert;break;case Sn:t=wA.IncrementClamp;break;case Cn:t=wA.DecrementClamp;break;case wn:t=wA.IncrementWrap;break;case Tn:t=wA.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=SA.Add;break;case fe:t=SA.Subtract;break;case pe:t=SA.ReverseSubtract;break;case me:t=SA.Min;break;case he:t=SA.Max;break;default:console.error(`THREE.WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?vA.Uint16:vA.Uint32),n.side){case ne:r.frontFace=gA.CCW,r.cullMode=_A.Back;break;case re:r.frontFace=gA.CCW,r.cullMode=_A.Front;break;case ie:r.frontFace=gA.CCW,r.cullMode=_A.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?CA.All:CA.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=pA.Always;else{let n=e.depthFunc;switch(n){case De:t=pA.Never;break;case Oe:t=pA.Always;break;case ke:t=pA.Less;break;case Ae:t=pA.LessEqual;break;case je:t=pA.Equal;break;case Me:t=pA.GreaterEqual;break;case Ne:t=pA.Greater;break;case Pe:t=pA.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},hj=class extends cA{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return jr(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{let e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o=0;for(let[,t]of e){let e=a[t],n=a[t+1],r=Number(n-e)/1e6;o+=r}return this.resultBuffer.unmap(),this.lastValue=o,o}catch(e){return console.error(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){console.error(`Error unmapping buffer:`,e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},gj=class extends Wk{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new cj(this),this.attributeUtils=new fj(this),this.bindingUtils=new pj(this),this.pipelineUtils=new mj(this),this.textureUtils=new HA(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?`compatibility`:void 0},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(NA),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;n.lost.then(t=>{let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)});let r=t.context===void 0?e.domElement.getContext(`webgpu`):t.context;this.device=n,this.context=r;let i=t.alpha?`premultiplied`:`opaque`;this.trackTimestamp=this.trackTimestamp&&this.hasFeature(NA.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return Kn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let t=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;if(i===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples){i={},r.descriptors=i;let e=()=>{n.removeEventListener(`dispose`,e),this.delete(n)};n.hasEventListener(`dispose`,e)===!1&&n.addEventListener(`dispose`,e)}let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:AA.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=AA.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:AA.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=AA.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};e.depthTexture.isArrayTexture&&(n.dimension=AA.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=n.dimensions}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||hA.Load,storeOp:t.storeOp||mA.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:hA.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=hA.Clear):r.loadOp=hA.Load,r.storeOp=mA.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=hA.Clear):t.loadOp=hA.Load,t.storeOp=mA.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=hA.Clear):o.depthLoadOp=hA.Load,o.depthStoreOp=mA.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=hA.Clear):o.stencilLoadOp=hA.Load,o.stencilStoreOp=mA.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(n),t.bundleSets.push(i)}t.currentPass=null}else{let n=s.beginRenderPass(a);if(t.currentPass=n,e.viewport&&this.updateViewport(e),e.scissor){let{x:t,y:r,width:i,height:a}=e.scissorValue;n.setScissorRect(t,r,i,a)}}t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:AA.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||hA.Clear,depthStoreOp:i.depthStoreOp||mA.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=hA.Clear):t.depthLoadOp=hA.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=hA.Clear):t.stencilLoadOp=hA.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=hA.Clear,e.storeOp=mA.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?hA.Clear:hA.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?hA.Clear:hA.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=mA.Store),u&&(i.stencilLoadOp=n?hA.Clear:hA.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=mA.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=hA.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=mA.Store):(s.depthLoadOp=hA.Load,s.depthStoreOp=mA.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=hA.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=mA.Store):(s.stencilLoadOp=hA.Load,s.stencilStoreOp=mA.Store));let d=i.createCommandEncoder({label:`clear`}),f=d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s});f.end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(e,n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r){let{passEncoderGPU:i}=this.get(e),a=this.get(r).pipeline;this.pipelineUtils.setPipeline(i,a);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);i.setBindGroup(e,r.group)}let o=this.device.limits.maxComputeWorkgroupsPerDimension,s=this.get(t);s.dispatchSize===void 0&&(s.dispatchSize={x:0,y:1,z:1});let{dispatchSize:c}=s;t.dispatchCount>o?(c.x=Math.min(t.dispatchCount,o),c.y=Math.ceil(t.dispatchCount/o)):c.x=t.dispatchCount,i.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a).pipeline,l=e.getIndex(),u=l!==null,d=e.getDrawParameters();if(d===null)return;let f=(t,n)=>{this.pipelineUtils.setPipeline(t,c),n.pipeline=c;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(u===!0&&n.index!==l){let e=this.get(l).buffer,r=l.array instanceof Uint16Array?vA.Uint16:vA.Uint32;t.setIndexBuffer(e,r),n.index=l}let d=e.getVertexBuffers();for(let e=0,r=d.length;e<r;e++){let r=d[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},p=(r,i)=>{if(f(r,i),n.isBatchedMesh===!0){let e=n._multiDrawStarts,i=n._multiDrawCounts,a=n._multiDrawCount,o=n._multiDrawInstances;o!==null&&jr(`THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);for(let s=0;s<a;s++){let a=o?o[s]:1,c=a>1?0:s;u===!0?r.drawIndexed(i[s],a,e[s]/l.array.BYTES_PER_ELEMENT,0,c):r.draw(i[s],a,e[s],c),t.update(n,i[s],a)}}else if(u===!0){let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndexedIndirect(e,0)}else r.drawIndexed(i,a,o,0,0);t.update(n,i,a)}else{let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndirect(e,0)}else r.draw(i,a,o,0);t.update(n,i,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let r=this.bindingUtils.createBindGroupIndex(i,e.layout);n.push(r)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),p(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}p(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;let n=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[n]||(this.timestampQueryPool[n]=new hj(this.device,n,2048));let r=this.timestampQueryPool[n],i=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new sj(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass,i=r.finish();this.get(t).bundleGPU=i,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){let n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){console.error(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=hA.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=hA.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=hA.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:n,width:i,height:a}=t.scissorValue;r.currentPass.setScissorRect(e,n,i,a)}}else this.device.queue.submit([o.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}},_j=class extends Ts{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},vj=class extends Ts{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},yj=class extends YO{constructor(){super(),this.addMaterial(xv,`MeshPhongMaterial`),this.addMaterial(_b,`MeshStandardMaterial`),this.addMaterial(yb,`MeshPhysicalMaterial`),this.addMaterial(Cb,`MeshToonMaterial`),this.addMaterial(dv,`MeshBasicMaterial`),this.addMaterial(yv,`MeshLambertMaterial`),this.addMaterial(X_,`MeshNormalMaterial`),this.addMaterial(Db,`MeshMatcapMaterial`),this.addMaterial(V_,`LineBasicMaterial`),this.addMaterial(U_,`LineDashedMaterial`),this.addMaterial(Nb,`PointsMaterial`),this.addMaterial(jb,`SpriteMaterial`),this.addMaterial(Ib,`ShadowMaterial`),this.addLight(YT,As),this.addLight(bO,Ns),this.addLight(wO,Fs),this.addLight(TO,Ts),this.addLight(kO,Ps),this.addLight(AO,ys),this.addLight(jO,Ls),this.addLight(EO,_j),this.addLight(OO,vj),this.addToneMapping(zC,ze),this.addToneMapping(BC,Be),this.addToneMapping(VC,Ve),this.addToneMapping(UC,He),this.addToneMapping(qC,Ue),this.addToneMapping(JC,We)}},bj=class extends vk{constructor(e={}){let t;e.forceWebGL?t=dA:(t=gj,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new dA(e)));let n=new t(e);super(n,e),this.library=new yj,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},xj={};_(xj,{BRDF_GGX:()=>Sj,BRDF_Lambert:()=>Cj,BasicShadowFilter:()=>wj,Break:()=>Tj,Const:()=>Fte,Continue:()=>Ej,DFGApprox:()=>Dj,D_GGX:()=>Oj,Discard:()=>kj,EPSILON:()=>Aj,F_Schlick:()=>jj,Fn:()=>Mj,INFINITY:()=>Nj,If:()=>Pj,Loop:()=>Ij,NodeAccess:()=>Bj,NodeShaderStage:()=>Lj,NodeType:()=>Rj,NodeUpdateType:()=>zj,PCFShadowFilter:()=>Vj,PCFSoftShadowFilter:()=>Hj,PI:()=>Uj,PI2:()=>Wj,Return:()=>Gj,Schlick_to_F0:()=>Kj,ScriptableNodeResources:()=>qj,ShaderNode:()=>Jj,Switch:()=>Fj,TBNViewMatrix:()=>Yj,VSMShadowFilter:()=>Xj,V_GGX_SmithCorrelated:()=>Zj,Var:()=>PP,abs:()=>Qj,acesFilmicToneMapping:()=>$j,acos:()=>eM,add:()=>tM,addNodeElement:()=>nM,agxToneMapping:()=>rM,all:()=>iM,alphaT:()=>aM,and:()=>oM,anisotropy:()=>sM,anisotropyB:()=>cM,anisotropyT:()=>lM,any:()=>uM,append:()=>mee,array:()=>hee,arrayBuffer:()=>gee,asin:()=>_ee,assign:()=>vee,atan:()=>yee,atan2:()=>bee,atomicAdd:()=>xee,atomicAnd:()=>See,atomicFunc:()=>Cee,atomicLoad:()=>Aee,atomicMax:()=>wee,atomicMin:()=>Tee,atomicOr:()=>Eee,atomicStore:()=>Dee,atomicSub:()=>Oee,atomicXor:()=>kee,attenuationColor:()=>jee,attenuationDistance:()=>Mee,attribute:()=>Nee,attributeArray:()=>Pee,backgroundBlurriness:()=>Fee,backgroundIntensity:()=>Iee,backgroundRotation:()=>Lee,batch:()=>Ree,billboarding:()=>zee,bitAnd:()=>Bee,bitNot:()=>Vee,bitOr:()=>Hee,bitXor:()=>Uee,bitangentGeometry:()=>Wee,bitangentLocal:()=>Gee,bitangentView:()=>Kee,bitangentWorld:()=>qee,bitcast:()=>Jee,blendBurn:()=>Yee,blendColor:()=>Xee,blendDodge:()=>Zee,blendOverlay:()=>Qee,blendScreen:()=>$ee,blur:()=>ete,bool:()=>tte,buffer:()=>nte,bufferAttribute:()=>rte,bumpMap:()=>ite,burn:()=>ate,bvec2:()=>ote,bvec3:()=>ste,bvec4:()=>cte,bypass:()=>lte,cache:()=>ute,call:()=>dte,cameraFar:()=>fte,cameraIndex:()=>pte,cameraNear:()=>mte,cameraNormalMatrix:()=>hte,cameraPosition:()=>gte,cameraProjectionMatrix:()=>_te,cameraProjectionMatrixInverse:()=>vte,cameraViewMatrix:()=>yte,cameraWorldMatrix:()=>bte,cbrt:()=>xte,cdl:()=>Ste,ceil:()=>Cte,checker:()=>wte,cineonToneMapping:()=>Tte,clamp:()=>dM,clearcoat:()=>Ete,clearcoatRoughness:()=>Dte,code:()=>Ote,color:()=>kte,colorSpaceToWorking:()=>Ate,colorToDirection:()=>jte,compute:()=>Mte,computeSkinning:()=>Nte,cond:()=>Pte,context:()=>Ite,convert:()=>Lte,convertColorSpace:()=>Rte,convertToTexture:()=>zte,cos:()=>fM,cross:()=>Bte,cubeTexture:()=>Vte,dFdx:()=>Hte,dFdy:()=>Ute,dashSize:()=>Wte,debug:()=>Gte,decrement:()=>Kte,decrementBefore:()=>qte,defaultBuildStages:()=>Jte,defaultShaderStages:()=>Yte,defined:()=>Xte,degrees:()=>Zte,deltaTime:()=>Qte,densityFog:()=>$te,densityFogFactor:()=>ene,depth:()=>tne,depthPass:()=>nne,difference:()=>rne,diffuseColor:()=>ine,directPointLight:()=>ane,directionToColor:()=>one,dispersion:()=>sne,distance:()=>cne,div:()=>lne,dodge:()=>une,dot:()=>pM,drawIndex:()=>dne,dynamicBufferAttribute:()=>fne,element:()=>pne,emissive:()=>mne,equal:()=>hne,equals:()=>gne,equirectUV:()=>_ne,exp:()=>vne,exp2:()=>yne,expression:()=>bne,faceDirection:()=>xne,faceForward:()=>Sne,faceforward:()=>Cne,float:()=>mM,floor:()=>wne,fog:()=>Tne,fract:()=>hM,frameGroup:()=>Ene,frameId:()=>Dne,frontFacing:()=>One,fwidth:()=>gM,gain:()=>kne,gapSize:()=>Ane,getConstNodeType:()=>jne,getCurrentStack:()=>Mne,getDirection:()=>Nne,getDistanceAttenuation:()=>Pne,getGeometryRoughness:()=>Fne,getNormalFromDepth:()=>Ine,getParallaxCorrectNormal:()=>Lne,getRoughness:()=>Rne,getScreenPosition:()=>zne,getShIrradianceAt:()=>Bne,getShadowMaterial:()=>Une,getShadowRenderObjectFunction:()=>Wne,getTextureIndex:()=>Vne,getViewPosition:()=>Hne,globalId:()=>Ire,glsl:()=>Gne,glslFn:()=>Kne,grayscale:()=>qne,greaterThan:()=>Jne,greaterThanEqual:()=>Yne,hash:()=>Xne,highpModelNormalViewMatrix:()=>Zne,highpModelViewMatrix:()=>Qne,hue:()=>$ne,increment:()=>ere,incrementBefore:()=>tre,instance:()=>nre,instanceIndex:()=>rre,instancedArray:()=>ire,instancedBufferAttribute:()=>are,instancedDynamicBufferAttribute:()=>ore,instancedMesh:()=>sre,int:()=>cre,inverseSqrt:()=>lre,inversesqrt:()=>ure,invocationLocalIndex:()=>dre,invocationSubgroupIndex:()=>fre,ior:()=>pre,iridescence:()=>mre,iridescenceIOR:()=>hre,iridescenceThickness:()=>gre,ivec2:()=>_re,ivec3:()=>vre,ivec4:()=>yre,js:()=>bre,label:()=>xre,length:()=>Sre,lengthSq:()=>Cre,lessThan:()=>wre,lessThanEqual:()=>Tre,lightPosition:()=>Ere,lightProjectionUV:()=>joe,lightShadowMatrix:()=>Dre,lightTargetDirection:()=>Ore,lightTargetPosition:()=>kre,lightViewPosition:()=>Are,lightingContext:()=>jre,lights:()=>Mre,linearDepth:()=>Nre,linearToneMapping:()=>Pre,localId:()=>Fre,log:()=>Lre,log2:()=>Rre,logarithmicDepthToViewZ:()=>zre,loop:()=>Bre,luminance:()=>Vre,mat2:()=>Ure,mat3:()=>Wre,mat4:()=>Gre,matcapUV:()=>Kre,materialAO:()=>qre,materialAlphaTest:()=>Jre,materialAnisotropy:()=>Yre,materialAnisotropyVector:()=>Xre,materialAttenuationColor:()=>Zre,materialAttenuationDistance:()=>Qre,materialClearcoat:()=>$re,materialClearcoatNormal:()=>eie,materialClearcoatRoughness:()=>tie,materialColor:()=>nie,materialDispersion:()=>rie,materialEmissive:()=>iie,materialIOR:()=>aie,materialIridescence:()=>oie,materialIridescenceIOR:()=>sie,materialIridescenceThickness:()=>cie,materialLightMap:()=>lie,materialLineDashOffset:()=>uie,materialLineDashSize:()=>die,materialLineGapSize:()=>fie,materialLineScale:()=>pie,materialLineWidth:()=>mie,materialMetalness:()=>hie,materialNormal:()=>gie,materialOpacity:()=>_ie,materialPointSize:()=>vie,materialReference:()=>yie,materialReflectivity:()=>bie,materialRefractionRatio:()=>xie,materialRotation:()=>Sie,materialRoughness:()=>Cie,materialSheen:()=>wie,materialSheenRoughness:()=>Tie,materialShininess:()=>Eie,materialSpecular:()=>Die,materialSpecularColor:()=>Oie,materialSpecularIntensity:()=>kie,materialSpecularStrength:()=>Aie,materialThickness:()=>jie,materialTransmission:()=>Mie,max:()=>_M,maxMipLevel:()=>Nie,mediumpModelViewMatrix:()=>Hre,metalness:()=>Pie,min:()=>Fie,mix:()=>vM,mixElement:()=>Iie,mod:()=>Lie,modInt:()=>Rie,modelDirection:()=>zie,modelNormalMatrix:()=>Bie,modelPosition:()=>Vie,modelRadius:()=>Hie,modelScale:()=>Uie,modelViewMatrix:()=>Wie,modelViewPosition:()=>Gie,modelViewProjection:()=>Kie,modelWorldMatrix:()=>qie,modelWorldMatrixInverse:()=>Jie,morphReference:()=>Yie,mrt:()=>Xie,mul:()=>yM,mx_aastep:()=>Zie,mx_cell_noise_float:()=>Qie,mx_contrast:()=>$ie,mx_fractal_noise_float:()=>eae,mx_fractal_noise_vec2:()=>tae,mx_fractal_noise_vec3:()=>nae,mx_fractal_noise_vec4:()=>rae,mx_hsvtorgb:()=>iae,mx_noise_float:()=>aae,mx_noise_vec3:()=>oae,mx_noise_vec4:()=>sae,mx_ramplr:()=>cae,mx_ramptb:()=>lae,mx_rgbtohsv:()=>uae,mx_safepower:()=>dae,mx_splitlr:()=>fae,mx_splittb:()=>pae,mx_srgb_texture_to_lin_rec709:()=>mae,mx_transform_uv:()=>hae,mx_worley_noise_float:()=>gae,mx_worley_noise_vec2:()=>_ae,mx_worley_noise_vec3:()=>vae,namespace:()=>yae,negate:()=>bae,neutralToneMapping:()=>xae,nodeArray:()=>Sae,nodeImmutable:()=>Cae,nodeObject:()=>wae,nodeObjects:()=>Tae,nodeProxy:()=>Eae,normalFlat:()=>Dae,normalGeometry:()=>Oae,normalLocal:()=>kae,normalMap:()=>Aae,normalView:()=>jae,normalWorld:()=>Mae,normalize:()=>Nae,not:()=>Pae,notEqual:()=>Fae,numWorkgroups:()=>Iae,objectDirection:()=>Lae,objectGroup:()=>Rae,objectPosition:()=>zae,objectRadius:()=>Bae,objectScale:()=>Vae,objectViewPosition:()=>Hae,objectWorldMatrix:()=>Uae,oneMinus:()=>Wae,or:()=>Gae,orthographicDepthToViewZ:()=>Kae,oscSawtooth:()=>qae,oscSine:()=>Jae,oscSquare:()=>Yae,oscTriangle:()=>Xae,output:()=>Zae,outputStruct:()=>Qae,overlay:()=>$ae,overloadingFn:()=>eoe,parabola:()=>toe,parallaxDirection:()=>noe,parallaxUV:()=>roe,parameter:()=>ioe,pass:()=>aoe,passTexture:()=>ooe,pcurve:()=>soe,perspectiveDepthToViewZ:()=>coe,pmremTexture:()=>loe,pointShadow:()=>rN,pointUV:()=>uoe,pointWidth:()=>doe,positionGeometry:()=>foe,positionLocal:()=>poe,positionPrevious:()=>moe,positionView:()=>hoe,positionViewDirection:()=>goe,positionWorld:()=>_oe,positionWorldDirection:()=>voe,posterize:()=>yoe,pow:()=>bM,pow2:()=>boe,pow3:()=>xoe,pow4:()=>Soe,premult:()=>Coe,property:()=>woe,radians:()=>Toe,rand:()=>Eoe,range:()=>Doe,rangeFog:()=>Ooe,rangeFogFactor:()=>koe,reciprocal:()=>Aoe,reference:()=>Moe,referenceBuffer:()=>xM,reflect:()=>SM,reflectVector:()=>CM,reflectView:()=>wM,reflector:()=>TM,refract:()=>EM,refractVector:()=>DM,refractView:()=>OM,reinhardToneMapping:()=>kM,remainder:()=>AM,remap:()=>jM,remapClamp:()=>MM,renderGroup:()=>NM,renderOutput:()=>PM,rendererReference:()=>FM,rotate:()=>IM,rotateUV:()=>LM,roughness:()=>RM,round:()=>zM,rtt:()=>BM,sRGBTransferEOTF:()=>VM,sRGBTransferOETF:()=>HM,sampler:()=>UM,samplerComparison:()=>WM,saturate:()=>GM,saturation:()=>KM,screen:()=>qM,screenCoordinate:()=>JM,screenSize:()=>YM,screenUV:()=>XM,scriptable:()=>ZM,scriptableValue:()=>QM,select:()=>$M,setCurrentStack:()=>eN,shaderStages:()=>tN,shadow:()=>nN,shadowPositionWorld:()=>iN,shapeCircle:()=>oN,sharedUniformGroup:()=>aN,sheen:()=>sN,sheenRoughness:()=>cN,shiftLeft:()=>lN,shiftRight:()=>uN,shininess:()=>dN,sign:()=>fN,sin:()=>pN,sinc:()=>mN,skinning:()=>hN,smoothstep:()=>gN,smoothstepElement:()=>_N,specularColor:()=>vN,specularF90:()=>yN,spherizeUV:()=>bN,split:()=>xN,spritesheetUV:()=>SN,sqrt:()=>CN,stack:()=>wN,step:()=>TN,storage:()=>EN,storageBarrier:()=>DN,storageObject:()=>ON,storageTexture:()=>kN,string:()=>AN,struct:()=>jN,sub:()=>MN,subgroupIndex:()=>NN,subgroupSize:()=>PN,tan:()=>FN,tangentGeometry:()=>IN,tangentLocal:()=>LN,tangentView:()=>RN,tangentWorld:()=>zN,temp:()=>BN,texture:()=>VN,texture3D:()=>HN,textureBarrier:()=>UN,textureBicubic:()=>WN,textureCubeUV:()=>GN,textureLoad:()=>KN,textureSize:()=>qN,textureStore:()=>JN,thickness:()=>YN,time:()=>XN,timerDelta:()=>ZN,timerGlobal:()=>QN,timerLocal:()=>$N,toneMapping:()=>eP,toneMappingExposure:()=>tP,toonOutlinePass:()=>nP,transformDirection:()=>rP,transformNormal:()=>iP,transformNormalToView:()=>aP,transformedBentNormalView:()=>oP,transformedBitangentView:()=>sP,transformedBitangentWorld:()=>cP,transformedClearcoatNormalView:()=>lP,transformedNormalView:()=>uP,transformedNormalWorld:()=>dP,transformedTangentView:()=>fP,transformedTangentWorld:()=>pP,transmission:()=>mP,transpose:()=>hP,triNoise3D:()=>gP,triplanarTexture:()=>_P,triplanarTextures:()=>vP,trunc:()=>yP,tslFn:()=>bP,uint:()=>xP,uniform:()=>SP,uniformArray:()=>wP,uniformCubeTexture:()=>CP,uniformGroup:()=>TP,uniformTexture:()=>EP,uniforms:()=>DP,unpremult:()=>OP,userData:()=>kP,uv:()=>AP,uvec2:()=>jP,uvec3:()=>MP,uvec4:()=>NP,varying:()=>FP,varyingProperty:()=>IP,vec2:()=>LP,vec3:()=>RP,vec4:()=>zP,vectorComponents:()=>BP,velocity:()=>VP,vertexColor:()=>HP,vertexIndex:()=>UP,vibrance:()=>WP,viewZToLogarithmicDepth:()=>GP,viewZToOrthographicDepth:()=>KP,viewZToPerspectiveDepth:()=>qP,viewport:()=>JP,viewportBottomLeft:()=>YP,viewportCoordinate:()=>XP,viewportDepthTexture:()=>ZP,viewportLinearDepth:()=>QP,viewportMipTexture:()=>$P,viewportResolution:()=>eF,viewportSafeUV:()=>tF,viewportSharedTexture:()=>nF,viewportSize:()=>rF,viewportTexture:()=>iF,viewportTopLeft:()=>aF,viewportUV:()=>oF,wgsl:()=>sF,wgslFn:()=>cF,workgroupArray:()=>lF,workgroupBarrier:()=>uF,workgroupId:()=>dF,workingToColorSpace:()=>fF,xor:()=>pF});const Sj=F.BRDF_GGX,Cj=F.BRDF_Lambert,wj=F.BasicShadowFilter,Tj=F.Break,Ej=F.Continue,Dj=F.DFGApprox,Oj=F.D_GGX,kj=F.Discard,Aj=F.EPSILON,jj=F.F_Schlick,Mj=F.Fn,Nj=F.INFINITY,Pj=F.If,Fj=F.Switch,Ij=F.Loop,Lj=F.NodeShaderStage,Rj=F.NodeType,zj=F.NodeUpdateType,Bj=F.NodeAccess,Vj=F.PCFShadowFilter,Hj=F.PCFSoftShadowFilter,Uj=F.PI,Wj=F.PI2,Gj=F.Return,Kj=F.Schlick_to_F0,qj=F.ScriptableNodeResources,Jj=F.ShaderNode,Yj=F.TBNViewMatrix,Xj=F.VSMShadowFilter,Zj=F.V_GGX_SmithCorrelated,Qj=F.abs,$j=F.acesFilmicToneMapping,eM=F.acos,tM=F.add,nM=F.addNodeElement,rM=F.agxToneMapping,iM=F.all,aM=F.alphaT,oM=F.and,sM=F.anisotropy,cM=F.anisotropyB,lM=F.anisotropyT,uM=F.any,mee=F.append,hee=F.array,gee=F.arrayBuffer,_ee=F.asin,vee=F.assign,yee=F.atan,bee=F.atan2,xee=F.atomicAdd,See=F.atomicAnd,Cee=F.atomicFunc,wee=F.atomicMax,Tee=F.atomicMin,Eee=F.atomicOr,Dee=F.atomicStore,Oee=F.atomicSub,kee=F.atomicXor,Aee=F.atomicLoad,jee=F.attenuationColor,Mee=F.attenuationDistance,Nee=F.attribute,Pee=F.attributeArray,Fee=F.backgroundBlurriness,Iee=F.backgroundIntensity,Lee=F.backgroundRotation,Ree=F.batch,zee=F.billboarding,Bee=F.bitAnd,Vee=F.bitNot,Hee=F.bitOr,Uee=F.bitXor,Wee=F.bitangentGeometry,Gee=F.bitangentLocal,Kee=F.bitangentView,qee=F.bitangentWorld,Jee=F.bitcast,Yee=F.blendBurn,Xee=F.blendColor,Zee=F.blendDodge,Qee=F.blendOverlay,$ee=F.blendScreen,ete=F.blur,tte=F.bool,nte=F.buffer,rte=F.bufferAttribute,ite=F.bumpMap,ate=F.burn,ote=F.bvec2,ste=F.bvec3,cte=F.bvec4,lte=F.bypass,ute=F.cache,dte=F.call,fte=F.cameraFar,pte=F.cameraIndex,mte=F.cameraNear,hte=F.cameraNormalMatrix,gte=F.cameraPosition,_te=F.cameraProjectionMatrix,vte=F.cameraProjectionMatrixInverse,yte=F.cameraViewMatrix,bte=F.cameraWorldMatrix,xte=F.cbrt,Ste=F.cdl,Cte=F.ceil,wte=F.checker,Tte=F.cineonToneMapping,dM=F.clamp,Ete=F.clearcoat,Dte=F.clearcoatRoughness,Ote=F.code,kte=F.color,Ate=F.colorSpaceToWorking,jte=F.colorToDirection,Mte=F.compute,Nte=F.computeSkinning,Pte=F.cond,Fte=F.Const,Ite=F.context,Lte=F.convert,Rte=F.convertColorSpace,zte=F.convertToTexture,fM=F.cos,Bte=F.cross,Vte=F.cubeTexture,Hte=F.dFdx,Ute=F.dFdy,Wte=F.dashSize,Gte=F.debug,Kte=F.decrement,qte=F.decrementBefore,Jte=F.defaultBuildStages,Yte=F.defaultShaderStages,Xte=F.defined,Zte=F.degrees,Qte=F.deltaTime,$te=F.densityFog,ene=F.densityFogFactor,tne=F.depth,nne=F.depthPass,rne=F.difference,ine=F.diffuseColor,ane=F.directPointLight,one=F.directionToColor,sne=F.dispersion,cne=F.distance,lne=F.div,une=F.dodge,pM=F.dot,dne=F.drawIndex,fne=F.dynamicBufferAttribute,pne=F.element,mne=F.emissive,hne=F.equal,gne=F.equals,_ne=F.equirectUV,vne=F.exp,yne=F.exp2,bne=F.expression,xne=F.faceDirection,Sne=F.faceForward,Cne=F.faceforward,mM=F.float,wne=F.floor,Tne=F.fog,hM=F.fract,Ene=F.frameGroup,Dne=F.frameId,One=F.frontFacing,gM=F.fwidth,kne=F.gain,Ane=F.gapSize,jne=F.getConstNodeType,Mne=F.getCurrentStack,Nne=F.getDirection,Pne=F.getDistanceAttenuation,Fne=F.getGeometryRoughness,Ine=F.getNormalFromDepth,Lne=F.getParallaxCorrectNormal,Rne=F.getRoughness,zne=F.getScreenPosition,Bne=F.getShIrradianceAt,Vne=F.getTextureIndex,Hne=F.getViewPosition,Une=F.getShadowMaterial,Wne=F.getShadowRenderObjectFunction,Gne=F.glsl,Kne=F.glslFn,qne=F.grayscale,Jne=F.greaterThan,Yne=F.greaterThanEqual,Xne=F.hash,Zne=F.highpModelNormalViewMatrix,Qne=F.highpModelViewMatrix,$ne=F.hue,ere=F.increment,tre=F.incrementBefore,nre=F.instance,rre=F.instanceIndex,ire=F.instancedArray,are=F.instancedBufferAttribute,ore=F.instancedDynamicBufferAttribute,sre=F.instancedMesh,cre=F.int,lre=F.inverseSqrt,ure=F.inversesqrt,dre=F.invocationLocalIndex,fre=F.invocationSubgroupIndex,pre=F.ior,mre=F.iridescence,hre=F.iridescenceIOR,gre=F.iridescenceThickness,_re=F.ivec2,vre=F.ivec3,yre=F.ivec4,bre=F.js,xre=F.label,Sre=F.length,Cre=F.lengthSq,wre=F.lessThan,Tre=F.lessThanEqual,Ere=F.lightPosition,Dre=F.lightShadowMatrix,Ore=F.lightTargetDirection,kre=F.lightTargetPosition,Are=F.lightViewPosition,jre=F.lightingContext,Mre=F.lights,Nre=F.linearDepth,Pre=F.linearToneMapping,Fre=F.localId,Ire=F.globalId,Lre=F.log,Rre=F.log2,zre=F.logarithmicDepthToViewZ,Bre=F.loop,Vre=F.luminance,Hre=F.mediumpModelViewMatrix,Ure=F.mat2,Wre=F.mat3,Gre=F.mat4,Kre=F.matcapUV,qre=F.materialAO,Jre=F.materialAlphaTest,Yre=F.materialAnisotropy,Xre=F.materialAnisotropyVector,Zre=F.materialAttenuationColor,Qre=F.materialAttenuationDistance,$re=F.materialClearcoat,eie=F.materialClearcoatNormal,tie=F.materialClearcoatRoughness,nie=F.materialColor,rie=F.materialDispersion,iie=F.materialEmissive,aie=F.materialIOR,oie=F.materialIridescence,sie=F.materialIridescenceIOR,cie=F.materialIridescenceThickness,lie=F.materialLightMap,uie=F.materialLineDashOffset,die=F.materialLineDashSize,fie=F.materialLineGapSize,pie=F.materialLineScale,mie=F.materialLineWidth,hie=F.materialMetalness,gie=F.materialNormal,_ie=F.materialOpacity,vie=F.materialPointSize,yie=F.materialReference,bie=F.materialReflectivity,xie=F.materialRefractionRatio,Sie=F.materialRotation,Cie=F.materialRoughness,wie=F.materialSheen,Tie=F.materialSheenRoughness,Eie=F.materialShininess,Die=F.materialSpecular,Oie=F.materialSpecularColor,kie=F.materialSpecularIntensity,Aie=F.materialSpecularStrength,jie=F.materialThickness,Mie=F.materialTransmission,_M=F.max,Nie=F.maxMipLevel,Pie=F.metalness,Fie=F.min,vM=F.mix,Iie=F.mixElement,Lie=F.mod,Rie=F.modInt,zie=F.modelDirection,Bie=F.modelNormalMatrix,Vie=F.modelPosition,Hie=F.modelRadius,Uie=F.modelScale,Wie=F.modelViewMatrix,Gie=F.modelViewPosition,Kie=F.modelViewProjection,qie=F.modelWorldMatrix,Jie=F.modelWorldMatrixInverse,Yie=F.morphReference,Xie=F.mrt,yM=F.mul,Zie=F.mx_aastep,Qie=F.mx_cell_noise_float,$ie=F.mx_contrast,eae=F.mx_fractal_noise_float,tae=F.mx_fractal_noise_vec2,nae=F.mx_fractal_noise_vec3,rae=F.mx_fractal_noise_vec4,iae=F.mx_hsvtorgb,aae=F.mx_noise_float,oae=F.mx_noise_vec3,sae=F.mx_noise_vec4,cae=F.mx_ramplr,lae=F.mx_ramptb,uae=F.mx_rgbtohsv,dae=F.mx_safepower,fae=F.mx_splitlr,pae=F.mx_splittb,mae=F.mx_srgb_texture_to_lin_rec709,hae=F.mx_transform_uv,gae=F.mx_worley_noise_float,_ae=F.mx_worley_noise_vec2,vae=F.mx_worley_noise_vec3,yae=F.namespace,bae=F.negate,xae=F.neutralToneMapping,Sae=F.nodeArray,Cae=F.nodeImmutable,wae=F.nodeObject,Tae=F.nodeObjects,Eae=F.nodeProxy,Dae=F.normalFlat,Oae=F.normalGeometry,kae=F.normalLocal,Aae=F.normalMap,jae=F.normalView,Mae=F.normalWorld,Nae=F.normalize,Pae=F.not,Fae=F.notEqual,Iae=F.numWorkgroups,Lae=F.objectDirection,Rae=F.objectGroup,zae=F.objectPosition,Bae=F.objectRadius,Vae=F.objectScale,Hae=F.objectViewPosition,Uae=F.objectWorldMatrix,Wae=F.oneMinus,Gae=F.or,Kae=F.orthographicDepthToViewZ,qae=F.oscSawtooth,Jae=F.oscSine,Yae=F.oscSquare,Xae=F.oscTriangle,Zae=F.output,Qae=F.outputStruct,$ae=F.overlay,eoe=F.overloadingFn,toe=F.parabola,noe=F.parallaxDirection,roe=F.parallaxUV,ioe=F.parameter,aoe=F.pass,ooe=F.passTexture,soe=F.pcurve,coe=F.perspectiveDepthToViewZ,loe=F.pmremTexture,uoe=F.pointUV,doe=F.pointWidth,foe=F.positionGeometry,poe=F.positionLocal,moe=F.positionPrevious,hoe=F.positionView,goe=F.positionViewDirection,_oe=F.positionWorld,voe=F.positionWorldDirection,yoe=F.posterize,bM=F.pow,boe=F.pow2,xoe=F.pow3,Soe=F.pow4,Coe=F.premult,woe=F.property,Toe=F.radians,Eoe=F.rand,Doe=F.range,Ooe=F.rangeFog,koe=F.rangeFogFactor,Aoe=F.reciprocal,joe=F.lightProjectionUV,Moe=F.reference,xM=F.referenceBuffer,SM=F.reflect,CM=F.reflectVector,wM=F.reflectView,TM=F.reflector,EM=F.refract,DM=F.refractVector,OM=F.refractView,kM=F.reinhardToneMapping,AM=F.remainder,jM=F.remap,MM=F.remapClamp,NM=F.renderGroup,PM=F.renderOutput,FM=F.rendererReference,IM=F.rotate,LM=F.rotateUV,RM=F.roughness,zM=F.round,BM=F.rtt,VM=F.sRGBTransferEOTF,HM=F.sRGBTransferOETF,UM=F.sampler,WM=F.samplerComparison,GM=F.saturate,KM=F.saturation,qM=F.screen,JM=F.screenCoordinate,YM=F.screenSize,XM=F.screenUV,ZM=F.scriptable,QM=F.scriptableValue,$M=F.select,eN=F.setCurrentStack,tN=F.shaderStages,nN=F.shadow,rN=F.pointShadow,iN=F.shadowPositionWorld,aN=F.sharedUniformGroup,oN=F.shapeCircle,sN=F.sheen,cN=F.sheenRoughness,lN=F.shiftLeft,uN=F.shiftRight,dN=F.shininess,fN=F.sign,pN=F.sin,mN=F.sinc,hN=F.skinning,gN=F.smoothstep,_N=F.smoothstepElement,vN=F.specularColor,yN=F.specularF90,bN=F.spherizeUV,xN=F.split,SN=F.spritesheetUV,CN=F.sqrt,wN=F.stack,TN=F.step,EN=F.storage,DN=F.storageBarrier,ON=F.storageObject,kN=F.storageTexture,AN=F.string,jN=F.struct,MN=F.sub,NN=F.subgroupIndex,PN=F.subgroupSize,FN=F.tan,IN=F.tangentGeometry,LN=F.tangentLocal,RN=F.tangentView,zN=F.tangentWorld,BN=F.temp,VN=F.texture,HN=F.texture3D,UN=F.textureBarrier,WN=F.textureBicubic,GN=F.textureCubeUV,KN=F.textureLoad,qN=F.textureSize,JN=F.textureStore,YN=F.thickness,XN=F.time,ZN=F.timerDelta,QN=F.timerGlobal,$N=F.timerLocal,eP=F.toneMapping,tP=F.toneMappingExposure,nP=F.toonOutlinePass,rP=F.transformDirection,iP=F.transformNormal,aP=F.transformNormalToView,oP=F.transformedBentNormalView,sP=F.transformedBitangentView,cP=F.transformedBitangentWorld,lP=F.transformedClearcoatNormalView,uP=F.transformedNormalView,dP=F.transformedNormalWorld,fP=F.transformedTangentView,pP=F.transformedTangentWorld,mP=F.transmission,hP=F.transpose,gP=F.triNoise3D,_P=F.triplanarTexture,vP=F.triplanarTextures,yP=F.trunc,bP=F.tslFn,xP=F.uint,SP=F.uniform,CP=F.uniformCubeTexture,wP=F.uniformArray,TP=F.uniformGroup,EP=F.uniformTexture,DP=F.uniforms,OP=F.unpremult,kP=F.userData,AP=F.uv,jP=F.uvec2,MP=F.uvec3,NP=F.uvec4,PP=F.Var,FP=F.varying,IP=F.varyingProperty,LP=F.vec2,RP=F.vec3,zP=F.vec4,BP=F.vectorComponents,VP=F.velocity,HP=F.vertexColor,UP=F.vertexIndex,WP=F.vibrance,GP=F.viewZToLogarithmicDepth,KP=F.viewZToOrthographicDepth,qP=F.viewZToPerspectiveDepth,JP=F.viewport,YP=F.viewportBottomLeft,XP=F.viewportCoordinate,ZP=F.viewportDepthTexture,QP=F.viewportLinearDepth,$P=F.viewportMipTexture,eF=F.viewportResolution,tF=F.viewportSafeUV,nF=F.viewportSharedTexture,rF=F.viewportSize,iF=F.viewportTexture,aF=F.viewportTopLeft,oF=F.viewportUV,sF=F.wgsl,cF=F.wgslFn,lF=F.workgroupArray,uF=F.workgroupBarrier,dF=F.workgroupId,fF=F.workingToColorSpace,pF=F.xor;function mF(e,t,n=1){let r=e.rgb,i=t.rgb,a=yM(r,i),o=yM(t.a,n),s=vM(r,a,o),c=_M(e.a,yM(t.a,n));return zP(s,c)}function hF(e,t,n=1){let r=yM(t.a,n),i=tM(r,yM(e.a,MN(1,r))),a=tM(yM(t.rgb,r),yM(e.rgb,yM(e.a,MN(1,r))));return zP(a,i)}const gF={normal:hF,multiply:mF};function _F(e,t,n=`normal`,r=1){let i=gF[n]||gF.normal;return i(e,t,r)}function vF(e,t){let n=yM(e.a,t.a);return zP(e.rgb,n)}function yF(e,t){let n=MN(1,t.a),r=yM(e.a,n);return zP(e.rgb,r)}function bF(e,t){let n=RP(.2126,.7152,.0722),r=pM(t.rgb,n),i=yM(e.a,r);return zP(e.rgb,i)}function xF(e,t){let n=RP(.2126,.7152,.0722),r=pM(t.rgb,n),i=MN(1,r),a=yM(e.a,i);return zP(e.rgb,a)}const SF={alpha:vF,alphaInverted:yF,luminance:bF,luminanceInverted:xF};function CF(e,t,n=`alpha`){let r=SF[n]||SF.alpha;return r(e,t)}const wF={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let TF=!1;const EF=()=>{try{if(wF!==void 0){let{MODE:e,DEV:t}=wF;return t||e===`development`}if(typeof window<`u`&&window.location){let e=window.location.hostname;return e===`localhost`||e===`127.0.0.1`||e.endsWith(`.local`)||e.includes(`dev.`)||e.startsWith(`dev-`)}return!1}catch{return!1}};function DF(){let e=`renderer_${Math.random().toString(36).substring(2,11)}`,t=null,n,r,i,a,o,s={nodes:new Map,rootId:null,idToNodeId:new Map},c=null,l=null,u=null,d=!1,f=!1,p=!1,m=null,h=!1,g=!0,_=0,v=0,y=0,b=0,x=8,S=.5,ee=.5,te=!1,ne=!1,re=!1,ie=[],ae=!1,oe=[],se=!1,ce=()=>{var e,t,n;return(e=t=(n=window).matchMedia)?.call(n,`(prefers-reduced-motion: reduce)`).matches??!1},le=(e,t)=>{if(e===_&&t===v)return;let i=performance.now();if(i-y<x)return;_=e,v=t,y=i,n.setSize(e,t,!1);let o=e/t,c=2,l=c*o;r.left=-l/2,r.right=l/2,r.top=c/2,r.bottom=-c/2,r.updateProjectionMatrix(),a.scale.set(l,c,1),s.rootId&&p&&fe(),we().catch(console.warn)},ue=e=>{if(!n||!r||!a)return;let t=e[0];if(!t)return;let{width:i,height:o}=t.contentRect,s=Math.round(i),c=Math.round(o);le(s,c)},de=e=>{let t=e[0];t&&(h=t.isIntersecting,h?(o&&d&&s.rootId&&fe(),g&&Te()):Ee())},fe=()=>{if(!s.rootId||!o||ne)return;let e=s.nodes.get(s.rootId);if(e){ne=!0;try{let e=_e(s.rootId);e&&o&&(o.fragmentNode=e,o.needsUpdate=!0)}catch(e){console.error(`Error composing shader tree:`,e)}finally{ne=!1}h&&we().catch(console.warn)}},pe=e=>{let t=[];return s.nodes.forEach(n=>{n.parentId===e&&t.push(n)}),t},me=e=>{for(let[t,n]of s.nodes.entries())if(n.metadata.id===e)return t;return null},he=(e,t,n,r)=>{var i,a;if(!(i=a=t.metadata.mask)?.source)return e;let o=t.metadata.mask.source,s=me(o);if(!s)return e;if(r.has(s))return console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`),e;let c=new Set(r);c.add(n);let l=_e(s,c),u=t.metadata.mask.type||`alpha`;return CF(e,l,u)},ge=e=>{var t,n;let r=s.nodes.get(e);if(!r||!r.metadata.id)return!1;let i=r.metadata.id;for(let e of s.nodes.values())if((t=n=e.metadata.mask)?.source===i)return!0;return!1},_e=(e,n=new Set)=>{let r=s.nodes.get(e);if(!r)return zP(0,0,0,0);let i=e=>{r.cleanupCallbacks.push(e)},a=e=>{r.beforeRenderCallbacks.push(e)},o=e=>{r.afterRenderCallbacks.push(e)},c=pe(e);if(c.length===0){let s=r.fragmentNodeFunc({uniforms:r.uniforms??{},childNode:void 0,onCleanup:i,onBeforeRender:a,onAfterRender:o,canvas:t});return he(s,r,e,n)}else{let s=[...c].sort((e,t)=>e.metadata.renderOrder-t.metadata.renderOrder),l=r.parentId===null;if(l){let c;for(let e of s){let t=e.metadata.opacity??(ge(e.id)?0:1);if(t===0&&!ge(e.id))continue;let r=_e(e.id,n),i;i=e.metadata.opacity===void 0?ge(e.id)?0:1:e.metadata.opacity,c=c===void 0?i===1?_F(zP(1,1,1,0),r,`normal`,1):_F(zP(1,1,1,0),r,e.metadata.blendMode,i):_F(c,r,e.metadata.blendMode,i)}let l=r.fragmentNodeFunc({uniforms:r.uniforms??{},childNode:c,onCleanup:i,onBeforeRender:a,onAfterRender:o,canvas:t});return he(l,r,e,n)}else{let c;for(let e of s){let t=_e(e.id,n),r=e.metadata.opacity??(ge(e.id)?0:1);if(r===0&&!ge(e.id))continue;let i;i=e.metadata.opacity===void 0?ge(e.id)?0:1:e.metadata.opacity,c=c===void 0?i===1?_F(zP(1,1,1,0),t,`normal`,1):_F(zP(1,1,1,0),t,e.metadata.blendMode,i):_F(c,t,e.metadata.blendMode,i)}let l=r.fragmentNodeFunc({uniforms:r.uniforms??{},childNode:c,onCleanup:i,onBeforeRender:a,onAfterRender:o,canvas:t});return he(l,r,e,n)}}},ve=(e,t,n,r,i={})=>{let a=0;if(n!==null){let e=Array.from(s.nodes.values()).filter(e=>e.parentId===n);e.length>0&&(a=Math.max(...e.map(e=>e.metadata.renderOrder))+1)}let c={id:e,fragmentNodeFunc:t,parentId:n,metadata:{blendMode:r?.blendMode||`normal`,opacity:r?.opacity,id:r?.id,mask:r?.mask,renderOrder:r?.renderOrder===void 0?a:r?.renderOrder},uniforms:i,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};s.nodes.set(e,c),n===null&&(s.rootId=e),o&&d&&(ie.includes(e)||ie.push(e),ae||(ae=!0,queueMicrotask(()=>{ae=!1,ie=[],fe()})))},ye=(e,t,n)=>{let r=s.nodes.get(e);if(!r||!r.uniforms){console.warn(`Node or uniforms not found for ID: ${e}`);return}let i=r.uniforms[t];if(!i||!i.uniform){console.warn(`Uniform ${t} not found in node: ${e}`);return}i.uniform.value=n,h&&we()},be=(e,t)=>{var n,r,i,a,c,l,u,f;let p=s.nodes.get(e);if(!p)return;let m=!1;t.blendMode!==void 0&&p.metadata.blendMode!==t.blendMode&&(p.metadata.blendMode=t.blendMode,m=!0),t.opacity!==void 0&&p.metadata.opacity!==t.opacity&&(p.metadata.opacity=t.opacity,m=!0),t.renderOrder!==void 0&&p.metadata.renderOrder!==t.renderOrder&&(p.metadata.renderOrder=t.renderOrder,m=!0),t.id!==void 0&&p.metadata.id!==t.id&&(p.metadata.id=t.id,m=!0),t.mask!==void 0&&((n=c=p.metadata.mask)?.source!==(r=l=t.mask)?.source||(i=u=p.metadata.mask)?.type!==(a=f=t.mask)?.type)&&(p.metadata.mask=t.mask,m=!0),m&&o&&d?(oe.includes(e)||oe.push(e),se||(se=!0,queueMicrotask(()=>{se=!1,oe=[],fe()}))):h&&we()},xe=e=>{if(!s.nodes.has(e))return;let t=s.nodes.get(e);if(t&&t.cleanupCallbacks.length>0)for(let n of t.cleanupCallbacks)try{n()}catch(t){console.error(`Error executing cleanup callback for node ${e}:`,t)}let n=pe(e);for(let e of n)xe(e.id);s.rootId===e&&(s.rootId=null),s.nodes.delete(e),o&&d&&fe()},Se=e=>{let t={deltaTime:e,pointer:{x:S,y:ee},pointerActive:te,dimensions:{width:_,height:v}};for(let e of s.nodes.values())if(e.beforeRenderCallbacks.length>0)for(let n of e.beforeRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing before render callback for node ${e.id}:`,t)}},Ce=e=>{let t={deltaTime:e,pointer:{x:S,y:ee},pointerActive:te,dimensions:{width:_,height:v}};for(let e of s.nodes.values())if(e.afterRenderCallbacks.length>0)for(let n of e.afterRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing after render callback for node ${e.id}:`,t)}},we=async()=>{if(!d||!n||!i||!r||!o)return;let e=performance.now(),t=b>0?(e-b)/1e3:.016,a=Math.min(t,.1);b=e,Se(a);try{if(ne)return;n instanceof bj?await n.renderAsync(i,r).then(()=>{d&&Ce(a)}).catch(e=>{console.error(`WebGPU render error:`,e)}):(n.render(i,r),Ce(a))}catch(e){console.error(`Render frame error:`,e)}},Te=()=>{if(c||!g||!h)return;let e=()=>{c=requestAnimationFrame(e),we().catch(console.warn)};e()},Ee=()=>{c&&(cancelAnimationFrame(c),c=null)},De=n=>{if(!t){console.log(`[${e}] No canvas element in updatePointerCoords`);return}let r,i;if(`touches`in n){if(n.touches.length===0)return;r=n.touches[0].clientX,i=n.touches[0].clientY}else r=n.clientX,i=n.clientY;let a=t.getBoundingClientRect(),o=(r-a.left)/a.width,s=(i-a.top)/a.height;S=o,ee=s},Oe=e=>{De(e)},ke=e=>{De(e)},Ae=()=>{te=!1,we().catch(console.warn)},je=()=>{te=!1,we().catch(console.warn)},Me=()=>{te=!0,we().catch(console.warn)},Ne=()=>{te=!0,we().catch(console.warn)},Pe=async({canvas:s})=>{if(d||f)return;f=!0,m=new AbortController;let c=m;try{if(t=s,i=new bo,i.background=null,r=new js(-1,1,1,-1,.1,10),r.position.z=1,r.lookAt(0,0,0),re||(window.addEventListener(`mousemove`,Oe),window.addEventListener(`touchmove`,ke),window.addEventListener(`mouseup`,Ae),window.addEventListener(`touchend`,je),s.addEventListener(`mousedown`,Me),s.addEventListener(`touchstart`,Ne),re=!0,console.log(`[${e}] Added event listeners`)),c.signal.aborted)return;try{if(n=new bj({canvas:s,antialias:!0,alpha:!0,depth:!1,powerPreference:`high-performance`}),await n.init(),c.signal.aborted)return}catch(e){if(c.signal.aborted)return;console.error(`[Shaders] WebGPU initialization error:`,e);return}if(c.signal.aborted)return;n.setPixelRatio(Math.min(window.devicePixelRatio,2)),n.outputColorSpace=hn,o=new dv({transparent:!0}),o.fragmentNode=zP(0,0,0,0);let f=new Ho(2,2);a=new Za(f,o),i.add(a),l=new ResizeObserver(ue),l.observe(s),u=new IntersectionObserver(de,{threshold:0}),u.observe(s),g=!ce();let{width:m,height:_}=s.getBoundingClientRect();le(Math.round(m),Math.round(_)),p=!0,await we(),g&&h&&Te(),c.signal.aborted||(d=!0)}catch(e){console.error(`[Shaders] Initialization error:`,e)}finally{f=!1,m===c&&(m=null)}},Fe=()=>{!EF()||TF||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),TF=!0)},Ie=()=>{if(console.log(`[${e}] Cleanup called`),m&&m.abort(),l&&(l.disconnect(),l=null),u&&(u.disconnect(),u=null),re&&(console.log(`[${e}] Removing event listeners`),t&&(t.removeEventListener(`mousedown`,Me),t.removeEventListener(`touchstart`,Ne)),window&&(window.removeEventListener(`mousemove`,Oe),window.removeEventListener(`touchmove`,ke),window.removeEventListener(`mouseup`,Ae),window.removeEventListener(`touchend`,je)),re=!1),Ee(),s.nodes.clear(),s.rootId=null,s.idToNodeId.clear(),ie=[],ae=!1,oe=[],se=!1,a){i&&i.remove(a);try{a.geometry&&typeof a.geometry.dispose==`function`&&a.geometry.dispose()}catch(e){console.warn(`Error disposing geometry:`,e)}try{a.material instanceof va&&typeof a.material.dispose==`function`&&a.material.dispose()}catch(e){console.warn(`Error disposing material:`,e)}}if(n&&typeof n.dispose==`function`)try{n.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}t=null,n=null,r=null,i=null,a=null,o=null,d=!1,f=!1,p=!1,m=null,_=0,v=0,h=!1,g=!0,S=.5,ee=.5,te=!1};return{initialize:Pe,cleanup:Ie,registerNode:ve,removeNode:xe,updateUniformValue:ye,updateNodeMetadata:be,showLicenseWarning:Fe}}const{uniform:OF}=xj;function kF(e,t,n){let r={};return Object.entries(e.props).forEach(([e,i])=>{let a=t[e],o=a;i.transform&&(o=i.transform(a)),r[e]={uniform:OF(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:AF,fract:jF,sin:MF,dot:NF}=xj,PF=e=>jF(MF(NF(e,AF(12.12345,78.12345))).mul(40000.12345)),Noe=(e=.03)=>t=>PF(t).mul(e).mul(.10012345),{vec2:FF}=xj,Poe=(e=FF(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=xj,c=r*1.618033988749895,l=r*2.718281828459045,u=(Math.sin(r)+2)*5,d=(Math.cos(r)+2)*5,f=i(a(e.x.mul(n).mul(u).add(s.mul(.1)).add(c)),o(e.y.mul(n).mul(u).add(s.mul(.1)).add(l))),p=i(a(e.y.mul(n).mul(d).add(s.mul(.05)).add(l)),o(e.x.mul(n).mul(d).add(s.mul(.05)).add(c))),m=f.add(p).mul(t);return e.add(m)},Foe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=xj,c=a(a(e.r,e.g),e.b),l=o(n,n+r,c).mul(i).mul(1),u=e.rgb.add(t.rgb.mul(l));return s(u,e.a)},Ioe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=xj,c=s(),l=c.x.sub(.5).sub(a(r)).mul(2),u=c.y.sub(.5).add(a(i)).mul(2),d=l.mul(l).add(u.mul(u)).sqrt();return a(1).sub(o(a(1).sub(a(t)),a(1).sub(a(t)).add(a(n)),d.mul(a(1).add(a(n)))))},IF=`177`,LF=0,RF=3,zF=0,BF=1,VF=0,HF=1,UF=100,WF=204,GF=205,KF=3,qF=0,JF=0,YF=300,XF=301,ZF=302,QF=306,$F=1e3,eI=1001,tI=1002,nI=1003,rI=1006,iI=1008,aI=1008,oI=1009,sI=1013,cI=1014,lI=1015,uI=1016,dI=1023,fI=1026,pI=1027,mI=1028,hI=1030,gI=2300,_I=2301,vI=2302,yI=2400,bI=2401,xI=2402,SI=0,CI=1,wI=``,TI=`srgb`,EI=`srgb-linear`,DI=`linear`,OI=`srgb`,kI=7680,AI=519,jI=512,MI=513,NI=514,PI=515,FI=516,II=517,LI=518,RI=519,zI=35044,BI=35048,VI=2e3,HI=2001;var UI=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const WI=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let GI=1234567;const KI=Math.PI/180,qI=180/Math.PI;function JI(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=WI[e&255]+WI[e>>8&255]+WI[e>>16&255]+WI[e>>24&255]+`-`+WI[t&255]+WI[t>>8&255]+`-`+WI[t>>16&15|64]+WI[t>>24&255]+`-`+WI[n&63|128]+WI[n>>8&255]+`-`+WI[n>>16&255]+WI[n>>24&255]+WI[r&255]+WI[r>>8&255]+WI[r>>16&255]+WI[r>>24&255];return i.toLowerCase()}function YI(e,t,n){return Math.max(t,Math.min(n,e))}function XI(e,t){return(e%t+t)%t}function ZI(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function QI(e,t,n){return e===t?0:(n-e)/(t-e)}function $I(e,t,n){return(1-n)*e+n*t}function eL(e,t,n,r){return $I(e,t,1-Math.exp(-n*r))}function tL(e,t=1){return t-Math.abs(XI(e,t*2)-t)}function nL(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function rL(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function iL(e,t){return e+Math.floor(Math.random()*(t-e+1))}function aL(e,t){return e+Math.random()*(t-e)}function oL(e){return e*(.5-Math.random())}function sL(e){e!==void 0&&(GI=e);let t=GI+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function cL(e){return e*KI}function lL(e){return e*qI}function uL(e){return(e&e-1)==0&&e!==0}function dL(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function fL(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function pL(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function mL(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function hL(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const gL={DEG2RAD:KI,RAD2DEG:qI,generateUUID:JI,clamp:YI,euclideanModulo:XI,mapLinear:ZI,inverseLerp:QI,lerp:$I,damp:eL,pingpong:tL,smoothstep:nL,smootherstep:rL,randInt:iL,randFloat:aL,randFloatSpread:oL,seededRandom:sL,degToRad:cL,radToDeg:lL,isPowerOfTwo:uL,ceilPowerOfTwo:dL,floorPowerOfTwo:fL,setQuaternionFromProperEuler:pL,normalize:hL,denormalize:mL};var _L=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=YI(this.x,e.x,t.x),this.y=YI(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=YI(this.x,e,t),this.y=YI(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(YI(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(YI(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},vL=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(YI(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},L=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(bL.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(bL.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=YI(this.x,e.x,t.x),this.y=YI(this.y,e.y,t.y),this.z=YI(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=YI(this.x,e,t),this.y=YI(this.y,e,t),this.z=YI(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(YI(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return yL.copy(this).projectOnVector(e),this.sub(yL)}reflect(e){return this.sub(yL.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(YI(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const yL=new L,bL=new vL;var xL=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(SL.makeScale(e,t)),this}rotate(e){return this.premultiply(SL.makeRotation(-e)),this}translate(e,t){return this.premultiply(SL.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const SL=new xL;function CL(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function wL(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}const TL={};function EL(e){e in TL||(TL[e]=!0,console.warn(e))}const DL=new xL().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),OL=new xL().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function kL(){let e={enabled:!0,workingColorSpace:EI,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===OI&&(e.r=jL(e.r),e.g=jL(e.g),e.b=jL(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===OI&&(e.r=ML(e.r),e.g=ML(e.g),e.b=ML(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===wI?DI:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return EL(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return EL(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[EI]:{primaries:t,whitePoint:r,transfer:DI,toXYZ:DL,fromXYZ:OL,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:TI},outputColorSpaceConfig:{drawingBufferColorSpace:TI}},[TI]:{primaries:t,whitePoint:r,transfer:OI,toXYZ:DL,fromXYZ:OL,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:TI}}}),e}const AL=kL();function jL(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function ML(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let NL;var PL=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{NL===void 0&&(NL=wL(`canvas`)),NL.width=e.width,NL.height=e.height;let t=NL.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=NL}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=wL(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=jL(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(jL(t[e]/255)*255):t[e]=jL(t[e]);return{data:t,width:e.width,height:e.height}}else return console.warn(`THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}};let FL=0;var IL=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:FL++}),this.uuid=JI(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(LL(r[t].image)):e.push(LL(r[t]))}else e=LL(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function LL(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?PL.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let RL=0;const zL=new L;var BL=class e extends UI{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=eI,i=eI,a=rI,o=iI,s=dI,c=oI,l=e.DEFAULT_ANISOTROPY,u=wI){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:RL++}),this.uuid=JI(),this.name=``,this.source=new IL(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new _L(0,0),this.repeat=new _L(1,1),this.center=new _L(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xL,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(zL).x}get height(){return this.source.getSize(zL).y}get depth(){return this.source.getSize(zL).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==YF)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case $F:e.x-=Math.floor(e.x);break;case eI:e.x=e.x<0?0:1;break;case tI:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case $F:e.y-=Math.floor(e.y);break;case eI:e.y=e.y<0?0:1;break;case tI:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};BL.DEFAULT_IMAGE=null,BL.DEFAULT_MAPPING=YF,BL.DEFAULT_ANISOTROPY=1;var VL=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=YI(this.x,e.x,t.x),this.y=YI(this.y,e.y,t.y),this.z=YI(this.z,e.z,t.z),this.w=YI(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=YI(this.x,e,t),this.y=YI(this.y,e,t),this.z=YI(this.z,e,t),this.w=YI(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(YI(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},HL=class extends UI{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rI,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new VL(0,0,e,t),this.scissorTest=!1,this.viewport=new VL(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new BL(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:rI,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new IL(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},UL=class extends BL{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=nI,this.minFilter=nI,this.wrapR=eI,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},WL=class{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(KL.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(KL.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=KL.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,KL):KL.fromBufferAttribute(r,t),KL.applyMatrix4(e.matrixWorld),this.expandByPoint(KL);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),qL.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),qL.copy(e.boundingBox)),qL.applyMatrix4(e.matrixWorld),this.union(qL)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,KL),KL.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eR),tR.subVectors(this.max,eR),JL.subVectors(e.a,eR),YL.subVectors(e.b,eR),XL.subVectors(e.c,eR),ZL.subVectors(YL,JL),QL.subVectors(XL,YL),$L.subVectors(JL,XL);let t=[0,-ZL.z,ZL.y,0,-QL.z,QL.y,0,-$L.z,$L.y,ZL.z,0,-ZL.x,QL.z,0,-QL.x,$L.z,0,-$L.x,-ZL.y,ZL.x,0,-QL.y,QL.x,0,-$L.y,$L.x,0];return!iR(t,JL,YL,XL,tR)||(t=[1,0,0,0,1,0,0,0,1],!iR(t,JL,YL,XL,tR))?!1:(nR.crossVectors(ZL,QL),t=[nR.x,nR.y,nR.z],iR(t,JL,YL,XL,tR))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,KL).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(KL).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(GL[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),GL[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),GL[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),GL[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),GL[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),GL[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),GL[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),GL[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(GL),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const GL=[new L,new L,new L,new L,new L,new L,new L,new L],KL=new L,qL=new WL,JL=new L,YL=new L,XL=new L,ZL=new L,QL=new L,$L=new L,eR=new L,tR=new L,nR=new L,rR=new L;function iR(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){rR.fromArray(e,a);let o=i.x*Math.abs(rR.x)+i.y*Math.abs(rR.y)+i.z*Math.abs(rR.z),s=t.dot(rR),c=n.dot(rR),l=r.dot(rR);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const aR=new WL,oR=new L,sR=new L;var cR=class{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?aR.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;oR.subVectors(e,this.center);let t=oR.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(oR,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(sR.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oR.copy(e.center).add(sR)),this.expandByPoint(oR.copy(e.center).sub(sR))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const lR=new L,uR=new L,dR=new L,fR=new L,pR=new L,mR=new L,hR=new L;var gR=class{constructor(e=new L,t=new L(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,lR)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=lR.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(lR.copy(this.origin).addScaledVector(this.direction,t),lR.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){uR.copy(e).add(t).multiplyScalar(.5),dR.copy(t).sub(e).normalize(),fR.copy(this.origin).sub(uR);let i=e.distanceTo(t)*.5,a=-this.direction.dot(dR),o=fR.dot(this.direction),s=-fR.dot(dR),c=fR.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(uR).addScaledVector(dR,d),f}intersectSphere(e,t){lR.subVectors(e.center,this.origin);let n=lR.dot(this.direction),r=lR.dot(lR)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,lR)!==null}intersectTriangle(e,t,n,r,i){pR.subVectors(t,e),mR.subVectors(n,e),hR.crossVectors(pR,mR);let a=this.direction.dot(hR),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fR.subVectors(this.origin,e);let s=o*this.direction.dot(mR.crossVectors(fR,mR));if(s<0)return null;let c=o*this.direction.dot(pR.cross(fR));if(c<0||s+c>a)return null;let l=-o*fR.dot(hR);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},_R=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/vR.setFromMatrixColumn(e,0).length(),i=1/vR.setFromMatrixColumn(e,1).length(),a=1/vR.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(bR,e,xR)}lookAt(e,t,n){let r=this.elements;return wR.subVectors(e,t),wR.lengthSq()===0&&(wR.z=1),wR.normalize(),SR.crossVectors(n,wR),SR.lengthSq()===0&&(Math.abs(n.z)===1?wR.x+=1e-4:wR.z+=1e-4,wR.normalize(),SR.crossVectors(n,wR)),SR.normalize(),CR.crossVectors(wR,SR),r[0]=SR.x,r[4]=CR.x,r[8]=wR.x,r[1]=SR.y,r[5]=CR.y,r[9]=wR.y,r[2]=SR.z,r[6]=CR.z,r[10]=wR.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=vR.set(r[0],r[1],r[2]).length(),a=vR.set(r[4],r[5],r[6]).length(),o=vR.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],yR.copy(this);let c=1/i,l=1/a,u=1/o;return yR.elements[0]*=c,yR.elements[1]*=c,yR.elements[2]*=c,yR.elements[4]*=l,yR.elements[5]*=l,yR.elements[6]*=l,yR.elements[8]*=u,yR.elements[9]*=u,yR.elements[10]*=u,t.setFromRotationMatrix(yR),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=VI){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===VI)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===HI)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=VI){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===VI)p=(a+i)*u,m=-2*u;else if(o===HI)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const vR=new L,yR=new _R,bR=new L(0,0,0),xR=new L(1,1,1),SR=new L,CR=new L,wR=new L,TR=new _R,ER=new vL;var DR=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(YI(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-YI(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(YI(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-YI(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(YI(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-YI(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return TR.makeRotationFromQuaternion(e),this.setFromRotationMatrix(TR,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ER.setFromEuler(this),this.setFromQuaternion(ER,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};DR.DEFAULT_ORDER=`XYZ`;var OR=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}};let kR=0;const AR=new L,jR=new vL,MR=new _R,NR=new L,PR=new L,FR=new L,IR=new vL,LR=new L(1,0,0),RR=new L(0,1,0),zR=new L(0,0,1),BR={type:`added`},VR={type:`removed`},HR={type:`childadded`,child:null},UR={type:`childremoved`,child:null};var WR=class e extends UI{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:kR++}),this.uuid=JI(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new L,n=new DR,r=new vL,i=new L(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new _R},normalMatrix:{value:new xL}}),this.matrix=new _R,this.matrixWorld=new _R,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new OR,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return jR.setFromAxisAngle(e,t),this.quaternion.multiply(jR),this}rotateOnWorldAxis(e,t){return jR.setFromAxisAngle(e,t),this.quaternion.premultiply(jR),this}rotateX(e){return this.rotateOnAxis(LR,e)}rotateY(e){return this.rotateOnAxis(RR,e)}rotateZ(e){return this.rotateOnAxis(zR,e)}translateOnAxis(e,t){return AR.copy(e).applyQuaternion(this.quaternion),this.position.add(AR.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(LR,e)}translateY(e){return this.translateOnAxis(RR,e)}translateZ(e){return this.translateOnAxis(zR,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(MR.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?NR.copy(e):NR.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),PR.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?MR.lookAt(PR,NR,this.up):MR.lookAt(NR,PR,this.up),this.quaternion.setFromRotationMatrix(MR),r&&(MR.extractRotation(r.matrixWorld),jR.setFromRotationMatrix(MR),this.quaternion.premultiply(jR.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error(`THREE.Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(BR),HR.child=e,this.dispatchEvent(HR),HR.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(VR),UR.child=e,this.dispatchEvent(UR),UR.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),MR.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),MR.multiply(e.parent.matrixWorld)),e.applyMatrix4(MR),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(BR),HR.child=e,this.dispatchEvent(HR),HR.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(PR,e,FR),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(PR,IR,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};WR.DEFAULT_UP=new L(0,1,0),WR.DEFAULT_MATRIX_AUTO_UPDATE=!0,WR.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const GR=new L,KR=new L,qR=new L,JR=new L,YR=new L,XR=new L,ZR=new L,QR=new L,$R=new L,ez=new L,tz=new VL,nz=new VL,rz=new VL;var iz=class e{constructor(e=new L,t=new L,n=new L){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),GR.subVectors(e,t),r.cross(GR);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){GR.subVectors(r,t),KR.subVectors(n,t),qR.subVectors(e,t);let a=GR.dot(GR),o=GR.dot(KR),s=GR.dot(qR),c=KR.dot(KR),l=KR.dot(qR),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,JR)===null?!1:JR.x>=0&&JR.y>=0&&JR.x+JR.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,JR)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,JR.x),s.addScaledVector(a,JR.y),s.addScaledVector(o,JR.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return tz.setScalar(0),nz.setScalar(0),rz.setScalar(0),tz.fromBufferAttribute(e,t),nz.fromBufferAttribute(e,n),rz.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(tz,i.x),a.addScaledVector(nz,i.y),a.addScaledVector(rz,i.z),a}static isFrontFacing(e,t,n,r){return GR.subVectors(n,t),KR.subVectors(e,t),GR.cross(KR).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return GR.subVectors(this.c,this.b),KR.subVectors(this.a,this.b),GR.cross(KR).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;YR.subVectors(r,n),XR.subVectors(i,n),QR.subVectors(e,n);let s=YR.dot(QR),c=XR.dot(QR);if(s<=0&&c<=0)return t.copy(n);$R.subVectors(e,r);let l=YR.dot($R),u=XR.dot($R);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(YR,a);ez.subVectors(e,i);let f=YR.dot(ez),p=XR.dot(ez);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(XR,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return ZR.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(ZR,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(YR,a).addScaledVector(XR,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const az={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},oz={h:0,s:0,l:0},sz={h:0,s:0,l:0};function cz(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var lz=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=TI){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,AL.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=AL.workingColorSpace){return this.r=e,this.g=t,this.b=n,AL.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=AL.workingColorSpace){if(e=XI(e,1),t=YI(t,0,1),n=YI(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=cz(i,r,e+1/3),this.g=cz(i,r,e),this.b=cz(i,r,e-1/3)}return AL.colorSpaceToWorking(this,r),this}setStyle(e,t=TI){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=TI){let n=az[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=jL(e.r),this.g=jL(e.g),this.b=jL(e.b),this}copyLinearToSRGB(e){return this.r=ML(e.r),this.g=ML(e.g),this.b=ML(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=TI){return AL.workingToColorSpace(uz.copy(this),e),Math.round(YI(uz.r*255,0,255))*65536+Math.round(YI(uz.g*255,0,255))*256+Math.round(YI(uz.b*255,0,255))}getHexString(e=TI){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=AL.workingColorSpace){AL.workingToColorSpace(uz.copy(this),t);let n=uz.r,r=uz.g,i=uz.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=AL.workingColorSpace){return AL.workingToColorSpace(uz.copy(this),t),e.r=uz.r,e.g=uz.g,e.b=uz.b,e}getStyle(e=TI){AL.workingToColorSpace(uz.copy(this),e);let t=uz.r,n=uz.g,r=uz.b;return e===TI?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(oz),this.setHSL(oz.h+e,oz.s+t,oz.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(oz),e.getHSL(sz);let n=$I(oz.h,sz.h,t),r=$I(oz.s,sz.s,t),i=$I(oz.l,sz.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const uz=new lz;lz.NAMES=az;let dz=0;var fz=class extends UI{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:dz++}),this.uuid=JI(),this.name=``,this.type=`Material`,this.blending=HF,this.side=zF,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=WF,this.blendDst=GF,this.blendEquation=UF,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new lz(0,0,0),this.blendAlpha=0,this.depthFunc=KF,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AI,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kI,this.stencilZFail=kI,this.stencilZPass=kI,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==HF&&(n.blending=this.blending),this.side!==zF&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==WF&&(n.blendSrc=this.blendSrc),this.blendDst!==GF&&(n.blendDst=this.blendDst),this.blendEquation!==UF&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==KF&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==AI&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kI&&(n.stencilFail=this.stencilFail),this.stencilZFail!==kI&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==kI&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},pz=class extends fz{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new lz(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new DR,this.combine=qF,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const mz=new L,hz=new _L;let gz=0;var _z=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:gz++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=zI,this.updateRanges=[],this.gpuType=lI,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)hz.fromBufferAttribute(this,t),hz.applyMatrix3(e),this.setXY(t,hz.x,hz.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.applyMatrix3(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.applyMatrix4(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.applyNormalMatrix(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mz.fromBufferAttribute(this,t),mz.transformDirection(e),this.setXYZ(t,mz.x,mz.y,mz.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=mL(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=hL(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=mL(t,this.array)),t}setX(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=mL(t,this.array)),t}setY(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=mL(t,this.array)),t}setZ(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=mL(t,this.array)),t}setW(e,t){return this.normalized&&(t=hL(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array),i=hL(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==zI&&(e.usage=this.usage),e}},vz=class extends _z{constructor(e,t,n){super(new Uint16Array(e),t,n)}},yz=class extends _z{constructor(e,t,n){super(new Uint32Array(e),t,n)}},bz=class extends _z{constructor(e,t,n){super(new Float32Array(e),t,n)}};let xz=0;const Sz=new _R,Cz=new WR,wz=new L,Tz=new WL,Ez=new WL,Dz=new L;var Oz=class e extends UI{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:xz++}),this.uuid=JI(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(CL(e)?yz:vz)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new xL().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Sz.makeRotationFromQuaternion(e),this.applyMatrix4(Sz),this}rotateX(e){return Sz.makeRotationX(e),this.applyMatrix4(Sz),this}rotateY(e){return Sz.makeRotationY(e),this.applyMatrix4(Sz),this}rotateZ(e){return Sz.makeRotationZ(e),this.applyMatrix4(Sz),this}translate(e,t,n){return Sz.makeTranslation(e,t,n),this.applyMatrix4(Sz),this}scale(e,t,n){return Sz.makeScale(e,t,n),this.applyMatrix4(Sz),this}lookAt(e){return Cz.lookAt(e),Cz.updateMatrix(),this.applyMatrix4(Cz.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wz).negate(),this.translate(wz.x,wz.y,wz.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new bz(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new WL);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Tz.setFromBufferAttribute(n),this.morphTargetsRelative?(Dz.addVectors(this.boundingBox.min,Tz.min),this.boundingBox.expandByPoint(Dz),Dz.addVectors(this.boundingBox.max,Tz.max),this.boundingBox.expandByPoint(Dz)):(this.boundingBox.expandByPoint(Tz.min),this.boundingBox.expandByPoint(Tz.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(`THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cR);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new L,1/0);return}if(e){let n=this.boundingSphere.center;if(Tz.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ez.setFromBufferAttribute(n),this.morphTargetsRelative?(Dz.addVectors(Tz.min,Ez.min),Tz.expandByPoint(Dz),Dz.addVectors(Tz.max,Ez.max),Tz.expandByPoint(Dz)):(Tz.expandByPoint(Ez.min),Tz.expandByPoint(Ez.max))}Tz.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Dz.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Dz));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Dz.fromBufferAttribute(a,t),o&&(wz.fromBufferAttribute(e,t),Dz.add(wz)),r=Math.max(r,n.distanceToSquared(Dz))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error(`THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new _z(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new L,s[e]=new L;let c=new L,l=new L,u=new L,d=new _L,f=new _L,p=new _L,m=new L,h=new L;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new L,y=new L,b=new L,x=new L;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new _z(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new L,i=new L,a=new L,o=new L,s=new L,c=new L,l=new L,u=new L;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Dz.fromBufferAttribute(e,t),Dz.normalize(),e.setXYZ(t,Dz.x,Dz.y,Dz.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new _z(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const kz=new _R,Az=new gR,jz=new cR,Mz=new L,Nz=new L,Pz=new L,Fz=new L,Iz=new L,Lz=new L,Rz=new L,zz=new L;var Bz=class extends WR{constructor(e=new Oz,t=new pz){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Lz.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Iz.fromBufferAttribute(s,e),a?Lz.addScaledVector(Iz,r):Lz.addScaledVector(Iz.sub(t),r))}t.add(Lz)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),jz.copy(n.boundingSphere),jz.applyMatrix4(i),Az.copy(e.ray).recast(e.near),!(jz.containsPoint(Az.origin)===!1&&(Az.intersectSphere(jz,Mz)===null||Az.origin.distanceToSquared(Mz)>(e.far-e.near)**2))&&(kz.copy(i).invert(),Az.copy(e.ray).applyMatrix4(kz),!(n.boundingBox!==null&&Az.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Az)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Hz(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Hz(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Hz(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Hz(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function Vz(e,t,n,r,i,a,o,s){let c;if(c=t.side===BF?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===zF,s),c===null)return null;zz.copy(s),zz.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(zz);return l<n.near||l>n.far?null:{distance:l,point:zz.clone(),object:e}}function Hz(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Nz),e.getVertexPosition(c,Pz),e.getVertexPosition(l,Fz);let u=Vz(e,t,n,r,Nz,Pz,Fz,Rz);if(u){let e=new L;iz.getBarycoord(Rz,Nz,Pz,Fz,e),i&&(u.uv=iz.getInterpolatedAttribute(i,s,c,l,e,new _L)),a&&(u.uv1=iz.getInterpolatedAttribute(a,s,c,l,e,new _L)),o&&(u.normal=iz.getInterpolatedAttribute(o,s,c,l,e,new L),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new L,materialIndex:0};iz.getNormal(Nz,Pz,Fz,t.normal),u.face=t,u.barycoord=e}return u}var Uz=class e extends Oz{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new bz(c,3)),this.setAttribute(`normal`,new bz(l,3)),this.setAttribute(`uv`,new bz(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new L;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Wz=class extends WR{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new _R,this.projectionMatrix=new _R,this.projectionMatrixInverse=new _R,this.coordinateSystem=VI}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const Gz=new L,Kz=new _L,qz=new _L;var Jz=class extends Wz{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=qI*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(KI*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return qI*2*Math.atan(Math.tan(KI*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Gz.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Gz.x,Gz.y).multiplyScalar(-e/Gz.z),Gz.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Gz.x,Gz.y).multiplyScalar(-e/Gz.z)}getViewSize(e,t){return this.getViewBounds(e,Kz,qz),t.subVectors(qz,Kz)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(KI*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Yz=class extends BL{constructor(e=[],t=XF,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Xz=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=zI,this.updateRanges=[],this.version=0,this.uuid=JI()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=JI()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=JI()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const Zz=new L;var Qz=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Zz.fromBufferAttribute(this,t),Zz.applyMatrix4(e),this.setXYZ(t,Zz.x,Zz.y,Zz.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Zz.fromBufferAttribute(this,t),Zz.applyNormalMatrix(e),this.setXYZ(t,Zz.x,Zz.y,Zz.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Zz.fromBufferAttribute(this,t),Zz.transformDirection(e),this.setXYZ(t,Zz.x,Zz.y,Zz.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=mL(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=hL(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=hL(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=mL(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=mL(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=mL(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=mL(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=hL(t,this.array),n=hL(n,this.array),r=hL(r,this.array),i=hL(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new _z(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},$z=class extends BL{constructor(e=null,t=1,n=1,r,i,a,o,s,c=nI,l=nI,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},eB=class extends _z{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const tB=new L,nB=new L,rB=new xL;var iB=class{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=tB.subVectors(n,t).cross(nB.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(tB),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||rB.getNormalMatrix(e),r=this.coplanarPoint(tB).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},aB=class extends BL{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=nI,this.minFilter=nI,this.generateMipmaps=!1,this.needsUpdate=!0}},oB=class extends BL{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},sB=class extends BL{constructor(e,t,n=cI,r,i,a,o=nI,s=nI,c,l=fI,u=1){if(l!==fI&&l!==pI)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new IL(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};function cB(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function lB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var uB=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},dB=class extends uB{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yI,endingEnd:yI}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case bI:i=e,o=2*t-n;break;case xI:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case bI:a=e,s=2*n-t;break;case xI:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},fB=class extends uB{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},pB=class extends uB{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},mB=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=cB(t,this.TimeBufferType),this.values=cB(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:cB(e.times,Array),values:cB(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new pB(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new fB(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new dB(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case gI:t=this.InterpolantFactoryMethodDiscrete;break;case _I:t=this.InterpolantFactoryMethodLinear;break;case vI:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return gI;case this.InterpolantFactoryMethodLinear:return _I;case this.InterpolantFactoryMethodSmooth:return vI}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&lB(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===vI,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};mB.prototype.ValueTypeName=``,mB.prototype.TimeBufferType=Float32Array,mB.prototype.ValueBufferType=Float32Array,mB.prototype.DefaultInterpolation=_I;var hB=class extends mB{constructor(e,t,n){super(e,t,n)}};hB.prototype.ValueTypeName=`bool`,hB.prototype.ValueBufferType=Array,hB.prototype.DefaultInterpolation=gI,hB.prototype.InterpolantFactoryMethodLinear=void 0,hB.prototype.InterpolantFactoryMethodSmooth=void 0;var gB=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}};gB.prototype.ValueTypeName=`color`;var _B=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}};_B.prototype.ValueTypeName=`number`;var vB=class extends uB{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)vL.slerpFlat(i,0,a,c-o,a,c,s);return i}},yB=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new vB(this.times,this.values,this.getValueSize(),e)}};yB.prototype.ValueTypeName=`quaternion`,yB.prototype.InterpolantFactoryMethodSmooth=void 0;var bB=class extends mB{constructor(e,t,n){super(e,t,n)}};bB.prototype.ValueTypeName=`string`,bB.prototype.ValueBufferType=Array,bB.prototype.DefaultInterpolation=gI,bB.prototype.InterpolantFactoryMethodLinear=void 0,bB.prototype.InterpolantFactoryMethodSmooth=void 0;var xB=class extends mB{constructor(e,t,n,r){super(e,t,n,r)}};xB.prototype.ValueTypeName=`vector`;const SB={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};var CB=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const wB=new CB;var TB=class{constructor(e){this.manager=e===void 0?wB:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};TB.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var EB=class extends TB{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=SB.get(e);if(a!==void 0)return i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0),a;let o=wL(`img`);function s(){l(),SB.add(e,this),t&&t(this),i.manager.itemEnd(e)}function c(t){l(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener(`load`,s,!1),o.removeEventListener(`error`,c,!1)}return o.addEventListener(`load`,s,!1),o.addEventListener(`error`,c,!1),e.slice(0,5)!==`data:`&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(e),o.src=e,o}},DB=class extends TB{constructor(e){super(e)}load(e,t,n,r){let i=new BL,a=new EB(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){i.image=e,i.needsUpdate=!0,t!==void 0&&t(i)},n,r),i}},OB=class extends Wz{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const kB=`\\[\\]\\.:\\/`,AB=RegExp(`[`+kB+`]`,`g`),jB=`[^`+kB+`]`,MB=`[^`+kB.replace(`\\.`,``)+`]`,NB=/((?:WC+[\/:])*)/.source.replace(`WC`,jB),PB=/(WCOD+)?/.source.replace(`WCOD`,MB),FB=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,jB),IB=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,jB),LB=RegExp(`^`+NB+PB+FB+IB+`$`),RB=[`material`,`materials`,`bones`,`map`];var zB=class{constructor(e,t,n){let r=n||BB.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},BB=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(AB,``)}static parseTrackName(e){let t=LB.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);RB.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};BB.Composite=zB,BB.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},BB.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},BB.prototype.GetterByBindingType=[BB.prototype._getValue_direct,BB.prototype._getValue_array,BB.prototype._getValue_arrayElement,BB.prototype._getValue_toArray],BB.prototype.SetterByBindingTypeAndVersioning=[[BB.prototype._setValue_direct,BB.prototype._setValue_direct_setNeedsUpdate,BB.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[BB.prototype._setValue_array,BB.prototype._setValue_array_setNeedsUpdate,BB.prototype._setValue_array_setMatrixWorldNeedsUpdate],[BB.prototype._setValue_arrayElement,BB.prototype._setValue_arrayElement_setNeedsUpdate,BB.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[BB.prototype._setValue_fromArray,BB.prototype._setValue_fromArray_setNeedsUpdate,BB.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Loe=new Float32Array(1);var VB=class extends Xz{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},HB=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:IF}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=IF);const UB={name:`ASCII`,props:{characters:{default:`@%#*+=-:.`,description:`Characters to use for ASCII effect (light to dark)`,ui:{type:`text`,label:`Characters`}},cellSize:{default:30,description:`Size of each ASCII character cell in pixels`,ui:{type:`range`,min:8,max:100,step:1,label:`Cell Size`}},fontFamily:{default:`jetbrains mono`,description:`Font family for characters`,ui:{type:`select`,options:[{label:`JetBrains Mono`,value:`jetbrains mono`},{label:`Courier New`,value:`courier new`},{label:`Monaco`,value:`monaco`},{label:`Consolas`,value:`consolas`}],label:`Font Family`}}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,onBeforeRender:r,canvas:i})=>{let{vec2:a,vec3:o,vec4:s,floor:c,fract:l,dot:u,screenUV:d,convertToTexture:f,texture:p}=xj;if(!t)return s(0,0,0,0);let m=Math.round(i.clientWidth),h=Math.round(i.clientHeight),g=f(t,m,h),_=(e,t,n)=>{let r=e.length,i=Math.max(2,Math.ceil(Math.sqrt(r))),a=Math.max(8,t-4),o=document.createElement(`canvas`);o.width=i*t,o.height=i*t;let s=o.getContext(`2d`);s.fillStyle=`#000000`,s.fillRect(0,0,o.width,o.height),s.fillStyle=`#ffffff`,s.font=`${a}px ${n}`,s.textAlign=`center`,s.textBaseline=`middle`;for(let n=0;n<r;n++){let r=e[n],a=Math.floor(n/i),o=n%i,c=o*t+t/2,l=a*t+t/2;s.fillText(r,c,l)}return console.log(`Atlas created: ${r} chars, ${i}x${i} grid, ${o.width}x${o.height}px`),console.log(`Characters: "${e}"`),{canvas:o,atlasSize:i,cellSize:t,charCount:r}},v=_(e.characters.uniform.value,e.cellSize.uniform.value,e.fontFamily.uniform.value),y=new oB(v.canvas);y.minFilter=nI,y.magFilter=nI,y.generateMipmaps=!1;let b=p(y),x=e.characters.uniform.value,S=e.cellSize.uniform.value,ee=e.fontFamily.uniform.value,te=()=>{let t=e.characters.uniform.value,n=e.cellSize.uniform.value,r=e.fontFamily.uniform.value;(t!==x||n!==S||r!==ee)&&(v=_(t,n,r),y.image=v.canvas,y.needsUpdate=!0,x=t,S=n,ee=r)};r(()=>{te()}),n(()=>{y.dispose()});let ne=e.cellSize.uniform,re=a(m,h).div(ne),ie=d.mul(re),ae=c(ie),oe=l(ie),se=ae.add(a(.5)).div(re),ce=g.sample(se),le=u(ce.rgb,o(.299,.587,.114)),ue=v.charCount,de=le.mul(.8).add(.1),fe=de.mul(ue),pe=c(fe.min(ue-1e-4)),me=v.atlasSize,he=pe.mod(me),ge=c(pe.div(me)),_e=1/me,ve=a(oe.x,oe.y.sub(1).mul(-1)),ye=a(he,ge).mul(_e).add(ve.mul(_e)),be=b.sample(ye);return s(be.rgb.mul(ce.rgb),ce.a)}};var WB=r({__name:`Ascii`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},characters:{},cellSize:{},fontFamily:{}},{blendMode:`normal`,...Object.entries(UB.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${UB.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(UB.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(UB.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(UB,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,UB.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),GB=WB,KB=function(exports){"use strict";function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({}),qB,JB;function YB(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>{let n=0;if(!Array.isArray(e)){for(let r of t)n+=e*r;return n}for(let r=0;r<e.length;r++)n+=e[r]*(t[r]||0);return n}));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}function XB(e){return ZB(e)===`string`}function ZB(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function QB(e,{precision:t,unit:n}){return $B(e)?`none`:tV(e,t)+(n??``)}function $B(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function eV(e){return $B(e)?0:e}function tV(e,t){if(e===0)return 0;let n=~~e,r=0;n&&t&&(r=~~Math.log10(Math.abs(n))+1);let i=10**(t-r);return Math.floor(e*i+.5)/i}const nV={deg:1,grad:.9,rad:180/Math.PI,turn:360};function rV(e){if(!e)return;e=e.trim();let t=/^([a-z]+)\((.+?)\)$/i,n=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,a=e.match(t);if(a){let e=[];return a[2].replace(i,(t,i)=>{let a=i.match(r),o=i;if(a){let e=a[0],t=o.slice(0,-e.length);e===`%`?(o=new Number(t/100),o.type=`<percentage>`):(o=new Number(t*nV[e]),o.type=`<angle>`,o.unit=e)}else n.test(o)?(o=new Number(o),o.type=`<number>`):o===`none`&&(o=new Number(NaN),o.none=!0);t.startsWith(`/`)&&(o=o instanceof Number?o:new Number(o),o.alpha=!0),typeof o==`object`&&o instanceof Number&&(o.raw=i),e.push(o)}),{name:a[1].toLowerCase(),rawName:a[1],rawArgs:a[2],args:e}}}function iV(e){return e[e.length-1]}function aV(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function oV(e,t,n){return(n-e)/(t-e)}function sV(e,t,n){return aV(t[0],t[1],oV(e[0],e[1],n))}function cV(e){return e.map(e=>e.split(`|`).map(e=>{e=e.trim();let t=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))}function lV(e,t,n){return Math.max(Math.min(n,t),e)}function uV(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function dV(e,t){return uV(Math.abs(e)**t,e)}function fV(e,t){return t===0?0:e/t}function pV(e,t,n=0,r=e.length){for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}var mV=Object.freeze({__proto__:null,bisectLeft:pV,clamp:lV,copySign:uV,interpolate:aV,interpolateInv:oV,isNone:$B,isString:XB,last:iV,mapRange:sV,multiplyMatrices:YB,parseCoordGrammar:cV,parseFunction:rV,serializeNumber:QB,skipNone:eV,spow:dV,toPrecision:tV,type:ZB,zdiv:fV}),hV=class{add(e,t,n){if(typeof arguments[0]!=`string`){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?`unshift`:`push`](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}};const gV=new hV;var _V={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((qB=globalThis)==null||(qB=qB.process)==null||(qB=qB.env)==null||(qB=qB.NODE_ENV)==null?void 0:qB.toLowerCase())!==`test`,warn:function(e){var t,n;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(n=t.warn)==null||n.call(t,e))}};const vV={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function yV(e){return Array.isArray(e)?e:vV[e]}function bV(e,t,n,r={}){if(e=yV(e),t=yV(t),!e||!t)throw TypeError(`Missing white point to convert ${e?``:`from`}${!e&&!t?`/`:``}${t?``:`to`}`);if(e===t)return n;let i={W1:e,W2:t,XYZ:n,options:r};if(gV.run(`chromatic-adaptation-start`,i),i.M||(i.W1===vV.D65&&i.W2===vV.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===vV.D50&&i.W2===vV.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),gV.run(`chromatic-adaptation-end`,i),i.M)return YB(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const xV=new Set([`<number>`,`<percentage>`,`<angle>`]);function SV(e,t,n,r){let i=Object.entries(e.coords).map(([e,i],a)=>{let o=t.coordGrammar[a],s=r[a],c=s?.type,l;if(l=s.none?o.find(e=>xV.has(e)):o.find(e=>e==c),!l){let t=i.name||e;throw TypeError(`${c??s.raw} not allowed for ${t} in ${n}()`)}let u=l.range;c===`<percentage>`&&(u||=[0,1]);let d=i.range||i.refRange;return u&&d&&(r[a]=sV(u,d,r[a])),l});return i}function CV(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(gV.run(`parse-start`,i),i.color)return i.color;if(i.parsed=rV(i.str),i.parsed){let e=i.parsed.name;if(e===`color`){let e=i.parsed.args.shift(),n=e.startsWith(`--`)?e.substring(2):`--${e}`,r=[e,n],c=i.parsed.rawArgs.indexOf(`/`)>0?i.parsed.args.pop():1;for(let n of EV.all){let s=n.getFormat(`color`);if(s){var a,o;if(r.includes(s.id)||(a=o=s.ids)?.filter(e=>r.includes(e)).length){let r=Object.keys(n.coords).map((e,t)=>i.parsed.args[t]||0),a;return s.coordGrammar&&(a=SV(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&_V.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith(`--`)&&!s.id.startsWith(`--`)&&_V.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:n.id,coords:r,alpha:c}}}}let l=``,u=e in EV.registry?e:n;if(u in EV.registry){var s;let e=(s=EV.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;e&&(l=`Did you mean color(${e})?`)}throw TypeError(`Cannot parse color(${e}). `+(l||`Missing a plugin?`))}else for(let n of EV.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||iV(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=SV(n,r,e,o)),t&&Object.assign(t,{formatId:r.name,types:s}),{spaceId:n.id,coords:o,alpha:a}}}}else for(let e of EV.all)for(let n in e.formats){let r=e.formats[n];if(r.type!==`custom`||r.test&&!r.test(i.str))continue;let a=r.parse(i.str);if(a)return a.alpha??=1,t&&(t.formatId=n),a}throw TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function wV(e){if(Array.isArray(e))return e.map(wV);if(!e)throw TypeError(`Empty color reference`);XB(e)&&(e=CV(e));let t=e.space||e.spaceId;return t instanceof EV||(e.space=EV.get(t)),e.alpha===void 0&&(e.alpha=1),e}const TV=75e-6;var EV=(JB=class e{constructor(t){var n,r;this.id=t.id,this.name=t.name,this.base=t.base?e.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let i=t.coords??this.base.coords;for(let e in i)`name`in i[e]||(i[e].name=e);this.coords=i;let a=t.white??this.base.white??`D65`;for(let e in this.white=yV(a),this.formats=t.formats??{},this.formats){let t=this.formats[e];t.type||=`function`,t.name||=e}(n=r=this.formats.color)?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace===`self`?this:e.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=t.referred,Object.defineProperty(this,`path`,{value:DV(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),gV.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=TV}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let n=Object.values(this.coords);return e.every((e,r)=>{let i=n[r];if(i.type!==`angle`&&i.range){if(Number.isNaN(e))return!0;let[n,r]=i.range;return(n===void 0||e>=n-t)&&(r===void 0||e<=r+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!(`range`in e))}get cssId(){var e;return((e=this.formats)==null||(e=e.color)==null?void 0:e.id)||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type===`angle`)return!0;return!1}getFormat(e){if(typeof e==`object`)return e=OV(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=OV(t,this),t):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(t,n){if(arguments.length===1){let e=wV(t);[t,n]=[e.space,e.coords]}if(t=e.get(t),this.equals(t))return n;n=n.map(e=>Number.isNaN(e)?0:e);let r=this.path,i=t.path,a,o;for(let e=0;e<r.length&&r[e].equals(i[e]);e++)a=r[e],o=e;if(!a)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let e=r.length-1;e>o;e--)n=r[e].toBase(n);for(let e=o+1;e<i.length;e++)n=i[e].fromBase(n);return n}from(t,n){if(arguments.length===1){let e=wV(t);[t,n]=[e.space,e.coords]}return t=e.get(t),t.to(this,n)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let n=this.coords[t],r=n.range||n.refRange;e.push(r?.min??0)}return e}static get all(){return[...new Set(Object.values(e.registry))]}static register(e,t){if(arguments.length===1&&(t=arguments[0],e=t.id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,arguments.length===1&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(t,...n){if(!t||t instanceof e)return t;let r=ZB(t);if(r===`string`){let n=e.registry[t.toLowerCase()];if(!n)throw TypeError(`No color space found with id = "${t}"`);return n}if(n.length)return e.get(...n);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,n){let r=ZB(t),i,a;if(r===`string`?t.includes(`.`)?[i,a]=t.split(`.`):[i,a]=[,t]:Array.isArray(t)?[i,a]=t:(i=t.space,a=t.coordId),i=e.get(i),i||=n,!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(r=ZB(a),r===`number`||r===`string`&&a>=0){let e=Object.entries(i.coords)[a];if(e)return{space:i,id:e[0],index:a,...e[1]}}i=e.get(i);let o=a.toLowerCase(),s=0;for(let e in i.coords){var c,l;let t=i.coords[e];if(e.toLowerCase()===o||(c=l=t.name)?.toLowerCase()===o)return{space:i,id:e,index:s,...t};s++}throw TypeError(`No "${a}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(`, `)}`)}},KB.defineProperty(JB,`registry`,{}),KB.defineProperty(JB,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),JB);function DV(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function OV(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=cV(e.coords);let n=Object.entries(t).map(([t,n],r)=>{let i=e.coordGrammar[r][0],a=n.range||n.refRange,o=i.range,s=``;return i==`<percentage>`?(o=[0,100],s=`%`):i==`<angle>`&&(s=`deg`),{fromRange:a,toRange:o,suffix:s}});e.serializeCoords=(e,t)=>e.map((e,r)=>{let{fromRange:i,toRange:a,suffix:o}=n[r];return i&&a&&(e=sV(i,a,e)),e=QB(e,{precision:t,unit:o}),e})}return e}var kV=new EV({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{name:`X`},y:{name:`Y`},z:{name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),AV=class extends EV{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=kV,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=YB(e.toXYZ_M,t);return this.white!==this.base.white&&(n=bV(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=bV(this.base.white,this.white,t),YB(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function jV(e,t){return e=wV(e),!t||e.space.equals(t)?e.coords.slice():(t=EV.get(t),t.from(e))}function MV(e,t){e=wV(e);let{space:n,index:r}=EV.resolveCoord(t,e.space),i=jV(e,n);return i[r]}function NV(e,t,n){return e=wV(e),t=EV.get(t),e.coords=t.to(e.space,n),e}NV.returns=`color`;function PV(e,t,n){if(e=wV(e),arguments.length===2&&ZB(arguments[1])===`object`){let t=arguments[1];for(let n in t)PV(e,n,t[n])}else{typeof n==`function`&&(n=n(MV(e,t)));let{space:r,index:i}=EV.resolveCoord(t,e.space),a=jV(e,r);a[i]=n,NV(e,r,a)}return e}PV.returns=`color`;var FV=new EV({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:kV,fromBase:e=>bV(kV.white,`D50`,e),toBase:e=>bV(`D50`,kV.white,e)});const IV=216/24389,LV=24/116,RV=24389/27;let zV=vV.D50;var BV=new EV({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:zV,base:FV,fromBase(e){let t=e.map((e,t)=>e/zV[t]),n=t.map(e=>e>IV?Math.cbrt(e):(RV*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>LV?t[0]**3:(116*t[0]-16)/RV,e[0]>8?((e[0]+16)/116)**3:e[0]/RV,t[2]>LV?t[2]**3:(116*t[2]-16)/RV];return n.map((e,t)=>e*zV[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function VV(e){return(e%360+360)%360}function HV(e,t){if(e===`raw`)return t;let[n,r]=t.map(VV),i=r-n;return e===`increasing`?i<0&&(r+=360):e===`decreasing`?i>0&&(n+=360):e===`longer`?-180<i&&i<180&&(i>0?n+=360:r+=360):e===`shorter`&&(i>180?n+=360:i<-180&&(r+=360)),[n,r]}var UV=new EV({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:BV,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{lch:{coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const WV=25**7,GV=Math.PI,KV=180/GV,qV=GV/180;function JV(e){let t=e*e,n=t*t*t*e;return n}function YV(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=wV([e,t]);let[a,o,s]=BV.from(e),c=UV.from(BV,[a,o,s])[1],[l,u,d]=BV.from(t),f=UV.from(BV,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=JV(p),h=.5*(1-Math.sqrt(m/(m+WV))),g=(1+h)*o,_=(1+h)*u,v=Math.sqrt(g**2+s**2),y=Math.sqrt(_**2+d**2),b=g===0&&s===0?0:Math.atan2(s,g),x=_===0&&d===0?0:Math.atan2(d,_);b<0&&(b+=2*GV),x<0&&(x+=2*GV),b*=KV,x*=KV;let S=l-a,ee=y-v,te=x-b,ne=b+x,re=Math.abs(te),ie;v*y===0?ie=0:re<=180?ie=te:te>180?ie=te-360:te<-180?ie=te+360:_V.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*qV/2),oe=(a+l)/2,se=(v+y)/2,ce=JV(se),le;le=v*y===0?ne:re<=180?ne/2:ne<360?(ne+360)/2:(ne-360)/2;let ue=(oe-50)**2,de=1+.015*ue/Math.sqrt(20+ue),fe=1+.045*se,pe=1;pe-=.17*Math.cos((le-30)*qV),pe+=.24*Math.cos(2*le*qV),pe+=.32*Math.cos((3*le+6)*qV),pe-=.2*Math.cos((4*le-63)*qV);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+WV)),_e=-1*Math.sin(2*he*qV)*ge,ve=(S/(n*de))**2;return ve+=(ee/(r*fe))**2,ve+=(ae/(i*me))**2,ve+=_e*(ee/(r*fe))*(ae/(i*me)),Math.sqrt(ve)}const XV=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],ZV=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],QV=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],$V=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var eH=new EV({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:kV,fromBase(e){let t=YB(XV,e),n=t.map(e=>Math.cbrt(e));return YB(QV,n)},toBase(e){let t=YB($V,e),n=t.map(e=>e**3);return YB(ZV,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function tH(e,t){[e,t]=wV([e,t]);let[n,r,i]=eH.from(e),[a,o,s]=eH.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const nH=75e-6;function rH(e,t,{epsilon:n=nH}={}){e=wV(e),t||=e.space,t=EV.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function iH(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function aH(e,t,n=`lab`){n=EV.get(n);let r=n.from(e),i=n.from(t);return Math.sqrt(r.reduce((e,t,n)=>{let r=i[n];return isNaN(t)||isNaN(r)?e:e+(r-t)**2},0))}function oH(e,t){return aH(e,t,`lab`)}const sH=Math.PI,cH=sH/180;function lH(e,t,{l:n=2,c:r=1}={}){[e,t]=wV([e,t]);let[i,a,o]=BV.from(e),[,s,c]=UV.from(BV,[i,a,o]),[l,u,d]=BV.from(t),f=UV.from(BV,[l,u,d])[1];s<0&&(s=0),f<0&&(f=0);let p=i-l,m=s-f,h=a-u,g=o-d,_=h**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let y=.0638*s/(1+.0131*s)+.638,b;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*cH)):.36+Math.abs(.4*Math.cos((c+35)*cH));let x=s**4,S=Math.sqrt(x/(x+1900)),ee=y*(S*b+1-S),te=(p/(n*v))**2;return te+=(m/(r*y))**2,te+=_/ee**2,Math.sqrt(te)}const uH=203;var dH=new EV({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:kV,fromBase(e){return e.map(e=>Math.max(e*uH,0))},toBase(e){return e.map(e=>Math.max(e/uH,0))}});const fH=1.15,pH=.66,mH=2610/2**14,hH=2**14/2610,gH=3424/2**12,_H=2413/2**7,vH=2392/2**7,yH=1.7*2523/2**5,bH=2**5/(1.7*2523),xH=-.56,SH=16295499532821565e-27,CH=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],wH=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],TH=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],EH=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var DH=new EV({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:dH,fromBase(e){let[t,n,r]=e,i=fH*t-(fH-1)*r,a=pH*n-(pH-1)*t,o=YB(CH,[i,a,r]),s=o.map(function(e){let t=gH+_H*(e/1e4)**mH,n=1+vH*(e/1e4)**mH;return(t/n)**yH}),[c,l,u]=YB(TH,s),d=(1+xH)*c/(1+xH*c)-SH;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+SH)/(1+xH-xH*(t+SH)),a=YB(EH,[i,n,r]),o=a.map(function(e){let t=gH-e**bH,n=vH*e**bH-_H,r=1e4*(t/n)**hH;return r}),[s,c,l]=YB(wH,o),u=(s+(fH-1)*l)/fH,d=(c+(pH-1)*u)/pH;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),OH=new EV({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,1],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:DH,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){return[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]}});function kH(e,t){[e,t]=wV([e,t]);let[n,r,i]=OH.from(e),[a,o,s]=OH.from(t),c=n-a,l=r-o;Number.isNaN(i)&&Number.isNaN(s)?(i=0,s=0):Number.isNaN(i)?i=s:Number.isNaN(s)&&(s=i);let u=i-s,d=2*Math.sqrt(r*o)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(c**2+l**2+d**2)}const AH=3424/4096,jH=2413/128,MH=2392/128,NH=2610/16384,PH=2523/32,FH=16384/2610,IH=32/2523,LH=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],RH=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],zH=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],BH=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var VH=new EV({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:dH,fromBase(e){let t=YB(LH,e);return HH(t)},toBase(e){let t=UH(e);return YB(BH,t)}});function HH(e){let t=e.map(function(e){let t=AH+jH*(e/1e4)**NH,n=1+MH*(e/1e4)**NH;return(t/n)**PH});return YB(RH,t)}function UH(e){let t=YB(zH,e),n=t.map(function(e){let t=Math.max(e**IH-AH,0),n=jH-MH*e**IH;return 1e4*(t/n)**FH});return n}function WH(e,t){[e,t]=wV([e,t]);let[n,r,i]=VH.from(e),[a,o,s]=VH.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const GH=vV.D65,KH=.42,qH=1/KH,JH=2*Math.PI,YH=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],XH=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],ZH=[[460,451,288],[460,-891,-261],[460,-220,-6300]],QH={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},$H={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},eU=180/Math.PI,tU=Math.PI/180;function nU(e,t){let n=e.map(e=>{let n=dV(t*Math.abs(e)*.01,KH);return 400*uV(n,e)/(n+27.13)});return n}function rU(e,t){let n=100/t*27.13**qH;return e.map(e=>{let t=Math.abs(e);return uV(n*dV(t/(400-t),qH),e)})}function iU(e){let t=VV(e);t<=$H.h[0]&&(t+=360);let n=pV($H.h,t)-1,[r,i]=$H.h.slice(n,n+2),[a,o]=$H.e.slice(n,n+2),s=$H.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function aU(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=$H.h.slice(n,n+2),[a,o]=$H.e.slice(n,n+2);return VV((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function oU(e,t,n,r,i){let a={};a.discounting=i,a.refWhite=e,a.surround=r;let o=e.map(e=>e*100);a.la=t,a.yb=n;let s=o[1],c=YB(YH,o);r=QH[a.surround];let l=r[0];a.c=r[1],a.nc=r[2];let u=1/(5*a.la+1),d=u**4;a.fl=d*a.la+.1*(1-d)*(1-d)*Math.cbrt(5*a.la),a.flRoot=a.fl**.25,a.n=a.yb/s,a.z=1.48+Math.sqrt(a.n),a.nbb=.725*a.n**-.2,a.ncb=a.nbb;let f=i?1:Math.max(Math.min(l*(1-1/3.6*Math.exp((-a.la-42)/92)),1),0);a.dRgb=c.map(e=>aV(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=nU(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const sU=oU(GH,64/Math.PI*.2,20,`average`,!1);function cU(e,t){if(!(e.J!==void 0^e.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(e.C!==void 0^e.M!==void 0^e.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(e.h!==void 0^e.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(e.J===0||e.Q===0)return[0,0,0];let n=0;n=e.h===void 0?aU(e.H)*tU:VV(e.h)*tU;let r=Math.cos(n),i=Math.sin(n),a=0;e.J===void 0?e.Q!==void 0&&(a=.25*t.c*e.Q/((t.aW+4)*t.flRoot)):a=dV(e.J,1/2)*.1;let o=0;e.C===void 0?e.M===void 0?e.s!==void 0&&(o=4e-4*e.s**2*(t.aW+4)/t.c):o=e.M/t.flRoot/a:o=e.C/a;let s=dV(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*dV(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*fV(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=rU(YB(ZH,[d,p,m]).map(e=>e*1/1403),t.fl);return YB(XH,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function lU(e,t){let n=e.map(e=>e*100),r=nU(YB(YH,n).map((e,n)=>e*t.dRgb[n]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%JH+JH)%JH,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*fV(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=dV(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=dV(u/t.aW,.5*t.c*t.z),f=100*dV(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=VV(o*eU),_=iU(g),v=50*dV(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var uU=new EV({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:kV,fromBase(e){let t=lU(e,sU);return[t.J,t.M,t.h]},toBase(e){return cU({J:e[0],M:e[1],h:e[2]},sU)}});const dU=vV.D65,fU=216/24389,pU=24389/27;function mU(e){let t=e>fU?Math.cbrt(e):(pU*e+16)/116;return 116*t-16}function hU(e){return e>8?((e+16)/116)**3:e/pU}function gU(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=hU(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let c=2e-12,l=15,u=0,d=1/0;for(;u<=l;){a=cU({J:o,C:r,h:n},t);let e=Math.abs(a[1]-s);if(e<d){if(e<=c)return a;d=e}o-=(a[1]-s)*o/(2*a[1]),u+=1}return cU({J:o,C:r,h:n},t)}function _U(e,t){let n=mU(e[1]);if(n===0)return[0,0,0];let r=lU(e,vU);return[VV(r.h),r.C,n]}const vU=oU(dU,200/Math.PI*hU(50),hU(50)*100,`average`,!1);var yU=new EV({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:kV,fromBase(e){return _U(e)},toBase(e){return gU(e,vU)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const bU=Math.PI/180,xU=[1,.007,.0228];function SU(e){e[1]<0&&(e=yU.fromBase(yU.toBase(e)));let t=Math.log(Math.max(1+xU[2]*e[1]*vU.flRoot,1))/xU[2],n=e[0]*bU,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function CU(e,t){[e,t]=wV([e,t]);let[n,r,i]=SU(yU.from(e)),[a,o,s]=SU(yU.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var wU={deltaE76:oH,deltaECMC:lH,deltaE2000:YV,deltaEJz:kH,deltaEITP:WH,deltaEOK:tH,deltaEHCT:CU};function TU(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const EU={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function DU(e,{method:t=_V.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=wV(e),XB(arguments[1])?n=arguments[1]:n||=e.space,n=EV.get(n),rH(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=kU(e,{space:n});else{if(t!==`clip`&&!rH(e,n)){Object.prototype.hasOwnProperty.call(EU,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=EU[t]);let s=YV;if(r!==``){for(let e in wU)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=wU[e];break}}let c=DU(AU(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=EV.resolveCoord(a.channel),n=MV(AU(e,t.space),t.id);if($B(n)&&(n=0),n>=a.max)return AU({space:`xyz-d65`,coords:vV.D65},e.space);if(n<=a.min)return AU({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=EV.resolveCoord(t),c=r.space,l=r.id,u=AU(e,c);u.coords.forEach((e,t)=>{$B(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=TU(i),m=f,h=MV(u,l);for(;h-m>p;){let e=iH(u);e=DU(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=MV(u,l):h=MV(u,l),PV(u,l,(m+h)/2)}o=AU(u,n)}else o=c}else o=AU(e,n);if(t===`clip`||!rH(o,n,{epsilon:0})){let e=Object.values(n.coords).map(e=>e.range||[]);o.coords=o.coords.map((t,n)=>{let[r,i]=e[n];return r!==void 0&&(t=Math.max(r,t)),i!==void 0&&(t=Math.min(t,i)),t})}}return n!==e.space&&(o=AU(o,e.space)),e.coords=o.coords,e}DU.returns=`color`;const OU={WHITE:{space:eH,coords:[1,0,0]},BLACK:{space:eH,coords:[0,0,0]}};function kU(e,{space:t}={}){let n=.02,r=1e-4;e=wV(e),t||=e.space,t=EV.get(t);let i=EV.get(`oklch`);if(t.isUnbounded)return AU(e,t);let a=AU(e,i),o=a.coords[0];if(o>=1){let n=AU(OU.WHITE,t);return n.alpha=e.alpha,AU(n,t)}if(o<=0){let n=AU(OU.BLACK,t);return n.alpha=e.alpha,AU(n,t)}if(rH(a,t,{epsilon:0}))return AU(a,t);function s(e){let n=AU(e,t),r=Object.values(t.coords);return n.coords=n.coords.map((e,t)=>{if(`range`in r[t]){let[n,i]=r[t].range;return lV(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=iH(a),f=s(d),p=tH(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&rH(d,t,{epsilon:0}))c=e;else if(f=s(d),p=tH(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function AU(e,t,{inGamut:n}={}){e=wV(e),t=EV.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=DU(i,n===!0?void 0:n)),i}AU.returns=`color`;function jU(e,{precision:t=_V.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=wV(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??EV.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!rH(e)&&(s=DU(iH(e),r===!0?void 0:r).coords),n.type===`custom`)if(i.precision=t,n.serialize)a=n.serialize(s,e.alpha,i);else throw TypeError(`format ${o} can only be used to parse colors, not for serialization`);else{let r=n.name||`color`;n.serializeCoords?s=n.serializeCoords(s,t):t!==null&&(s=s.map(e=>QB(e,{precision:t})));let i=[...s];if(r===`color`){var c,l;let t=n.id||(c=l=n.ids)?.[0]||e.space.id;i.unshift(t)}let o=e.alpha;t!==null&&(o=QB(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const MU=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],NU=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var PU=new AV({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:MU,fromXYZ_M:NU});const FU=1.09929682680944,IU=.018053968510807;var LU=new AV({id:`rec2020`,name:`REC.2020`,base:PU,toBase(e){return e.map(function(e){return e<IU*4.5?e/4.5:((e+FU-1)/FU)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=IU?FU*e**.45-(FU-1):4.5*e})}});const RU=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],zU=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var BU=new AV({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:RU,fromXYZ_M:zU});const VU=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],HU=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var UU=new AV({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:VU,fromXYZ_M:HU}),WU={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let GU=[,,,].fill(`<percentage> | <number>[0, 255]`),KU=[,,,].fill(`<number>[0, 255]`);var qU=new AV({id:`srgb`,name:`sRGB`,base:UU,fromBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),formats:{rgb:{coords:GU},rgb_number:{name:`rgb`,commas:!0,coords:KU,noAlpha:!0},color:{},rgba:{coords:GU,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:KU},hex:{type:`custom`,toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,`$&$&`));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:`srgb`,coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:n=!0}={})=>{t<1&&e.push(t),e=e.map(e=>Math.round(e*255));let r=n&&e.every(e=>e%17==0),i=e.map(e=>r?(e/17).toString(16):e.toString(16).padStart(2,`0`)).join(``);return`#`+i}},keyword:{type:`custom`,test:e=>/^[a-z]+$/i.test(e),parse(e){e=e.toLowerCase();let t={spaceId:`srgb`,coords:null,alpha:1};if(e===`transparent`?(t.coords=WU.black,t.alpha=0):t.coords=WU[e],t.coords)return t}}}}),JU=new AV({id:`p3`,cssId:`display-p3`,name:`P3`,base:BU,fromBase:qU.fromBase,toBase:qU.toBase});_V.display_space=qU;let YU;if(typeof CSS<`u`&&CSS.supports)for(let e of[BV,LU,JU]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=jU(n);if(CSS.supports(`color`,r)){_V.display_space=e;break}}function XU(e,{space:t=_V.display_space,...n}={}){let r=jU(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!_V.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some($B)||$B(e.alpha);if(a&&!(YU??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=iH(e),i.coords=i.coords.map(eV),i.alpha=eV(i.alpha),r=jU(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=AU(i,t),r=new String(jU(i,n)),r.color=i}return r}function ZU(e,t){return e=wV(e),t=wV(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function QU(e){return MV(e,[kV,`y`])}function $U(e,t){PV(e,[kV,`y`],t)}function eW(e){Object.defineProperty(e.prototype,`luminance`,{get(){return QU(this)},set(e){$U(this,e)}})}var tW=Object.freeze({__proto__:null,getLuminance:QU,register:eW,setLuminance:$U});function nW(e,t){e=wV(e),t=wV(t);let n=Math.max(QU(e),0),r=Math.max(QU(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const rW=.56,iW=.57,aW=.62,oW=.65,sW=.022,cW=1.414,lW=.1,uW=5e-4,dW=1.14,fW=.027,pW=1.14;function mW(e){return e>=sW?e:e+(sW-e)**cW}function hW(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function gW(e,t){t=wV(t),e=wV(e);let n,r,i,a,o,s;t=AU(t,`srgb`),[a,o,s]=t.coords;let c=hW(a)*.2126729+hW(o)*.7151522+hW(s)*.072175;e=AU(e,`srgb`),[a,o,s]=e.coords;let l=hW(a)*.2126729+hW(o)*.7151522+hW(s)*.072175,u=mW(c),d=mW(l),f=d>u;return Math.abs(d-u)<uW?r=0:f?(n=d**rW-u**iW,r=n*dW):(n=d**oW-u**aW,r=n*pW),i=Math.abs(r)<lW?0:r>0?r-fW:r+fW,i*100}function _W(e,t){e=wV(e),t=wV(t);let n=Math.max(QU(e),0),r=Math.max(QU(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const vW=5e4;function yW(e,t){e=wV(e),t=wV(t);let n=Math.max(QU(e),0),r=Math.max(QU(t),0);return r>n&&([n,r]=[r,n]),r===0?vW:(n-r)/r}function bW(e,t){e=wV(e),t=wV(t);let n=MV(e,[BV,`l`]),r=MV(t,[BV,`l`]);return Math.abs(n-r)}const xW=216/24389,SW=24/116,CW=24389/27;let wW=vV.D65;var TW=new EV({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:wW,base:kV,fromBase(e){let t=e.map((e,t)=>e/wW[t]),n=t.map(e=>e>xW?Math.cbrt(e):(CW*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>SW?t[0]**3:(116*t[0]-16)/CW,e[0]>8?((e[0]+16)/116)**3:e[0]/CW,t[2]>SW?t[2]**3:(116*t[2]-16)/CW];return n.map((e,t)=>e*wW[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const EW=5**.5*.5+.5;function DW(e,t){e=wV(e),t=wV(t);let n=MV(e,[TW,`l`]),r=MV(t,[TW,`l`]),i=Math.abs(n**+EW-r**+EW),a=i**(1/EW)*Math.SQRT2-40;return a<7.5?0:a}var OW=Object.freeze({__proto__:null,contrastAPCA:gW,contrastDeltaPhi:DW,contrastLstar:bW,contrastMichelson:_W,contrastWCAG21:nW,contrastWeber:yW});function kW(e,t,n={}){XB(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(OW).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=wV(e),t=wV(t),OW)if(`contrast`+r.toLowerCase()===n.toLowerCase())return OW[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function AW(e){let[t,n,r]=jV(e,kV),i=t+15*n+3*r;return[4*t/i,9*n/i]}function jW(e){let[t,n,r]=jV(e,kV),i=t+n+r;return[t/i,n/i]}function MW(e){Object.defineProperty(e.prototype,`uv`,{get(){return AW(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return jW(this)}})}var NW=Object.freeze({__proto__:null,register:MW,uv:AW,xy:jW});function PW(e,t,n={}){XB(n)&&(n={method:n});let{method:r=_V.deltaE,...i}=n;for(let n in wU)if(`deltae`+r.toLowerCase()===n.toLowerCase())return wU[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function FW(e,t=.25){let n=EV.get(`oklch`,`lch`),r=[n,`l`];return PV(e,r,e=>e*(1+t))}function IW(e,t=.25){let n=EV.get(`oklch`,`lch`),r=[n,`l`];return PV(e,r,e=>e*(1-t))}var LW=Object.freeze({__proto__:null,darken:IW,lighten:FW});function RW(e,t,n=.5,r={}){[e,t]=[wV(e),wV(t)],ZB(n)===`object`&&([n,r]=[.5,n]);let i=BW(e,t,r);return i(n)}function zW(e,t,n={}){let r;VW(e)&&([r,n]=[e,t],[e,t]=r.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:a,steps:o=2,maxSteps:s=1e3,...c}=n;r||([e,t]=[wV(e),wV(t)],r=BW(e,t,c));let l=PW(e,t),u=i>0?Math.max(o,Math.ceil(l/i)+1):o,d=[];if(s!==void 0&&(u=Math.min(u,s)),u===1)d=[{p:.5,color:r(.5)}];else{let e=1/(u-1);d=Array.from({length:u},(t,n)=>{let i=n*e;return{p:i,color:r(i)}})}if(i>0){let e=d.reduce((e,t,n)=>{if(n===0)return 0;let r=PW(t.color,d[n-1].color,a);return Math.max(e,r)},0);for(;e>i;){e=0;for(let t=1;t<d.length&&d.length<s;t++){let n=d[t-1],i=d[t],a=(i.p+n.p)/2,o=r(a);e=Math.max(e,PW(o,n.color),PW(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function BW(e,t,n={}){if(VW(e)){let[n,r]=[e,t];return BW(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=wV(e),t=wV(t),e=iH(e),t=iH(t);let s={colors:[e,t],options:n};if(r=r?EV.get(r):EV.registry[_V.interpolationSpace]||e.space,i=i?EV.get(i):r,e=AU(e,r),t=AU(t,r),e=DU(e),t=DU(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[MV(e,a),MV(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=HV(i,[o,s]),PV(e,a,o),PV(t,a,s)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(n=>{n=a?a(n):n;let s=e.coords.map((e,r)=>{let i=t.coords[r];return aV(e,i,n)}),c=aV(e.alpha,t.alpha,n),l={space:r,coords:s,alpha:c};return o&&(l.coords=l.coords.map(e=>e/c)),i!==r&&(l=AU(l,i)),l},{rangeArgs:s})}function VW(e){return ZB(e)===`function`&&!!e.rangeArgs}_V.interpolationSpace=`lab`;function HW(e){e.defineFunction(`mix`,RW,{returns:`color`}),e.defineFunction(`range`,BW,{returns:`function<color>`}),e.defineFunction(`steps`,zW,{returns:`array<color>`})}var UW=Object.freeze({__proto__:null,isRange:VW,mix:RW,range:BW,register:HW,steps:zW}),WW=new EV({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:qU,fromBase:e=>{let t=Math.max(...e),n=Math.min(...e),[r,i,a]=e,[o,s,c]=[NaN,0,(n+t)/2],l=t-n;if(l!==0){switch(s=c===0||c===1?0:(t-c)/Math.min(c,1-c),t){case r:o=(i-a)/l+(i<a?6:0);break;case i:o=(a-r)/l+2;break;case a:o=(r-i)/l+4}o*=60}return s<0&&(o+=180,s=Math.abs(s)),o>=360&&(o-=360),[o,s*100,c*100]},toBase:e=>{let[t,n,r]=e;t%=360,t<0&&(t+=360),n/=100,r/=100;function i(e){let i=(e+t/30)%12,a=n*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsla:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commas:!0,lastAlpha:!0}}}),GW=new EV({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:WW,fromBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r+n*Math.min(r,1-r);return[t,i===0?0:200*(1-r/i),100*i]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r*(1-n/2);return[t,i===0||i===1?0:(r-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),KW=new EV({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:GW,fromBase(e){let[t,n,r]=e;return[t,r*(100-n)/100,100-r]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=n+r;if(i>=1){let e=n/i;return[t,0,e*100]}let a=1-r,o=a===0?0:1-n/a;return[t,o*100,a*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const qW=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],JW=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var YW=new AV({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:qW,fromXYZ_M:JW}),XW=new AV({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:YW,toBase:e=>e.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:e=>e.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const ZW=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],QW=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var $W=new AV({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:FV,toXYZ_M:ZW,fromXYZ_M:QW});const eG=1/512,tG=16/512;var nG=new AV({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:$W,toBase(e){return e.map(e=>e<tG?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=eG?e**(1/1.8):16*e)}}),rG=new EV({id:`oklch`,name:`Oklch`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:eH,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){let[t,n,r]=e,i,a;return isNaN(r)?(i=0,a=0):(i=n*Math.cos(r*Math.PI/180),a=n*Math.sin(r*Math.PI/180)),[t,i,a]},formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>[0,1]`,`<number> | <angle>`]}}});let iG=vV.D65;const aG=216/24389,oG=24389/27,[sG,cG]=AW({space:kV,coords:iG});var lG=new EV({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:iG,base:kV,fromBase(e){let t=[eV(e[0]),eV(e[1]),eV(e[2])],n=t[1],[r,i]=AW({space:kV,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=aG?oG*n:116*Math.cbrt(n)-16;return[a,13*a*(r-sG),13*a*(i-cG)]},toBase(e){let[t,n,r]=e;if(t===0||$B(t))return[0,0,0];n=eV(n),r=eV(r);let i=n/(13*t)+sG,a=r/(13*t)+cG,o=t<=8?t/oG:((t+16)/116)**3;return[o*(9*i/(4*a)),o,o*((12-3*i-20*a)/(4*a))]},formats:{color:{id:`--luv`,coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),uG=new EV({id:`lchuv`,name:`LChuv`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,220],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:lG,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),VV(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{color:{id:`--lchuv`,coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const dG=216/24389,fG=24389/27,pG=HU[0][0],mG=HU[0][1],hG=HU[0][2],gG=HU[1][0],_G=HU[1][1],vG=HU[1][2],yG=HU[2][0],bG=HU[2][1],xG=HU[2][2];function SG(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function CG(e){let t=(e+16)**3/1560896,n=t>dG?t:e/fG,r=n*(284517*pG-94839*hG),i=n*(838422*hG+769860*mG+731718*pG),a=n*(632260*hG-126452*mG),o=n*(284517*gG-94839*vG),s=n*(838422*vG+769860*_G+731718*gG),c=n*(632260*vG-126452*_G),l=n*(284517*yG-94839*xG),u=n*(838422*xG+769860*bG+731718*yG),d=n*(632260*xG-126452*bG);return{r0s:r/a,r0i:i*e/a,r1s:r/(a+126452),r1i:(i-769860)*e/(a+126452),g0s:o/c,g0i:s*e/c,g1s:o/(c+126452),g1i:(s-769860)*e/(c+126452),b0s:l/d,b0i:u*e/d,b1s:l/(d+126452),b1i:(u-769860)*e/(d+126452)}}function wG(e,t){let n=t/360*Math.PI*2,r=SG(e.r0s,e.r0i,n),i=SG(e.r1s,e.r1i,n),a=SG(e.g0s,e.g0i,n),o=SG(e.g1s,e.g1i,n),s=SG(e.b0s,e.b0i,n),c=SG(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var TG=new EV({id:`hsluv`,name:`HSLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:uG,gamutSpace:qU,fromBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=CG(t),a=wG(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=CG(r),a=wG(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});HU[0][0],HU[0][1],HU[0][2],HU[1][0],HU[1][1],HU[1][2],HU[2][0],HU[2][1],HU[2][2];function EG(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function DG(e){let t=EG(e.r0s,e.r0i),n=EG(e.r1s,e.r1i),r=EG(e.g0s,e.g0i),i=EG(e.g1s,e.g1i),a=EG(e.b0s,e.b0i),o=EG(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var OG=new EV({id:`hpluv`,name:`HPLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:uG,gamutSpace:`self`,fromBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=CG(t),r=DG(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[eV(e[0]),eV(e[1]),eV(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=CG(r),t=DG(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const kG=203,AG=2610/2**14,jG=2**14/2610,MG=2523/2**5,NG=2**5/2523,PG=3424/2**12,FG=2413/2**7,IG=2392/2**7;var LG=new AV({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:PU,toBase(e){return e.map(function(e){let t=(Math.max(e**NG-PG,0)/(FG-IG*e**NG))**jG;return t*1e4/kG})},fromBase(e){return e.map(function(e){let t=Math.max(e*kG/1e4,0),n=PG+FG*t**AG,r=1+IG*t**AG;return(n/r)**MG})}});const RG=.17883277,zG=.28466892,BG=.55991073,VG=3.7743;var HG=new AV({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:PU,toBase(e){return e.map(function(e){return e<=.5?e**2/3*VG:(Math.exp((e-BG)/RG)+zG)/12*VG})},fromBase(e){return e.map(function(e){return e/=VG,e<=1/12?Math.sqrt(3*e):RG*Math.log(12*e-zG)+BG})}});const UG={};gV.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=GG(e.W1,e.W2,e.options.method))}),gV.add(`chromatic-adaptation-end`,e=>{e.M||=GG(e.W1,e.W2,e.options.method)});function WG({id:e,toCone_M:t,fromCone_M:n}){UG[e]=arguments[0]}function GG(e,t,n=`Bradford`){let r=UG[n],[i,a,o]=YB(r.toCone_M,e),[s,c,l]=YB(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=YB(u,r.toCone_M),f=YB(r.fromCone_M,d);return f}WG({id:`von Kries`,toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),WG({id:`Bradford`,toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),WG({id:`CAT02`,toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),WG({id:`CAT16`,toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(vV,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),vV.ACES=[.32168/.33767,1,.34065/.33767];const KG=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],qG=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var JG=new AV({id:`acescg`,cssId:`--acescg`,name:`ACEScg`,coords:{r:{range:[0,65504],name:`Red`},g:{range:[0,65504],name:`Green`},b:{range:[0,65504],name:`Blue`}},referred:`scene`,white:vV.ACES,toXYZ_M:KG,fromXYZ_M:qG});const YG=2**-16,XG=-.35828683,ZG=(Math.log2(65504)+9.72)/17.52;var QG=new AV({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[XG,ZG],name:`Red`},g:{range:[XG,ZG],name:`Green`},b:{range:[XG,ZG],name:`Blue`}},referred:`scene`,base:JG,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-YG)*2:e<ZG?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(YG)+9.72)/17.52:e<YG?(Math.log2(YG+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),$G=Object.freeze({__proto__:null,A98RGB:XW,A98RGB_Linear:YW,ACEScc:QG,ACEScg:JG,CAM16_JMh:uU,HCT:yU,HPLuv:OG,HSL:WW,HSLuv:TG,HSV:GW,HWB:KW,ICTCP:VH,JzCzHz:OH,Jzazbz:DH,LCH:UV,LCHuv:uG,Lab:BV,Lab_D65:TW,Luv:lG,OKLCH:rG,OKLab:eH,P3:JU,P3_Linear:BU,ProPhoto:nG,ProPhoto_Linear:$W,REC_2020:LU,REC_2020_Linear:PU,REC_2100_HLG:HG,REC_2100_PQ:LG,XYZ_ABS_D65:dH,XYZ_D50:FV,XYZ_D65:kV,sRGB:qU,sRGB_Linear:UU}),eK=class e{constructor(...e){let t;e.length===1&&(t=wV(e[0]));let n,r,i;t?(n=t.space||t.spaceId,r=t.coords,i=t.alpha):[n,r,i]=e,Object.defineProperty(this,`space`,{value:EV.get(n),writable:!1,enumerable:!0,configurable:!0}),this.coords=r?r.slice():[0,0,0],this.alpha=i>1||i===void 0?1:i<0?0:i;for(let e=0;e<this.coords.length;e++)this.coords[e]===`NaN`&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new e(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let n=XU(this,...t);return n.color=new e(n.color),n}static get(t,...n){return t instanceof e?t:new e(t,...n)}static defineFunction(t,n,r=n){let{instance:i=!0,returns:a}=r,o=function(...t){let r=n(...t);if(a===`color`)r=e.get(r);else if(a===`function<color>`){let t=r;r=function(...n){let r=t(...n);return e.get(r)},Object.assign(r,t)}else a===`array<color>`&&(r=r.map(t=>e.get(t)));return r};t in e||(e[t]=o),i&&(e.prototype[t]=function(...e){return o(this,...e)})}static defineFunctions(t){for(let n in t)e.defineFunction(n,t[n],t[n])}static extend(exports){if(exports.register)exports.register(e);else for(let n in exports)e.defineFunction(n,exports[n])}};eK.defineFunctions({get:MV,getAll:jV,set:PV,setAll:NV,to:AU,equals:ZU,inGamut:rH,toGamut:DU,distance:aH,toString:jU}),Object.assign(eK,{util:mV,hooks:gV,WHITES:vV,Space:EV,spaces:EV.registry,parse:CV,defaults:_V});for(let e of Object.keys($G))EV.register($G[e]);for(let e in EV.registry)tK(e,EV.registry[e]);gV.add(`colorspace-init-end`,e=>{var t,n;tK(e.id,e),(t=n=e.aliases)?.forEach(t=>{tK(t,e)})});function tK(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(eK.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return EV.resolveCoord([t,n]),!0}catch{}return Reflect.has(e,n)},get:(e,n,r)=>{if(n&&typeof n!=`symbol`&&!(n in e)){let{index:r}=EV.resolveCoord([t,n]);if(r>=0)return e[r]}return Reflect.get(e,n,r)},set:(n,r,i,a)=>{if(r&&typeof r!=`symbol`&&!(r in n)||r>=0){let{index:a}=EV.resolveCoord([t,r]);if(a>=0)return n[a]=i,this.setAll(e,n),!0}return Reflect.set(n,r,i,a)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}eK.extend(wU),eK.extend({deltaE:PW}),Object.assign(eK,{deltaEMethods:wU}),eK.extend(LW),eK.extend({contrast:kW}),eK.extend(NW),eK.extend(tW),eK.extend(UW),eK.extend(OW);const{vec2:nK,vec4:rK}=xj,iK=e=>{let t=new eK(e);return rK(...t.to(`p3-linear`).coords,t.alpha).value},aK=e=>{let t=.5,n=.5,r=(e,t=!1)=>{if(typeof e==`number`)return e;let n=e.toLowerCase().trim();if(t){if(n===`top`)return 0;if(n===`bottom`)return 1;if(n===`center`)return .5}else{if(n===`left`)return 0;if(n===`right`)return 1;if(n===`center`)return .5}return console.warn(`Invalid position value: ${e}. Defaulting to center.`),.5};if(typeof e==`string`){let r=e.toLowerCase().trim().split(/\s+/);r.includes(`left`)?t=0:r.includes(`right`)?t=1:(r.includes(`center`)||r.length===1&&(r[0]===`top`||r[0]===`bottom`))&&(t=.5),r.includes(`top`)?n=0:r.includes(`bottom`)?n=1:(r.includes(`center`)||r.length===1&&(r[0]===`left`||r[0]===`right`))&&(n=.5),r.length===1&&r[0]===`center`&&(t=.5,n=.5)}else typeof e==`object`&&e?(t=r(e.x,!1),n=r(e.y,!0)):console.warn(`Invalid position value provided: ${e}. Defaulting to center.`);return nK(t,1-n).value},oK=e=>{if(typeof e==`number`)return(e%360+360)%360;let t=e.toLowerCase().trim();switch(t){case`to right`:return 0;case`to bottom`:return 90;case`to left`:return 180;case`to top`:return 270;case`to bottom right`:case`to right bottom`:return 45;case`to bottom left`:case`to left bottom`:return 135;case`to top left`:case`to left top`:return 225;case`to top right`:case`to right top`:return 315;case`from left`:return 0;case`from top`:return 90;case`from right`:return 180;case`from bottom`:return 270;case`from top left`:return 45;case`from top right`:return 135;case`from bottom right`:return 225;case`from bottom left`:return 315;default:let n=t.match(/^(-?\d*\.?\d+)(deg|rad|turn)?$/);if(n){let[,e,t=`deg`]=n,r=parseFloat(e);switch(t){case`deg`:return(r%360+360)%360;case`rad`:return(r*180/Math.PI%360+360)%360;case`turn`:return(r*360%360+360)%360;default:return(r%360+360)%360}}return console.warn(`Invalid angle value: ${e}. Defaulting to 0 degrees.`),0}},sK={name:`Checkerboard`,props:{colorA:{default:`#cccccc`,transform:iK,description:`First color of the checkerboard pattern`,ui:{type:`color`,label:`Color A`}},colorB:{default:`#999999`,transform:iK,description:`Second color of the checkerboard pattern`,ui:{type:`color`,label:`Color B`}},cells:{default:8,description:`Number of cells along the shortest canvas edge (creates square cells)`,ui:{type:`range`,min:1,max:50,step:1,label:`Cells`}}},fragmentNode:({uniforms:e})=>{let{vec2:t,mix:n,floor:r,mod:i,screenUV:a,viewportSize:o}=xj,s=o.x.div(o.y),c=t(a.x.mul(s),a.y.oneMinus()),l=e.cells.uniform,u=c.mul(l),d=r(u),f=i(d.x.add(d.y),2);return n(e.colorA.uniform,e.colorB.uniform,f)}};var cK=r({__name:`Checkerboard`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},colorA:{},colorB:{},cells:{}},{blendMode:`normal`,...Object.entries(sK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${sK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(sK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(sK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(sK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,sK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),lK=cK;const uK={name:`Circle`,props:{color:{default:`#ffffff`,transform:iK,description:`The color of the circle`,ui:{type:`color`,label:`Color`}},radius:{default:1,description:`The radius of the circle. A value of one (1) is sets the circle to fit the canvas.`,ui:{type:`range`,min:0,max:2,step:.01,label:`Radius`}},softness:{default:0,description:`Edge softness. Lower values like zero (0) are sharp, higher values like one (1) are softer.`,ui:{type:`range`,min:0,max:1,step:.01,label:`Softness`}},center:{default:{x:.5,y:.5},transform:aK,description:`The center point of the circle`,ui:{type:`text`,label:`Center Position`}}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,screenUV:o,viewportSize:s}=xj,c=s.x.div(s.y),l=t(o.x.mul(c),o.y),u=t(e.center.uniform.x.mul(c),e.center.uniform.y.oneMinus()),d=r(l.sub(u)),f=e.softness.uniform,p=e.radius.uniform.mul(.5),m=a(p,p.sub(f),d);return i(n(e.color.uniform.rgb,0),e.color.uniform,m)}};var dK=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},radius:{},softness:{},center:{}},{blendMode:`normal`,...Object.entries(uK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${uK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(uK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(uK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(uK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,uK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),fK=dK;const pK={name:`DotGrid`,props:{color:{default:`#ffffff`,description:`The color of the dot`,transform:iK,ui:{type:`color`,label:`Color`}},density:{default:100,description:`The number of dots on the longest canvas edge`,ui:{type:`range`,min:10,max:500,step:10,label:`Density`}},dotSize:{default:.3,description:`The size of each dot, zero (0) being invisible, one (1) filled the grid with no gaps`,ui:{type:`range`,min:0,max:1,step:.01,label:`Dot Size`}},twinkle:{default:0,description:`Intensity of the twinkle effect (0 = off, 1 = full twinkle)`,ui:{type:`range`,min:0,max:1,step:.01,label:`Twinkle`}}},fragmentNode:({uniforms:e})=>{let{screenUV:t,vec4:n,vec3:r,vec2:i,smoothstep:a,length:o,floor:s,float:c,viewportSize:l,time:u,sin:d,mix:f}=xj,p=t,m=e.density.uniform,h=e.dotSize.uniform,g=e.color.uniform,_=e.twinkle.uniform,v=l,y=v.x.div(v.y),b=i(p.x.mul(y),p.y.oneMinus()),x=b.mul(m),S=x.sub(s(x)),ee=o(S.sub(.5)),te=o(gM(b.mul(m))),ne=c(1).sub(a(h.mul(.5),h.mul(.5).add(te.mul(.5)),ee)),re=s(x),ie=re.x.mul(12.9898).add(re.y.mul(78.233)).sin().mul(43758.5453).fract(),ae=u.mul(2).add(ie.mul(6.28318)),oe=d(ae).mul(.5).add(.5),se=f(c(1),oe,_),ce=ne.mul(se),le=r(g).mul(ce);return n(le,ce)}};var mK=r({__name:`DotGrid`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},density:{},dotSize:{},twinkle:{}},{blendMode:`normal`,...Object.entries(pK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${pK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(pK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(pK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(pK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,pK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),hK=mK;const gK={name:`FilmGrain`,props:{intensity:{default:.25,description:`Grain intensity (0-1)`,ui:{type:`range`,min:0,max:1,step:.01,label:`Intensity`}},power:{default:.645,description:`Controls blending based on brightness`,ui:{type:`range`,min:0,max:2,step:.01,label:`Power`}},speed:{default:.5,description:`Animation speed of grain noise`,ui:{type:`range`,min:0,max:3,step:.1,label:`Speed`}}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||zP(0,0,0,0),r=AP(),i=e=>hM(pN(pM(e,LP(12.9898,78.233))).mul(43758.5453)),a=e=>pM(e,zP(.299,.587,.114,0)),o=i(r).add(XN.mul(e.speed.uniform)),s=hM(pN(o.mul(43758.5453))),c=vM(mM(.5),mM(.75),s).mul(e.intensity.uniform),l=bM(a(n),e.power.uniform),u=n.mul(c),d=dM(l,0,1),f=vM(u,n,d);return zP(f.x,f.y,f.z,n.w)}};var _K=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},power:{},speed:{}},{blendMode:`normal`,...Object.entries(gK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${gK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(gK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(gK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(gK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,gK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),vK=_K;const yK=new WeakMap,bK={name:`glassTiles`,props:{intensity:{default:1,description:`The intensity of the glass tiles effect`,ui:{type:`range`,min:0,max:5,step:.1,label:`Intensity`}},tileCount:{default:100,description:`Number of tiles across the shortest dimension`,ui:{type:`range`,min:1,max:200,step:1,label:`Tile Count`}}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,canvas:r})=>{let{vec2:i,vec4:a,floor:o,mul:s,div:c,sub:l,add:u,convertToTexture:d,screenUV:f,uniform:p}=xj;if(!t)return console.error(`You must pass a child component into the Glass Tiles shader.`),a(0);let m=d(t),h=p(1),g=()=>{r&&(h.value=r.clientWidth/r.clientHeight)};g();let _=yK.get(r);_||(_=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;m.setSize(n*i,r*i),g()}),_.observe(r),yK.set(r,_)),n(()=>{let e=yK.get(r);e&&(e.disconnect(),yK.delete(r))});let v=f,y=e.intensity.uniform,b=e.tileCount.uniform,x=i(h.greaterThanEqual(1).select(s(b,h),b),h.lessThan(1).select(c(b,h),b)),S=c(o(s(v,x)),x),ee=l(v,S),te=i(.5,.5),ne=s(y,.025),re=c(ee,c(i(1),x)),ie=l(re,te),ae=s(ie,ne),oe=u(ee,ae),se=u(oe,S);return a(m.sample(se))}};var xK=r({__name:`GlassTiles`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},tileCount:{}},{blendMode:`normal`,...Object.entries(bK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${bK.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(bK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(bK.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=kF(bK,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,bK.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),SK=xK;const CK={VERTEX:`vertex`,FRAGMENT:`fragment`},wK={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},TK=[`fragment`,`vertex`],Roe=[...TK,`compute`],EK=[`x`,`y`,`z`,`w`],DK=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let OK=1234567;const kK=Math.PI/180,AK=180/Math.PI;function jK(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=DK[e&255]+DK[e>>8&255]+DK[e>>16&255]+DK[e>>24&255]+`-`+DK[t&255]+DK[t>>8&255]+`-`+DK[t>>16&15|64]+DK[t>>24&255]+`-`+DK[n&63|128]+DK[n>>8&255]+`-`+DK[n>>16&255]+DK[n>>24&255]+DK[r&255]+DK[r>>8&255]+DK[r>>16&255]+DK[r>>24&255];return i.toLowerCase()}function MK(e,t,n){return Math.max(t,Math.min(n,e))}function NK(e,t){return(e%t+t)%t}function PK(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function FK(e,t,n){return e===t?0:(n-e)/(t-e)}function IK(e,t,n){return(1-n)*e+n*t}function LK(e,t,n,r){return IK(e,t,1-Math.exp(-n*r))}function RK(e,t=1){return t-Math.abs(NK(e,t*2)-t)}function zK(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function BK(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function VK(e,t){return e+Math.floor(Math.random()*(t-e+1))}function HK(e,t){return e+Math.random()*(t-e)}function UK(e){return e*(.5-Math.random())}function WK(e){e!==void 0&&(OK=e);let t=OK+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function GK(e){return e*kK}function KK(e){return e*AK}function qK(e){return(e&e-1)==0&&e!==0}function JK(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function YK(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function XK(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function ZK(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function QK(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const $K={DEG2RAD:kK,RAD2DEG:AK,generateUUID:jK,clamp:MK,euclideanModulo:NK,mapLinear:PK,inverseLerp:FK,lerp:IK,damp:LK,pingpong:RK,smoothstep:zK,smootherstep:BK,randInt:VK,randFloat:HK,randFloatSpread:UK,seededRandom:WK,degToRad:GK,radToDeg:KK,isPowerOfTwo:qK,ceilPowerOfTwo:JK,floorPowerOfTwo:YK,setQuaternionFromProperEuler:XK,normalize:QK,denormalize:ZK},eq=0,tq=1015,nq=``,rq=`srgb`,iq=`srgb-linear`,aq=`linear`,oq=`srgb`,sq=35044,cq=2e3,lq=2001;var uq=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(dq.makeScale(e,t)),this}rotate(e){return this.premultiply(dq.makeRotation(-e)),this}translate(e,t){return this.premultiply(dq.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const dq=new uq,fq={};function pq(e){e in fq||(fq[e]=!0,console.warn(e))}const mq=new uq().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),hq=new uq().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function gq(){let e={enabled:!0,workingColorSpace:iq,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===oq&&(e.r=vq(e.r),e.g=vq(e.g),e.b=vq(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===oq&&(e.r=yq(e.r),e.g=yq(e.g),e.b=yq(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===nq?aq:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return pq(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return pq(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[iq]:{primaries:t,whitePoint:r,transfer:aq,toXYZ:mq,fromXYZ:hq,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:rq},outputColorSpaceConfig:{drawingBufferColorSpace:rq}},[rq]:{primaries:t,whitePoint:r,transfer:oq,toXYZ:mq,fromXYZ:hq,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:rq}}}),e}const _q=gq();function vq(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function yq(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}const bq={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},xq={h:0,s:0,l:0},Sq={h:0,s:0,l:0};function Cq(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var wq=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=rq){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,_q.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=_q.workingColorSpace){return this.r=e,this.g=t,this.b=n,_q.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=_q.workingColorSpace){if(e=NK(e,1),t=MK(t,0,1),n=MK(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Cq(i,r,e+1/3),this.g=Cq(i,r,e),this.b=Cq(i,r,e-1/3)}return _q.colorSpaceToWorking(this,r),this}setStyle(e,t=rq){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=rq){let n=bq[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=vq(e.r),this.g=vq(e.g),this.b=vq(e.b),this}copyLinearToSRGB(e){return this.r=yq(e.r),this.g=yq(e.g),this.b=yq(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=rq){return _q.workingToColorSpace(Tq.copy(this),e),Math.round(MK(Tq.r*255,0,255))*65536+Math.round(MK(Tq.g*255,0,255))*256+Math.round(MK(Tq.b*255,0,255))}getHexString(e=rq){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=_q.workingColorSpace){_q.workingToColorSpace(Tq.copy(this),t);let n=Tq.r,r=Tq.g,i=Tq.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=_q.workingColorSpace){return _q.workingToColorSpace(Tq.copy(this),t),e.r=Tq.r,e.g=Tq.g,e.b=Tq.b,e}getStyle(e=rq){_q.workingToColorSpace(Tq.copy(this),e);let t=Tq.r,n=Tq.g,r=Tq.b;return e===rq?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(xq),this.setHSL(xq.h+e,xq.s+t,xq.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(xq),e.getHSL(Sq);let n=IK(xq.h,Sq.h,t),r=IK(xq.s,Sq.s,t),i=IK(xq.l,Sq.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Tq=new wq;wq.NAMES=bq;var Eq=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},Dq=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(MK(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Oq=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Aq.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Aq.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=MK(this.x,e.x,t.x),this.y=MK(this.y,e.y,t.y),this.z=MK(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=MK(this.x,e,t),this.y=MK(this.y,e,t),this.z=MK(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MK(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return kq.copy(this).projectOnVector(e),this.sub(kq)}reflect(e){return this.sub(kq.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(MK(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const kq=new Oq,Aq=new Dq;var jq=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/Mq.setFromMatrixColumn(e,0).length(),i=1/Mq.setFromMatrixColumn(e,1).length(),a=1/Mq.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Pq,e,Fq)}lookAt(e,t,n){let r=this.elements;return Rq.subVectors(e,t),Rq.lengthSq()===0&&(Rq.z=1),Rq.normalize(),Iq.crossVectors(n,Rq),Iq.lengthSq()===0&&(Math.abs(n.z)===1?Rq.x+=1e-4:Rq.z+=1e-4,Rq.normalize(),Iq.crossVectors(n,Rq)),Iq.normalize(),Lq.crossVectors(Rq,Iq),r[0]=Iq.x,r[4]=Lq.x,r[8]=Rq.x,r[1]=Iq.y,r[5]=Lq.y,r[9]=Rq.y,r[2]=Iq.z,r[6]=Lq.z,r[10]=Rq.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=Mq.set(r[0],r[1],r[2]).length(),a=Mq.set(r[4],r[5],r[6]).length(),o=Mq.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],Nq.copy(this);let c=1/i,l=1/a,u=1/o;return Nq.elements[0]*=c,Nq.elements[1]*=c,Nq.elements[2]*=c,Nq.elements[4]*=l,Nq.elements[5]*=l,Nq.elements[6]*=l,Nq.elements[8]*=u,Nq.elements[9]*=u,Nq.elements[10]*=u,t.setFromRotationMatrix(Nq),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=cq){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===cq)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===lq)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=cq){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===cq)p=(a+i)*u,m=-2*u;else if(o===lq)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const Mq=new Oq,Nq=new jq,Pq=new Oq(0,0,0),Fq=new Oq(1,1,1),Iq=new Oq,Lq=new Oq,Rq=new Oq;var zq=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=MK(this.x,e.x,t.x),this.y=MK(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=MK(this.x,e,t),this.y=MK(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MK(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(MK(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Bq=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=MK(this.x,e.x,t.x),this.y=MK(this.y,e.y,t.y),this.z=MK(this.z,e.z,t.z),this.w=MK(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=MK(this.x,e,t),this.y=MK(this.y,e,t),this.z=MK(this.z,e,t),this.w=MK(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MK(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function Vq(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const Hq=(...e)=>Vq(e);function Uq(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of Wq(e))n.push(Vq(r.slice(0,-4)),i.getCacheKey(t));return Vq(n)}function*Wq(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function Gq(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function Kq(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new wq(...t):n===`vec2`?new zq(...t):n===`vec3`?new Oq(...t):n===`vec4`?new Bq(...t):n===`mat2`?new Eq(...t):n===`mat3`?new uq(...t):n===`mat4`?new jq(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?Jq(t[0]):null}function qq(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function Jq(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Yq=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const Xq={analyze:`setup`,generate:`analyze`};let Zq=0;var Qq=class extends Yq{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=wK.NONE,this.updateBeforeType=wK.NONE,this.updateAfterType=wK.NONE,this.uuid=$K.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:Zq++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,wK.FRAME)}onRenderUpdate(e){return this.onUpdate(e,wK.RENDER)}onObjectUpdate(e){return this.onUpdate(e,wK.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of Wq(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Hq(Uq(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=Xq[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Wq(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},$q=Qq,eJ=class extends $q{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},tJ=eJ,nJ=class extends $q{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},rJ=nJ,iJ=class extends $q{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},aJ=iJ,oJ=class extends tJ{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},sJ=oJ;const cJ=EK.join(``);var lJ=class extends $q{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(EK.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===cJ.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},uJ=lJ,dJ=class extends tJ{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=EK[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},fJ=dJ,pJ=class extends tJ{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=EK[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},mJ=pJ,hJ=class extends $q{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Gq(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Gq(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=qq(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Kq(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}},gJ=hJ;const _J=/float|u?int/;var vJ=class extends gJ{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return _J.test(n)&&_J.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},yJ=vJ,bJ=class extends $q{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}},xJ=bJ;let SJ=null;const CJ=new Map;function R(e,t){if(CJ.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);CJ.set(e,t)}const wJ=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),TJ=e=>wJ(e).split(``).sort().join(``),EJ={setup(e,t){let n=t.shift();return e(ZJ(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(SJ.assign(n,...e),n);if(CJ.has(t)){let r=CJ.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&CJ.has(t.slice(0,t.length-6))){let r=CJ.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=wJ(t),XJ(new uJ(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=TJ(t.slice(3).toLowerCase()),n=>XJ(new fJ(e,t,XJ(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=TJ(t.slice(4).toLowerCase()),()=>XJ(new mJ(XJ(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),XJ(new uJ(e,t));else if(/^\d+$/.test(t)===!0)return XJ(new rJ(n,new yJ(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>XJ(new xJ(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},DJ=new WeakMap,OJ=new WeakMap,kJ=function(e,t=null){let n=Gq(e);if(n===`node`){let t=DJ.get(e);return t===void 0&&(t=new Proxy(e,EJ),DJ.set(e,t),DJ.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return XJ(GJ(e,t));else if(n===`shader`)return eY(e);return e},AJ=function(e,t=null){for(let n in e)e[n]=XJ(e[n],t);return e},jJ=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=XJ(e[r],t);return e},MJ=function(e,t=null,n=null,r=null){let i=e=>XJ(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...QJ(l(t)))):n===null?a=(...n)=>i(new e(t,...QJ(l(n)))):(n=XJ(n),a=(...r)=>i(new e(t,...QJ(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a};var NJ=class extends $q{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=OJ.get(e.constructor);r===void 0&&(r=new WeakMap,OJ.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=XJ(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=XJ(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=XJ(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},PJ=class extends $q{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return ZJ(e),XJ(new NJ(this,e))}setup(){return this.call()}};const FJ=[!1,!0],IJ=[0,1,2,3],LJ=[-1,-2],RJ=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],zJ=new Map;for(let e of FJ)zJ.set(e,new yJ(e));const BJ=new Map;for(let e of IJ)BJ.set(e,new yJ(e,`uint`));const VJ=new Map([...BJ].map(e=>new yJ(e.value,`int`)));for(let e of LJ)VJ.set(e,new yJ(e,`int`));const HJ=new Map([...VJ].map(e=>new yJ(e.value)));for(let e of RJ)HJ.set(e,new yJ(e));for(let e of RJ)HJ.set(-e,new yJ(-e));const UJ={bool:zJ,uint:BJ,ints:VJ,float:HJ},WJ=new Map([...zJ,...HJ]),GJ=(e,t)=>WJ.has(e)?WJ.get(e):e.isNode===!0?e:new yJ(e,t),KJ=e=>{try{return e.getNodeType()}catch{return}},qJ=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[Kq(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return XJ(t.get(n[0]));if(n.length===1){let t=GJ(n[0],e);return KJ(t)===e?XJ(t):XJ(new aJ(t,e))}let r=n.map(e=>GJ(e));return XJ(new sJ(r,e))}},JJ=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function YJ(e,t){return new Proxy(new PJ(e,t),EJ)}const XJ=(e,t=null)=>kJ(e,t),ZJ=(e,t=null)=>new AJ(e,t),QJ=(e,t=null)=>new jJ(e,t),z=(...e)=>new MJ(...e);let $J=0;const eY=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new YJ(e,n),i=(...e)=>{let t;ZJ(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ $J++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i};function tY(e){return SJ&&SJ.add(e),e}R(`toStack`,tY);const nY=new qJ(`color`),rY=new qJ(`float`,UJ.float),iY=new qJ(`int`,UJ.ints),aY=new qJ(`uint`,UJ.uint),oY=new qJ(`bool`,UJ.bool),sY=new qJ(`vec2`),cY=new qJ(`ivec2`),lY=new qJ(`uvec2`),uY=new qJ(`bvec2`),dY=new qJ(`vec3`),fY=new qJ(`ivec3`),pY=new qJ(`uvec3`),mY=new qJ(`bvec3`),hY=new qJ(`vec4`),gY=new qJ(`ivec4`),_Y=new qJ(`uvec4`),vY=new qJ(`bvec4`),yY=new qJ(`mat2`),bY=new qJ(`mat3`),xY=new qJ(`mat4`);R(`toColor`,nY),R(`toFloat`,rY),R(`toInt`,iY),R(`toUint`,aY),R(`toBool`,oY),R(`toVec2`,sY),R(`toIVec2`,cY),R(`toUVec2`,lY),R(`toBVec2`,uY),R(`toVec3`,dY),R(`toIVec3`,fY),R(`toUVec3`,pY),R(`toBVec3`,mY),R(`toVec4`,hY),R(`toIVec4`,gY),R(`toUVec4`,_Y),R(`toBVec4`,vY),R(`toMat2`,yY),R(`toMat3`,bY),R(`toMat4`,xY);const SY=z(rJ).setParameterLength(2),CY=(e,t)=>XJ(new aJ(XJ(e),t));R(`element`,SY),R(`convert`,CY),R(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),tY(e)));const wY={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var TY=class e extends tJ{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(wY[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===cq;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const EY=z(TY,`+`).setParameterLength(2,1/0).setName(`add`),DY=z(TY,`-`).setParameterLength(2,1/0).setName(`sub`),OY=z(TY,`*`).setParameterLength(2,1/0).setName(`mul`),kY=z(TY,`/`).setParameterLength(2,1/0).setName(`div`),AY=z(TY,`%`).setParameterLength(2).setName(`mod`),jY=z(TY,`==`).setParameterLength(2).setName(`equal`),MY=z(TY,`!=`).setParameterLength(2).setName(`notEqual`),NY=z(TY,`<`).setParameterLength(2).setName(`lessThan`),PY=z(TY,`>`).setParameterLength(2).setName(`greaterThan`),FY=z(TY,`<=`).setParameterLength(2).setName(`lessThanEqual`),IY=z(TY,`>=`).setParameterLength(2).setName(`greaterThanEqual`),LY=z(TY,`&&`).setParameterLength(2,1/0).setName(`and`),RY=z(TY,`||`).setParameterLength(2,1/0).setName(`or`),zY=z(TY,`!`).setParameterLength(1).setName(`not`),BY=z(TY,`^^`).setParameterLength(2).setName(`xor`),VY=z(TY,`&`).setParameterLength(2).setName(`bitAnd`),HY=z(TY,`~`).setParameterLength(2).setName(`bitNot`),UY=z(TY,`|`).setParameterLength(2).setName(`bitOr`),WY=z(TY,`^`).setParameterLength(2).setName(`bitXor`),GY=z(TY,`<<`).setParameterLength(2).setName(`shiftLeft`),KY=z(TY,`>>`).setParameterLength(2).setName(`shiftRight`),qY=eY(([e])=>(e.addAssign(1),e)),JY=eY(([e])=>(e.subAssign(1),e)),YY=eY(([e])=>{let t=iY(e).toConst();return e.addAssign(1),t}),XY=eY(([e])=>{let t=iY(e).toConst();return e.subAssign(1),t});R(`add`,EY),R(`sub`,DY),R(`mul`,OY),R(`div`,kY),R(`mod`,AY),R(`equal`,jY),R(`notEqual`,MY),R(`lessThan`,NY),R(`greaterThan`,PY),R(`lessThanEqual`,FY),R(`greaterThanEqual`,IY),R(`and`,LY),R(`or`,RY),R(`not`,zY),R(`xor`,BY),R(`bitAnd`,VY),R(`bitNot`,HY),R(`bitOr`,UY),R(`bitXor`,WY),R(`shiftLeft`,GY),R(`shiftRight`,KY),R(`incrementBefore`,qY),R(`decrementBefore`,JY),R(`increment`,YY),R(`decrement`,XY);const ZY=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),AY(e,t)),QY=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),AY(iY(e),iY(t)));R(`remainder`,ZY),R(`modInt`,QY);var B=class e extends tJ{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=DY(1,n);else if(i===e.RECIPROCAL)a=kY(1,n);else if(i===e.DIFFERENCE)a=bX(DY(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=hY(dY(i),0):e=hY(dY(e),0);let o=OY(e,i).xyz;a=fX(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===cq&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===cq&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===lq&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};B.ALL=`all`,B.ANY=`any`,B.RADIANS=`radians`,B.DEGREES=`degrees`,B.EXP=`exp`,B.EXP2=`exp2`,B.LOG=`log`,B.LOG2=`log2`,B.SQRT=`sqrt`,B.INVERSE_SQRT=`inversesqrt`,B.FLOOR=`floor`,B.CEIL=`ceil`,B.NORMALIZE=`normalize`,B.FRACT=`fract`,B.SIN=`sin`,B.COS=`cos`,B.TAN=`tan`,B.ASIN=`asin`,B.ACOS=`acos`,B.ATAN=`atan`,B.ABS=`abs`,B.SIGN=`sign`,B.LENGTH=`length`,B.NEGATE=`negate`,B.ONE_MINUS=`oneMinus`,B.DFDX=`dFdx`,B.DFDY=`dFdy`,B.ROUND=`round`,B.RECIPROCAL=`reciprocal`,B.TRUNC=`trunc`,B.FWIDTH=`fwidth`,B.TRANSPOSE=`transpose`,B.BITCAST=`bitcast`,B.EQUALS=`equals`,B.MIN=`min`,B.MAX=`max`,B.STEP=`step`,B.REFLECT=`reflect`,B.DISTANCE=`distance`,B.DIFFERENCE=`difference`,B.DOT=`dot`,B.CROSS=`cross`,B.POW=`pow`,B.TRANSFORM_DIRECTION=`transformDirection`,B.MIX=`mix`,B.CLAMP=`clamp`,B.REFRACT=`refract`,B.SMOOTHSTEP=`smoothstep`,B.FACEFORWARD=`faceforward`;const $Y=rY(Math.PI),zoe=rY(Math.PI*2),eX=z(B,B.ALL).setParameterLength(1),tX=z(B,B.ANY).setParameterLength(1),nX=z(B,B.RADIANS).setParameterLength(1),rX=z(B,B.DEGREES).setParameterLength(1),iX=z(B,B.EXP).setParameterLength(1),aX=z(B,B.EXP2).setParameterLength(1),oX=z(B,B.LOG).setParameterLength(1),sX=z(B,B.LOG2).setParameterLength(1),cX=z(B,B.SQRT).setParameterLength(1),lX=z(B,B.INVERSE_SQRT).setParameterLength(1),uX=z(B,B.FLOOR).setParameterLength(1),dX=z(B,B.CEIL).setParameterLength(1),fX=z(B,B.NORMALIZE).setParameterLength(1),pX=z(B,B.FRACT).setParameterLength(1),mX=z(B,B.SIN).setParameterLength(1),hX=z(B,B.COS).setParameterLength(1),gX=z(B,B.TAN).setParameterLength(1),_X=z(B,B.ASIN).setParameterLength(1),vX=z(B,B.ACOS).setParameterLength(1),yX=z(B,B.ATAN).setParameterLength(1,2),bX=z(B,B.ABS).setParameterLength(1),xX=z(B,B.SIGN).setParameterLength(1),SX=z(B,B.LENGTH).setParameterLength(1),CX=z(B,B.NEGATE).setParameterLength(1),wX=z(B,B.ONE_MINUS).setParameterLength(1),TX=z(B,B.DFDX).setParameterLength(1),EX=z(B,B.DFDY).setParameterLength(1),DX=z(B,B.ROUND).setParameterLength(1),OX=z(B,B.RECIPROCAL).setParameterLength(1),kX=z(B,B.TRUNC).setParameterLength(1),AX=z(B,B.FWIDTH).setParameterLength(1),jX=z(B,B.TRANSPOSE).setParameterLength(1),MX=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),jY(e,t)),NX=z(B,B.MIN).setParameterLength(2,1/0),PX=z(B,B.MAX).setParameterLength(2,1/0),FX=z(B,B.STEP).setParameterLength(2),IX=z(B,B.REFLECT).setParameterLength(2),LX=z(B,B.DISTANCE).setParameterLength(2),RX=z(B,B.DIFFERENCE).setParameterLength(2),zX=z(B,B.DOT).setParameterLength(2),BX=z(B,B.CROSS).setParameterLength(2),VX=z(B,B.POW).setParameterLength(2),HX=z(B,B.POW,2).setParameterLength(1),UX=z(B,B.POW,3).setParameterLength(1),WX=z(B,B.POW,4).setParameterLength(1),GX=z(B,B.TRANSFORM_DIRECTION).setParameterLength(2),KX=e=>OY(xX(e),VX(bX(e),1/3)),qX=e=>zX(e,e),JX=z(B,B.MIX).setParameterLength(3),YX=(e,t=0,n=1)=>XJ(new B(B.CLAMP,XJ(e),XJ(t),XJ(n))),XX=e=>YX(e),ZX=z(B,B.REFRACT).setParameterLength(3),QX=z(B,B.SMOOTHSTEP).setParameterLength(3),$X=z(B,B.FACEFORWARD).setParameterLength(3),eZ=eY(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=zX(e.xy,sY(t,n)),a=AY(i,$Y);return pX(mX(a).mul(r))}),tZ=(e,t,n)=>JX(t,n,e),nZ=(e,t,n)=>QX(t,n,e),rZ=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),yX(e,t));R(`all`,eX),R(`any`,tX),R(`equals`,MX),R(`radians`,nX),R(`degrees`,rX),R(`exp`,iX),R(`exp2`,aX),R(`log`,oX),R(`log2`,sX),R(`sqrt`,cX),R(`inverseSqrt`,lX),R(`floor`,uX),R(`ceil`,dX),R(`normalize`,fX),R(`fract`,pX),R(`sin`,mX),R(`cos`,hX),R(`tan`,gX),R(`asin`,_X),R(`acos`,vX),R(`atan`,yX),R(`abs`,bX),R(`sign`,xX),R(`length`,SX),R(`lengthSq`,qX),R(`negate`,CX),R(`oneMinus`,wX),R(`dFdx`,TX),R(`dFdy`,EX),R(`round`,DX),R(`reciprocal`,OX),R(`trunc`,kX),R(`fwidth`,AX),R(`atan2`,rZ),R(`min`,NX),R(`max`,PX),R(`step`,FX),R(`reflect`,IX),R(`distance`,LX),R(`dot`,zX),R(`cross`,BX),R(`pow`,VX),R(`pow2`,HX),R(`pow3`,UX),R(`pow4`,WX),R(`transformDirection`,GX),R(`mix`,tZ),R(`clamp`,YX),R(`refract`,ZX),R(`smoothstep`,nZ),R(`faceForward`,$X),R(`difference`,RX),R(`saturate`,XX),R(`cbrt`,KX),R(`transpose`,jX),R(`rand`,eZ);var iZ=class extends tJ{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const aZ=(...e)=>{let t;if(e.length===1){let n=e[0];t=new iZ(null,n.length,n)}else{let n=e[0],r=e[1];t=new iZ(n,r)}return XJ(t)};R(`toArray`,(e,t)=>aZ(Array(t).fill(e)));var oZ=class extends $q{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const sZ=e=>new oZ(e),cZ=(e,t=0)=>new oZ(e,!0,t),lZ=cZ(`render`),uZ=sZ(`object`);var dZ=class extends gJ{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=uZ}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const fZ=(e,t)=>{let n=JJ(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return XJ(new dZ(r,n))};var pZ=class extends $q{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const mZ=(e,t)=>XJ(new pZ(e,t));var hZ=class extends tJ{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=EK.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const gZ=z(hZ).setParameterLength(2);R(`assign`,gZ);var _Z=class extends tJ{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(rY(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(rY(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const vZ=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?QJ(t):ZJ(t[0]),XJ(new _Z(XJ(e),t)));R(`call`,vZ);var yZ=class extends $q{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?mZ(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
397
397
|
|
|
398
398
|
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
399
399
|
|