@inweb/viewer-three 27.2.0 → 27.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/viewer-three.js +72 -21
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +71 -21
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +5 -5
- package/src/Viewer/components/CameraComponent.ts +1 -1
- package/src/Viewer/components/InfoComponent.ts +5 -1
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +68 -21
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +1 -0
- package/src/Viewer/models/ModelImpl.ts +1 -0
package/dist/viewer-three.min.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Three=t.ODA.Three||{}))}(this,function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,n){this._commands.set(t,{id:t,handler:e,thisArg:n,description:i})}registerCommandAlias(t,e){this.registerCommand(e,(e,...i)=>this.executeCommand(t,e,...i))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach((e,i)=>t.set(i,e)),t}executeCommand(t,e,...i){const n=this._commands.get(t);if(!n){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:s,thisArg:r}=n,a=s.apply(r,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),a}}const i=new Map;function n(t=""){let n=i.get(t);return n||(n=new e,i.set(t,n)),n}class s{constructor(){this._providers=new Map}registerDragger(t,e){this._providers.set(t,e)}registerDraggerAlias(t,e){const i=this._providers.get(t);i&&this.registerDragger(e,t=>i(t))}getDraggers(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createDragger(t,e){const i=this._providers.get(t);if(!i)return null;const n=i(e);return n.name=t,n}}const r=new Map;function a(t=""){let e=r.get(t);return e||(e=new s,r.set(t,e)),e}class o{constructor(){this._providers=new Map}registerComponent(t,e){this._providers.set(t,e)}registerComponentAlias(t,e){const i=this._providers.get(t);i&&this.registerComponent(e,t=>i(t))}getComponents(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createComponent(t,e){const i=this._providers.get(t);if(!i)return null;const n=i(e);return n.name=t,n}}const h=new Map;function l(t=""){let e=h.get(t);return e||(e=new o,h.set(t,e)),e}let c=class{constructor(){this.name="",this.abortController=new AbortController}dispose(){this.abortController.abort(),this.abortController=void 0}isSupport(t,e){return!1}load(t,e,i){return Promise.resolve(this)}cancel(){this.abortController.abort()}yield(){return new Promise(t=>{setTimeout(t,0)})}extractFileName(t){const e=/[^/\\?#:]+(?=\?|#|$)/;return"string"==typeof t?(t.match(e)||[])[0]:t instanceof globalThis.File?(t.name.match(e)||[])[0]:void 0}};class d{constructor(){this._providers=new Map}registerLoader(t,e){this._providers.set(t,e)}getLoader(t){return this._providers.get(t)}getLoaders(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createLoader(t,e,i){let n=null;return this._providers.forEach((s,r)=>{const a=s(t);a.isSupport(e,i)&&(n=a,n.name=r)}),n}}const u=new Map;function p(t=""){let e=u.get(t);return e||(e=new d,u.set(t,e)),e}function m(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective",snapshotMimeType:"image/jpeg",snapshotQuality:.25}}class f{constructor(t){this._emitter=t,this._data={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective",snapshotMimeType:"image/jpeg",snapshotQuality:.25},this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective",snapshotMimeType:"image/jpeg",snapshotQuality:.25}}change(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=f.defaults(),i=t.reduce((t,i)=>(t[i]=e[i],t),{});this.data={...this.data,...i}}else this.data={...this.data,...f.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...f.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}get rulerUnit(){return this._data.rulerUnit}set rulerUnit(t){this._data.rulerUnit=t,this.change()}get rulerPrecision(){return this._data.rulerPrecision}set rulerPrecision(t){this._data.rulerPrecision=t,this.change()}get cameraMode(){return this._data.cameraMode||"perspective"}set cameraMode(t){this._data.cameraMode=t,this.change()}}const g=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],v=g;class _{constructor(){this.performance={fps:0,frameTime:0,timeToFirstRender:0,loadTime:0},this.render={viewport:{width:0,height:0},antialiasing:"",drawCalls:0,triangles:0,points:0,lines:0},this.scene={objects:0,triangles:0,points:0,lines:0,edges:0},this.optimizedScene={objects:0,triangles:0,points:0,lines:0,edges:0},this.memory={geometries:0,geometryBytes:0,textures:0,textureBytes:0,materials:0,totalEstimatedGpuBytes:0,usedJSHeapSize:0},this.system={webglRenderer:"",webglVendor:""}}}
|
|
24
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Three=t.ODA.Three||{}))}(this,function(t){"use strict";class e{constructor(){this._commands=new Map}registerCommand(t,e,i,n){this._commands.set(t,{id:t,handler:e,thisArg:n,description:i})}registerCommandAlias(t,e){this.registerCommand(e,(e,...i)=>this.executeCommand(t,e,...i))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach((e,i)=>t.set(i,e)),t}executeCommand(t,e,...i){const n=this._commands.get(t);if(!n){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:s,thisArg:r}=n,a=s.apply(r,[e,...i]);return null==e||e.emit({type:"command",data:t,args:i}),a}}const i=new Map;function n(t=""){let n=i.get(t);return n||(n=new e,i.set(t,n)),n}class s{constructor(){this._providers=new Map}registerDragger(t,e){this._providers.set(t,e)}registerDraggerAlias(t,e){const i=this._providers.get(t);i&&this.registerDragger(e,t=>i(t))}getDraggers(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createDragger(t,e){const i=this._providers.get(t);if(!i)return null;const n=i(e);return n.name=t,n}}const r=new Map;function a(t=""){let e=r.get(t);return e||(e=new s,r.set(t,e)),e}class o{constructor(){this._providers=new Map}registerComponent(t,e){this._providers.set(t,e)}registerComponentAlias(t,e){const i=this._providers.get(t);i&&this.registerComponent(e,t=>i(t))}getComponents(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createComponent(t,e){const i=this._providers.get(t);if(!i)return null;const n=i(e);return n.name=t,n}}const h=new Map;function l(t=""){let e=h.get(t);return e||(e=new o,h.set(t,e)),e}let c=class{constructor(){this.name="",this.abortController=new AbortController}dispose(){this.abortController.abort(),this.abortController=void 0}isSupport(t,e){return!1}load(t,e,i){return Promise.resolve(this)}cancel(){this.abortController.abort()}yield(){return new Promise(t=>{setTimeout(t,0)})}extractFileName(t){const e=/[^/\\?#:]+(?=\?|#|$)/;return"string"==typeof t?(t.match(e)||[])[0]:t instanceof globalThis.File?(t.name.match(e)||[])[0]:void 0}};class d{constructor(){this._providers=new Map}registerLoader(t,e){this._providers.set(t,e)}getLoader(t){return this._providers.get(t)}getLoaders(){const t=new Map;return this._providers.forEach((e,i)=>t.set(i,e)),t}createLoader(t,e,i){let n=null;return this._providers.forEach((s,r)=>{const a=s(t);a.isSupport(e,i)&&(n=a,n.name=r)}),n}}const u=new Map;function p(t=""){let e=u.get(t);return e||(e=new d,u.set(t,e)),e}function m(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective",snapshotMimeType:"image/jpeg",snapshotQuality:.25}}class f{constructor(t){this._emitter=t,this._data={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective",snapshotMimeType:"image/jpeg",snapshotQuality:.25},this.loadFromStorage()}static defaults(){return{showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0,geometryType:"vsfx",rulerUnit:"Default",rulerPrecision:2,cameraMode:"perspective",snapshotMimeType:"image/jpeg",snapshotQuality:.25}}change(){void 0!==this._emitter&&(this.saveToStorage(),this._emitter.emit({type:"optionschange",data:this}))}saveToStorage(){if("undefined"!=typeof window)try{localStorage.setItem("od-client-settings",JSON.stringify(this.data))}catch(t){console.error("Cannot save client settings.",t)}}loadFromStorage(){if("undefined"!=typeof window)try{const t=localStorage.getItem("od-client-settings");if(t){const e=JSON.parse(t);this.data={...e}}}catch(t){console.error("Cannot load client settings.",t)}}resetToDefaults(t){if(void 0!==t){const e=f.defaults(),i=t.reduce((t,i)=>(t[i]=e[i],t),{});this.data={...this.data,...i}}else this.data={...this.data,...f.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,i=!e&&t.sceneGraph;this._data={...f.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:i},this.change()}get showWCS(){return this._data.showWCS}set showWCS(t){this._data.showWCS=t,this.change()}get cameraAnimation(){return this._data.cameraAnimation}set cameraAnimation(t){this._data.cameraAnimation=t,this.change()}get antialiasing(){return this._data.antialiasing}set antialiasing(t){this._data.antialiasing=t,this.change()}get groundShadow(){return this._data.groundShadow}set groundShadow(t){this._data.groundShadow=t,this.change()}get shadows(){return this._data.shadows}set shadows(t){this._data.shadows=t,this.change()}get cameraAxisXSpeed(){return this._data.cameraAxisXSpeed}set cameraAxisXSpeed(t){this._data.cameraAxisXSpeed=t,this.change()}get cameraAxisYSpeed(){return this._data.cameraAxisYSpeed}set cameraAxisYSpeed(t){this.cameraAxisYSpeed=t,this.change()}get ambientOcclusion(){return this._data.ambientOcclusion}set ambientOcclusion(t){this._data.ambientOcclusion=t,this.change()}get enableStreamingMode(){return this._data.enableStreamingMode}set enableStreamingMode(t){this._data.enableStreamingMode=t,t||(this._data.enablePartialMode=!1),this.change()}get enablePartialMode(){return this._data.enablePartialMode}set enablePartialMode(t){this._data.enablePartialMode=t,t&&(this._data.enableStreamingMode=!0,this._data.sceneGraph=!1),this.change()}get memoryLimit(){return this._data.memoryLimit}set memoryLimit(t){this._data.memoryLimit=t,this.change()}get cuttingPlaneFillColor(){return this._data.cuttingPlaneFillColor}set cuttingPlaneFillColor(t){this._data.cuttingPlaneFillColor=t,this.change()}get edgesColor(){return this._data.edgesColor}set edgesColor(t){this._data.edgesColor=t,this.change()}get facesColor(){return this._data.facesColor}set facesColor(t){this._data.facesColor=t,this.change()}get edgesVisibility(){return this._data.edgesVisibility}set edgesVisibility(t){this._data.edgesVisibility=t,this.change()}get edgesOverlap(){return this._data.edgesOverlap}set edgesOverlap(t){this._data.edgesOverlap=t,this.change()}get facesOverlap(){return this._data.facesOverlap}set facesOverlap(t){this._data.facesOverlap=t,this.change()}get facesTransparancy(){return this._data.facesTransparancy}set facesTransparancy(t){this._data.facesTransparancy=t,this.change()}get enableCustomHighlight(){return this._data.enableCustomHighlight}set enableCustomHighlight(t){this._data.enableCustomHighlight=t,this.change()}get sceneGraph(){return this._data.sceneGraph}set sceneGraph(t){this._data.sceneGraph=t,t&&(this._data.enablePartialMode=!1),this.change()}get edgeModel(){return Boolean(this._data.edgeModel)}set edgeModel(t){this._data.edgeModel=Boolean(t),this.change()}get reverseZoomWheel(){return this._data.reverseZoomWheel}set reverseZoomWheel(t){this._data.reverseZoomWheel=!!t,this.change()}get enableZoomWheel(){return this._data.enableZoomWheel}set enableZoomWheel(t){this._data.enableZoomWheel=!!t,this.change()}get enableGestures(){return this._data.enableGestures}set enableGestures(t){this._data.enableGestures=!!t,this.change()}get geometryType(){return this._data.geometryType}set geometryType(t){this._data.geometryType=t,this.change()}get rulerUnit(){return this._data.rulerUnit}set rulerUnit(t){this._data.rulerUnit=t,this.change()}get rulerPrecision(){return this._data.rulerPrecision}set rulerPrecision(t){this._data.rulerPrecision=t,this.change()}get cameraMode(){return this._data.cameraMode||"perspective"}set cameraMode(t){this._data.cameraMode=t,this.change()}}const g=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],v=g;class _{constructor(){this.performance={fps:0,frameTime:0,timeToFirstRender:0,loadTime:0},this.render={viewport:{width:0,height:0},antialiasing:"",drawCalls:0,triangles:0,points:0,lines:0},this.scene={objects:0,triangles:0,points:0,lines:0,edges:0},this.optimizedScene={objects:0,triangles:0,points:0,lines:0,edges:0},this.memory={geometries:0,geometryBytes:0,optimizedGeometryBytes:0,textures:0,textureBytes:0,materials:0,totalEstimatedGpuBytes:0,usedJSHeapSize:0},this.system={webglRenderer:"",webglVendor:""}}}
|
|
25
25
|
/**
|
|
26
26
|
* @license
|
|
27
27
|
* Copyright 2010-2025 Three.js Authors
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
* Copyright 2010-2025 Three.js Authors
|
|
33
33
|
* SPDX-License-Identifier: MIT
|
|
34
34
|
*/
|
|
35
|
-
function fd(){let t=null,e=!1,i=null,n=null;function s(e,r){i(e,r),n=t.requestAnimationFrame(s)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(s),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function gd(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const s=e.get(i);if(void 0===s)e.set(i,function(e,i){const n=e.array,s=e.usage,r=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,s),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)o=t.HALF_FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:r}}(i,n));else if(s.version<i.version){if(s.size!==i.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,i,n){const s=i.array,r=i.updateRanges;if(t.bindBuffer(n,e),0===r.length)t.bufferSubData(n,0,s);else{r.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<r.length;t++){const i=r[e],n=r[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,r[e]=n)}r.length=e+1;for(let e=0,i=r.length;e<i;e++){const i=r[e];t.bufferSubData(n,i.start*s.BYTES_PER_ELEMENT,s,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(s.buffer,i,n),s.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:y}})),"undefined"!=typeof window&&(window.__THREE__?ui("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=y);const vd={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn v;\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadow = step( depth, dp );\n\t\t\t#else\n\t\t\t\tshadow = step( dp, depth );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},_d={common:{diffuse:{value:new _s(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Pi},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Pi}},envmap:{envMap:{value:null},envMapRotation:{value:new Pi},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Pi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Pi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Pi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Pi},normalScale:{value:new Ai(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Pi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Pi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Pi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Pi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _s(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new _s(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0},uvTransform:{value:new Pi}},sprite:{diffuse:{value:new _s(16777215)},opacity:{value:1},center:{value:new Ai(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pi},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0}}},yd={basic:{uniforms:ir([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.fog]),vertexShader:vd.meshbasic_vert,fragmentShader:vd.meshbasic_frag},lambert:{uniforms:ir([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,_d.lights,{emissive:{value:new _s(0)}}]),vertexShader:vd.meshlambert_vert,fragmentShader:vd.meshlambert_frag},phong:{uniforms:ir([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,_d.lights,{emissive:{value:new _s(0)},specular:{value:new _s(1118481)},shininess:{value:30}}]),vertexShader:vd.meshphong_vert,fragmentShader:vd.meshphong_frag},standard:{uniforms:ir([_d.common,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.roughnessmap,_d.metalnessmap,_d.fog,_d.lights,{emissive:{value:new _s(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:vd.meshphysical_vert,fragmentShader:vd.meshphysical_frag},toon:{uniforms:ir([_d.common,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.gradientmap,_d.fog,_d.lights,{emissive:{value:new _s(0)}}]),vertexShader:vd.meshtoon_vert,fragmentShader:vd.meshtoon_frag},matcap:{uniforms:ir([_d.common,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,{matcap:{value:null}}]),vertexShader:vd.meshmatcap_vert,fragmentShader:vd.meshmatcap_frag},points:{uniforms:ir([_d.points,_d.fog]),vertexShader:vd.points_vert,fragmentShader:vd.points_frag},dashed:{uniforms:ir([_d.common,_d.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:vd.linedashed_vert,fragmentShader:vd.linedashed_frag},depth:{uniforms:ir([_d.common,_d.displacementmap]),vertexShader:vd.depth_vert,fragmentShader:vd.depth_frag},normal:{uniforms:ir([_d.common,_d.bumpmap,_d.normalmap,_d.displacementmap,{opacity:{value:1}}]),vertexShader:vd.meshnormal_vert,fragmentShader:vd.meshnormal_frag},sprite:{uniforms:ir([_d.sprite,_d.fog]),vertexShader:vd.sprite_vert,fragmentShader:vd.sprite_frag},background:{uniforms:{uvTransform:{value:new Pi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:vd.background_vert,fragmentShader:vd.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pi}},vertexShader:vd.backgroundCube_vert,fragmentShader:vd.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:vd.cube_vert,fragmentShader:vd.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:vd.equirect_vert,fragmentShader:vd.equirect_frag},distance:{uniforms:ir([_d.common,_d.displacementmap,{referencePosition:{value:new Li},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:vd.distance_vert,fragmentShader:vd.distance_frag},shadow:{uniforms:ir([_d.lights,_d.fog,{color:{value:new _s(0)},opacity:{value:1}}]),vertexShader:vd.shadow_vert,fragmentShader:vd.shadow_frag}};yd.physical={uniforms:ir([yd.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pi},clearcoatNormalScale:{value:new Ai(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Pi},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Pi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Pi},sheen:{value:0},sheenColor:{value:new _s(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Pi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Pi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Pi},transmissionSamplerSize:{value:new Ai},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pi},attenuationDistance:{value:0},attenuationColor:{value:new _s(0)},specularColor:{value:new _s(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pi},anisotropyVector:{value:new Ai},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pi}}]),vertexShader:vd.meshphysical_vert,fragmentShader:vd.meshphysical_frag};const xd={r:0,b:0,g:0},bd=new Un,Sd=new En;function wd(t,e,i,n,s,r,a){const o=new _s(0);let h,l,c=!0===r?0:1,d=null,u=0,p=null;function m(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){n=(t.backgroundBlurriness>0?i:e).get(n)}return n}function f(e,i){e.getRGB(xd,nr(t)),n.buffers.color.setClear(xd.r,xd.g,xd.b,i,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,f(o,c)},render:function(e){let i=!1;const s=m(e);null===s?f(o,c):s&&s.isColor&&(f(s,1),i=!0);const r=t.xr.getEnvironmentBlendMode();"additive"===r?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===r&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const n=m(i);n&&(n.isCubeTexture||n.mapping===gt)?(void 0===l&&(l=new Qs(new tr(1,1,1),new rr({name:"BackgroundCubeMaterial",uniforms:er(yd.backgroundCube.uniforms),vertexShader:yd.backgroundCube.vertexShader,fragmentShader:yd.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(l)),bd.copy(i.backgroundRotation),bd.x*=-1,bd.y*=-1,bd.z*=-1,n.isCubeTexture&&!1===n.isRenderTargetTexture&&(bd.y*=-1,bd.z*=-1),l.material.uniforms.envMap.value=n,l.material.uniforms.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Sd.makeRotationFromEuler(bd)),l.material.toneMapped=Ui.getTransfer(n.colorSpace)!==Ve,d===n&&u===n.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):n&&n.isTexture&&(void 0===h&&(h=new Qs(new Ih(2,2),new rr({name:"BackgroundMaterial",uniforms:er(yd.background.uniforms),vertexShader:yd.background.vertexShader,fragmentShader:yd.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(h)),h.material.uniforms.t2D.value=n,h.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,h.material.toneMapped=Ui.getTransfer(n.colorSpace)!==Ve,!0===n.matrixAutoUpdate&&n.updateMatrix(),h.material.uniforms.uvTransform.value.copy(n.matrix),d===n&&u===n.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==h&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}}}function Md(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},s=l(null);let r=s,a=!1;function o(e){return t.bindVertexArray(e)}function h(e){return t.deleteVertexArray(e)}function l(t){const e=[],n=[],s=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,s[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:s,object:t,attributes:{},index:null}}function c(){const t=r.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function d(t){u(t,0)}function u(e,i){const n=r.newAttributes,s=r.enabledAttributes,a=r.attributeDivisors;n[e]=1,0===s[e]&&(t.enableVertexAttribArray(e),s[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=r.newAttributes,i=r.enabledAttributes;for(let n=0,s=i.length;n<s;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function m(e,i,n,s,r,a,o){!0===o?t.vertexAttribIPointer(e,i,n,r,a):t.vertexAttribPointer(e,i,n,s,r,a)}function f(){g(),a=!0,r!==s&&(r=s,o(r.object))}function g(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:function(i,s,h,f,g){let v=!1;const _=function(e,i,s){const r=!0===s.wireframe;let a=n[e.id];void 0===a&&(a={},n[e.id]=a);let o=a[i.id];void 0===o&&(o={},a[i.id]=o);let h=o[r];void 0===h&&(h=l(t.createVertexArray()),o[r]=h);return h}(f,h,s);r!==_&&(r=_,o(r.object)),v=function(t,e,i,n){const s=r.attributes,a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){const i=s[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return r.attributesNum!==o||r.index!==n}(i,f,h,g),v&&function(t,e,i,n){const s={},a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),s[e]=n,o++}}r.attributes=s,r.attributesNum=o,r.index=n}(i,f,h,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(i,n,s,r){c();const a=r.attributes,o=s.getAttributes(),h=n.defaultAttributeValues;for(const n in o){const s=o[n];if(s.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,h=e.get(o);if(void 0===h)continue;const l=h.buffer,c=h.type,p=h.bytesPerElement,f=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===Rt;if(o.isInterleavedBufferAttribute){const e=o.data,h=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<s.locationSize;t++)u(s.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<s.locationSize;t++)d(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<s.locationSize;t++)m(s.location+t,a/s.locationSize,c,n,h*p,(g+a/s.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<s.locationSize;t++)u(s.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<s.locationSize;t++)d(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<s.locationSize;t++)m(s.location+t,a/s.locationSize,c,n,a*p,a/s.locationSize*t*p,f)}}else if(void 0!==h){const e=h[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(s.location,e);break;case 3:t.vertexAttrib3fv(s.location,e);break;case 4:t.vertexAttrib4fv(s.location,e);break;default:t.vertexAttrib1fv(s.location,e)}}}}p()}(i,s,h,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t.id]},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const s=i[t.id];for(const t in s)h(s[t].object),delete s[t];delete i[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function Td(t,e,i){let n;function s(e,s,r){0!==r&&(t.drawArraysInstanced(n,e,s,r),i.update(s,n,r))}this.setMode=function(t){n=t},this.render=function(e,s){t.drawArrays(n,e,s),i.update(s,n,1)},this.renderInstances=s,this.renderMultiDraw=function(t,s,r){if(0===r)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,s,0,r);let a=0;for(let t=0;t<r;t++)a+=s[t];i.update(a,n,1)},this.renderMultiDrawInstances=function(t,r,a,o){if(0===a)return;const h=e.get("WEBGL_multi_draw");if(null===h)for(let e=0;e<t.length;e++)s(t[e],r[e],o[e]);else{h.multiDrawArraysInstancedWEBGL(n,t,0,r,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=r[t]*o[t];i.update(e,n,1)}}}function Ed(t,e,i,n){let s;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=r(a);o!==a&&(ui("WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==s)return s;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");s=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s},getMaxPrecision:r,textureFormatReadable:function(e){return e===Gt||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const s=i===Dt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==Et&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==Pt&&!s)},precision:a,logarithmicDepthBuffer:!0===i.logarithmicDepthBuffer,reversedDepthBuffer:!0===i.reversedDepthBuffer&&e.has("EXT_clip_control"),maxTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:t.getParameter(t.MAX_SAMPLES),samples:t.getParameter(t.SAMPLES)}}function Ad(t){const e=this;let i=null,n=0,s=!1,r=!1;const a=new ga,o=new Pi,h={value:null,needsUpdate:!1};function l(t,i,n,s){const r=null!==t?t.length:0;let l=null;if(0!==r){if(l=h.value,!0!==s||null===l){const e=n+4*r,s=i.matrixWorldInverse;o.getNormalMatrix(s),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==r;++e,i+=4)a.copy(t[e]).applyMatrix4(s,o),a.normal.toArray(l,i),l[i+3]=a.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=r,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||s;return s=e,n=t.length,i},this.beginShadows=function(){r=!0,l(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(t,e){i=l(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!s||null===d||0===d.length||r&&!p)r?l(null):function(){h.value!==i&&(h.value=i,h.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=r?0:n,e=4*t;let s=m.clippingState||null;h.value=s,s=l(d,o,e,c);for(let t=0;t!==e;++t)s[t]=i[t];m.clippingState=s,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function Cd(t){let e=new WeakMap;function i(t,e){return e===mt?t.mapping=ut:e===ft&&(t.mapping=pt),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get:function(s){if(s&&s.isTexture){const r=s.mapping;if(r===mt||r===ft){if(e.has(s)){return i(e.get(s).texture,s.mapping)}{const r=s.image;if(r&&r.height>0){const a=new mr(r.height);return a.fromEquirectangularTexture(t,s),e.set(s,a),s.addEventListener("dispose",n),i(a.texture,s.mapping)}return null}}}return s},dispose:function(){e=new WeakMap}}}const Ld=[.125,.215,.35,.446,.526,.582],Rd=20,Id=new Bl,Pd=new _s;let Dd=null,Od=0,Nd=0,Ud=!1;const Fd=new Li;class Bd{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,i=.1,n=100,s={}){const{size:r=256,position:a=Fd}=s;Dd=this._renderer.getRenderTarget(),Od=this._renderer.getActiveCubeFace(),Nd=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,i,n,o,a),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Hd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Gd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Dd,Od,Nd),this._renderer.xr.enabled=Ud,t.scissorTest=!1,zd(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ut||t.mapping===pt?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Dd=this._renderer.getRenderTarget(),Od=this._renderer.getActiveCubeFace(),Nd=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:wt,minFilter:wt,generateMipmaps:!1,type:Dt,format:Gt,colorSpace:Ge,depthBuffer:!1},n=kd(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=kd(t,e,i);const{_lodMax:n}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let s=t;const r=t-4+1+Ld.length;for(let a=0;a<r;a++){const r=Math.pow(2,s);e.push(r);let o=1/r;a>t-4?o=Ld[a-t+4-1]:0===a&&(o=0),i.push(o);const h=1/(r-2),l=-h,c=1+h,d=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),_=new Float32Array(f*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,m*p*t),_.set(d,f*p*t);const s=[t,t,t,t,t,t];y.set(s,g*p*t)}const x=new zs;x.setAttribute("position",new Ls(v,m)),x.setAttribute("uv",new Ls(_,f)),x.setAttribute("faceIndex",new Ls(y,g)),n.push(new Qs(x,null)),s>4&&s--}return{lodMeshes:n,sizeLods:e,sigmas:i}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(Rd),s=new Li(0,1,0),r=new rr({name:"SphericalGaussianBlur",defines:{n:Rd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Vd(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return r}(n,t,e),this._ggxMaterial=function(t,e,i){const n=new rr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Vd(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 3.2: Transform view direction to hemisphere configuration\n\t\t\t\tvec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tfloat lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n\t\t\t\tvec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(Vh, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + Vh.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return n}(n,t,e)}return n}_compileMaterial(t){const e=new Qs(new zs,t);this._renderer.compile(e,Id)}_sceneToCubeUV(t,e,i,n,s){const r=new cr(90,1,e,i),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],h=this._renderer,l=h.autoClear,c=h.toneMapping;h.getClearColor(Pd),h.toneMapping=0,h.autoClear=!1;h.state.buffers.depth.getReversed()&&(h.setRenderTarget(n),h.clearDepth(),h.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new Qs(new tr,new Ss({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,u=d.material;let p=!1;const m=t.background;m?m.isColor&&(u.color.copy(m),t.background=null,p=!0):(u.color.copy(Pd),p=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(r.up.set(0,a[e],0),r.position.set(s.x,s.y,s.z),r.lookAt(s.x+o[e],s.y,s.z)):1===i?(r.up.set(0,0,a[e]),r.position.set(s.x,s.y,s.z),r.lookAt(s.x,s.y+o[e],s.z)):(r.up.set(0,a[e],0),r.position.set(s.x,s.y,s.z),r.lookAt(s.x,s.y,s.z+o[e]));const l=this._cubeSize;zd(n,i*l,e>2?l:0,l,l),h.setRenderTarget(n),p&&h.render(d,r),h.render(t,r)}h.toneMapping=c,h.autoClear=l,t.background=m}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===ut||t.mapping===pt;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Hd()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Gd());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;s.uniforms.envMap.value=t;const a=this._cubeSize;zd(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(r,Id)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let e=1;e<n;e++)this._applyGGXFilter(t,e-1,e);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[i];a.material=r;const o=r.uniforms,h=i/(this._lodMeshes.length-1),l=e/(this._lodMeshes.length-1),c=Math.sqrt(h*h-l*l)*(0+1.25*h),{_lodMax:d}=this,u=this._sizeLods[i],p=3*u*(i>d-4?i-d+4:0),m=4*(this._cubeSize-u);o.envMap.value=t.texture,o.roughness.value=c,o.mipInt.value=d-e,zd(s,p,m,3*u,2*u),n.setRenderTarget(s),n.render(a,Id),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=d-i,zd(t,p,m,3*u,2*u),n.setRenderTarget(t),n.render(a,Id)}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==r&&"longitudinal"!==r&&pi("blur direction must be either latitudinal or longitudinal!");const l=this._lodMeshes[n];l.material=h;const c=h.uniforms,d=this._sizeLods[i]-1,u=isFinite(s)?Math.PI/(2*d):2*Math.PI/39,p=s/u,m=isFinite(s)?1+Math.floor(3*p):Rd;m>Rd&&ui(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Rd;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===r,a&&(c.poleAxis.value=a);const{_lodMax:v}=this;c.dTheta.value=u,c.mipInt.value=v-i;const _=this._sizeLods[n];zd(e,3*_*(n>v-4?n-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(l,Id)}}function kd(t,e,i){const n=new Zi(t,e,i);return n.texture.mapping=gt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function zd(t,e,i,n,s){t.viewport.set(e,i,n,s),t.scissor.set(e,i,n,s)}function Gd(){return new rr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Vd(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Hd(){return new rr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Vd(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Vd(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Wd(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get:function(s){if(s&&s.isTexture){const r=s.mapping,a=r===mt||r===ft,o=r===ut||r===pt;if(a||o){let r=e.get(s);const h=void 0!==r?r.texture.pmremVersion:0;if(s.isRenderTargetTexture&&s.pmremVersion!==h)return null===i&&(i=new Bd(t)),r=a?i.fromEquirectangular(s,r):i.fromCubemap(s,r),r.texture.pmremVersion=s.pmremVersion,e.set(s,r),r.texture;if(void 0!==r)return r.texture;{const h=s.image;return a&&h&&h.height>0||o&&h&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(h)?(null===i&&(i=new Bd(t)),r=a?i.fromEquirectangular(s):i.fromCubemap(s),r.texture.pmremVersion=s.pmremVersion,e.set(s,r),s.addEventListener("dispose",n),r.texture):null}}}return s},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function jd(t){const e={};function i(i){if(void 0!==e[i])return e[i];const n=t.getExtension(i);return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&mi("WebGLRenderer: "+t+" extension not supported."),e}}}function Xd(t,e,i,n){const s={},r=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete s[o.id];const h=r.get(o);h&&(e.remove(h),r.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,s=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],s=t[e+1],r=t[e+2];i.push(n,s,s,r,r,n)}}else{if(void 0===s)return;{const t=s.array;a=s.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,s=e+2;i.push(t,n,n,s,s,t)}}}const o=new(ni(i)?Is:Rs)(i,1);o.version=a;const h=r.get(t);h&&e.remove(h),r.set(t,o)}return{get:function(t,e){return!0===s[e.id]||(e.addEventListener("dispose",a),s[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=r.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return r.get(t)}}}function Yd(t,e,i){let n,s,r;function a(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,s,e*r,o),i.update(a,n,o))}this.setMode=function(t){n=t},this.setIndex=function(t){s=t.type,r=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,s,e*r),i.update(a,n,1)},this.renderInstances=a,this.renderMultiDraw=function(t,r,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,r,0,s,t,0,a);let o=0;for(let t=0;t<a;t++)o+=r[t];i.update(o,n,1)},this.renderMultiDrawInstances=function(t,o,h,l){if(0===h)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/r,o[e],l[e]);else{c.multiDrawElementsInstancedWEBGL(n,o,0,s,t,0,l,0,h);let e=0;for(let t=0;t<h;t++)e+=o[t]*l[t];i.update(e,n,1)}}}function qd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,s){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=s*(i/3);break;case t.LINES:e.lines+=s*(i/2);break;case t.LINE_STRIP:e.lines+=s*(i-1);break;case t.LINE_LOOP:e.lines+=s*i;break;case t.POINTS:e.points+=s*i;break;default:pi("WebGLInfo: Unknown draw mode:",n)}}}}function Zd(t,e,i){const n=new WeakMap,s=new Yi;return{update:function(r,a,o){const h=r.morphTargetInfluences,l=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==l?l.length:0;let d=n.get(a);if(void 0===d||d.count!==c){void 0!==d&&d.texture.dispose();const u=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let _=0;!0===u&&(_=1),!0===p&&(_=2),!0===m&&(_=3);let y=a.attributes.position.count*_,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const b=new Float32Array(y*x*4*c),S=new Ki(b,y,x,c);S.type=Pt,S.needsUpdate=!0;const w=4*_;for(let T=0;T<c;T++){const E=f[T],A=g[T],C=v[T],L=y*x*4*T;for(let R=0;R<E.count;R++){const I=R*w;!0===u&&(s.fromBufferAttribute(E,R),b[L+I+0]=s.x,b[L+I+1]=s.y,b[L+I+2]=s.z,b[L+I+3]=0),!0===p&&(s.fromBufferAttribute(A,R),b[L+I+4]=s.x,b[L+I+5]=s.y,b[L+I+6]=s.z,b[L+I+7]=0),!0===m&&(s.fromBufferAttribute(C,R),b[L+I+8]=s.x,b[L+I+9]=s.y,b[L+I+10]=s.z,b[L+I+11]=4===C.itemSize?s.w:1)}}function M(){S.dispose(),n.delete(a),a.removeEventListener("dispose",M)}d={count:c,texture:S,size:new Ai(y,x)},n.set(a,d),a.addEventListener("dispose",M)}if(!0===r.isInstancedMesh&&null!==r.morphTexture)o.getUniforms().setValue(t,"morphTexture",r.morphTexture,i);else{let P=0;for(let O=0;O<h.length;O++)P+=h[O];const D=a.morphTargetsRelative?1:1-P;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",h)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Kd(t,e,i,n){let s=new WeakMap;function r(t){const e=t.target;e.removeEventListener("dispose",r),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(a){const o=n.render.frame,h=a.geometry,l=e.get(a,h);if(s.get(l)!==o&&(e.update(l),s.set(l,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",r)&&a.addEventListener("dispose",r),s.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),s.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;s.get(t)!==o&&(t.update(),s.set(t,o))}return l},dispose:function(){s=new WeakMap}}}const Jd={[it]:"LINEAR_TONE_MAPPING",[nt]:"REINHARD_TONE_MAPPING",[st]:"CINEON_TONE_MAPPING",[rt]:"ACES_FILMIC_TONE_MAPPING",[ot]:"AGX_TONE_MAPPING",[ht]:"NEUTRAL_TONE_MAPPING",[at]:"CUSTOM_TONE_MAPPING"};function Qd(t,e,i,n,s){const r=new Zi(e,i,{type:t,depthBuffer:n,stencilBuffer:s}),a=new Zi(e,i,{type:Dt,depthBuffer:!1,stencilBuffer:!1}),o=new zs;o.setAttribute("position",new Ps([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new Ps([0,2,0,0,2,0],2));const h=new Vh({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),l=new Qs(o,h),c=new Bl(-1,1,1,-1,0,1);let d,u=null,p=null,m=!1,f=null,g=[],v=!1;this.setSize=function(t,e){r.setSize(t,e),a.setSize(t,e);for(let i=0;i<g.length;i++){const n=g[i];n.setSize&&n.setSize(t,e)}},this.setEffects=function(t){g=t,v=g.length>0&&!0===g[0].isRenderPass;const e=r.width,i=r.height;for(let t=0;t<g.length;t++){const n=g[t];n.setSize&&n.setSize(e,i)}},this.begin=function(t,e){if(m)return!1;if(0===t.toneMapping&&0===g.length)return!1;if(f=e,null!==e){const t=e.width,i=e.height;r.width===t&&r.height===i||this.setSize(t,i)}return!1===v&&t.setRenderTarget(r),d=t.toneMapping,t.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(t,e){t.toneMapping=d,m=!0;let i=r,n=a;for(let s=0;s<g.length;s++){const r=g[s];if(!1!==r.enabled&&(r.render(t,n,i,e),!1!==r.needsSwap)){const t=i;i=n,n=t}}if(u!==t.outputColorSpace||p!==t.toneMapping){u=t.outputColorSpace,p=t.toneMapping,h.defines={},Ui.getTransfer(u)===Ve&&(h.defines.SRGB_TRANSFER="");const e=Jd[p];e&&(h.defines[e]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=i.texture,t.setRenderTarget(f),t.render(l,c),f=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){r.dispose(),a.dispose(),o.dispose(),h.dispose()}}const $d=new Xi,tu=new po(1,1),eu=new Ki,iu=new Ji,nu=new pr,su=[],ru=[],au=new Float32Array(16),ou=new Float32Array(9),hu=new Float32Array(4);function lu(t,e,i){const n=t[0];if(n<=0||n>0)return t;const s=e*i;let r=su[s];if(void 0===r&&(r=new Float32Array(s),su[s]=r),0!==e){n.toArray(r,0);for(let n=1,s=0;n!==e;++n)s+=i,t[n].toArray(r,s)}return r}function cu(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function du(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function uu(t,e){let i=ru[e];void 0===i&&(i=new Int32Array(e),ru[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function pu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function mu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(cu(i,e))return;t.uniform2fv(this.addr,e),du(i,e)}}function fu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(cu(i,e))return;t.uniform3fv(this.addr,e),du(i,e)}}function gu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(cu(i,e))return;t.uniform4fv(this.addr,e),du(i,e)}}function vu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(cu(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),du(i,e)}else{if(cu(i,n))return;hu.set(n),t.uniformMatrix2fv(this.addr,!1,hu),du(i,n)}}function _u(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(cu(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),du(i,e)}else{if(cu(i,n))return;ou.set(n),t.uniformMatrix3fv(this.addr,!1,ou),du(i,n)}}function yu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(cu(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),du(i,e)}else{if(cu(i,n))return;au.set(n),t.uniformMatrix4fv(this.addr,!1,au),du(i,n)}}function xu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function bu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(cu(i,e))return;t.uniform2iv(this.addr,e),du(i,e)}}function Su(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(cu(i,e))return;t.uniform3iv(this.addr,e),du(i,e)}}function wu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(cu(i,e))return;t.uniform4iv(this.addr,e),du(i,e)}}function Mu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Tu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(cu(i,e))return;t.uniform2uiv(this.addr,e),du(i,e)}}function Eu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(cu(i,e))return;t.uniform3uiv(this.addr,e),du(i,e)}}function Au(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(cu(i,e))return;t.uniform4uiv(this.addr,e),du(i,e)}}function Cu(t,e,i){const n=this.cache,s=i.allocateTextureUnit();let r;n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),this.type===t.SAMPLER_2D_SHADOW?(tu.compareFunction=i.isReversedDepthBuffer()?Je:qe,r=tu):r=$d,i.setTexture2D(e||r,s)}function Lu(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture3D(e||iu,s)}function Ru(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTextureCube(e||nu,s)}function Iu(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture2DArray(e||eu,s)}function Pu(t,e){t.uniform1fv(this.addr,e)}function Du(t,e){const i=lu(e,this.size,2);t.uniform2fv(this.addr,i)}function Ou(t,e){const i=lu(e,this.size,3);t.uniform3fv(this.addr,i)}function Nu(t,e){const i=lu(e,this.size,4);t.uniform4fv(this.addr,i)}function Uu(t,e){const i=lu(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Fu(t,e){const i=lu(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Bu(t,e){const i=lu(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function ku(t,e){t.uniform1iv(this.addr,e)}function zu(t,e){t.uniform2iv(this.addr,e)}function Gu(t,e){t.uniform3iv(this.addr,e)}function Hu(t,e){t.uniform4iv(this.addr,e)}function Vu(t,e){t.uniform1uiv(this.addr,e)}function Wu(t,e){t.uniform2uiv(this.addr,e)}function ju(t,e){t.uniform3uiv(this.addr,e)}function Xu(t,e){t.uniform4uiv(this.addr,e)}function Yu(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);let a;cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r)),a=this.type===t.SAMPLER_2D_SHADOW?tu:$d;for(let t=0;t!==s;++t)i.setTexture2D(e[t]||a,r[t])}function qu(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r));for(let t=0;t!==s;++t)i.setTexture3D(e[t]||iu,r[t])}function Zu(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r));for(let t=0;t!==s;++t)i.setTextureCube(e[t]||nu,r[t])}function Ku(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r));for(let t=0;t!==s;++t)i.setTexture2DArray(e[t]||eu,r[t])}class Ju{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return pu;case 35664:return mu;case 35665:return fu;case 35666:return gu;case 35674:return vu;case 35675:return _u;case 35676:return yu;case 5124:case 35670:return xu;case 35667:case 35671:return bu;case 35668:case 35672:return Su;case 35669:case 35673:return wu;case 5125:return Mu;case 36294:return Tu;case 36295:return Eu;case 36296:return Au;case 35678:case 36198:case 36298:case 36306:case 35682:return Cu;case 35679:case 36299:case 36307:return Lu;case 35680:case 36300:case 36308:case 36293:return Ru;case 36289:case 36303:case 36311:case 36292:return Iu}}(e.type)}}class Qu{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Pu;case 35664:return Du;case 35665:return Ou;case 35666:return Nu;case 35674:return Uu;case 35675:return Fu;case 35676:return Bu;case 5124:case 35670:return ku;case 35667:case 35671:return zu;case 35668:case 35672:return Gu;case 35669:case 35673:return Hu;case 5125:return Vu;case 36294:return Wu;case 36295:return ju;case 36296:return Xu;case 35678:case 36198:case 36298:case 36306:case 35682:return Yu;case 35679:case 36299:case 36307:return qu;case 35680:case 36300:case 36308:case 36293:return Zu;case 36289:case 36303:case 36311:case 36292:return Ku}}(e.type)}}class $u{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let s=0,r=n.length;s!==r;++s){const r=n[s];r.setValue(t,e[r.id],i)}}}const tp=/(\w+)(\])?(\[|\.)?/g;function ep(t,e){t.seq.push(e),t.map[e.id]=e}function ip(t,e,i){const n=t.name,s=n.length;for(tp.lastIndex=0;;){const r=tp.exec(n),a=tp.lastIndex;let o=r[1];const h="]"===r[2],l=r[3];if(h&&(o|=0),void 0===l||"["===l&&a+2===s){ep(i,void 0===l?new Ju(o,t,e):new Qu(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new $u(o),ep(i,t)),i=t}}}class np{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);ip(i,t.getUniformLocation(e,i.name),this)}const n=[],s=[];for(const e of this.seq)e.type===t.SAMPLER_2D_SHADOW||e.type===t.SAMPLER_CUBE_SHADOW||e.type===t.SAMPLER_2D_ARRAY_SHADOW?n.push(e):s.push(e);n.length>0&&(this.seq=n.concat(s))}setValue(t,e,i,n){const s=this.map[e];void 0!==s&&s.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let s=0,r=e.length;s!==r;++s){const r=e[s],a=i[r.id];!1!==a.needsUpdate&&r.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,s=t.length;n!==s;++n){const s=t[n];s.id in e&&i.push(s)}return i}}function sp(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let rp=0;const ap=new Pi;function op(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(n&&""===s)return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const n=parseInt(r[1]);return i.toUpperCase()+"\n\n"+s+"\n\n"+function(t,e){const i=t.split("\n"),n=[],s=Math.max(e-6,0),r=Math.min(e+6,i.length);for(let t=s;t<r;t++){const s=t+1;n.push(`${s===e?">":" "} ${s}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return s}function hp(t,e){const i=function(t){Ui._getMatrix(ap,Ui.workingColorSpace,t);const e=`mat3( ${ap.elements.map(t=>t.toFixed(4))} )`;switch(Ui.getTransfer(t)){case He:return[e,"LinearTransferOETF"];case Ve:return[e,"sRGBTransferOETF"];default:return ui("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}const lp={[it]:"Linear",[nt]:"Reinhard",[st]:"Cineon",[rt]:"ACESFilmic",[ot]:"AgX",[ht]:"Neutral",[at]:"Custom"};function cp(t,e){const i=lp[e];return void 0===i?(ui("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const dp=new Li;function up(){Ui.getLuminanceCoefficients(dp);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${dp.x.toFixed(4)}, ${dp.y.toFixed(4)}, ${dp.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function pp(t){return""!==t}function mp(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function fp(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const gp=/^[ \t]*#include +<([\w\d./]+)>/gm;function vp(t){return t.replace(gp,yp)}const _p=new Map;function yp(t,e){let i=vd[e];if(void 0===i){const t=_p.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=vd[t],ui('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return vp(i)}const xp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function bp(t){return t.replace(xp,Sp)}function Sp(t,e,i,n){let s="";for(let t=parseInt(e);t<parseInt(i);t++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return s}function wp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}const Mp={[S]:"SHADOWMAP_TYPE_PCF",[w]:"SHADOWMAP_TYPE_VSM"};const Tp={[ut]:"ENVMAP_TYPE_CUBE",[pt]:"ENVMAP_TYPE_CUBE",[gt]:"ENVMAP_TYPE_CUBE_UV"};const Ep={[pt]:"ENVMAP_MODE_REFRACTION"};const Ap={[$]:"ENVMAP_BLENDING_MULTIPLY",[tt]:"ENVMAP_BLENDING_MIX",[et]:"ENVMAP_BLENDING_ADD"};function Cp(t,e,i,n){const s=t.getContext(),r=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(t){return Mp[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(i),l=function(t){return!1===t.envMap?"ENVMAP_TYPE_CUBE":Tp[t.envMapMode]||"ENVMAP_TYPE_CUBE"}(i),c=function(t){return!1===t.envMap?"ENVMAP_MODE_REFLECTION":Ep[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}(i),d=function(t){return!1===t.envMap?"ENVMAP_BLENDING_NONE":Ap[t.combine]||"ENVMAP_BLENDING_NONE"}(i),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(pp).join("\n")}(i),m=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(r),f=s.createProgram();let g,v,_=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(pp).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(pp).join("\n"),v.length>0&&(v+="\n")):(g=[wp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(pp).join("\n"),v=[wp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor||i.batchingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?vd.tonemapping_pars_fragment:"",0!==i.toneMapping?cp("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",vd.colorspace_pars_fragment,hp("linearToOutputTexel",i.outputColorSpace),up(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(pp).join("\n")),a=vp(a),a=mp(a,i),a=fp(a,i),o=vp(o),o=mp(o,i),o=fp(o,i),a=bp(a),o=bp(o),!0!==i.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",i.glslVersion===ti?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ti?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const y=_+g+a,x=_+v+o,b=sp(s,s.VERTEX_SHADER,y),S=sp(s,s.FRAGMENT_SHADER,x);function w(e){if(t.debug.checkShaderErrors){const i=s.getProgramInfoLog(f)||"",n=s.getShaderInfoLog(b)||"",r=s.getShaderInfoLog(S)||"",a=i.trim(),o=n.trim(),h=r.trim();let l=!0,c=!0;if(!1===s.getProgramParameter(f,s.LINK_STATUS))if(l=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(s,f,b,S);else{const t=op(s,b,"vertex"),i=op(s,S,"fragment");pi("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(f,s.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+a+"\n"+t+"\n"+i)}else""!==a?ui("WebGLProgram: Program Info Log:",a):""!==o&&""!==h||(c=!1);c&&(e.diagnostics={runnable:l,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:h,prefix:v}})}s.deleteShader(b),s.deleteShader(S),M=new np(s,f),T=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const n=t.getActiveAttrib(e,s),r=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[r]={type:n.type,location:t.getAttribLocation(e,r),locationSize:a}}return i}(s,f)}let M,T;s.attachShader(f,b),s.attachShader(f,S),void 0!==i.index0AttributeName?s.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(f,0,"position"),s.linkProgram(f),this.getUniforms=function(){return void 0===M&&w(this),M},this.getAttributes=function(){return void 0===T&&w(this),T};let E=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=s.getProgramParameter(f,37297)),E},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=rp++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=S,this}let Lp=0;class Rp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),s=this._getShaderStage(i),r=this._getShaderCacheForMaterial(t);return!1===r.has(n)&&(r.add(n),n.usedTimes++),!1===r.has(s)&&(r.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new Ip(t),e.set(t,i)),i}}class Ip{constructor(t){this.id=Lp++,this.code=t,this.usedTimes=0}}function Pp(t,e,i,n,s,r,a){const o=new Fn,h=new Rp,l=new Set,c=[],d=new Map,u=s.logarithmicDepthBuffer;let p=s.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function f(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(r,o,c,d,g){const v=d.fog,_=g.geometry,y=r.isMeshStandardMaterial?d.environment:null,x=(r.isMeshStandardMaterial?i:e).get(r.envMap||y),b=x&&x.mapping===gt?x.image.height:null,S=m[r.type];null!==r.precision&&(p=s.getMaxPrecision(r.precision),p!==r.precision&&ui("WebGLProgram.getParameters:",r.precision,"not supported, using",p,"instead."));const w=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,M=void 0!==w?w.length:0;let T,E,A,C,L=0;if(void 0!==_.morphAttributes.position&&(L=1),void 0!==_.morphAttributes.normal&&(L=2),void 0!==_.morphAttributes.color&&(L=3),S){const t=yd[S];T=t.vertexShader,E=t.fragmentShader}else T=r.vertexShader,E=r.fragmentShader,h.update(r),A=h.getVertexShaderID(r),C=h.getFragmentShaderID(r);const R=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),P=!0===g.isInstancedMesh,D=!0===g.isBatchedMesh,O=!!r.map,N=!!r.matcap,U=!!x,F=!!r.aoMap,B=!!r.lightMap,k=!!r.bumpMap,z=!!r.normalMap,G=!!r.displacementMap,H=!!r.emissiveMap,V=!!r.metalnessMap,W=!!r.roughnessMap,j=r.anisotropy>0,X=r.clearcoat>0,Y=r.dispersion>0,q=r.iridescence>0,Z=r.sheen>0,K=r.transmission>0,J=j&&!!r.anisotropyMap,Q=X&&!!r.clearcoatMap,$=X&&!!r.clearcoatNormalMap,tt=X&&!!r.clearcoatRoughnessMap,et=q&&!!r.iridescenceMap,it=q&&!!r.iridescenceThicknessMap,nt=Z&&!!r.sheenColorMap,st=Z&&!!r.sheenRoughnessMap,rt=!!r.specularMap,at=!!r.specularColorMap,ot=!!r.specularIntensityMap,ht=K&&!!r.transmissionMap,lt=K&&!!r.thicknessMap,ct=!!r.gradientMap,dt=!!r.alphaMap,ut=r.alphaTest>0,pt=!!r.alphaHash,mt=!!r.extensions;let ft=0;r.toneMapped&&(null!==R&&!0!==R.isXRRenderTarget||(ft=t.toneMapping));const vt={shaderID:S,shaderType:r.type,shaderName:r.name,vertexShader:T,fragmentShader:E,defines:r.defines,customVertexShaderID:A,customFragmentShaderID:C,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:p,batching:D,batchingColor:D&&null!==g._colorsTexture,instancing:P,instancingColor:P&&null!==g.instanceColor,instancingMorph:P&&null!==g.morphTexture,outputColorSpace:null===R?t.outputColorSpace:!0===R.isXRRenderTarget?R.texture.colorSpace:Ge,alphaToCoverage:!!r.alphaToCoverage,map:O,matcap:N,envMap:U,envMapMode:U&&x.mapping,envMapCubeUVHeight:b,aoMap:F,lightMap:B,bumpMap:k,normalMap:z,displacementMap:G,emissiveMap:H,normalMapObjectSpace:z&&1===r.normalMapType,normalMapTangentSpace:z&&0===r.normalMapType,metalnessMap:V,roughnessMap:W,anisotropy:j,anisotropyMap:J,clearcoat:X,clearcoatMap:Q,clearcoatNormalMap:$,clearcoatRoughnessMap:tt,dispersion:Y,iridescence:q,iridescenceMap:et,iridescenceThicknessMap:it,sheen:Z,sheenColorMap:nt,sheenRoughnessMap:st,specularMap:rt,specularColorMap:at,specularIntensityMap:ot,transmission:K,transmissionMap:ht,thicknessMap:lt,gradientMap:ct,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:dt,alphaTest:ut,alphaHash:pt,combine:r.combine,mapUv:O&&f(r.map.channel),aoMapUv:F&&f(r.aoMap.channel),lightMapUv:B&&f(r.lightMap.channel),bumpMapUv:k&&f(r.bumpMap.channel),normalMapUv:z&&f(r.normalMap.channel),displacementMapUv:G&&f(r.displacementMap.channel),emissiveMapUv:H&&f(r.emissiveMap.channel),metalnessMapUv:V&&f(r.metalnessMap.channel),roughnessMapUv:W&&f(r.roughnessMap.channel),anisotropyMapUv:J&&f(r.anisotropyMap.channel),clearcoatMapUv:Q&&f(r.clearcoatMap.channel),clearcoatNormalMapUv:$&&f(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&f(r.clearcoatRoughnessMap.channel),iridescenceMapUv:et&&f(r.iridescenceMap.channel),iridescenceThicknessMapUv:it&&f(r.iridescenceThicknessMap.channel),sheenColorMapUv:nt&&f(r.sheenColorMap.channel),sheenRoughnessMapUv:st&&f(r.sheenRoughnessMap.channel),specularMapUv:rt&&f(r.specularMap.channel),specularColorMapUv:at&&f(r.specularColorMap.channel),specularIntensityMapUv:ot&&f(r.specularIntensityMap.channel),transmissionMapUv:ht&&f(r.transmissionMap.channel),thicknessMapUv:lt&&f(r.thicknessMap.channel),alphaMapUv:dt&&f(r.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(z||j),vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!_.attributes.uv&&(O||dt),fog:!!v,useFog:!0===r.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===r.flatShading&&!1===r.wireframe,sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:u,reversedDepthBuffer:I,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:M,morphTextureStride:L,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:ft,decodeVideoTexture:O&&!0===r.map.isVideoTexture&&Ui.getTransfer(r.map.colorSpace)===Ve,decodeVideoTextureEmissive:H&&!0===r.emissiveMap.isVideoTexture&&Ui.getTransfer(r.emissiveMap.colorSpace)===Ve,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:mt&&!0===r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(mt&&!0===r.extensions.multiDraw||D)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.instancing&&o.enable(0);e.instancingColor&&o.enable(1);e.instancingMorph&&o.enable(2);e.matcap&&o.enable(3);e.envMap&&o.enable(4);e.normalMapObjectSpace&&o.enable(5);e.normalMapTangentSpace&&o.enable(6);e.clearcoat&&o.enable(7);e.iridescence&&o.enable(8);e.alphaTest&&o.enable(9);e.vertexColors&&o.enable(10);e.vertexAlphas&&o.enable(11);e.vertexUv1s&&o.enable(12);e.vertexUv2s&&o.enable(13);e.vertexUv3s&&o.enable(14);e.vertexTangents&&o.enable(15);e.anisotropy&&o.enable(16);e.alphaHash&&o.enable(17);e.batching&&o.enable(18);e.dispersion&&o.enable(19);e.batchingColor&&o.enable(20);e.gradientMap&&o.enable(21);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reversedDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.decodeVideoTextureEmissive&&o.enable(20);e.alphaToCoverage&&o.enable(21);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=m[t.type];let i;if(e){const t=yd[e];i=sr.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n=d.get(i);return void 0!==n?++n.usedTimes:(n=new Cp(t,i,e,r),c.push(n),d.set(i,n)),n},releaseProgram:function(t){if(0===--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),d.delete(t.cacheKey),t.destroy()}},releaseShaderCache:function(t){h.remove(t)},programs:c,dispose:function(){h.dispose()}}}function Dp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Op(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Np(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Up(){const t=[];let e=0;const i=[],n=[],s=[];function r(i,n,s,r,a,o){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:s,groupOrder:r,renderOrder:i.renderOrder,z:a,group:o},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=s,h.groupOrder=r,h.renderOrder=i.renderOrder,h.z=a,h.group=o),e++,h}return{opaque:i,transmissive:n,transparent:s,init:function(){e=0,i.length=0,n.length=0,s.length=0},push:function(t,e,a,o,h,l){const c=r(t,e,a,o,h,l);a.transmission>0?n.push(c):!0===a.transparent?s.push(c):i.push(c)},unshift:function(t,e,a,o,h,l){const c=r(t,e,a,o,h,l);a.transmission>0?n.unshift(c):!0===a.transparent?s.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||Op),n.length>1&&n.sort(e||Np),s.length>1&&s.sort(e||Np)}}}function Fp(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let s;return void 0===n?(s=new Up,t.set(e,[s])):i>=n.length?(s=new Up,n.push(s)):s=n[i],s},dispose:function(){t=new WeakMap}}}function Bp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Li,color:new _s};break;case"SpotLight":i={position:new Li,direction:new Li,color:new _s,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Li,color:new _s,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Li,skyColor:new _s,groundColor:new _s};break;case"RectAreaLight":i={color:new _s,position:new Li,halfWidth:new Li,halfHeight:new Li}}return t[e.id]=i,i}}}let kp=0;function zp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Gp(t){const e=new Bp,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ai};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ai,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)n.probe.push(new Li);const s=new Li,r=new En,a=new En;return{setup:function(s){let r=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let h=0,l=0,c=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,_=0;s.sort(zp);for(let t=0,y=s.length;t<y;t++){const y=s[t],x=y.color,b=y.intensity,S=y.distance;let w=null;if(y.shadow&&y.shadow.map&&(w=y.shadow.map.texture.format===Xt?y.shadow.map.texture:y.shadow.map.depthTexture||y.shadow.map.texture),y.isAmbientLight)r+=x.r*b,a+=x.g*b,o+=x.b*b;else if(y.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(y.sh.coefficients[t],b);_++}else if(y.isDirectionalLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[h]=e,n.directionalShadowMap[h]=w,n.directionalShadowMatrix[h]=y.shadow.matrix,p++}n.directional[h]=t,h++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=S,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,n.spot[c]=t;const s=y.shadow;if(y.map&&(n.spotLightMap[g]=y.map,g++,s.updateMatrices(y),y.castShadow&&v++),n.spotLightMatrix[c]=s.matrix,y.castShadow){const t=i.get(y);t.shadowIntensity=s.intensity,t.shadowBias=s.bias,t.shadowNormalBias=s.normalBias,t.shadowRadius=s.radius,t.shadowMapSize=s.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=w,f++}c++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),n.rectArea[d]=t,d++}else if(y.isPointLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),t.distance=y.distance,t.decay=y.decay,y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[l]=e,n.pointShadowMap[l]=w,n.pointShadowMatrix[l]=y.shadow.matrix,m++}n.point[l]=t,l++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(b),t.groundColor.copy(y.groundColor).multiplyScalar(b),n.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=_d.LTC_FLOAT_1,n.rectAreaLTC2=_d.LTC_FLOAT_2):(n.rectAreaLTC1=_d.LTC_HALF_1,n.rectAreaLTC2=_d.LTC_HALF_2)),n.ambient[0]=r,n.ambient[1]=a,n.ambient[2]=o;const y=n.hash;y.directionalLength===h&&y.pointLength===l&&y.spotLength===c&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===m&&y.numSpotShadows===f&&y.numSpotMaps===g&&y.numLightProbes===_||(n.directional.length=h,n.spot.length=c,n.rectArea.length=d,n.point.length=l,n.hemi.length=u,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=m,n.pointShadowMap.length=m,n.spotShadow.length=f,n.spotShadowMap.length=f,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=m,n.spotLightMatrix.length=f+g-v,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=v,n.numLightProbes=_,y.directionalLength=h,y.pointLength=l,y.spotLength=c,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=f,y.numSpotMaps=g,y.numLightProbes=_,n.version=kp++)},setupView:function(t,e){let i=0,o=0,h=0,l=0,c=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(u.matrixWorld),s.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(d),i++}else if(u.isSpotLight){const t=n.spot[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),s.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(d),h++}else if(u.isRectAreaLight){const t=n.rectArea[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),r.copy(u.matrixWorld),r.premultiply(d),a.extractRotation(r),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),l++}else if(u.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:n}}function Hp(t){const e=new Gp(t),i=[],n=[];const s={lightsArray:i,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){s.camera=t,i.length=0,n.length=0},state:s,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)}}}function Vp(t){let e=new WeakMap;return{get:function(i,n=0){const s=e.get(i);let r;return void 0===s?(r=new Hp(t),e.set(i,[r])):n>=s.length?(r=new Hp(t),s.push(r)):r=s[n],r},dispose:function(){e=new WeakMap}}}const Wp=[new Li(1,0,0),new Li(-1,0,0),new Li(0,1,0),new Li(0,-1,0),new Li(0,0,1),new Li(0,0,-1)],jp=[new Li(0,-1,0),new Li(0,-1,0),new Li(0,0,1),new Li(0,0,-1),new Li(0,-1,0),new Li(0,-1,0)],Xp=new En,Yp=new Li,qp=new Li;function Zp(t,e,i){let n=new xa;const s=new Ai,r=new Ai,a=new Yi,o=new Kh,h=new Jh,l={},c=i.maxTextureSize,d={[M]:1,[T]:0,[E]:2},u=new rr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ai},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new zs;m.setAttribute("position",new Ls(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Qs(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(i,n){const r=e.update(f);u.defines.VSM_SAMPLES!==i.blurSamples&&(u.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Zi(s.x,s.y,{format:Xt,type:Dt})),u.uniforms.shadow_pass.value=i.map.depthTexture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,u,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,p,f,null)}function y(e,i,n,s){let r=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)r=a;else if(r=!0===n.isPointLight?h:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0||!0===i.alphaToCoverage){const t=r.uuid,e=i.uuid;let n=l[t];void 0===n&&(n={},l[t]=n);let s=n[e];void 0===s&&(s=r.clone(),n[e]=s,i.addEventListener("dispose",b)),r=s}if(r.visible=i.visible,r.wireframe=i.wireframe,r.side=3===s?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],r.alphaMap=i.alphaMap,r.alphaTest=!0===i.alphaToCoverage?.5:i.alphaTest,r.map=i.map,r.clipShadows=i.clipShadows,r.clippingPlanes=i.clippingPlanes,r.clipIntersection=i.clipIntersection,r.displacementMap=i.displacementMap,r.displacementScale=i.displacementScale,r.displacementBias=i.displacementBias,r.wireframeLinewidth=i.wireframeLinewidth,r.linewidth=i.linewidth,!0===n.isPointLight&&!0===r.isMeshDistanceMaterial){t.properties.get(r).light=n}return r}function x(i,s,r,a,o){if(!1===i.visible)return;if(i.layers.test(s.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,i.matrixWorld);const n=e.update(i),h=i.material;if(Array.isArray(h)){const e=n.groups;for(let l=0,c=e.length;l<c;l++){const c=e[l],d=h[c.materialIndex];if(d&&d.visible){const e=y(i,d,a,o);i.onBeforeShadow(t,i,s,r,n,e,c),t.renderBufferDirect(r,null,n,e,i,c),i.onAfterShadow(t,i,s,r,n,e,c)}}}else if(h.visible){const e=y(i,h,a,o);i.onBeforeShadow(t,i,s,r,n,e,null),t.renderBufferDirect(r,null,n,e,i,null),i.onAfterShadow(t,i,s,r,n,e,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)x(h[t],s,r,a,o)}function b(t){t.target.removeEventListener("dispose",b);for(const e in l){const i=l[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;2===e.type&&(ui("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),e.type=1);const h=t.getRenderTarget(),l=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=v!==this.type;p&&i.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.needsUpdate=!0):t.material.needsUpdate=!0)});for(let h=0,l=e.length;h<l;h++){const l=e[h],d=l.shadow;if(void 0===d){ui("WebGLShadowMap:",l,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;s.copy(d.mapSize);const m=d.getFrameExtents();if(s.multiply(m),r.copy(d.mapSize),(s.x>c||s.y>c)&&(s.x>c&&(r.x=Math.floor(c/m.x),s.x=r.x*m.x,d.mapSize.x=r.x),s.y>c&&(r.y=Math.floor(c/m.y),s.y=r.y*m.y,d.mapSize.y=r.y)),null===d.map||!0===p){if(null!==d.map&&(null!==d.map.depthTexture&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),3===this.type){if(l.isPointLight){ui("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}d.map=new Zi(s.x,s.y,{format:Xt,type:Dt,minFilter:wt,magFilter:wt,generateMipmaps:!1}),d.map.texture.name=l.name+".shadowMap",d.map.depthTexture=new po(s.x,s.y,Pt),d.map.depthTexture.name=l.name+".shadowMapDepth",d.map.depthTexture.format=Ht,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=xt,d.map.depthTexture.magFilter=xt}else{l.isPointLight?(d.map=new mr(s.x),d.map.depthTexture=new mo(s.x,It)):(d.map=new Zi(s.x,s.y),d.map.depthTexture=new po(s.x,s.y,It)),d.map.depthTexture.name=l.name+".shadowMap",d.map.depthTexture.format=Ht;const e=t.state.buffers.depth.getReversed();1===this.type?(d.map.depthTexture.compareFunction=e?Je:qe,d.map.depthTexture.minFilter=wt,d.map.depthTexture.magFilter=wt):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=xt,d.map.depthTexture.magFilter=xt)}d.camera.updateProjectionMatrix()}const f=d.map.isWebGLCubeRenderTarget?6:1;for(let e=0;e<f;e++){if(d.map.isWebGLCubeRenderTarget)t.setRenderTarget(d.map,e),t.clear();else{0===e&&(t.setRenderTarget(d.map),t.clear());const i=d.getViewport(e);a.set(r.x*i.x,r.y*i.y,r.x*i.z,r.y*i.w),u.viewport(a)}if(l.isPointLight){const t=d.camera,i=d.matrix,n=l.distance||t.far;n!==t.far&&(t.far=n,t.updateProjectionMatrix()),Yp.setFromMatrixPosition(l.matrixWorld),t.position.copy(Yp),qp.copy(t.position),qp.add(Wp[e]),t.up.copy(jp[e]),t.lookAt(qp),t.updateMatrixWorld(),i.makeTranslation(-Yp.x,-Yp.y,-Yp.z),Xp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),d._frustum.setFromProjectionMatrix(Xp,t.coordinateSystem,t.reversedDepth)}else d.updateMatrices(l);n=d.getFrustum(),x(i,o,d.camera,l,this.type)}!0!==d.isPointLightShadow&&3===this.type&&_(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(h,l,d)}}const Kp={[j]:1,[Y]:6,[Z]:7,[q]:5,[X]:0,[J]:2,[Q]:4,[K]:3};function Jp(t,e){const i=new function(){let e=!1;const i=new Yi;let n=null;const s=new Yi(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,r,a,o){!0===o&&(e*=a,n*=a,r*=a),i.set(e,n,r,a),!1===s.equals(i)&&(t.clearColor(e,n,r,a),s.copy(i))},reset:function(){e=!1,n=null,s.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,s=null,r=null,a=null;return{setReversed:function(t){if(n!==t){const i=e.get("EXT_clip_control");t?i.clipControlEXT(i.LOWER_LEFT_EXT,i.ZERO_TO_ONE_EXT):i.clipControlEXT(i.LOWER_LEFT_EXT,i.NEGATIVE_ONE_TO_ONE_EXT),n=t;const s=a;a=null,this.setClear(s)}},getReversed:function(){return n},setTest:function(e){e?st(t.DEPTH_TEST):rt(t.DEPTH_TEST)},setMask:function(e){s===e||i||(t.depthMask(e),s=e)},setFunc:function(e){if(n&&(e=Kp[e]),r!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}r=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(n&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){i=!1,s=null,r=null,a=null,n=!1}}},s=new function(){let e=!1,i=null,n=null,s=null,r=null,a=null,o=null,h=null,l=null;return{setTest:function(i){e||(i?st(t.STENCIL_TEST):rt(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&s===i&&r===a||(t.stencilFunc(e,i,a),n=e,s=i,r=a)},setOp:function(e,i,n){a===e&&o===i&&h===n||(t.stencilOp(e,i,n),a=e,o=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,s=null,r=null,a=null,o=null,h=null,l=null}}},r=new WeakMap,a=new WeakMap;let o={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new _s(0,0,0),b=0,S=!1,w=null,M=null,T=null,E=null,j=null;const X=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const Z=t.getParameter(t.VERSION);-1!==Z.indexOf("WebGL")?(q=parseFloat(/^WebGL (\d)/.exec(Z)[1]),Y=q>=1):-1!==Z.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let K=null,J={};const Q=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),tt=(new Yi).fromArray(Q),et=(new Yi).fromArray($);function it(e,i,n,s){const r=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,s,0,t.RGBA,t.UNSIGNED_BYTE,r):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,r);return a}const nt={};function st(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function rt(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}nt[t.TEXTURE_2D]=it(t.TEXTURE_2D,t.TEXTURE_2D,1),nt[t.TEXTURE_CUBE_MAP]=it(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),nt[t.TEXTURE_2D_ARRAY]=it(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),nt[t.TEXTURE_3D]=it(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),s.setClear(0),st(t.DEPTH_TEST),n.setFunc(3),lt(!1),ct(1),st(t.CULL_FACE),ht(0);const at={[A]:t.FUNC_ADD,[C]:t.FUNC_SUBTRACT,[L]:t.FUNC_REVERSE_SUBTRACT};at[103]=t.MIN,at[104]=t.MAX;const ot={[R]:t.ZERO,[I]:t.ONE,[P]:t.SRC_COLOR,[O]:t.SRC_ALPHA,[z]:t.SRC_ALPHA_SATURATE,[B]:t.DST_COLOR,[U]:t.DST_ALPHA,[D]:t.ONE_MINUS_SRC_COLOR,[N]:t.ONE_MINUS_SRC_ALPHA,[k]:t.ONE_MINUS_DST_COLOR,[F]:t.ONE_MINUS_DST_ALPHA,[G]:t.CONSTANT_COLOR,[H]:t.ONE_MINUS_CONSTANT_COLOR,[V]:t.CONSTANT_ALPHA,[W]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,s,r,a,o,h,l,c){if(0!==e){if(!1===u&&(st(t.BLEND),u=!0),5===e)r=r||i,a=a||n,o=o||s,i===m&&r===v||(t.blendEquationSeparate(at[i],at[r]),m=i,v=r),n===f&&s===g&&a===_&&o===y||(t.blendFuncSeparate(ot[n],ot[s],ot[a],ot[o]),f=n,g=s,_=a,y=o),!1!==h.equals(x)&&l===b||(t.blendColor(h.r,h.g,h.b,l),x.copy(h),b=l),p=e,S=!1;else if(e!==p||c!==S){if(m===A&&v===A||(t.blendEquation(t.FUNC_ADD),m=A,v=A),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:pi("WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:pi("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:pi("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:pi("WebGLState: Invalid blending: ",e)}f=null,g=null,_=null,y=null,x.set(0,0,0),b=0,p=e,S=c}}else!0===u&&(rt(t.BLEND),u=!1)}function lt(e){w!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),w=e)}function ct(e){0!==e?(st(t.CULL_FACE),e!==M&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):rt(t.CULL_FACE),M=e}function dt(e,i,n){e?(st(t.POLYGON_OFFSET_FILL),E===i&&j===n||(t.polygonOffset(i,n),E=i,j=n)):rt(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:s},enable:st,disable:rt,bindFramebuffer:function(e,i){return h[e]!==i&&(t.bindFramebuffer(e,i),h[e]=i,e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=c,s=!1;if(e){n=l.get(i),void 0===n&&(n=[],l.set(i,n));const r=e.textures;if(n.length!==r.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=r.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=r.length,s=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,s=!0);s&&t.drawBuffers(n)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,r){2===e.side?rt(t.CULL_FACE):st(t.CULL_FACE);let a=1===e.side;r&&(a=!a),lt(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;s.setTest(o),o&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?st(t.SAMPLE_ALPHA_TO_COVERAGE):rt(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:lt,setCullFace:ct,setLineWidth:function(e){e!==T&&(Y&&t.lineWidth(e),T=e)},setPolygonOffset:dt,setScissorTest:function(e){e?st(t.SCISSOR_TEST):rt(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+X-1),K!==e&&(t.activeTexture(e),K=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===K?t.TEXTURE0+X-1:K);let s=J[n];void 0===s&&(s={type:void 0,texture:void 0},J[n]=s),s.type===e&&s.texture===i||(K!==n&&(t.activeTexture(n),K=n),t.bindTexture(e,i||nt[e]),s.type=e,s.texture=i)},unbindTexture:function(){const e=J[K];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let s=n.get(e);void 0===s&&(s=t.getUniformBlockIndex(i,e.name),n.set(e,s))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);r.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),r.set(i,n))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){pi("WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){pi("WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},scissor:function(e){!1===tt.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),tt.copy(e))},viewport:function(e){!1===et.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),et.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),o={},K=null,J={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new _s(0,0,0),b=0,S=!1,w=null,M=null,T=null,E=null,j=null,tt.set(0,0,t.canvas.width,t.canvas.height),et.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),s.reset()}}}function Qp(t,e,i,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),l=new Ai,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):oi("canvas")}function f(t,e,i){let n=1;const s=V(t);if((s.width>i||s.height>i)&&(n=i/Math.max(s.width,s.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*s.width),r=Math.floor(n*s.height);void 0===d&&(d=m(i,r));const a=e?m(i,r):d;a.width=i,a.height=r;return a.getContext("2d").drawImage(t,0,0,i,r),ui("WebGLRenderer: Texture has been resized from ("+s.width+"x"+s.height+") to ("+i+"x"+r+")."),a}return"data"in t&&ui("WebGLRenderer: Image in DataTexture is too big ("+s.width+"x"+s.height+")."),t}return t}function g(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function _(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(i,n,s,r,a=!1){if(null!==i){if(void 0!==t[i])return t[i];ui("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;if(n===t.RED&&(s===t.FLOAT&&(o=t.R32F),s===t.HALF_FLOAT&&(o=t.R16F),s===t.UNSIGNED_BYTE&&(o=t.R8)),n===t.RED_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.R8UI),s===t.UNSIGNED_SHORT&&(o=t.R16UI),s===t.UNSIGNED_INT&&(o=t.R32UI),s===t.BYTE&&(o=t.R8I),s===t.SHORT&&(o=t.R16I),s===t.INT&&(o=t.R32I)),n===t.RG&&(s===t.FLOAT&&(o=t.RG32F),s===t.HALF_FLOAT&&(o=t.RG16F),s===t.UNSIGNED_BYTE&&(o=t.RG8)),n===t.RG_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RG8UI),s===t.UNSIGNED_SHORT&&(o=t.RG16UI),s===t.UNSIGNED_INT&&(o=t.RG32UI),s===t.BYTE&&(o=t.RG8I),s===t.SHORT&&(o=t.RG16I),s===t.INT&&(o=t.RG32I)),n===t.RGB_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RGB8UI),s===t.UNSIGNED_SHORT&&(o=t.RGB16UI),s===t.UNSIGNED_INT&&(o=t.RGB32UI),s===t.BYTE&&(o=t.RGB8I),s===t.SHORT&&(o=t.RGB16I),s===t.INT&&(o=t.RGB32I)),n===t.RGBA_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),s===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),s===t.UNSIGNED_INT&&(o=t.RGBA32UI),s===t.BYTE&&(o=t.RGBA8I),s===t.SHORT&&(o=t.RGBA16I),s===t.INT&&(o=t.RGBA32I)),n===t.RGB&&(s===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),s===t.UNSIGNED_INT_10F_11F_11F_REV&&(o=t.R11F_G11F_B10F)),n===t.RGBA){const e=a?He:Ui.getTransfer(r);s===t.FLOAT&&(o=t.RGBA32F),s===t.HALF_FLOAT&&(o=t.RGBA16F),s===t.UNSIGNED_BYTE&&(o=e===Ve?t.SRGB8_ALPHA8:t.RGBA8),s===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),s===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function x(e,i){let n;return e?null===i||i===It||i===Ut?n=t.DEPTH24_STENCIL8:i===Pt?n=t.DEPTH32F_STENCIL8:i===Lt&&(n=t.DEPTH24_STENCIL8,ui("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===It||i===Ut?n=t.DEPTH_COMPONENT24:i===Pt?n=t.DEPTH_COMPONENT32F:i===Lt&&(n=t.DEPTH_COMPONENT16),n}function b(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==xt&&t.minFilter!==wt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function S(t){const e=t.target;e.removeEventListener("dispose",S),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,s=u.get(i);if(s){const n=s[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&M(t),0===Object.keys(s).length&&u.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function w(e){const i=e.target;i.removeEventListener("dispose",w),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const s=e.textures;for(let e=0,i=s.length;e<i;e++){const i=n.get(s[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(s[e])}n.remove(e)}(i)}function M(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const s=e.source;delete u.get(s)[i.__cacheKey],a.memory.textures--}let T=0;function E(e,s){const r=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&r.__version!==e.version){const t=e.image;if(null===t)ui("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(r,e,s);ui("WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(r.__webglTexture=e.sourceTexture?e.sourceTexture:null);i.bindTexture(t.TEXTURE_2D,r.__webglTexture,t.TEXTURE0+s)}const A={[vt]:t.REPEAT,[_t]:t.CLAMP_TO_EDGE,[yt]:t.MIRRORED_REPEAT},C={[xt]:t.NEAREST,[bt]:t.NEAREST_MIPMAP_NEAREST,[St]:t.NEAREST_MIPMAP_LINEAR,[wt]:t.LINEAR,[Mt]:t.LINEAR_MIPMAP_NEAREST,[Tt]:t.LINEAR_MIPMAP_LINEAR},L={[je]:t.NEVER,[Qe]:t.ALWAYS,[Xe]:t.LESS,[qe]:t.LEQUAL,[Ye]:t.EQUAL,[Je]:t.GEQUAL,[Ze]:t.GREATER,[Ke]:t.NOTEQUAL};function R(i,r){if(r.type!==Pt||!1!==e.has("OES_texture_float_linear")||r.magFilter!==wt&&r.magFilter!==Mt&&r.magFilter!==St&&r.magFilter!==Tt&&r.minFilter!==wt&&r.minFilter!==Mt&&r.minFilter!==St&&r.minFilter!==Tt||ui("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,A[r.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[r.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[r.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[r.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[r.minFilter]),r.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,L[r.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(r.magFilter===xt)return;if(r.minFilter!==St&&r.minFilter!==Tt)return;if(r.type===Pt&&!1===e.has("OES_texture_float_linear"))return;if(r.anisotropy>1||n.get(r).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,s.getMaxAnisotropy())),n.get(r).__currentAnisotropy=r.anisotropy}}}function I(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",S));const s=i.source;let r=u.get(s);void 0===r&&(r={},u.set(s,r));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===r[o]&&(r[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),r[o].usedTimes++;const s=r[e.__cacheKey];void 0!==s&&(r[e.__cacheKey].usedTimes--,0===s.usedTimes&&M(i)),e.__cacheKey=o,e.__webglTexture=r[o].texture}return n}function P(t,e,i){return Math.floor(Math.floor(t/i)/e)}function D(e,a,o){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const l=I(e,a),c=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=Ui.getPrimaries(Ui.workingColorSpace),n=a.colorSpace===ke?null:Ui.getPrimaries(a.colorSpace),u=a.colorSpace===ke||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=f(a.image,!1,s.maxTextureSize);p=H(a,p);const m=r.convert(a.format,a.colorSpace),_=r.convert(a.type);let S,w=y(a.internalFormat,m,_,a.colorSpace,a.isVideoTexture);R(h,a);const M=a.mipmaps,T=!0!==a.isVideoTexture,E=void 0===d.__version||!0===l,A=c.dataReady,C=b(a,p);if(a.isDepthTexture)w=x(a.format===Vt,a.type),E&&(T?i.texStorage2D(t.TEXTURE_2D,1,w,p.width,p.height):i.texImage2D(t.TEXTURE_2D,0,w,p.width,p.height,0,m,_,null));else if(a.isDataTexture)if(M.length>0){T&&E&&i.texStorage2D(t.TEXTURE_2D,C,w,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)S=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,S.width,S.height,m,_,S.data):i.texImage2D(t.TEXTURE_2D,e,w,S.width,S.height,0,m,_,S.data);a.generateMipmaps=!1}else T?(E&&i.texStorage2D(t.TEXTURE_2D,C,w,p.width,p.height),A&&function(e,n,s,r){const a=e.updateRanges;if(0===a.length)i.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,s,r,n.data);else{a.sort((t,e)=>t.start-e.start);let o=0;for(let t=1;t<a.length;t++){const e=a[o],i=a[t],s=e.start+e.count,r=P(i.start,n.width,4),h=P(e.start,n.width,4);i.start<=s+1&&r===h&&P(i.start+i.count-1,n.width,4)===r?e.count=Math.max(e.count,i.start+i.count-e.start):(++o,a[o]=i)}a.length=o+1;const h=t.getParameter(t.UNPACK_ROW_LENGTH),l=t.getParameter(t.UNPACK_SKIP_PIXELS),c=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,n.width);for(let e=0,o=a.length;e<o;e++){const o=a[e],h=Math.floor(o.start/4),l=Math.ceil(o.count/4),c=h%n.width,d=Math.floor(h/n.width),u=l,p=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,c),t.pixelStorei(t.UNPACK_SKIP_ROWS,d),i.texSubImage2D(t.TEXTURE_2D,0,c,d,u,p,s,r,n.data)}e.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,h),t.pixelStorei(t.UNPACK_SKIP_PIXELS,l),t.pixelStorei(t.UNPACK_SKIP_ROWS,c)}}(a,p,m,_)):i.texImage2D(t.TEXTURE_2D,0,w,p.width,p.height,0,m,_,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){T&&E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,w,M[0].width,M[0].height,p.depth);for(let e=0,n=M.length;e<n;e++)if(S=M[e],a.format!==Gt)if(null!==m)if(T){if(A)if(a.layerUpdates.size>0){const n=md(S.width,S.height,a.format,a.type);for(const s of a.layerUpdates){const r=S.data.subarray(s*n/S.data.BYTES_PER_ELEMENT,(s+1)*n/S.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,s,S.width,S.height,1,m,r)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,S.width,S.height,p.depth,m,S.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,w,S.width,S.height,p.depth,0,S.data,0,0);else ui("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,S.width,S.height,p.depth,m,_,S.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,w,S.width,S.height,p.depth,0,m,_,S.data)}else{T&&E&&i.texStorage2D(t.TEXTURE_2D,C,w,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)S=M[e],a.format!==Gt?null!==m?T?A&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,S.width,S.height,m,S.data):i.compressedTexImage2D(t.TEXTURE_2D,e,w,S.width,S.height,0,S.data):ui("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,S.width,S.height,m,_,S.data):i.texImage2D(t.TEXTURE_2D,e,w,S.width,S.height,0,m,_,S.data)}else if(a.isDataArrayTexture)if(T){if(E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,w,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=md(p.width,p.height,a.format,a.type);for(const n of a.layerUpdates){const s=p.data.subarray(n*e/p.data.BYTES_PER_ELEMENT,(n+1)*e/p.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,n,p.width,p.height,1,m,_,s)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,w,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isData3DTexture)T?(E&&i.texStorage3D(t.TEXTURE_3D,C,w,p.width,p.height,p.depth),A&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)):i.texImage3D(t.TEXTURE_3D,0,w,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isFramebufferTexture){if(E)if(T)i.texStorage2D(t.TEXTURE_2D,C,w,p.width,p.height);else{let e=p.width,n=p.height;for(let s=0;s<C;s++)i.texImage2D(t.TEXTURE_2D,s,w,e,n,0,m,_,null),e>>=1,n>>=1}}else if(M.length>0){if(T&&E){const e=V(M[0]);i.texStorage2D(t.TEXTURE_2D,C,w,e.width,e.height)}for(let e=0,n=M.length;e<n;e++)S=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m,_,S):i.texImage2D(t.TEXTURE_2D,e,w,m,_,S);a.generateMipmaps=!1}else if(T){if(E){const e=V(p);i.texStorage2D(t.TEXTURE_2D,C,w,e.width,e.height)}A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,m,_,p)}else i.texImage2D(t.TEXTURE_2D,0,w,m,_,p);g(a)&&v(h),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function O(e,s,a,h,l,c){const d=r.convert(a.format,a.colorSpace),u=r.convert(a.type),p=y(a.internalFormat,d,u,a.colorSpace),m=n.get(s),f=n.get(a);if(f.__renderTarget=s,!m.__hasExternalTextures){const e=Math.max(1,s.width>>c),n=Math.max(1,s.height>>c);l===t.TEXTURE_3D||l===t.TEXTURE_2D_ARRAY?i.texImage3D(l,c,p,e,n,s.depth,0,d,u,null):i.texImage2D(l,c,p,e,n,0,d,u,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),G(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,h,l,f.__webglTexture,0,z(s)):(l===t.TEXTURE_2D||l>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,h,l,f.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function N(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const s=i.depthTexture,r=s&&s.isDepthTexture?s.type:null,a=x(i.stencilBuffer,r),h=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,z(i),a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,z(i),a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,h,t.RENDERBUFFER,e)}else{const e=i.textures;for(let s=0;s<e.length;s++){const a=e[s],h=r.convert(a.format,a.colorSpace),l=r.convert(a.type),c=y(a.internalFormat,h,l,a.colorSpace);G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,z(i),c,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,z(i),c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e,s,a){const h=!0===s.isWebGLCubeRenderTarget;if(i.bindFramebuffer(t.FRAMEBUFFER,e),!s.depthTexture||!s.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const l=n.get(s.depthTexture);if(l.__renderTarget=s,l.__webglTexture&&s.depthTexture.image.width===s.width&&s.depthTexture.image.height===s.height||(s.depthTexture.image.width=s.width,s.depthTexture.image.height=s.height,s.depthTexture.needsUpdate=!0),h){if(void 0===l.__webglInit&&(l.__webglInit=!0,s.depthTexture.addEventListener("dispose",S)),void 0===l.__webglTexture){l.__webglTexture=t.createTexture(),i.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),R(t.TEXTURE_CUBE_MAP,s.depthTexture);const e=r.convert(s.depthTexture.format),n=r.convert(s.depthTexture.type);let a;s.depthTexture.format===Ht?a=t.DEPTH_COMPONENT24:s.depthTexture.format===Vt&&(a=t.DEPTH24_STENCIL8);for(let i=0;i<6;i++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,a,s.width,s.height,0,e,n,null)}}else E(s.depthTexture,0);const c=l.__webglTexture,d=z(s),u=h?t.TEXTURE_CUBE_MAP_POSITIVE_X+a:t.TEXTURE_2D,p=s.depthTexture.format===Vt?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(s.depthTexture.format===Ht)G(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,c,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,c,0);else{if(s.depthTexture.format!==Vt)throw new Error("Unknown depthTexture format");G(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,c,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,c,0)}}function F(e){const s=n.get(e),r=!0===e.isWebGLCubeRenderTarget;if(s.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(s.__depthDisposeCallback&&s.__depthDisposeCallback(),t){const e=()=>{delete s.__boundDepthTexture,delete s.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),s.__depthDisposeCallback=e}s.__boundDepthTexture=t}if(e.depthTexture&&!s.__autoAllocateDepthBuffer)if(r)for(let t=0;t<6;t++)U(s.__webglFramebuffer[t],e,t);else{const t=e.texture.mipmaps;t&&t.length>0?U(s.__webglFramebuffer[0],e,0):U(s.__webglFramebuffer,e,0)}else if(r){s.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer[n]),void 0===s.__webglDepthbuffer[n])s.__webglDepthbuffer[n]=t.createRenderbuffer(),N(s.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,r=s.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,r)}}else{const n=e.texture.mipmaps;if(n&&n.length>0?i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer[0]):i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer),void 0===s.__webglDepthbuffer)s.__webglDepthbuffer=t.createRenderbuffer(),N(s.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=s.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}}i.bindFramebuffer(t.FRAMEBUFFER,null)}const B=[],k=[];function z(t){return Math.min(s.maxSamples,t.samples)}function G(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function H(t,e){const i=t.colorSpace,n=t.format,s=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==Ge&&i!==ke&&(Ui.getTransfer(i)===Ve?n===Gt&&s===Et||ui("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):pi("WebGLTextures: Unsupported texture color space:",i)),e}function V(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(l.width=t.naturalWidth||t.width,l.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(l.width=t.displayWidth,l.height=t.displayHeight):(l.width=t.width,l.height=t.height),l}this.allocateTextureUnit=function(){const t=T;return t>=s.maxTextures&&ui("WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+s.maxTextures),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(e,s){const r=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&r.__version!==e.version?D(r,e,s):(e.isExternalTexture&&(r.__webglTexture=e.sourceTexture?e.sourceTexture:null),i.bindTexture(t.TEXTURE_2D_ARRAY,r.__webglTexture,t.TEXTURE0+s))},this.setTexture3D=function(e,s){const r=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&r.__version!==e.version?D(r,e,s):i.bindTexture(t.TEXTURE_3D,r.__webglTexture,t.TEXTURE0+s)},this.setTextureCube=function(e,a){const o=n.get(e);!0!==e.isCubeDepthTexture&&e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const h=I(e,a),l=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(l);if(l.version!==c.__version||!0===h){i.activeTexture(t.TEXTURE0+o);const e=Ui.getPrimaries(Ui.workingColorSpace),n=a.colorSpace===ke?null:Ui.getPrimaries(a.colorSpace),d=a.colorSpace===ke||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?a.image[t].image:a.image[t]:f(a.image[t],!0,s.maxCubemapSize),m[t]=H(a,m[t]);const _=m[0],x=r.convert(a.format,a.colorSpace),S=r.convert(a.type),w=y(a.internalFormat,x,S,a.colorSpace),M=!0!==a.isVideoTexture,T=void 0===c.__version||!0===h,E=l.dataReady;let A,C=b(a,_);if(R(t.TEXTURE_CUBE_MAP,a),u){M&&T&&i.texStorage2D(t.TEXTURE_CUBE_MAP,C,w,_.width,_.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let n=0;n<A.length;n++){const s=A[n];a.format!==Gt?null!==x?M?E&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,x,s.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,w,s.width,s.height,0,s.data):ui("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,x,S,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,w,s.width,s.height,0,x,S,s.data)}}}else{if(A=a.mipmaps,M&&T){A.length>0&&C++;const e=V(m[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,C,w,e.width,e.height)}for(let e=0;e<6;e++)if(p){M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,x,S,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,w,m[e].width,m[e].height,0,x,S,m[e].data);for(let n=0;n<A.length;n++){const s=A[n].image[e].image;M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,s.width,s.height,x,S,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,w,s.width,s.height,0,x,S,s.data)}}else{M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,S,m[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,w,x,S,m[e]);for(let n=0;n<A.length;n++){const s=A[n];M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,x,S,s.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,w,x,S,s.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),c.__version=l.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,s){const r=n.get(e);void 0!==i&&O(r.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==s&&F(e)},this.setupRenderTarget=function(e){const s=e.texture,o=n.get(e),h=n.get(s);e.addEventListener("dispose",w);const l=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=l.length>1;if(d||(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=s.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(s.mipmaps&&s.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i<s.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(s.mipmaps&&s.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<s.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,i=l.length;e<i;e++){const i=n.get(l[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===G(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<l.length;i++){const n=l[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const s=r.convert(n.format,n.colorSpace),a=r.convert(n.type),h=y(n.internalFormat,s,a,n.colorSpace,!0===e.isXRRenderTarget),c=z(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,h,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),N(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),R(t.TEXTURE_CUBE_MAP,s);for(let i=0;i<6;i++)if(s.mipmaps&&s.mipmaps.length>0)for(let n=0;n<s.mipmaps.length;n++)O(o.__webglFramebuffer[i][n],e,s,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else O(o.__webglFramebuffer[i],e,s,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);g(s)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){for(let s=0,r=l.length;s<r;s++){const r=l[s],a=n.get(r);let h=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(h=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(h,a.__webglTexture),R(h,r),O(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0+s,h,0),g(r)&&v(h)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,h.__webglTexture),R(n,s),s.mipmaps&&s.mipmaps.length>0)for(let i=0;i<s.mipmaps.length;i++)O(o.__webglFramebuffer[i],e,s,t.COLOR_ATTACHMENT0,n,i);else O(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0,n,0);g(s)&&v(n),i.unbindTexture()}e.depthBuffer&&F(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let s=0,r=e.length;s<r;s++){const r=e[s];if(g(r)){const e=_(t),s=n.get(r).__webglTexture;i.bindTexture(e,s),v(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===G(e)){const s=e.textures,r=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),d=s.length>1;if(d)for(let e=0;e<s.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);const u=e.texture.mipmaps;u&&u.length>0?i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<s.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(s[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,r,a,0,0,r,a,o,t.NEAREST),!0===h&&(B.length=0,k.length=0,B.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(B.push(l),k.push(l),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,k)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<s.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const r=n.get(s[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,r,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&h){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=F,this.setupFrameBufferTexture=O,this.useMultisampledRTT=G,this.isReversedDepthBuffer=function(){return i.buffers.depth.getReversed()}}function $p(t,e){return{convert:function(i,n=""){let s;const r=Ui.getTransfer(n);if(i===Et)return t.UNSIGNED_BYTE;if(i===Ot)return t.UNSIGNED_SHORT_4_4_4_4;if(i===Nt)return t.UNSIGNED_SHORT_5_5_5_1;if(i===Ft)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===Bt)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===At)return t.BYTE;if(i===Ct)return t.SHORT;if(i===Lt)return t.UNSIGNED_SHORT;if(i===Rt)return t.INT;if(i===It)return t.UNSIGNED_INT;if(i===Pt)return t.FLOAT;if(i===Dt)return t.HALF_FLOAT;if(i===kt)return t.ALPHA;if(i===zt)return t.RGB;if(i===Gt)return t.RGBA;if(i===Ht)return t.DEPTH_COMPONENT;if(i===Vt)return t.DEPTH_STENCIL;if(i===Wt)return t.RED;if(i===jt)return t.RED_INTEGER;if(i===Xt)return t.RG;if(i===Yt)return t.RG_INTEGER;if(i===qt)return t.RGBA_INTEGER;if(i===Zt||i===Kt||i===Jt||i===Qt)if(r===Ve){if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===s)return null;if(i===Zt)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Kt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Jt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Qt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(s=e.get("WEBGL_compressed_texture_s3tc"),null===s)return null;if(i===Zt)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Kt)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Jt)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Qt)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===$t||i===te||i===ee||i===ie){if(s=e.get("WEBGL_compressed_texture_pvrtc"),null===s)return null;if(i===$t)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===te)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ee)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ie)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===ne||i===se||i===re||i===ae||i===oe||i===he||i===le){if(s=e.get("WEBGL_compressed_texture_etc"),null===s)return null;if(i===ne||i===se)return r===Ve?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===re)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===ae)return s.COMPRESSED_R11_EAC;if(i===oe)return s.COMPRESSED_SIGNED_R11_EAC;if(i===he)return s.COMPRESSED_RG11_EAC;if(i===le)return s.COMPRESSED_SIGNED_RG11_EAC}if(i===ce||i===de||i===ue||i===pe||i===me||i===fe||i===ge||i===ve||i===_e||i===ye||i===xe||i===be||i===Se||i===we){if(s=e.get("WEBGL_compressed_texture_astc"),null===s)return null;if(i===ce)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===de)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ue)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===pe)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===me)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===fe)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===ge)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ve)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===_e)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ye)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===xe)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===be)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Se)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===we)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===Me||i===Te||i===Ee){if(s=e.get("EXT_texture_compression_bptc"),null===s)return null;if(i===Me)return r===Ve?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Te)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ee)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===Ae||i===Ce||i===Le||i===Re){if(s=e.get("EXT_texture_compression_rgtc"),null===s)return null;if(i===Ae)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Ce)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Le)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Re)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Ut?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class tm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const i=new fo(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new rr({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Qs(new Ih(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class em extends fi{constructor(t,e){super();const i=this;let n=null,s=1,r=null,a="local-floor",o=1,h=null,l=null,c=null,d=null,u=null,p=null;const m="undefined"!=typeof XRWebGLBinding,f=new tm,g={},v=e.getContextAttributes();let _=null,y=null;const x=[],b=[],S=new Ai;let w=null;const M=new cr;M.viewport=new Yi;const T=new cr;T.viewport=new Yi;const E=[M,T],A=new sc;let C=null,L=null;function R(t){const e=b.indexOf(t.inputSource);if(-1===e)return;const i=x[e];void 0!==i&&(i.update(t.inputSource,t.frame,h||r),i.dispatchEvent({type:t.type,data:t.inputSource}))}function I(){n.removeEventListener("select",R),n.removeEventListener("selectstart",R),n.removeEventListener("selectend",R),n.removeEventListener("squeeze",R),n.removeEventListener("squeezestart",R),n.removeEventListener("squeezeend",R),n.removeEventListener("end",I),n.removeEventListener("inputsourceschange",P);for(let t=0;t<x.length;t++){const e=b[t];null!==e&&(b[t]=null,x[t].disconnect(e))}C=null,L=null,f.reset();for(const t in g)delete g[t];t.setRenderTarget(_),u=null,d=null,c=null,n=null,y=null,F.stop(),i.isPresenting=!1,t.setPixelRatio(w),t.setSize(S.width,S.height,!1),i.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=b.indexOf(i);n>=0&&(b[n]=null,x[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=b.indexOf(i);if(-1===n){for(let t=0;t<x.length;t++){if(t>=b.length){b.push(i),n=t;break}if(null===b[t]){b[t]=i,n=t;break}}if(-1===n)break}const s=x[n];s&&s.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new vr,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new vr,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new vr,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){s=t,!0===i.isPresenting&&ui("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&ui("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||r},this.setReferenceSpace=function(t){h=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return null===c&&m&&(c=new XRWebGLBinding(n,e)),c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){_=t.getRenderTarget(),n.addEventListener("select",R),n.addEventListener("selectstart",R),n.addEventListener("selectend",R),n.addEventListener("squeeze",R),n.addEventListener("squeezestart",R),n.addEventListener("squeezeend",R),n.addEventListener("end",I),n.addEventListener("inputsourceschange",P),!0!==v.xrCompatible&&await e.makeXRCompatible(),w=t.getPixelRatio(),t.getSize(S);if(m&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,r=null,a=null;v.depth&&(a=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=v.stencil?Vt:Ht,r=v.stencil?Ut:It);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:s};c=this.getBinding(),d=c.createProjectionLayer(o),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Zi(d.textureWidth,d.textureHeight,{format:Gt,type:Et,depthTexture:new po(d.textureWidth,d.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{const i={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new Zi(u.framebufferWidth,u.framebufferHeight,{format:Gt,type:Et,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(o),h=null,r=await n.requestReferenceSpace(a),F.setContext(n),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new Li,O=new Li;function N(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(i=f.depthFar)),A.near=T.near=M.near=e,A.far=T.far=M.far=i,C===A.near&&L===A.far||(n.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,L=A.far),A.layers.mask=6|t.layers.mask,M.layers.mask=3&A.layers.mask,T.layers.mask=5&A.layers.mask;const s=t.parent,r=A.cameras;N(A,s);for(let t=0;t<r.length;t++)N(r[t],s);2===r.length?function(t,e,i){D.setFromMatrixPosition(e.matrixWorld),O.setFromMatrixPosition(i.matrixWorld);const n=D.distanceTo(O),s=e.projectionMatrix.elements,r=i.projectionMatrix.elements,a=s[14]/(s[10]-1),o=s[14]/(s[10]+1),h=(s[9]+1)/s[5],l=(s[9]-1)/s[5],c=(s[8]-1)/s[0],d=(r[8]+1)/r[0],u=a*c,p=a*d,m=n/(-c+d),f=m*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===s[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,i=o+m,s=u-f,r=p+(n-f),c=h*o/i*e,d=l*o/i*e;t.projectionMatrix.makePerspective(s,r,c,d,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,M,T):A.projectionMatrix.copy(M.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*yi*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,s)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let U=null;const F=new fd;F.setAnimationLoop(function(e,s){if(l=s.getViewerPose(h||r),p=s,null!==l){const e=l.views;null!==u&&(t.setRenderTargetFramebuffer(y,u.framebuffer),t.setRenderTarget(y));let s=!1;e.length!==A.cameras.length&&(A.cameras.length=0,s=!0);for(let i=0;i<e.length;i++){const n=e[i];let r=null;if(null!==u)r=u.getViewport(n);else{const e=c.getViewSubImage(d,n);r=e.viewport,0===i&&(t.setRenderTargetTextures(y,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(y))}let a=E[i];void 0===a&&(a=new cr,a.layers.enable(i),a.viewport=new Yi,E[i]=a),a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(n.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(r.x,r.y,r.width,r.height),0===i&&(A.matrix.copy(a.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===s&&A.cameras.push(a)}const r=n.enabledFeatures;if(r&&r.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&m){c=i.getBinding();const t=c.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&f.init(t,n.renderState)}if(r&&r.includes("camera-access")&&m){t.state.unbindTexture(),c=i.getBinding();for(let t=0;t<e.length;t++){const i=e[t].camera;if(i){let t=g[i];t||(t=new fo,g[i]=t);const e=c.getCameraImage(i);t.sourceTexture=e}}}}for(let t=0;t<x.length;t++){const e=b[t],i=x[t];null!==e&&void 0!==i&&i.update(e,s,h||r)}U&&U(e,s),s.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:s}),p=null}),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const im=new Un,nm=new En;function sm(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const s=e.get(n),r=s.envMap,a=s.envMapRotation;r&&(t.envMap.value=r,im.copy(a),im.x*=-1,im.y*=-1,im.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(im.y*=-1,im.z*=-1),t.envMapRotation.value.setFromMatrix4(nm.makeRotationFromEuler(im)),t.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,nr(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,s,r,a,o){s.isMeshBasicMaterial||s.isMeshLambertMaterial?n(t,s):s.isMeshToonMaterial?(n(t,s),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,s)):s.isMeshPhongMaterial?(n(t,s),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,s)):s.isMeshStandardMaterial?(n(t,s),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,s),s.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,s,o)):s.isMeshMatcapMaterial?(n(t,s),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,s)):s.isMeshDepthMaterial?n(t,s):s.isMeshDistanceMaterial?(n(t,s),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,s)):s.isMeshNormalMaterial?n(t,s):s.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,s),s.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,s)):s.isPointsMaterial?function(t,e,n,s){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*s,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s,r,a):s.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s):s.isShadowMaterial?(t.color.value.copy(s.color),t.opacity.value=s.opacity):s.isShaderMaterial&&(s.uniformsNeedUpdate=!1)}}}function rm(t,e,i,n){let s={},r={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function h(t,e,i,n){const s=t.value,r=e+"_"+i;if(void 0===n[r])return n[r]="number"==typeof s||"boolean"==typeof s?s:s.clone(),!0;{const t=n[r];if("number"==typeof s||"boolean"==typeof s){if(t!==s)return n[r]=s,!0}else if(!1===t.equals(s))return t.copy(s),!0}return!1}function l(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?ui("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ui("WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(s[i.id]),delete s[i.id],delete r[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,d){let u=s[i.id];void 0===u&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,s=e.length;t<s;t++){const s=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=s.length;t<e;t++){const e=s[t],r=Array.isArray(e.value)?e.value:[e.value];for(let t=0,s=r.length;t<s;t++){const s=l(r[t]),a=i%n,o=a%s.boundary,h=a+o;i+=o,0!==h&&n-h<s.storage&&(i+=n-h),e.__data=new Float32Array(s.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=s.storage}}}const s=i%n;s>0&&(i+=n-s);t.__size=i,t.__cache={}}(i),u=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return pi("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),s=e.__size,r=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,s,r),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),s[i.id]=u,i.addEventListener("dispose",c));const p=d.program;n.updateUBOMapping(i,p);const m=e.render.frame;r[i.id]!==m&&(!function(e){const i=s[e.id],n=e.uniforms,r=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=Array.isArray(n[e])?n[e]:[n[e]];for(let n=0,s=i.length;n<s;n++){const s=i[n];if(!0===h(s,e,n,r)){const e=s.__offset,i=Array.isArray(s.value)?s.value:[s.value];let n=0;for(let r=0;r<i.length;r++){const a=i[r],o=l(a);"number"==typeof a||"boolean"==typeof a?(s.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+n,s.__data)):a.isMatrix3?(s.__data[0]=a.elements[0],s.__data[1]=a.elements[1],s.__data[2]=a.elements[2],s.__data[3]=0,s.__data[4]=a.elements[3],s.__data[5]=a.elements[4],s.__data[6]=a.elements[5],s.__data[7]=0,s.__data[8]=a.elements[6],s.__data[9]=a.elements[7],s.__data[10]=a.elements[8],s.__data[11]=0):(a.toArray(s.__data,n),n+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,s.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),r[i.id]=m)},dispose:function(){for(const e in s)t.deleteBuffer(s[e]);a=[],s={},r={}}}}const am=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let om=null;class hm{constructor(t={}){const{canvas:e=hi(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:h=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:c=!1,reversedDepthBuffer:d=!1,outputBufferType:u=Et}=t;let p;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const m=u,f=new Set([qt,Yt,jt]),g=new Set([Et,It,Lt,Ut,Ot,Nt]),v=new Uint32Array(4),_=new Int32Array(4);let x=null,b=null;const S=[],w=[];let M=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let E=!1;this._outputColorSpace=ze;let A=0,C=0,L=null,R=-1,I=null;const P=new Yi,D=new Yi;let O=null;const N=new _s(0);let U=0,F=e.width,B=e.height,k=1,z=null,G=null;const H=new Yi(0,0,F,B),V=new Yi(0,0,F,B);let W=!1;const j=new xa;let X=!1,Y=!1;const q=new En,Z=new Li,K=new Yi,J={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Q=!1;function $(){return null===L?k:1}let tt,et,it,nt,st,rt,at,ot,ht,lt,ct,dt,ut,pt,mt,ft,gt,vt,yt,xt,bt,St,Mt,At,Ct=i;function Rt(t,i){return e.getContext(t,i)}try{const t={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${y}`),e.addEventListener("webglcontextlost",Bt,!1),e.addEventListener("webglcontextrestored",kt,!1),e.addEventListener("webglcontextcreationerror",zt,!1),null===Ct){const e="webgl2";if(Ct=Rt(e,t),null===Ct)throw Rt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw pi("WebGLRenderer: "+t.message),t}function Pt(){tt=new jd(Ct),tt.init(),St=new $p(Ct,tt),et=new Ed(Ct,tt,t,St),it=new Jp(Ct,tt),et.reversedDepthBuffer&&d&&it.buffers.depth.setReversed(!0),nt=new qd(Ct),st=new Dp,rt=new Qp(Ct,tt,it,st,et,St,nt),at=new Cd(T),ot=new Wd(T),ht=new gd(Ct),Mt=new Md(Ct,ht),lt=new Xd(Ct,ht,nt,Mt),ct=new Kd(Ct,lt,ht,nt),yt=new Zd(Ct,et,rt),ft=new Ad(st),dt=new Pp(T,at,ot,tt,et,Mt,ft),ut=new sm(T,st),pt=new Fp,mt=new Vp(tt),vt=new wd(T,at,ot,it,ct,p,o),gt=new Zp(T,ct,et),At=new rm(Ct,nt,et,it),xt=new Td(Ct,tt,nt),bt=new Yd(Ct,tt,nt),nt.programs=dt.programs,T.capabilities=et,T.extensions=tt,T.properties=st,T.renderLists=pt,T.shadowMap=gt,T.state=it,T.info=nt}Pt(),m!==Et&&(M=new Qd(m,e.width,e.height,n,s));const Ft=new em(T,Ct);function Bt(t){t.preventDefault(),di("WebGLRenderer: Context Lost."),E=!0}function kt(){di("WebGLRenderer: Context Restored."),E=!1;const t=nt.autoReset,e=gt.enabled,i=gt.autoUpdate,n=gt.needsUpdate,s=gt.type;Pt(),nt.autoReset=t,gt.enabled=e,gt.autoUpdate=i,gt.needsUpdate=n,gt.type=s}function zt(t){pi("WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Gt(t){const e=t.target;e.removeEventListener("dispose",Gt),function(t){(function(t){const e=st.get(t).programs;void 0!==e&&(e.forEach(function(t){dt.releaseProgram(t)}),t.isShaderMaterial&&dt.releaseShaderCache(t))})(t),st.remove(t)}(e)}function Ht(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,ie(t,e,i),t.side=0,t.needsUpdate=!0,ie(t,e,i),t.side=2):ie(t,e,i)}this.xr=Ft,this.getContext=function(){return Ct},this.getContextAttributes=function(){return Ct.getContextAttributes()},this.forceContextLoss=function(){const t=tt.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=tt.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(t){void 0!==t&&(k=t,this.setSize(F,B,!1))},this.getSize=function(t){return t.set(F,B)},this.setSize=function(t,i,n=!0){Ft.isPresenting?ui("WebGLRenderer: Can't change size while VR device is presenting."):(F=t,B=i,e.width=Math.floor(t*k),e.height=Math.floor(i*k),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),null!==M&&M.setSize(e.width,e.height),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(F*k,B*k).floor()},this.setDrawingBufferSize=function(t,i,n){F=t,B=i,k=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.setEffects=function(t){if(m!==Et){if(t)for(let e=0;e<t.length;e++)if(!0===t[e].isOutputPass){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}M.setEffects(t||[])}else console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(t){return t.copy(P)},this.getViewport=function(t){return t.copy(H)},this.setViewport=function(t,e,i,n){t.isVector4?H.set(t.x,t.y,t.z,t.w):H.set(t,e,i,n),it.viewport(P.copy(H).multiplyScalar(k).round())},this.getScissor=function(t){return t.copy(V)},this.setScissor=function(t,e,i,n){t.isVector4?V.set(t.x,t.y,t.z,t.w):V.set(t,e,i,n),it.scissor(D.copy(V).multiplyScalar(k).round())},this.getScissorTest=function(){return W},this.setScissorTest=function(t){it.setScissorTest(W=t)},this.setOpaqueSort=function(t){z=t},this.setTransparentSort=function(t){G=t},this.getClearColor=function(t){return t.copy(vt.getClearColor())},this.setClearColor=function(){vt.setClearColor(...arguments)},this.getClearAlpha=function(){return vt.getClearAlpha()},this.setClearAlpha=function(){vt.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==L){const e=L.texture.format;t=f.has(e)}if(t){const t=L.texture.type,e=g.has(t),i=vt.getClearColor(),n=vt.getClearAlpha(),s=i.r,r=i.g,a=i.b;e?(v[0]=s,v[1]=r,v[2]=a,v[3]=n,Ct.clearBufferuiv(Ct.COLOR,0,v)):(_[0]=s,_[1]=r,_[2]=a,_[3]=n,Ct.clearBufferiv(Ct.COLOR,0,_))}else n|=Ct.COLOR_BUFFER_BIT}e&&(n|=Ct.DEPTH_BUFFER_BIT),i&&(n|=Ct.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Ct.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Bt,!1),e.removeEventListener("webglcontextrestored",kt,!1),e.removeEventListener("webglcontextcreationerror",zt,!1),vt.dispose(),pt.dispose(),mt.dispose(),st.dispose(),at.dispose(),ot.dispose(),ct.dispose(),Mt.dispose(),At.dispose(),dt.dispose(),Ft.dispose(),Ft.removeEventListener("sessionstart",Wt),Ft.removeEventListener("sessionend",Zt),Kt.stop()},this.renderBufferDirect=function(t,e,i,n,s,r){null===e&&(e=J);const a=s.isMesh&&s.matrixWorld.determinant()<0,o=function(t,e,i,n,s){!0!==e.isScene&&(e=J);rt.resetTextureUnits();const r=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===L?T.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Ge,h=(n.isMeshStandardMaterial?ot:at).get(n.envMap||a),l=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(m=T.toneMapping));const f=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,g=void 0!==f?f.length:0,v=st.get(n),_=b.state.lights;if(!0===X&&(!0===Y||t!==I)){const e=t===I&&n.id===R;ft.setState(n,t,e)}let y=!1;n.version===v.__version?v.needsLights&&v.lightsStateVersion!==_.state.version||v.outputColorSpace!==o||s.isBatchedMesh&&!1===v.batching?y=!0:s.isBatchedMesh||!0!==v.batching?s.isBatchedMesh&&!0===v.batchingColor&&null===s.colorTexture||s.isBatchedMesh&&!1===v.batchingColor&&null!==s.colorTexture||s.isInstancedMesh&&!1===v.instancing?y=!0:s.isInstancedMesh||!0!==v.instancing?s.isSkinnedMesh&&!1===v.skinning?y=!0:s.isSkinnedMesh||!0!==v.skinning?s.isInstancedMesh&&!0===v.instancingColor&&null===s.instanceColor||s.isInstancedMesh&&!1===v.instancingColor&&null!==s.instanceColor||s.isInstancedMesh&&!0===v.instancingMorph&&null===s.morphTexture||s.isInstancedMesh&&!1===v.instancingMorph&&null!==s.morphTexture||v.envMap!==h||!0===n.fog&&v.fog!==r?y=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===ft.numPlanes&&v.numIntersection===ft.numIntersection?(v.vertexAlphas!==l||v.vertexTangents!==c||v.morphTargets!==d||v.morphNormals!==u||v.morphColors!==p||v.toneMapping!==m||v.morphTargetsCount!==g)&&(y=!0):y=!0:y=!0:y=!0:y=!0:(y=!0,v.__version=n.version);let x=v.currentProgram;!0===y&&(x=ie(n,e,s));let S=!1,w=!1,M=!1;const E=x.getUniforms(),A=v.uniforms;it.useProgram(x.program)&&(S=!0,w=!0,M=!0);n.id!==R&&(R=n.id,w=!0);if(S||I!==t){it.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),E.setValue(Ct,"projectionMatrix",t.projectionMatrix),E.setValue(Ct,"viewMatrix",t.matrixWorldInverse);const e=E.map.cameraPosition;void 0!==e&&e.setValue(Ct,Z.setFromMatrixPosition(t.matrixWorld)),et.logarithmicDepthBuffer&&E.setValue(Ct,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&E.setValue(Ct,"isOrthographic",!0===t.isOrthographicCamera),I!==t&&(I=t,w=!0,M=!0)}v.needsLights&&(_.state.directionalShadowMap.length>0&&E.setValue(Ct,"directionalShadowMap",_.state.directionalShadowMap,rt),_.state.spotShadowMap.length>0&&E.setValue(Ct,"spotShadowMap",_.state.spotShadowMap,rt),_.state.pointShadowMap.length>0&&E.setValue(Ct,"pointShadowMap",_.state.pointShadowMap,rt));if(s.isSkinnedMesh){E.setOptional(Ct,s,"bindMatrix"),E.setOptional(Ct,s,"bindMatrixInverse");const t=s.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),E.setValue(Ct,"boneTexture",t.boneTexture,rt))}s.isBatchedMesh&&(E.setOptional(Ct,s,"batchingTexture"),E.setValue(Ct,"batchingTexture",s._matricesTexture,rt),E.setOptional(Ct,s,"batchingIdTexture"),E.setValue(Ct,"batchingIdTexture",s._indirectTexture,rt),E.setOptional(Ct,s,"batchingColorTexture"),null!==s._colorsTexture&&E.setValue(Ct,"batchingColorTexture",s._colorsTexture,rt));const C=i.morphAttributes;void 0===C.position&&void 0===C.normal&&void 0===C.color||yt.update(s,i,x);(w||v.receiveShadow!==s.receiveShadow)&&(v.receiveShadow=s.receiveShadow,E.setValue(Ct,"receiveShadow",s.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(A.envMap.value=h,A.flipEnvMap.value=h.isCubeTexture&&!1===h.isRenderTargetTexture?-1:1);n.isMeshStandardMaterial&&null===n.envMap&&null!==e.environment&&(A.envMapIntensity.value=e.environmentIntensity);void 0!==A.dfgLUT&&(A.dfgLUT.value=(null===om&&(om=new ta(am,16,16,Xt,Dt),om.name="DFG_LUT",om.minFilter=wt,om.magFilter=wt,om.wrapS=_t,om.wrapT=_t,om.generateMipmaps=!1,om.needsUpdate=!0),om));w&&(E.setValue(Ct,"toneMappingExposure",T.toneMappingExposure),v.needsLights&&(D=M,(P=A).ambientLightColor.needsUpdate=D,P.lightProbe.needsUpdate=D,P.directionalLights.needsUpdate=D,P.directionalLightShadows.needsUpdate=D,P.pointLights.needsUpdate=D,P.pointLightShadows.needsUpdate=D,P.spotLights.needsUpdate=D,P.spotLightShadows.needsUpdate=D,P.rectAreaLights.needsUpdate=D,P.hemisphereLights.needsUpdate=D),r&&!0===n.fog&&ut.refreshFogUniforms(A,r),ut.refreshMaterialUniforms(A,n,k,B,b.state.transmissionRenderTarget[t.id]),np.upload(Ct,ne(v),A,rt));var P,D;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(np.upload(Ct,ne(v),A,rt),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&E.setValue(Ct,"center",s.center);if(E.setValue(Ct,"modelViewMatrix",s.modelViewMatrix),E.setValue(Ct,"normalMatrix",s.normalMatrix),E.setValue(Ct,"modelMatrix",s.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++){const i=t[e];At.update(i,x),At.bind(i,x)}}return x}(t,e,i,n,s);it.setMaterial(n,a);let h=i.index,l=1;if(!0===n.wireframe){if(h=lt.getWireframeAttribute(i),void 0===h)return;l=2}const c=i.drawRange,d=i.attributes.position;let u=c.start*l,p=(c.start+c.count)*l;null!==r&&(u=Math.max(u,r.start*l),p=Math.min(p,(r.start+r.count)*l)),null!==h?(u=Math.max(u,0),p=Math.min(p,h.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Mt.setup(s,n,o,i,h);let g=xt;if(null!==h&&(f=ht.get(h),g=bt,g.setIndex(f)),s.isMesh)!0===n.wireframe?(it.setLineWidth(n.wireframeLinewidth*$()),g.setMode(Ct.LINES)):g.setMode(Ct.TRIANGLES);else if(s.isLine){let t=n.linewidth;void 0===t&&(t=1),it.setLineWidth(t*$()),s.isLineSegments?g.setMode(Ct.LINES):s.isLineLoop?g.setMode(Ct.LINE_LOOP):g.setMode(Ct.LINE_STRIP)}else s.isPoints?g.setMode(Ct.POINTS):s.isSprite&&g.setMode(Ct.TRIANGLES);if(s.isBatchedMesh)if(null!==s._multiDrawInstances)mi("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),g.renderMultiDrawInstances(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount,s._multiDrawInstances);else if(tt.get("WEBGL_multi_draw"))g.renderMultiDraw(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount);else{const t=s._multiDrawStarts,e=s._multiDrawCounts,i=s._multiDrawCount,r=h?ht.get(h).bytesPerElement:1,a=st.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(Ct,"_gl_DrawID",n),g.render(t[n]/r,e[n])}else if(s.isInstancedMesh)g.renderInstances(u,m,s.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);g.renderInstances(u,m,e)}else g.render(u,m)},this.compile=function(t,e,i=null){null===i&&(i=t),b=mt.get(i),b.init(e),w.push(b),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))}),b.setupLights();const n=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let s=0;s<e.length;s++){const r=e[s];Ht(r,i,t),n.add(r)}else Ht(e,i,t),n.add(e)}),b=w.pop(),n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(e=>{function i(){n.forEach(function(t){st.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==tt.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let Vt=null;function Wt(){Kt.stop()}function Zt(){Kt.start()}const Kt=new fd;function Jt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)b.pushLight(t),t.castShadow&&b.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||j.intersectsSprite(t)){n&&K.setFromMatrixPosition(t.matrixWorld).applyMatrix4(q);const e=ct.update(t),s=t.material;s.visible&&x.push(t,e,s,i,K.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||j.intersectsObject(t))){const e=ct.update(t),s=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),K.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),K.copy(e.boundingSphere.center)),K.applyMatrix4(t.matrixWorld).applyMatrix4(q)),Array.isArray(s)){const n=e.groups;for(let r=0,a=n.length;r<a;r++){const a=n[r],o=s[a.materialIndex];o&&o.visible&&x.push(t,e,o,i,K.z,a)}}else s.visible&&x.push(t,e,s,i,K.z,null)}const s=t.children;for(let t=0,r=s.length;t<r;t++)Jt(s[t],e,i,n)}function Qt(t,e,i,n){const{opaque:s,transmissive:r,transparent:a}=t;b.setupLightsView(i),!0===X&&ft.setGlobalState(T.clippingPlanes,i),n&&it.viewport(P.copy(n)),s.length>0&&te(s,e,i),r.length>0&&te(r,e,i),a.length>0&&te(a,e,i),it.buffers.depth.setTest(!0),it.buffers.depth.setMask(!0),it.buffers.color.setMask(!0),it.setPolygonOffset(!1)}function $t(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;if(void 0===b.state.transmissionRenderTarget[n.id]){const t=tt.has("EXT_color_buffer_half_float")||tt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[n.id]=new Zi(1,1,{generateMipmaps:!0,type:t?Dt:Et,minFilter:Tt,samples:et.samples,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ui.workingColorSpace})}const r=b.state.transmissionRenderTarget[n.id],a=n.viewport||P;r.setSize(a.z*T.transmissionResolutionScale,a.w*T.transmissionResolutionScale);const o=T.getRenderTarget(),h=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(r),T.getClearColor(N),U=T.getClearAlpha(),U<1&&T.setClearColor(16777215,.5),T.clear(),Q&&vt.render(i);const c=T.toneMapping;T.toneMapping=0;const d=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),b.setupLightsView(n),!0===X&&ft.setGlobalState(T.clippingPlanes,n),te(t,i,n),rt.updateMultisampleRenderTarget(r),rt.updateRenderTargetMipmap(r),!1===tt.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let s=0,r=e.length;s<r;s++){const r=e[s],{object:a,geometry:o,material:h,group:l}=r;if(2===h.side&&a.layers.test(n.layers)){const e=h.side;h.side=1,h.needsUpdate=!0,ee(a,i,n,o,h,l),h.side=e,h.needsUpdate=!0,t=!0}}!0===t&&(rt.updateMultisampleRenderTarget(r),rt.updateRenderTargetMipmap(r))}T.setRenderTarget(o,h,l),T.setClearColor(N,U),void 0!==d&&(n.viewport=d),T.toneMapping=c}function te(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let s=0,r=t.length;s<r;s++){const r=t[s],{object:a,geometry:o,group:h}=r;let l=r.material;!0===l.allowOverride&&null!==n&&(l=n),a.layers.test(i.layers)&&ee(a,e,i,o,l,h)}}function ee(t,e,i,n,s,r){t.onBeforeRender(T,e,i,n,s,r),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),s.onBeforeRender(T,e,i,n,t,r),!0===s.transparent&&2===s.side&&!1===s.forceSinglePass?(s.side=1,s.needsUpdate=!0,T.renderBufferDirect(i,e,n,s,t,r),s.side=0,s.needsUpdate=!0,T.renderBufferDirect(i,e,n,s,t,r),s.side=2):T.renderBufferDirect(i,e,n,s,t,r),t.onAfterRender(T,e,i,n,s,r)}function ie(t,e,i){!0!==e.isScene&&(e=J);const n=st.get(t),s=b.state.lights,r=b.state.shadowsArray,a=s.state.version,o=dt.getParameters(t,s.state,r,e,i),h=dt.getProgramCacheKey(o);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?ot:at).get(t.envMap||n.environment),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===l&&(t.addEventListener("dispose",Gt),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return se(t,o),c}else o.uniforms=dt.getUniforms(t),t.onBeforeCompile(o,T),c=dt.acquireProgram(o,h),l.set(h,c),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=ft.uniform),se(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(d.ambientLightColor.value=s.state.ambient,d.lightProbe.value=s.state.probe,d.directionalLights.value=s.state.directional,d.directionalLightShadows.value=s.state.directionalShadow,d.spotLights.value=s.state.spot,d.spotLightShadows.value=s.state.spotShadow,d.rectAreaLights.value=s.state.rectArea,d.ltc_1.value=s.state.rectAreaLTC1,d.ltc_2.value=s.state.rectAreaLTC2,d.pointLights.value=s.state.point,d.pointLightShadows.value=s.state.pointShadow,d.hemisphereLights.value=s.state.hemi,d.directionalShadowMap.value=s.state.directionalShadowMap,d.directionalShadowMatrix.value=s.state.directionalShadowMatrix,d.spotShadowMap.value=s.state.spotShadowMap,d.spotLightMatrix.value=s.state.spotLightMatrix,d.spotLightMap.value=s.state.spotLightMap,d.pointShadowMap.value=s.state.pointShadowMap,d.pointShadowMatrix.value=s.state.pointShadowMatrix),n.currentProgram=c,n.uniformsList=null,c}function ne(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=np.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function se(t,e){const i=st.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Kt.setAnimationLoop(function(t){Vt&&Vt(t)}),"undefined"!=typeof self&&Kt.setContext(self),this.setAnimationLoop=function(t){Vt=t,Ft.setAnimationLoop(t),null===t?Kt.stop():Kt.start()},Ft.addEventListener("sessionstart",Wt),Ft.addEventListener("sessionend",Zt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void pi("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===E)return;const i=!0===Ft.enabled&&!0===Ft.isPresenting,n=null!==M&&(null===L||i)&&M.begin(T,L);if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0!==Ft.enabled||!0!==Ft.isPresenting||null!==M&&!1!==M.isCompositing()||(!0===Ft.cameraAutoUpdate&&Ft.updateCamera(e),e=Ft.getCamera()),!0===t.isScene&&t.onBeforeRender(T,t,e,L),b=mt.get(t,w.length),b.init(e),w.push(b),q.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),j.setFromProjectionMatrix(q,ei,e.reversedDepth),Y=this.localClippingEnabled,X=ft.init(this.clippingPlanes,Y),x=pt.get(t,S.length),x.init(),S.push(x),!0===Ft.enabled&&!0===Ft.isPresenting){const t=T.xr.getDepthSensingMesh();null!==t&&Jt(t,e,-1/0,T.sortObjects)}Jt(t,e,0,T.sortObjects),x.finish(),!0===T.sortObjects&&x.sort(z,G),Q=!1===Ft.enabled||!1===Ft.isPresenting||!1===Ft.hasDepthSensing(),Q&&vt.addToRenderList(x,t),this.info.render.frame++,!0===X&&ft.beginShadows();const s=b.state.shadowsArray;gt.render(s,t,e),!0===X&&ft.endShadows(),!0===this.info.autoReset&&this.info.reset();if(!1===(n&&M.hasRenderPass())){const i=x.opaque,n=x.transmissive;if(b.setupLights(),e.isArrayCamera){const s=e.cameras;if(n.length>0)for(let e=0,r=s.length;e<r;e++){$t(i,n,t,s[e])}Q&&vt.render(t);for(let e=0,i=s.length;e<i;e++){const i=s[e];Qt(x,t,i,i.viewport)}}else n.length>0&&$t(i,n,t,e),Q&&vt.render(t),Qt(x,t,e)}null!==L&&0===C&&(rt.updateMultisampleRenderTarget(L),rt.updateRenderTargetMipmap(L)),n&&M.end(T),!0===t.isScene&&t.onAfterRender(T,t,e),Mt.resetDefaultState(),R=-1,I=null,w.pop(),w.length>0?(b=w[w.length-1],!0===X&&ft.setGlobalState(T.clippingPlanes,b.state.camera)):b=null,S.pop(),x=S.length>0?S[S.length-1]:null},this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return L},this.setRenderTargetTextures=function(t,e,i){const n=st.get(t);n.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===n.__autoAllocateDepthBuffer&&(n.__useRenderToTexture=!1),st.get(t.texture).__webglTexture=e,st.get(t.depthTexture).__webglTexture=n.__autoAllocateDepthBuffer?void 0:i,n.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const i=st.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e};const re=Ct.createFramebuffer();this.setRenderTarget=function(t,e=0,i=0){L=t,A=e,C=i;let n=null,s=!1,r=!1;if(t){const a=st.get(t);if(void 0!==a.__useDefaultFramebuffer)return it.bindFramebuffer(Ct.FRAMEBUFFER,a.__webglFramebuffer),P.copy(t.viewport),D.copy(t.scissor),O=t.scissorTest,it.viewport(P),it.scissor(D),it.setScissorTest(O),void(R=-1);if(void 0===a.__webglFramebuffer)rt.setupRenderTarget(t);else if(a.__hasExternalTextures)rt.rebindTextures(t,st.get(t.texture).__webglTexture,st.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(a.__boundDepthTexture!==e){if(null!==e&&st.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");rt.setupDepthRenderbuffer(t)}}const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(r=!0);const h=st.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=Array.isArray(h[e])?h[e][i]:h[e],s=!0):n=t.samples>0&&!1===rt.useMultisampledRTT(t)?st.get(t).__webglMultisampledFramebuffer:Array.isArray(h)?h[i]:h,P.copy(t.viewport),D.copy(t.scissor),O=t.scissorTest}else P.copy(H).multiplyScalar(k).floor(),D.copy(V).multiplyScalar(k).floor(),O=W;0!==i&&(n=re);if(it.bindFramebuffer(Ct.FRAMEBUFFER,n)&&it.drawBuffers(t,n),it.viewport(P),it.scissor(D),it.setScissorTest(O),s){const n=st.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(r){const n=e;for(let e=0;e<t.textures.length;e++){const s=st.get(t.textures[e]);Ct.framebufferTextureLayer(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0+e,s.__webglTexture,i,n)}}else if(null!==t&&0!==i){const e=st.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,e.__webglTexture,i)}R=-1},this.readRenderTargetPixels=function(t,e,i,n,s,r,a,o=0){if(!t||!t.isWebGLRenderTarget)return void pi("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=st.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){it.bindFramebuffer(Ct.FRAMEBUFFER,h);try{const a=t.textures[o],h=a.format,l=a.type;if(!et.textureFormatReadable(h))return void pi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(l))return void pi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-s&&(t.textures.length>1&&Ct.readBuffer(Ct.COLOR_ATTACHMENT0+o),Ct.readPixels(e,i,n,s,St.convert(h),St.convert(l),r))}finally{const t=null!==L?st.get(L).__webglFramebuffer:null;it.bindFramebuffer(Ct.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,s,r,a,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=st.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-s){it.bindFramebuffer(Ct.FRAMEBUFFER,h);const a=t.textures[o],l=a.format,c=a.type;if(!et.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=Ct.createBuffer();Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,d),Ct.bufferData(Ct.PIXEL_PACK_BUFFER,r.byteLength,Ct.STREAM_READ),t.textures.length>1&&Ct.readBuffer(Ct.COLOR_ATTACHMENT0+o),Ct.readPixels(e,i,n,s,St.convert(l),St.convert(c),0);const u=null!==L?st.get(L).__webglFramebuffer:null;it.bindFramebuffer(Ct.FRAMEBUFFER,u);const p=Ct.fenceSync(Ct.SYNC_GPU_COMMANDS_COMPLETE,0);return Ct.flush(),await function(t,e,i){return new Promise(function(n,s){setTimeout(function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:s();break;case t.TIMEOUT_EXPIRED:setTimeout(r,i);break;default:n()}},i)})}(Ct,p,4),Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,d),Ct.getBufferSubData(Ct.PIXEL_PACK_BUFFER,0,r),Ct.deleteBuffer(d),Ct.deleteSync(p),r}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){const n=Math.pow(2,-i),s=Math.floor(t.image.width*n),r=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;rt.setTexture2D(t,0),Ct.copyTexSubImage2D(Ct.TEXTURE_2D,i,0,0,a,o,s,r),it.unbindTexture()};const ae=Ct.createFramebuffer(),oe=Ct.createFramebuffer();this.copyTextureToTexture=function(t,e,i=null,n=null,s=0,r=null){let a,o,h,l,c,d,u,p,m;null===r&&(0!==s?(mi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),r=s,s=0):r=0);const f=t.isCompressedTexture?t.mipmaps[r]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,h=i.isBox3?i.max.z-i.min.z:1,l=i.min.x,c=i.min.y,d=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-s);a=Math.floor(f.width*e),o=Math.floor(f.height*e),h=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,l=0,c=0,d=0}null!==n?(u=n.x,p=n.y,m=n.z):(u=0,p=0,m=0);const g=St.convert(e.format),v=St.convert(e.type);let _;e.isData3DTexture?(rt.setTexture3D(e,0),_=Ct.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(rt.setTexture2DArray(e,0),_=Ct.TEXTURE_2D_ARRAY):(rt.setTexture2D(e,0),_=Ct.TEXTURE_2D),Ct.pixelStorei(Ct.UNPACK_FLIP_Y_WEBGL,e.flipY),Ct.pixelStorei(Ct.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Ct.pixelStorei(Ct.UNPACK_ALIGNMENT,e.unpackAlignment);const y=Ct.getParameter(Ct.UNPACK_ROW_LENGTH),x=Ct.getParameter(Ct.UNPACK_IMAGE_HEIGHT),b=Ct.getParameter(Ct.UNPACK_SKIP_PIXELS),S=Ct.getParameter(Ct.UNPACK_SKIP_ROWS),w=Ct.getParameter(Ct.UNPACK_SKIP_IMAGES);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,f.width),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,f.height),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,l),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,c),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,d);const M=t.isDataArrayTexture||t.isData3DTexture,T=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=st.get(t),n=st.get(e),f=st.get(i.__renderTarget),g=st.get(n.__renderTarget);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,f.__webglFramebuffer),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<h;i++)M&&(Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,st.get(t).__webglTexture,s,d+i),Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,st.get(e).__webglTexture,r,m+i)),Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.DEPTH_BUFFER_BIT,Ct.NEAREST);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else if(0!==s||t.isRenderTargetTexture||st.has(t)){const i=st.get(t),n=st.get(e);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,ae),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,oe);for(let t=0;t<h;t++)M?Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,i.__webglTexture,s,d+t):Ct.framebufferTexture2D(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,i.__webglTexture,s),T?Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,n.__webglTexture,r,m+t):Ct.framebufferTexture2D(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,n.__webglTexture,r),0!==s?Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.COLOR_BUFFER_BIT,Ct.NEAREST):T?Ct.copyTexSubImage3D(_,r,u,p,m+t,l,c,a,o):Ct.copyTexSubImage2D(_,r,u,p,l,c,a,o);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else T?t.isDataTexture||t.isData3DTexture?Ct.texSubImage3D(_,r,u,p,m,a,o,h,g,v,f.data):e.isCompressedArrayTexture?Ct.compressedTexSubImage3D(_,r,u,p,m,a,o,h,g,f.data):Ct.texSubImage3D(_,r,u,p,m,a,o,h,g,v,f):t.isDataTexture?Ct.texSubImage2D(Ct.TEXTURE_2D,r,u,p,a,o,g,v,f.data):t.isCompressedTexture?Ct.compressedTexSubImage2D(Ct.TEXTURE_2D,r,u,p,f.width,f.height,g,f.data):Ct.texSubImage2D(Ct.TEXTURE_2D,r,u,p,a,o,g,v,f);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,y),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,x),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,b),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,S),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,w),0===r&&e.generateMipmaps&&Ct.generateMipmap(_),it.unbindTexture()},this.initRenderTarget=function(t){void 0===st.get(t).__webglFramebuffer&&rt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?rt.setTextureCube(t,0):t.isData3DTexture?rt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?rt.setTexture2DArray(t,0):rt.setTexture2D(t,0),it.unbindTexture()},this.resetState=function(){A=0,C=0,L=null,it.reset(),Mt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ei}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Ui._getDrawingBufferColorSpace(t),e.unpackColorSpace=Ui._getUnpackColorSpace()}}var lm=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:A,AddOperation:2,AdditiveAnimationBlendMode:Be,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:kt,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Gl,AnimationAction:Cc,AnimationClip:gl,AnimationLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Ml(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(e){n?n(e):pi(e),s.manager.itemError(t)}},i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=gl.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends fi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,r=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==s;++t){const s=n[t],h=s.name;let c=l[h];if(void 0!==c)++c.referenceCount,r[t]=c;else{if(c=r[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new gc(Ac.create(i,h,n),s.ValueTypeName,s.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),r[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let r=s[e];if(void 0===r)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=r;else{const e=r.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),r.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,r=this._actionsByClip,a=r[s],o=a.knownActions,h=o[o.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,o[l]=h,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete r[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let r=n[e];void 0===r&&(r={},n[e]=r),r[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,r=this._bindingsByRootAndName,a=r[n],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[s],0===Object.keys(a).length&&delete r[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new al(new Float32Array(2),new Float32Array(2),1,Lc),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let r="string"==typeof t?gl.findByName(n,t):t;const a=null!==r?r.uuid:t,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==r?r.blendMode:Fe),void 0!==o){const t=o.actionByRoot[s];if(void 0!==t&&t.blendMode===i)return t;h=o.knownActions[0],null===r&&(r=h._clip)}if(null===r)return null;const l=new Cc(this,r,e,i);return this._bindAction(l,h),this._addInactiveAction(l,a,s),l}existingAction(t,e){const i=e||this._root,n=i.uuid,s="string"==typeof t?gl.findByName(i,t):t,r=s?s.uuid:t,a=this._actionsByClip[r];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,s,r)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(r);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(void 0!==s){const t=s.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const s=n._cacheIndex,r=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,r._cacheIndex=s,e[s]=r,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=xi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,s=this._bindings,r=s.length;let a,o=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],d=c.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(c);for(let t=0,e=r;t!==e;++t)s[t].push(new Ac(c,i[t],n[t]))}else if(u<h){a=t[u];const o=--h,l=t[o];e[l.uuid]=u,t[u]=l,e[d]=o,t[o]=c;for(let t=0,e=r;t!==e;++t){const e=s[t],r=e[o];let a=e[u];e[u]=r,void 0===a&&(a=new Ac(c,i[t],n[t])),e[o]=a}}else t[u]!==a&&pi("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_;for(let r=0,a=arguments.length;r!==a;++r){const a=arguments[r],o=a.uuid,h=e[o];if(void 0!==h&&h>=s){const r=s++,l=t[r];e[l.uuid]=h,t[h]=l,e[o]=r,t[r]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[r],s=e[h];e[h]=n,e[r]=s}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_,r=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h<s){const a=--s,o=t[a],l=--r,c=t[l];e[o.uuid]=h,t[h]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],s=e[l];e[h]=n,e[a]=s,e.pop()}}else{const s=--r,a=t[s];s>0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[h]=e[s],e.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const s=this._bindings;if(void 0!==n)return s[n];const r=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);n=s.length,i[t]=n,r.push(t),a.push(e),s.push(c);for(let i=l,n=o.length;i!==n;++i){const n=o[i];c[i]=new Ac(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,s=this._parsedPaths,r=this._bindings,a=r.length-1,o=r[a];e[t[a]]=i,r[i]=o,r.pop(),s[i]=s[a],s.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:class{static convertArray(t,e){return tl(t,e)}static isTypedArray(t){return ai(t)}static getKeyframeOrder(t){return el(t)}static sortedArray(t,e,i){return il(t,e,i)}static flattenJSON(t,e,i,n){nl(t,e,i,n)}static subclip(t,e,i,n,s=30){return function(t,e,i,n,s=30){const r=t.clone();r.name=e;const a=[];for(let t=0;t<r.tracks.length;++t){const e=r.tracks[t],o=e.getValueSize(),h=[],l=[];for(let t=0;t<e.times.length;++t){const r=e.times[t]*s;if(!(r<i||r>=n)){h.push(e.times[t]);for(let i=0;i<o;++i)l.push(e.values[t*o+i])}}0!==h.length&&(e.times=tl(h,e.times.constructor),e.values=tl(l,e.values.constructor),a.push(e))}r.tracks=a;let o=1/0;for(let t=0;t<r.tracks.length;++t)o>r.tracks[t].times[0]&&(o=r.tracks[t].times[0]);for(let t=0;t<r.tracks.length;++t)r.tracks[t].shift(-1*o);return r.resetDuration(),r}(t,e,i,n,s)}static makeClipAdditive(t,e=0,i=t,n=30){return function(t,e=0,i=t,n=30){n<=0&&(n=30);const s=i.tracks.length,r=e/n;for(let e=0;e<s;++e){const n=i.tracks[e],s=n.ValueTypeName;if("bool"===s||"string"===s)continue;const a=t.tracks.find(function(t){return t.name===n.name&&t.ValueTypeName===s});if(void 0===a)continue;let o=0;const h=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=h/3);let l=0;const c=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=c/3);const d=n.times.length-1;let u;if(r<=n.times[0]){const t=o,e=h-o;u=n.values.slice(t,e)}else if(r>=n.times[d]){const t=d*h+o,e=t+h-o;u=n.values.slice(t,e)}else{const t=n.createInterpolant(),e=o,i=h-o;t.evaluate(r),u=t.resultBuffer.slice(e,i)}"quaternion"===s&&(new Ci).fromArray(u).normalize().conjugate().toArray(u);const p=a.times.length;for(let t=0;t<p;++t){const e=t*c+l;if("quaternion"===s)Ci.multiplyQuaternionsFlat(a.values,e,u,0,a.values,e);else{const t=c-2*l;for(let i=0;i<t;++i)a.values[e+i]-=u[i]}}}return t.blendMode=Be,t}(t,e,i,n)}},ArcCurve:Lo,ArrayCamera:sc,ArrowHelper:class extends $n{constructor(t=new Li(0,0,1),e=new Li(0,0,0),i=1,n=16776960,s=.2*i,r=.2*s){super(),this.type="ArrowHelper",void 0===dd&&(dd=new zs,dd.setAttribute("position",new Ps([0,0,0,0,1,0],3)),ud=new yo(.5,1,5,1),ud.translate(0,-.5,0)),this.position.copy(e),this.line=new Ka(dd,new Ha({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Qs(ud,new Ss({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,s,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{cd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(cd,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:lt,Audio:dc,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:tc,AudioListener:class extends $n{constructor(){super(),this.type="AudioListener",this.context=tc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new rc}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ac,oc,hc),lc.set(0,0,-1).applyQuaternion(oc),cc.set(0,1,0).applyQuaternion(oc),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ac.x,t),e.positionY.linearRampToValueAtTime(ac.y,t),e.positionZ.linearRampToValueAtTime(ac.z,t),e.forwardX.linearRampToValueAtTime(lc.x,t),e.forwardY.linearRampToValueAtTime(lc.y,t),e.forwardZ.linearRampToValueAtTime(lc.z,t),e.upX.linearRampToValueAtTime(cc.x,t),e.upY.linearRampToValueAtTime(cc.y,t),e.upZ.linearRampToValueAtTime(cc.z,t)}else e.setPosition(ac.x,ac.y,ac.z),e.setOrientation(lc.x,lc.y,lc.z,cc.x,cc.y,cc.z)}},AudioLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Ml(this.manager);function a(e){n?n(e):pi(e),s.manager.itemError(t)}r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(t){try{const i=t.slice(0);tc.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(t){a(t)}},i,n)}},AxesHelper:class extends to{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new zs;i.setAttribute("position",new Ps(e,3)),i.setAttribute("color",new Ps([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new Ha({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new _s,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(i),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:Ga,Bone:$r,BooleanKeyframeTrack:ll,Box2:class{constructor(t=new Ai(1/0,1/0),e=new Ai(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=zc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,zc).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Box3:Qi,Box3Helper:class extends to{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new zs;n.setIndex(new Ls(i,1)),n.setAttribute("position",new Ps([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new Ha({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:tr,BoxHelper:class extends to{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),s=new zs;s.setIndex(new Ls(i,1)),s.setAttribute("position",new Ls(n,3)),super(s,new Ha({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&ld.setFromObject(this.object),ld.isEmpty())return;const t=ld.min,e=ld.max,i=this.geometry.attributes.position,n=i.array;n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=t.x,n[4]=e.y,n[5]=e.z,n[6]=t.x,n[7]=t.y,n[8]=e.z,n[9]=e.x,n[10]=t.y,n[11]=e.z,n[12]=e.x,n[13]=e.y,n[14]=t.z,n[15]=t.x,n[16]=e.y,n[17]=t.z,n[18]=t.x,n[19]=t.y,n[20]=t.z,n[21]=e.x,n[22]=t.y,n[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:Ls,BufferGeometry:zs,BufferGeometryLoader:ql,ByteType:At,Cache:_l,Camera:ar,CameraHelper:class extends to{constructor(t){const e=new zs,i=new Ha({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],r={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),s.push(0,0,0),void 0===r[t]&&(r[t]=[]),r[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new Ps(n,3)),e.setAttribute("color",new Ps(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update();const h=new _s(16755200),l=new _s(16711680),c=new _s(43775),d=new _s(16777215),u=new _s(3355443);this.setColors(h,l,c,d,u)}setColors(t,e,i,n,s){const r=this.geometry.getAttribute("color");return r.setXYZ(0,t.r,t.g,t.b),r.setXYZ(1,t.r,t.g,t.b),r.setXYZ(2,t.r,t.g,t.b),r.setXYZ(3,t.r,t.g,t.b),r.setXYZ(4,t.r,t.g,t.b),r.setXYZ(5,t.r,t.g,t.b),r.setXYZ(6,t.r,t.g,t.b),r.setXYZ(7,t.r,t.g,t.b),r.setXYZ(8,t.r,t.g,t.b),r.setXYZ(9,t.r,t.g,t.b),r.setXYZ(10,t.r,t.g,t.b),r.setXYZ(11,t.r,t.g,t.b),r.setXYZ(12,t.r,t.g,t.b),r.setXYZ(13,t.r,t.g,t.b),r.setXYZ(14,t.r,t.g,t.b),r.setXYZ(15,t.r,t.g,t.b),r.setXYZ(16,t.r,t.g,t.b),r.setXYZ(17,t.r,t.g,t.b),r.setXYZ(18,t.r,t.g,t.b),r.setXYZ(19,t.r,t.g,t.b),r.setXYZ(20,t.r,t.g,t.b),r.setXYZ(21,t.r,t.g,t.b),r.setXYZ(22,t.r,t.g,t.b),r.setXYZ(23,t.r,t.g,t.b),r.setXYZ(24,e.r,e.g,e.b),r.setXYZ(25,e.r,e.g,e.b),r.setXYZ(26,e.r,e.g,e.b),r.setXYZ(27,e.r,e.g,e.b),r.setXYZ(28,e.r,e.g,e.b),r.setXYZ(29,e.r,e.g,e.b),r.setXYZ(30,e.r,e.g,e.b),r.setXYZ(31,e.r,e.g,e.b),r.setXYZ(32,i.r,i.g,i.b),r.setXYZ(33,i.r,i.g,i.b),r.setXYZ(34,i.r,i.g,i.b),r.setXYZ(35,i.r,i.g,i.b),r.setXYZ(36,i.r,i.g,i.b),r.setXYZ(37,i.r,i.g,i.b),r.setXYZ(38,n.r,n.g,n.b),r.setXYZ(39,n.r,n.g,n.b),r.setXYZ(40,s.r,s.g,s.b),r.setXYZ(41,s.r,s.g,s.b),r.setXYZ(42,s.r,s.g,s.b),r.setXYZ(43,s.r,s.g,s.b),r.setXYZ(44,s.r,s.g,s.b),r.setXYZ(45,s.r,s.g,s.b),r.setXYZ(46,s.r,s.g,s.b),r.setXYZ(47,s.r,s.g,s.b),r.setXYZ(48,s.r,s.g,s.b),r.setXYZ(49,s.r,s.g,s.b),r.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap;let i,n;if(od.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)i=1,n=0;else if(this.camera.coordinateSystem===ei)i=-1,n=1;else{if(this.camera.coordinateSystem!==ii)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);i=0,n=1}hd("c",e,t,od,0,0,i),hd("t",e,t,od,0,0,n),hd("n1",e,t,od,-1,-1,i),hd("n2",e,t,od,1,-1,i),hd("n3",e,t,od,-1,1,i),hd("n4",e,t,od,1,1,i),hd("f1",e,t,od,-1,-1,n),hd("f2",e,t,od,1,-1,n),hd("f3",e,t,od,-1,1,n),hd("f4",e,t,od,1,1,n),hd("u1",e,t,od,.7,1.1,i),hd("u2",e,t,od,-.7,1.1,i),hd("u3",e,t,od,0,2,i),hd("cf1",e,t,od,-1,0,n),hd("cf2",e,t,od,1,0,n),hd("cf3",e,t,od,0,-1,n),hd("cf4",e,t,od,0,1,n),hd("cn1",e,t,od,-1,0,i),hd("cn2",e,t,od,1,0,i),hd("cn3",e,t,od,0,-1,i),hd("cn4",e,t,od,0,1,i),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:uo,CapsuleGeometry:go,CatmullRomCurve3:No,CineonToneMapping:3,CircleGeometry:vo,ClampToEdgeWrapping:_t,Clock:rc,Color:_s,ColorKeyframeTrack:cl,ColorManagement:Ui,CompressedArrayTexture:class extends co{constructor(t,e,i,n,s,r){super(t,e,i,s,r),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=_t,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends co{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,ut),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:co,CompressedTextureLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=[],a=new co,o=new Ml(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials);let h=0;function l(l){o.load(t[l],function(t){const i=s.parse(t,!0);r[l]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},h+=1,6===h&&(1===i.mipmapCount&&(a.minFilter=wt),a.image=r,a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)l(e);else o.load(t,function(t){const i=s.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){r[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)r[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),r[e].format=i.format,r[e].width=i.width,r[e].height=i.height}a.image=r}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=wt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:yo,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:pd,CubeCamera:ur,CubeDepthTexture:mo,CubeReflectionMapping:ut,CubeRefractionMapping:pt,CubeTexture:pr,CubeTextureLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=new pr;s.colorSpace=ze;const r=new El(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);let a=0;function o(i){r.load(t[i],function(t){s.images[i]=t,a++,6===a&&(s.needsUpdate=!0,e&&e(s))},void 0,n)}for(let e=0;e<t.length;++e)o(e);return s}},CubeUVReflectionMapping:gt,CubicBezierCurve:ko,CubicBezierCurve3:zo,CubicInterpolant:rl,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:Ao,CurvePath:Yo,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:_o,Cylindrical:class{constructor(t=1,e=0,i=0){this.radius=t,this.theta=e,this.y=i}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Ji,DataArrayTexture:Ki,DataTexture:ta,DataTextureLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new ta,a=new Ml(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(t){let i;try{i=s.parse(t)}catch(t){if(void 0===n)return void t(t);n(t)}void 0!==i.image?r.image=i.image:void 0!==i.data&&(r.image.width=i.width,r.image.height=i.height,r.image.data=i.data),r.wrapS=void 0!==i.wrapS?i.wrapS:_t,r.wrapT=void 0!==i.wrapT?i.wrapT:_t,r.magFilter=void 0!==i.magFilter?i.magFilter:wt,r.minFilter=void 0!==i.minFilter?i.minFilter:wt,r.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(r.colorSpace=i.colorSpace),void 0!==i.flipY&&(r.flipY=i.flipY),void 0!==i.format&&(r.format=i.format),void 0!==i.type&&(r.type=i.type),void 0!==i.mipmaps&&(r.mipmaps=i.mipmaps,r.minFilter=Tt),1===i.mipmapCount&&(r.minFilter=wt),void 0!==i.generateMipmaps&&(r.generateMipmaps=i.generateMipmaps),r.needsUpdate=!0,e&&e(r,i)},i,n),r}},DataUtils:class{static toHalfFloat(t){return Ms(t)}static fromHalfFloat(t){return Ts(t)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:xl,DepthFormat:Ht,DepthStencilFormat:Vt,DepthTexture:po,DetachedBindMode:ct,DirectionalLight:zl,DirectionalLightHelper:class extends $n{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new zs;n.setAttribute("position",new Ps([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new Ha({fog:!1,toneMapped:!1});this.lightPlane=new Ka(n,s),this.add(this.lightPlane),n=new zs,n.setAttribute("position",new Ps([0,0,0,0,0,1],3)),this.targetLine=new Ka(n,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),nd.setFromMatrixPosition(this.light.matrixWorld),sd.setFromMatrixPosition(this.light.target.matrixWorld),rd.subVectors(sd,nd),this.lightPlane.lookAt(sd),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(sd),this.targetLine.scale.z=rd.length()}},DiscreteInterpolant:ol,DodecahedronGeometry:bo,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:Eo,EllipseCurve:Co,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:mt,EquirectangularRefractionMapping:ft,Euler:Un,EventDispatcher:fi,ExternalTexture:fo,ExtrudeGeometry:Eh,FileLoader:Ml,Float16BufferAttribute:class extends Ls{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=Ts(this.array[t*this.itemSize]);return this.normalized&&(e=Mi(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize]=Ms(e),this}getY(t){let e=Ts(this.array[t*this.itemSize+1]);return this.normalized&&(e=Mi(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize+1]=Ms(e),this}getZ(t){let e=Ts(this.array[t*this.itemSize+2]);return this.normalized&&(e=Mi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize+2]=Ms(e),this}getW(t){let e=Ts(this.array[t*this.itemSize+3]);return this.normalized&&(e=Mi(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize+3]=Ms(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Ti(e,this.array),i=Ti(i,this.array)),this.array[t+0]=Ms(e),this.array[t+1]=Ms(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Ti(e,this.array),i=Ti(i,this.array),n=Ti(n,this.array)),this.array[t+0]=Ms(e),this.array[t+1]=Ms(i),this.array[t+2]=Ms(n),this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=Ti(e,this.array),i=Ti(i,this.array),n=Ti(n,this.array),s=Ti(s,this.array)),this.array[t+0]=Ms(e),this.array[t+1]=Ms(i),this.array[t+2]=Ms(n),this.array[t+3]=Ms(s),this}},Float32BufferAttribute:Ps,FloatType:Pt,Fog:yr,FogExp2:_r,FramebufferTexture:class extends Xi{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=xt,this.minFilter=xt,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:xa,FrustumArray:wa,GLBufferAttribute:class{constructor(t,e,i,n,s,r=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=s,this.normalized=r,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:ti,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:Je,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends to{constructor(t=10,e=10,i=4473924,n=8947848){i=new _s(i),n=new _s(n);const s=e/2,r=t/e,a=t/2,o=[],h=[];for(let t=0,l=0,c=-a;t<=e;t++,c+=r){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===s?i:n;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new zs;l.setAttribute("position",new Ps(o,3)),l.setAttribute("color",new Ps(h,3));super(l,new Ha({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:fr,HalfFloatType:Dt,HemisphereLight:Ll,HemisphereLightHelper:class extends $n{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new Rh(e);n.rotateY(.5*Math.PI),this.material=new Ss({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const s=n.getAttribute("position"),r=new Float32Array(3*s.count);n.setAttribute("color",new Ls(r,3)),this.add(new Qs(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");ed.copy(this.light.color),id.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?ed:id;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(td.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:Ch,ImageBitmapLoader:class extends bl{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&ui("ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&ui("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=_l.get(`image-bitmap:${t}`);if(void 0!==r)return s.manager.itemStart(t),r.then?void r.then(i=>{if(!0!==Ql.has(r))return e&&e(i),s.manager.itemEnd(t),i;n&&n(Ql.get(r)),s.manager.itemError(t),s.manager.itemEnd(t)}):(setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(i){return _l.add(`image-bitmap:${t}`,i),e&&e(i),s.manager.itemEnd(t),i}).catch(function(e){n&&n(e),Ql.set(o,e),_l.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});_l.add(`image-bitmap:${t}`,o),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ImageLoader:El,ImageUtils:zi,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:sa,InstancedBufferGeometry:Yl,InstancedInterleavedBuffer:Pc,InstancedMesh:ua,Int16BufferAttribute:class extends Ls{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends Ls{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends Ls{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:Rt,InterleavedBuffer:br,InterleavedBufferAttribute:wr,Interpolant:sl,InterpolateDiscrete:Ie,InterpolateLinear:Pe,InterpolateSmooth:De,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:We,KeyframeTrack:hl,LOD:Hr,LatheGeometry:Lh,Layers:Fn,LessCompare:513,LessDepth:2,LessEqualCompare:qe,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:Cl,LightProbe:Wl,Line:Ka,Line3:qc,LineBasicMaterial:Ha,LineCurve:Go,LineCurve3:Ho,LineDashedMaterial:$h,LineLoop:eo,LineSegments:to,LinearFilter:wt,LinearInterpolant:al,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:Tt,LinearMipmapNearestFilter:Mt,LinearSRGBColorSpace:Ge,LinearToneMapping:1,LinearTransfer:He,Loader:bl,LoaderUtils:Xl,LoadingManager:yl,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,MOUSE:x,Material:bs,MaterialLoader:jl,MathUtils:Ei,Matrix2:kc,Matrix3:Pi,Matrix4:En,MaxEquation:104,Mesh:Qs,MeshBasicMaterial:Ss,MeshDepthMaterial:Kh,MeshDistanceMaterial:Jh,MeshLambertMaterial:Zh,MeshMatcapMaterial:Qh,MeshNormalMaterial:qh,MeshPhongMaterial:Xh,MeshPhysicalMaterial:jh,MeshStandardMaterial:Wh,MeshToonMaterial:Yh,MinEquation:103,MirroredRepeatWrapping:yt,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:xt,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:St,NearestMipmapNearestFilter:bt,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:ke,NoNormalPacking:"",NoToneMapping:0,NormalAnimationBlendMode:Fe,NormalBlending:1,NormalGAPacking:"ga",NormalRGPacking:"rg",NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:dl,Object3D:$n,ObjectLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=""===this.path?Xl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new Ml(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){let r=null;try{r=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void e("ObjectLoader: Can't parse "+t+".",e.message)}const a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t)),void pi("ObjectLoader: Can't load "+t);s.parse(r,e)},i,n)}async loadAsync(t,e){const i=""===this.path?Xl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new Ml(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const s=await n.loadAsync(t,e),r=JSON.parse(s),a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(r)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,n),r=this.parseImages(t.images,function(){void 0!==e&&e(h)}),a=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,s,o,a,i),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),this.bindLightTargets(h),void 0!==e){let t=!1;for(const e in r)if(r[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),s=await this.parseImagesAsync(t.images),r=this.parseTextures(t.textures,s),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,n,a,r,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new Zo).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse(function(t){t.isBone&&(n[t.uuid]=t)}),void 0!==t)for(let e=0,s=t.length;e<s;e++){const s=(new na).fromJSON(t[e],n);i[s.uuid]=s}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new ql;for(let s=0,r=t.length;s<r;s++){let r;const a=t[s];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":r=n.parse(a);break;default:a.type in Gh?r=Gh[a.type].fromJSON(a,e):ui(`ObjectLoader: Unsupported geometry type "${a.type}"`)}r.uuid=a.uuid,void 0!==a.name&&(r.name=a.name),void 0!==a.userData&&(r.userData=a.userData),i[a.uuid]=r}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const s=new jl;s.setTextures(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0===i[r.uuid]&&(i[r.uuid]=s.parse(r)),n[r.uuid]=i[r.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],s=gl.parse(n);e[s.uuid]=s}return e}parseImages(t,e){const i=this,n={};let s;function r(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),s.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new yl(e);s=new El(i),s.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],s=i.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=r(s[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new ta(i.data,i.width,i.height)))}n[i.uuid]=new Hi(t)}else{const t=r(i.url);n[i.uuid]=new Hi(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function s(t){if("string"==typeof t){const i=t,s=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(s)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new El(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],n=await s(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new ta(n.data,n.width,n.height)))}i[n.uuid]=new Hi(t)}else{const t=await s(n.url);i[n.uuid]=new Hi(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(ui("ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let s=0,r=t.length;s<r;s++){const r=t[s];void 0===r.image&&ui('ObjectLoader: No "image" specified for',r.uuid),void 0===e[r.image]&&ui("ObjectLoader: Undefined image",r.image);const a=e[r.image],o=a.data;let h;Array.isArray(o)?(h=new pr,6===o.length&&(h.needsUpdate=!0)):(h=o&&o.data?new ta:new Xi,o&&(h.needsUpdate=!0)),h.source=a,h.uuid=r.uuid,void 0!==r.name&&(h.name=r.name),void 0!==r.mapping&&(h.mapping=i(r.mapping,Zl)),void 0!==r.channel&&(h.channel=r.channel),void 0!==r.offset&&h.offset.fromArray(r.offset),void 0!==r.repeat&&h.repeat.fromArray(r.repeat),void 0!==r.center&&h.center.fromArray(r.center),void 0!==r.rotation&&(h.rotation=r.rotation),void 0!==r.wrap&&(h.wrapS=i(r.wrap[0],Kl),h.wrapT=i(r.wrap[1],Kl)),void 0!==r.format&&(h.format=r.format),void 0!==r.internalFormat&&(h.internalFormat=r.internalFormat),void 0!==r.type&&(h.type=r.type),void 0!==r.colorSpace&&(h.colorSpace=r.colorSpace),void 0!==r.minFilter&&(h.minFilter=i(r.minFilter,Jl)),void 0!==r.magFilter&&(h.magFilter=i(r.magFilter,Jl)),void 0!==r.anisotropy&&(h.anisotropy=r.anisotropy),void 0!==r.flipY&&(h.flipY=r.flipY),void 0!==r.generateMipmaps&&(h.generateMipmaps=r.generateMipmaps),void 0!==r.premultiplyAlpha&&(h.premultiplyAlpha=r.premultiplyAlpha),void 0!==r.unpackAlignment&&(h.unpackAlignment=r.unpackAlignment),void 0!==r.compareFunction&&(h.compareFunction=r.compareFunction),void 0!==r.userData&&(h.userData=r.userData),n[r.uuid]=h}return n}parseObject(t,e,i,n,s){let r,a,o;function h(t){return void 0===e[t]&&ui("ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,s=t.length;n<s;n++){const s=t[n];void 0===i[s]&&ui("ObjectLoader: Undefined material",s),e.push(i[s])}return e}return void 0===i[t]&&ui("ObjectLoader: Undefined material",t),i[t]}}function c(t){return void 0===n[t]&&ui("ObjectLoader: Undefined texture",t),n[t]}switch(t.type){case"Scene":r=new xr,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new _s(t.background):r.background=c(t.background)),void 0!==t.environment&&(r.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new yr(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new _r(t.fog.color,t.fog.density)),""!==t.fog.name&&(r.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(r.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(r.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&r.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(r.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&r.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":r=new cr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new Bl(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new Gl(t.color,t.intensity);break;case"DirectionalLight":r=new zl(t.color,t.intensity),r.target=t.target||"";break;case"PointLight":r=new Fl(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new Hl(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new Nl(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),r.target=t.target||"";break;case"HemisphereLight":r=new Ll(t.color,t.groundColor,t.intensity);break;case"LightProbe":const e=(new Vl).fromArray(t.sh);r=new Wl(e,t.intensity);break;case"SkinnedMesh":a=h(t.geometry),o=l(t.material),r=new Qr(a,o),void 0!==t.bindMode&&(r.bindMode=t.bindMode),void 0!==t.bindMatrix&&r.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(r.skeleton=t.skeleton);break;case"Mesh":a=h(t.geometry),o=l(t.material),r=new Qs(a,o);break;case"InstancedMesh":a=h(t.geometry),o=l(t.material);const i=t.count,n=t.instanceMatrix,s=t.instanceColor;r=new ua(a,o,i),r.instanceMatrix=new sa(new Float32Array(n.array),16),void 0!==s&&(r.instanceColor=new sa(new Float32Array(s.array),s.itemSize));break;case"BatchedMesh":a=h(t.geometry),o=l(t.material),r=new Ga(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),r.geometry=a,r.perObjectFrustumCulled=t.perObjectFrustumCulled,r.sortObjects=t.sortObjects,r._drawRanges=t.drawRanges,r._reservedRanges=t.reservedRanges,r._geometryInfo=t.geometryInfo.map(t=>{let e=null,i=null;return void 0!==t.boundingBox&&(e=(new Qi).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=(new vn).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}}),r._instanceInfo=t.instanceInfo,r._availableInstanceIds=t._availableInstanceIds,r._availableGeometryIds=t._availableGeometryIds,r._nextIndexStart=t.nextIndexStart,r._nextVertexStart=t.nextVertexStart,r._geometryCount=t.geometryCount,r._maxInstanceCount=t.maxInstanceCount,r._maxVertexCount=t.maxVertexCount,r._maxIndexCount=t.maxIndexCount,r._geometryInitialized=t.geometryInitialized,r._matricesTexture=c(t.matricesTexture.uuid),r._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(r._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(r.boundingSphere=(new vn).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(r.boundingBox=(new Qi).fromJSON(t.boundingBox));break;case"LOD":r=new Hr;break;case"Line":r=new Ka(h(t.geometry),l(t.material));break;case"LineLoop":r=new eo(h(t.geometry),l(t.material));break;case"LineSegments":r=new to(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":r=new oo(h(t.geometry),l(t.material));break;case"Sprite":r=new Br(l(t.material));break;case"Group":r=new fr;break;case"Bone":r=new $r;break;default:r=new $n}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.up&&r.up.fromArray(t.up),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(r.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)r.add(this.parseObject(a[t],e,i,n,s))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];r.animations.push(s[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(r.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=r.getObjectByProperty("uuid",i.object);void 0!==n&&r.addLevel(n,i.distance,i.hysteresis)}}return r}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?ui("ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,n=t.getObjectByProperty("uuid",i);e.target=void 0!==n?n:new $n}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:Rh,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:N,OneMinusSrcColorFactor:203,OrthographicCamera:Bl,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Bd,Path:qo,PerspectiveCamera:cr,Plane:ga,PlaneGeometry:Ih,PlaneHelper:class extends Ka{constructor(t,e=1,i=16776960){const n=i,s=new zs;s.setAttribute("position",new Ps([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),s.computeBoundingSphere(),super(s,new Ha({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const r=new zs;r.setAttribute("position",new Ps([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Qs(r,new Ss({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:Fl,PointLightHelper:class extends Qs{constructor(t,e,i){super(new Oh(e,4,2),new Ss({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:oo,PointsMaterial:io,PolarGridHelper:class extends to{constructor(t=10,e=16,i=8,n=64,s=4473924,r=8947848){s=new _s(s),r=new _s(r);const a=[],o=[];if(e>1)for(let i=0;i<e;i++){const n=i/e*(2*Math.PI),h=Math.sin(n)*t,l=Math.cos(n)*t;a.push(0,0,0),a.push(h,0,l);const c=1&i?s:r;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<i;e++){const h=1&e?s:r,l=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*l,s=Math.cos(e)*l;a.push(i,0,s),o.push(h.r,h.g,h.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*l,s=Math.cos(e)*l,a.push(i,0,s),o.push(h.r,h.g,h.b)}}const h=new zs;h.setAttribute("position",new Ps(a,3)),h.setAttribute("color",new Ps(o,3));super(h,new Ha({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:xo,PositionalAudio:class extends dc{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(uc,pc,mc),fc.set(0,0,1).applyQuaternion(pc);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(uc.x,t),e.positionY.linearRampToValueAtTime(uc.y,t),e.positionZ.linearRampToValueAtTime(uc.z,t),e.orientationX.linearRampToValueAtTime(fc.x,t),e.orientationY.linearRampToValueAtTime(fc.y,t),e.orientationZ.linearRampToValueAtTime(fc.z,t)}else e.setPosition(uc.x,uc.y,uc.z),e.setOrientation(fc.x,fc.y,fc.z)}},PropertyBinding:Ac,PropertyMixer:gc,QuadraticBezierCurve:Vo,QuadraticBezierCurve3:Wo,Quaternion:Ci,QuaternionKeyframeTrack:pl,QuaternionLinearInterpolant:ul,R11_EAC_Format:ae,RED_GREEN_RGTC2_Format:Le,RED_RGTC1_Format:Ae,REVISION:y,RG11_EAC_Format:he,RGBADepthPacking:3201,RGBAFormat:Gt,RGBAIntegerFormat:qt,RGBA_ASTC_10x10_Format:be,RGBA_ASTC_10x5_Format:_e,RGBA_ASTC_10x6_Format:ye,RGBA_ASTC_10x8_Format:xe,RGBA_ASTC_12x10_Format:Se,RGBA_ASTC_12x12_Format:we,RGBA_ASTC_4x4_Format:ce,RGBA_ASTC_5x4_Format:de,RGBA_ASTC_5x5_Format:ue,RGBA_ASTC_6x5_Format:pe,RGBA_ASTC_6x6_Format:me,RGBA_ASTC_8x5_Format:fe,RGBA_ASTC_8x6_Format:ge,RGBA_ASTC_8x8_Format:ve,RGBA_BPTC_Format:Me,RGBA_ETC2_EAC_Format:re,RGBA_PVRTC_2BPPV1_Format:ie,RGBA_PVRTC_4BPPV1_Format:ee,RGBA_S3TC_DXT1_Format:Kt,RGBA_S3TC_DXT3_Format:Jt,RGBA_S3TC_DXT5_Format:Qt,RGBDepthPacking:3202,RGBFormat:zt,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:Te,RGB_BPTC_UNSIGNED_Format:Ee,RGB_ETC1_Format:ne,RGB_ETC2_Format:se,RGB_PVRTC_2BPPV1_Format:te,RGB_PVRTC_4BPPV1_Format:$t,RGB_S3TC_DXT1_Format:Zt,RGDepthPacking:3203,RGFormat:Xt,RGIntegerFormat:Yt,RawShaderMaterial:Vh,Ray:Tn,Raycaster:Oc,RectAreaLight:Hl,RedFormat:Wt,RedIntegerFormat:jt,ReinhardToneMapping:2,RenderTarget:qi,RenderTarget3D:class extends qi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new Ji(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:vt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:Ph,SIGNED_R11_EAC_Format:oe,SIGNED_RED_GREEN_RGTC2_Format:Re,SIGNED_RED_RGTC1_Format:Ce,SIGNED_RG11_EAC_Format:le,SRGBColorSpace:ze,SRGBTransfer:Ve,Scene:xr,ShaderChunk:vd,ShaderLib:yd,ShaderMaterial:rr,ShadowMaterial:Hh,Shape:Zo,ShapeGeometry:Dh,ShapePath:class{constructor(){this.type="ShapePath",this.color=new _s,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new qo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,s,r){return this.currentPath.bezierCurveTo(t,e,i,n,s,r),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let s=i-1,r=0;r<i;s=r++){let i=e[s],a=e[r],o=a.x-i.x,h=a.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=e[r],o=-o,a=e[s],h=-h),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=wh.isClockWise,n=this.subPaths;if(0===n.length)return[];let s,r,a;const o=[];if(1===n.length)return r=n[0],a=new Zo,a.curves=r.curves,o.push(a),o;let h=!i(n[0].getPoints());h=t?!h:h;const l=[],c=[];let d,u,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=n.length;e<a;e++)r=n[e],d=r.getPoints(),s=i(d),s=t?!s:s,s?(!h&&c[m]&&m++,c[m]={s:new Zo,p:d},c[m].s.curves=r.curves,h&&m++,p[m]=[]):p[m].push({h:r,p:d[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],s=new Zo;s.curves=n.curves,e.push(s)}return e}(n);if(c.length>1){let t=!1,i=0;for(let t=0,e=c.length;t<e;t++)l[t]=[];for(let n=0,s=c.length;n<s;n++){const s=p[n];for(let r=0;r<s.length;r++){const a=s[r];let o=!0;for(let s=0;s<c.length;s++)e(a.p,c[s].p)&&(n!==s&&i++,o?(o=!1,l[s].push(a)):t=!0);o&&l[n].push(a)}}i>0&&!1===t&&(p=l)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),u=p[t];for(let t=0,e=u.length;t<e;t++)a.holes.push(u[t].h)}return o}},ShapeUtils:wh,ShortType:Ct,Skeleton:na,SkeletonHelper:class extends to{constructor(t){const e=$c(t),i=new zs,n=[],s=[];for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),s.push(0,0,0),s.push(0,0,0))}i.setAttribute("position",new Ps(n,3)),i.setAttribute("color",new Ps(s,3));super(i,new Ha({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const r=new _s(255),a=new _s(65280);this.setColors(r,a)}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");Qc.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const s=e[t];s.parent&&s.parent.isBone&&(Jc.multiplyMatrices(Qc,s.matrixWorld),Kc.setFromMatrixPosition(Jc),n.setXYZ(i,Kc.x,Kc.y,Kc.z),Jc.multiplyMatrices(Qc,s.parent.matrixWorld),Kc.setFromMatrixPosition(Jc),n.setXYZ(i+1,Kc.x,Kc.y,Kc.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const i=this.geometry.getAttribute("color");for(let n=0;n<i.count;n+=2)i.setXYZ(n,t.r,t.g,t.b),i.setXYZ(n+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Qr,Source:Hi,Sphere:vn,SphereGeometry:Oh,Spherical:Bc,SphericalHarmonics3:Vl,SplineCurve:jo,SpotLight:Nl,SpotLightHelper:class extends $n{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new zs,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const s=t/i*Math.PI*2,r=e/i*Math.PI*2;n.push(Math.cos(s),Math.sin(s),1,Math.cos(r),Math.sin(r),1)}i.setAttribute("position",new Ps(n,3));const s=new Ha({fog:!1,toneMapped:!1});this.cone=new to(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Zc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Zc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:Br,SpriteMaterial:Mr,SrcAlphaFactor:O,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:$e,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new cr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new cr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,nc.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,s=e.near*Math.tan(_i*e.fov*.5)/e.zoom;let r,a;ic.elements[12]=-i,ec.elements[12]=i,r=-s*e.aspect+n,a=s*e.aspect+n,nc.elements[0]=2*e.near/(a-r),nc.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(nc),r=-s*e.aspect-n,a=s*e.aspect-n,nc.elements[0]=2*e.near/(a-r),nc.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(nc)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(ic),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(ec)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:ml,SubtractEquation:101,SubtractiveBlending:3,TOUCH:b,TangentSpaceNormalMap:0,TetrahedronGeometry:Nh,Texture:Xi,TextureLoader:Al,TextureUtils:class{static contain(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,i,n){return md(t,e,i,n)}},Timer:class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=Fc.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}},TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:Uh,TorusKnotGeometry:Fh,Triangle:ps,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:Bh,UVMapping:dt,Uint16BufferAttribute:Rs,Uint32BufferAttribute:Is,Uint8BufferAttribute:class extends Ls{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends Ls{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:Rc,UniformsGroup:class extends fi{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Ic++}),this.name="",this.usage=$e,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,i=e.length;t<i;t++){const i=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<i.length;t++)this.uniforms.push(i[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:_d,UniformsUtils:sr,UnsignedByteType:Et,UnsignedInt101111Type:Bt,UnsignedInt248Type:Ut,UnsignedInt5999Type:Ft,UnsignedIntType:It,UnsignedShort4444Type:Ot,UnsignedShort5551Type:Nt,UnsignedShortType:Lt,VSMShadowMap:3,Vector2:Ai,Vector3:Li,Vector4:Yi,VectorKeyframeTrack:fl,VideoFrameTexture:class extends lo{constructor(t,e,i,n,s,r,a,o){super({},t,e,i,n,s,r,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:lo,WebGL3DRenderTarget:class extends Zi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ji(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Zi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ki(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:ei,WebGLCubeRenderTarget:mr,WebGLRenderTarget:Zi,WebGLRenderer:hm,WebGLUtils:$p,WebGPUCoordinateSystem:ii,WebXRController:vr,WireframeGeometry:kh,WrapAroundEnding:Ue,ZeroCurvatureEnding:Oe,ZeroFactor:200,ZeroSlopeEnding:Ne,ZeroStencilOp:0,createCanvasElement:hi,error:pi,getConsoleFunction:function(){return ci},log:di,setConsoleFunction:function(t){ci=t},warn:ui,warnOnce:mi});const cm=new Oc,dm=new Li,um=new Li,pm=new Ci,mm={X:new Li(1,0,0),Y:new Li(0,1,0),Z:new Li(0,0,1)},fm={type:"change"},gm={type:"mouseDown",mode:null},vm={type:"mouseUp",mode:null},_m={type:"objectChange"};class ym extends pd{constructor(t,e=null){super(void 0,e);const i=new zm(this);this._root=i;const n=new Gm;this._gizmo=n,i.add(n);const s=new Hm;this._plane=s,i.add(s);const r=this;function a(t,e){let i=e;Object.defineProperty(r,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,s[t]=e,n[t]=e,r.dispatchEvent({type:t+"-changed",value:e}),r.dispatchEvent(fm))}}),r[t]=e,s[t]=e,n[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new Li,h=new Li,l=new Ci,c=new Ci,d=new Li,u=new Ci,p=new Li,m=new Li,f=new Li,g=new Li;a("worldPosition",o),a("worldPositionStart",h),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",m),a("rotationAxis",f),a("rotationAngle",0),a("eye",g),this._offset=new Li,this._startNorm=new Li,this._endNorm=new Li,this._cameraScale=new Li,this._parentPosition=new Li,this._parentQuaternion=new Ci,this._parentQuaternionInv=new Ci,this._parentScale=new Li,this._worldScaleStart=new Li,this._worldQuaternionInv=new Ci,this._worldScale=new Li,this._positionStart=new Li,this._quaternionStart=new Ci,this._scaleStart=new Li,this._getPointer=xm.bind(this),this._onPointerDown=Sm.bind(this),this._onPointerHover=bm.bind(this),this._onPointerMove=wm.bind(this),this._onPointerUp=Mm.bind(this),null!==e&&this.connect(e)}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&cm.setFromCamera(t,this.camera);const e=Tm(this._gizmo.picker[this.mode],cm);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&cm.setFromCamera(t,this.camera);const e=Tm(this._plane,cm,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,gm.mode=this.mode,this.dispatchEvent(gm)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let s=this.space;if("scale"===i?s="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(s="world"),void 0===n||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&cm.setFromCamera(t,this.camera);const r=Tm(this._plane,cm,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===s&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===s&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===s&&(n.position.applyQuaternion(pm.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===s&&(n.parent&&n.position.add(dm.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(dm.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),um.set(t,t,t)}else dm.copy(this.pointStart),um.copy(this.pointEnd),dm.applyQuaternion(this._worldQuaternionInv),um.applyQuaternion(this._worldQuaternionInv),um.divide(dm),-1===e.search("X")&&(um.x=1),-1===e.search("Y")&&(um.y=1),-1===e.search("Z")&&(um.z=1);n.scale.copy(this._scaleStart).multiply(um),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(dm.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(dm.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(mm[e]),dm.copy(mm[e]),"local"===s&&dm.applyQuaternion(this.worldQuaternion),dm.cross(this.eye),0===dm.length()?i=!0:this.rotationAngle=this._offset.dot(dm.normalize())*t),("E"===e||i)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===s&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(pm.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(pm.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(fm),this.dispatchEvent(_m)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(vm.mode=this.mode,this.dispatchEvent(vm)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(fm),this.dispatchEvent(_m),this.pointStart.copy(this.pointEnd))}getRaycaster(){return cm}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}setColors(t,e,i,n){const s=this._gizmo.materialLib;s.xAxis.color.set(t),s.yAxis.color.set(e),s.zAxis.color.set(i),s.active.color.set(n),s.xAxisTransparent.color.set(t),s.yAxisTransparent.color.set(e),s.zAxisTransparent.color.set(i),s.activeTransparent.color.set(n),s.xAxis._color&&s.xAxis._color.set(t),s.yAxis._color&&s.yAxis._color.set(e),s.zAxis._color&&s.zAxis._color.set(i),s.active._color&&s.active._color.set(n),s.xAxisTransparent._color&&s.xAxisTransparent._color.set(t),s.yAxisTransparent._color&&s.yAxisTransparent._color.set(e),s.zAxisTransparent._color&&s.zAxisTransparent._color.set(i),s.activeTransparent._color&&s.activeTransparent._color.set(n)}}function xm(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function bm(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Sm(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function wm(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Mm(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Tm(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const Em=new Un,Am=new Li(0,1,0),Cm=new Li(0,0,0),Lm=new En,Rm=new Ci,Im=new Ci,Pm=new Li,Dm=new En,Om=new Li(1,0,0),Nm=new Li(0,1,0),Um=new Li(0,0,1),Fm=new Li,Bm=new Li,km=new Li;class zm extends $n{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class Gm extends $n{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new Ss({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Ha({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const s=t.clone();s.color.setHex(16711680);const r=t.clone();r.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const l=t.clone();l.color.setHex(255),l.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;const u=t.clone();u.color.setHex(16776960);const p=t.clone();p.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:r,zAxis:a,active:u,xAxisTransparent:o,yAxisTransparent:h,zAxisTransparent:l,activeTransparent:d};const m=new _o(0,.04,.1,12);m.translate(0,.05,0);const f=new tr(.08,.08,.08);f.translate(0,.04,0);const g=new zs;g.setAttribute("position",new Ps([0,0,0,1,0,0],3));const v=new _o(.0075,.0075,.5,3);function _(t,e){const i=new Uh(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}v.translate(0,.25,0);const y={X:[[new Qs(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new Qs(m,s),[-.5,0,0],[0,0,Math.PI/2]],[new Qs(v,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Qs(m,r),[0,.5,0]],[new Qs(m,r),[0,-.5,0],[Math.PI,0,0]],[new Qs(v,r)]],Z:[[new Qs(m,a),[0,0,.5],[Math.PI/2,0,0]],[new Qs(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Qs(v,a),null,[Math.PI/2,0,0]]],XYZ:[[new Qs(new Rh(.1,0),c),[0,0,0]]],XY:[[new Qs(new tr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Qs(new tr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},x={X:[[new Qs(new _o(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Qs(new _o(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Qs(new _o(.2,0,.6,4),i),[0,.3,0]],[new Qs(new _o(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Qs(new _o(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Qs(new _o(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Qs(new Rh(.2,0),i)]],XY:[[new Qs(new tr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Qs(new tr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},b={START:[[new Qs(new Rh(.01,2),n),null,null,null,"helper"]],END:[[new Qs(new Rh(.01,2),n),null,null,null,"helper"]],DELTA:[[new Ka(function(){const t=new zs;return t.setAttribute("position",new Ps([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new Ka(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ka(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ka(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},S={XYZE:[[new Qs(_(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new Qs(_(.5,.5),s)]],Y:[[new Qs(_(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new Qs(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Qs(_(.75,1),d),null,[0,Math.PI/2,0]]]},w={AXIS:[[new Ka(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new Qs(new Oh(.25,10,8),i)]],X:[[new Qs(new Uh(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Qs(new Uh(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Qs(new Uh(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Qs(new Uh(.75,.1,2,24),i)]]},T={X:[[new Qs(f,s),[.5,0,0],[0,0,-Math.PI/2]],[new Qs(v,s),[0,0,0],[0,0,-Math.PI/2]],[new Qs(f,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Qs(f,r),[0,.5,0]],[new Qs(v,r)],[new Qs(f,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Qs(f,a),[0,0,.5],[Math.PI/2,0,0]],[new Qs(v,a),[0,0,0],[Math.PI/2,0,0]],[new Qs(f,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Qs(new tr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Qs(new tr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Qs(new tr(.1,.1,.1),c)]]},E={X:[[new Qs(new _o(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Qs(new _o(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Qs(new _o(.2,0,.6,4),i),[0,.3,0]],[new Qs(new _o(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Qs(new _o(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Qs(new _o(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Qs(new tr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Qs(new tr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Qs(new tr(.2,.2,.2),i),[0,0,0]]]},A={X:[[new Ka(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ka(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ka(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(t){const e=new $n;for(const i in t)for(let n=t[i].length;n--;){const s=t[i][n][0].clone(),r=t[i][n][1],a=t[i][n][2],o=t[i][n][3],h=t[i][n][4];s.name=i,s.tag=h,r&&s.position.set(r[0],r[1],r[2]),a&&s.rotation.set(a[0],a[1],a[2]),o&&s.scale.set(o[0],o[1],o[2]),s.updateMatrix();const l=s.geometry.clone();l.applyMatrix4(s.matrix),s.geometry=l,s.renderOrder=1/0,s.position.set(0,0,0),s.rotation.set(0,0,0),s.scale.set(1,1,1),e.add(s)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(y)),this.add(this.gizmo.rotate=C(S)),this.add(this.gizmo.scale=C(T)),this.add(this.picker.translate=C(x)),this.add(this.picker.rotate=C(M)),this.add(this.picker.scale=C(E)),this.add(this.helper.translate=C(b)),this.add(this.helper.rotate=C(w)),this.add(this.helper.scale=C(A)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Im;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let s;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),s=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(s*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(Am.copy(Om).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(Am.copy(Nm).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(Am.copy(Um).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(Am.copy(Um).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(Am.copy(Om).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(Am.copy(Nm).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(Rm.copy(e),Am.copy(this.eye).applyQuaternion(pm.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(Lm.lookAt(this.eye,Cm,Nm)),"X"===n.name&&(pm.setFromAxisAngle(Om,Math.atan2(-Am.y,Am.z)),pm.multiplyQuaternions(Rm,pm),n.quaternion.copy(pm)),"Y"===n.name&&(pm.setFromAxisAngle(Nm,Math.atan2(Am.x,Am.z)),pm.multiplyQuaternions(Rm,pm),n.quaternion.copy(pm)),"Z"===n.name&&(pm.setFromAxisAngle(Um,Math.atan2(Am.y,Am.x)),pm.multiplyQuaternions(Rm,pm),n.quaternion.copy(pm)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(t){return n.name===t}))&&(n.material.color.copy(this.materialLib.active.color),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(pm.setFromEuler(Em.set(0,0,0)),n.quaternion.copy(e).multiply(pm),Math.abs(Am.copy(Om).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(pm.setFromEuler(Em.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(pm),Math.abs(Am.copy(Nm).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(pm.setFromEuler(Em.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(pm),Math.abs(Am.copy(Um).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(pm.setFromEuler(Em.set(0,Math.PI/2,0)),Am.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(Lm.lookAt(Cm,Am,Nm)),n.quaternion.multiply(pm),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),dm.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),dm.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(dm),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class Hm extends Qs{constructor(){super(new Ih(1e5,1e5,2,2),new Ss({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),Fm.copy(Om).applyQuaternion("local"===e?this.worldQuaternion:Im),Bm.copy(Nm).applyQuaternion("local"===e?this.worldQuaternion:Im),km.copy(Um).applyQuaternion("local"===e?this.worldQuaternion:Im),Am.copy(Bm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Am.copy(this.eye).cross(Fm),Pm.copy(Fm).cross(Am);break;case"Y":Am.copy(this.eye).cross(Bm),Pm.copy(Bm).cross(Am);break;case"Z":Am.copy(this.eye).cross(km),Pm.copy(km).cross(Am);break;case"XY":Pm.copy(km);break;case"YZ":Pm.copy(Fm);break;case"XZ":Am.copy(km),Pm.copy(Bm);break;case"XYZ":case"E":Pm.set(0,0,0)}break;default:Pm.set(0,0,0)}0===Pm.length()?this.quaternion.copy(this.cameraQuaternion):(Dm.lookAt(dm.set(0,0,0),Pm,Am),this.quaternion.setFromRotationMatrix(Dm)),super.updateMatrixWorld(t)}}class Vm extends Ka{constructor(t,e=1,i=16776960,n=new Li){const s=new zs;s.setAttribute("position",new Ps([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),s.computeBoundingSphere(),super(s,new Ha({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=n;const r=new zs;r.setAttribute("position",new Ps([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.helper=new Qs(r,new Ss({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(t){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(t)}}const Wm={type:"change"},jm={type:"start"},Xm={type:"end"},Ym=-1,qm=0,Zm=1,Km=2,Jm=3,Qm=4,$m=5,tf=6;class ef extends fi{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Li,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.DOLLY,RIGHT:x.PAN},this.touches={ONE:b.ROTATE,TWO:b.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",C),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",C),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(Wm),i.update(),i.state=Ym},this.update=function(){const e=new Li,a=(new Ci).setFromUnitVectors(t.up,new Li(0,1,0)),h=a.clone().invert(),l=new Li,c=new Ci,d=new Li,u=2*Math.PI;return function(){const t=i.object.position;e.copy(t).sub(i.target),e.applyQuaternion(a),s.setFromVector3(e),i.autoRotate&&i.state===Ym&&o(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(s.theta+=r.theta*i.dampingFactor,s.phi+=r.phi*i.dampingFactor):(s.theta+=r.theta,s.phi+=r.phi);let p=i.minAzimuthAngle,m=i.maxAzimuthAngle;return isFinite(p)&&isFinite(m)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),m<-Math.PI?m+=u:m>Math.PI&&(m-=u),s.theta=p<=m?Math.max(p,Math.min(m,s.theta)):s.theta>(p+m)/2?Math.max(p,s.theta):Math.min(m,s.theta)),s.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,s.phi)),s.makeSafe(),s.radius*=i.scale,s.radius=Math.max(i.minDistance,Math.min(i.maxDistance,s.radius)),!0===i.enableDamping?i.target.addScaledVector(i.panOffset,i.dampingFactor):i.target.add(i.panOffset),e.setFromSpherical(s),e.applyQuaternion(h),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(r.theta*=1-i.dampingFactor,r.phi*=1-i.dampingFactor,i.panOffset.multiplyScalar(1-i.dampingFactor)):(r.set(0,0,0),i.panOffset.set(0,0,0)),i.scale=1,!!(i.zoomChanged||l.distanceToSquared(i.object.position)>n||8*(1-c.dot(i.object.quaternion))>n||d.distanceToSquared(i.target)>0)&&(i.dispatchEvent(Wm),l.copy(i.object.position),c.copy(i.object.quaternion),d.copy(i.target),i.zoomChanged=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",L),i.domElement.removeEventListener("pointerdown",M),i.domElement.removeEventListener("pointercancel",E),i.domElement.removeEventListener("wheel",A),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",C),i._domElementKeyEvents=null)};const i=this;i.state=Ym;const n=1e-6,s=new Bc,r=new Bc;function a(){return Math.pow(.95,i.zoomSpeed)}function o(t){r.theta-=t}function h(t){r.phi-=t}i.scale=1,i.panOffset=new Li,i.zoomChanged=!1,i.rotateStart=new Ai,i.rotateEnd=new Ai,i.rotateDelta=new Ai,i.panStart=new Ai,i.panEnd=new Ai,i.panDelta=new Ai,i.dollyStart=new Ai,i.dollyEnd=new Ai,i.dollyDelta=new Ai,i.dollyScale=0,i.pointers=[],i.pointerPositions={};const l=function(){const t=new Li;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),i.panOffset.add(t)}}(),c=function(){const t=new Li;return function(e,n){!0===i.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),i.panOffset.add(t)}}(),d=function(){const t=new Li;return function(e,n){const s=i.domElement;if(i.object.isPerspectiveCamera){const r=i.object.position;t.copy(r).sub(i.target);let a=t.length();a*=Math.tan(i.object.fov/2*Math.PI/180),l(2*e*a/s.clientHeight,i.object.matrix),c(2*n*a/s.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(l(e*(i.object.right-i.object.left)/i.object.zoom/s.clientWidth,i.object.matrix),c(n*(i.object.top-i.object.bottom)/i.object.zoom/s.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function u(t){i.object.isPerspectiveCamera?i.scale/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function p(t){i.object.isPerspectiveCamera?i.scale*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function m(t){i.rotateStart.set(t.clientX,t.clientY)}function f(t){i.panStart.set(t.clientX,t.clientY)}function g(){if(1===i.pointers.length)i.rotateStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.rotateStart.set(t,e)}}function v(){if(1===i.pointers.length)i.panStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.panStart.set(t,e)}}function _(){const t=i.pointers[0].pageX-i.pointers[1].pageX,e=i.pointers[0].pageY-i.pointers[1].pageY,n=Math.sqrt(t*t+e*e);i.dollyStart.set(0,n)}function y(t){if(1==i.pointers.length)i.rotateEnd.set(t.pageX,t.pageY);else{const e=I(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);i.rotateEnd.set(n,s)}i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd)}function S(t){if(1===i.pointers.length)i.panEnd.set(t.pageX,t.pageY);else{const e=I(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);i.panEnd.set(n,s)}i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd)}function w(t){const e=I(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);i.dollyEnd.set(0,r),i.dollyDelta.set(0,Math.pow(i.dollyEnd.y/i.dollyStart.y,i.zoomSpeed)),u(i.dollyDelta.y),i.dollyStart.copy(i.dollyEnd)}function M(t){!1!==i.enabled&&(0===i.pointers.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",T),i.domElement.addEventListener("pointerup",E)),function(t){i.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(R(t),i.pointers.length){case 1:switch(i.touches.ONE){case b.ROTATE:if(!1===i.enableRotate)return;g(),i.state=Jm;break;case b.PAN:if(!1===i.enablePan)return;v(),i.state=Qm;break;default:i.state=Ym}break;case 2:switch(i.touches.TWO){case b.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&_(),i.enablePan&&v(),i.state=$m;break;case b.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&_(),i.enableRotate&&g(),i.state=tf;break;default:i.state=Ym}break;default:i.state=Ym}i.state!==Ym&&i.dispatchEvent(jm)}(t):function(t){let e;switch(t.button){case 0:e=i.mouseButtons.LEFT;break;case 1:e=i.mouseButtons.MIDDLE;break;case 2:e=i.mouseButtons.RIGHT;break;default:e=-1}switch(e){case x.DOLLY:if(!1===i.enableZoom)return;!function(t){i.dollyStart.set(t.clientX,t.clientY)}(t),i.state=Zm;break;case x.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;f(t),i.state=Km}else{if(!1===i.enableRotate)return;m(t),i.state=qm}break;case x.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;m(t),i.state=qm}else{if(!1===i.enablePan)return;f(t),i.state=Km}break;default:i.state=Ym}i.state!==Ym&&i.dispatchEvent(jm)}(t))}function T(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(R(t),i.state){case Jm:if(!1===i.enableRotate)return;y(t),i.update();break;case Qm:if(!1===i.enablePan)return;S(t),i.update();break;case $m:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&w(t),i.enablePan&&S(t)}(t),i.update();break;case tf:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&w(t),i.enableRotate&&y(t)}(t),i.update();break;default:i.state=Ym}}(t):function(t){switch(i.state){case qm:if(!1===i.enableRotate)return;!function(t){i.rotateEnd.set(t.clientX,t.clientY),i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd),i.update()}(t);break;case Zm:if(!1===i.enableZoom)return;!function(t){i.dollyEnd.set(t.clientX,t.clientY),i.dollyDelta.subVectors(i.dollyEnd,i.dollyStart),i.dollyDelta.y<0?(i.dollyScale=1/a(),u(a())):i.dollyDelta.y>0&&(i.dollyScale=a(),p(a())),i.dollyStart.copy(i.dollyEnd),i.update()}(t);break;case Km:if(!1===i.enablePan)return;!function(t){i.panEnd.set(t.clientX,t.clientY),i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd),i.update()}(t)}}(t))}function E(t){!function(t){delete i.pointerPositions[t.pointerId];for(let e=0;e<i.pointers.length;e++)if(i.pointers[e].pointerId==t.pointerId)return void i.pointers.splice(e,1)}(t),0===i.pointers.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E)),i.dispatchEvent(Xm),i.state=Ym}function A(t){!1!==i.enabled&&!1!==i.enableZoom&&i.state===Ym&&(t.preventDefault(),i.dispatchEvent(jm),function(t){i.dollyEnd.set(i.domElement.clientWidth/2,i.domElement.clientHeight/2),i.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(i.dollyScale=1/a(),p(a())):t.deltaY>0&&(i.dollyScale=a(),u(a())),i.dollyStart.copy(i.dollyEnd),i.update(),0!==t.deltaY&&(i.state=Zm,i.dispatchEvent(Wm),i.state=Ym)}(t),i.dispatchEvent(Xm))}function C(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?h(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?h(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function L(t){!1!==i.enabled&&t.preventDefault()}function R(t){let e=i.pointerPositions[t.pointerId];void 0===e&&(e=new Ai,i.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function I(t){const e=t.pointerId===i.pointers[0].pointerId?i.pointers[1]:i.pointers[0];return i.pointerPositions[e.pointerId]}i.domElement.addEventListener("contextmenu",L),i.domElement.addEventListener("pointerdown",M),i.domElement.addEventListener("pointercancel",E),i.domElement.addEventListener("wheel",A,{passive:!1}),this.update()}}class nf{constructor(t){this.updateControls=()=>{this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.updateControlsCamera=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.object=this.viewer.camera,this.orbit.update()},this.optionsChange=({data:t})=>{this.orbit.zoomSpeed=Math.abs(this.orbit.zoomSpeed)*(t.reverseZoomWheel?-1:1)},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case qm:case Jm:this.viewer.emitEvent({type:"orbit"});break;case Km:case Qm:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case Zm:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.viewer.emitEvent({type:"changecamera"}),this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new ef(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.PAN,RIGHT:x.PAN},this.orbit.touches={ONE:b.ROTATE,TWO:b.DOLLY_PAN},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=t,this.viewer.addEventListener("databasechunk",this.updateControls),this.viewer.addEventListener("clear",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.addEventListener("zoom",this.updateControls),this.viewer.addEventListener("drawviewpoint",this.updateControls),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("contextmenu",this.stopContextMenu),this.updateControls(),this.updateControlsCamera()}dispose(){this.viewer.removeEventListener("databasechunk",this.updateControls),this.viewer.removeEventListener("clear",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.removeEventListener("zoom",this.updateControls),this.viewer.removeEventListener("drawviewpoint",this.updateControls),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("start",this.controlsStart),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class sf extends nf{constructor(t,e,i){super(t),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=t=>{this.orbit.enabled=!t.value},this.updatePlaneSize=()=>{this.planeHelper.size=this.viewer.extents.getSize(new Li).length()||1,this.viewer.update()},this.updateTransformCamera=()=>{this.transform.camera=this.viewer.camera},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const n=t.extents.getSize(new Li).length()||1,s=t.extents.getCenter(new Li),r=-s.dot(e);this.plane=new ga(e,r),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new Vm(this.plane,n,i,s),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new $n,this.planeCenter.position.copy(s),this.viewer.helpers.add(this.planeCenter),this.transform=new ym(t.camera,t.canvas),this.transform.showX=!!e.x,this.transform.showY=!!e.y,this.transform.showZ=!!e.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform.getHelper()),this.viewer.addEventListener("explode",this.updatePlaneSize),this.viewer.addEventListener("show",this.updatePlaneSize),this.viewer.addEventListener("showall",this.updatePlaneSize),this.viewer.addEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.removeEventListener("explode",this.updatePlaneSize),this.viewer.removeEventListener("show",this.updatePlaneSize),this.viewer.removeEventListener("showall",this.updatePlaneSize),this.viewer.removeEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.getHelper().removeFromParent(),this.transform.detach(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class rf extends sf{constructor(t){super(t,new Li(1,0,0),16711680)}}class af extends sf{constructor(t){super(t,new Li(0,1,0),65280)}}class of extends sf{constructor(t){super(t,new Li(0,0,1),255)}}const hf={Meters:{name:"Meters",symbol:"m",scale:1},Centimeters:{name:"Centimeters",symbol:"cm",scale:.01},Millimeters:{name:"Millimeters",symbol:"mm",scale:.001},Feet:{name:"Feet",symbol:"ft",scale:.3048},Inches:{name:"Inches",symbol:"in",scale:.0254},Yards:{name:"Yards",symbol:"yd",scale:.9144},Kilometers:{name:"Kilometers",symbol:"km",scale:1e3},Miles:{name:"Miles",symbol:"mi",scale:1609.344},Micrometers:{name:"Micrometers",symbol:"µm",scale:1e-6},Mils:{name:"Mils",symbol:"mil",scale:254e-7},MicroInches:{name:"Micro-inches",symbol:"µin",scale:2.54e-8},Default:{name:"File units",symbol:"",scale:1}},lf={Default:{name:"",symbol:"",scale:1}};function cf(t,e,i){return i*(1/(lf[t]||lf.Default).scale)*((lf[e]||lf.Default).scale||1)}function df(t,e,i){let n=t.toFixed(e);return"Auto"===i&&(n=n.replace(/\.0+$/,"").replace(/\.$/,"")),+n!==t&&(n="~ "+n),n}function uf(t,e,i=2){let n;return n="Auto"===i?function(t){const e=Math.abs(t);return e>=1e3?0:e>=10?1:e>=.1?2:e>=.001?3:e>0?Math.floor(-Math.log10(e))+1:2}(t):Number.isFinite(i)?i:parseFloat(i),Number.isFinite(n)?n<0?n=0:n>10&&(n=10):n=2,lf[e]?df(t,n,i)+" "+lf[e].symbol:e?df(t,n,i)+" "+e:df(t,n,i)}Object.keys(hf).forEach(t=>lf[t]=hf[t]),Object.keys(hf).forEach(t=>lf[hf[t].symbol]=hf[t]);const pf=new Li,mf=new Li,ff=new Li,gf=new qc,vf=new Li,_f=new Li;class yf{constructor(t,e,i){this.camera=t,this.renderer=e,this.canvas=i,this.threshold=1e-4,this.raycaster=new Oc,this.detectRadiusInPixels=this.isMobile()?50:10,this.edgesCache=new WeakMap}isMobile(){return"undefined"!=typeof navigator&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t,e){const i=this.canvas.getBoundingClientRect(),n=(t.x-i.left)/i.width*2-1,s=-(t.y-i.top)/i.height*2+1,r=new Ai(n,s);this.raycaster.setFromCamera(r,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:this.threshold},Line2:{threshold:this.threshold},LOD:{},Points:{threshold:this.threshold},Sprite:{}};let a=this.raycaster.intersectObjects(e,!1);return(this.renderer.clippingPlanes||[]).forEach(t=>{a=a.filter(e=>t.distanceToPoint(e.point)>=0)}),a}getDetectRadius(t){const e=this.camera;if(e.isOrthographicCamera){const t=(e.top-e.bottom)/e.zoom/this.canvas.height;return this.detectRadiusInPixels*t}if(e.isPerspectiveCamera){const i=e.position.distanceTo(t),n=2*Math.tan(Ei.degToRad(.5*e.fov))*i/this.canvas.height;return this.detectRadiusInPixels*n}return.1}getSnapPoint(t,e){const i=this.getPointerIntersects(t,e);if(0===i.length)return;const n=i[0].object,s=i[0].point,r=n.worldToLocal(s.clone());let a,o=this.getDetectRadius(s);const h=n.geometry,l=h.attributes.position.array;for(let t=0;t<l.length;t+=3){pf.set(l[t],l[t+1],l[t+2]);const e=pf.distanceTo(r);e<o&&(o=e,a=pf.clone())}if(a)return n.localToWorld(a);let c=this.edgesCache.get(h);c||(c=new Eo(h),this.edgesCache.set(h,c));const d=c.attributes.position.array;for(let t=0;t<d.length;t+=6){mf.set(d[t],d[t+1],d[t+2]),ff.set(d[t+3],d[t+4],d[t+5]),gf.set(mf,ff),gf.getCenter(vf);const e=vf.distanceTo(r);if(e<o){o=e,a=vf.clone();continue}gf.closestPointToPoint(r,!0,_f);const i=_f.distanceTo(r);i<o&&(o=i,a=_f.clone())}return a?n.localToWorld(a):s.clone()}}const xf=new Ai;class bf extends nf{constructor(t){super(t),this.scale=1,this.units="",this.precision=2,this.onPointerDown=t=>{if(0!==t.button)return;const e=this.snapper.getMousePosition(t,xf);this.line.startPoint=this.snapper.getSnapPoint(e,this.objects),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint},this.onPointerMove=t=>{if(this.orbit.enabled&&-1!==this.orbit.state)return;const e=this.snapper.getMousePosition(t,xf),i=this.snapper.getSnapPoint(e,this.objects);i&&this.line.endPoint&&i.equals(this.line.endPoint)||(this.line.endPoint=i,this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>0?(this.line=new Mf(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)):(this.line.startPoint=void 0,this.line.endPoint=void 0,this.line.render()),this.viewer.canvas.releasePointerCapture(t.pointerId),this.orbit.enabled=!0},this.onPointerCancel=t=>{this.viewer.canvas.dispatchEvent(new PointerEvent("pointerup",t))},this.onPointerLeave=()=>{this.line.endPoint=void 0,this.line.render()},this.clearOverlay=()=>{this.overlay.clear(),this.line=new Mf(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)},this.renderOverlay=()=>{this.overlay.render()},this.updateObjects=()=>{this.objects.length=0,this.viewer.models.forEach(t=>{t.getVisibleObjects().forEach(t=>this.objects.push(t))})},this.updateSnapperCamera=()=>{this.snapper.camera=this.viewer.camera,this.overlay.camera=this.viewer.camera},this.updateUnits=()=>{var t,e;const i=this.viewer.models[0],n=null!==(t=this.viewer.options.rulerUnit)&&void 0!==t?t:"Default",s=null!==(e=this.viewer.options.rulerPrecision)&&void 0!==e?e:"Default";i?"Default"===n?(this.scale=i.getUnitScale(),this.units=i.getUnitString()):(this.scale=cf(i.getUnits(),n,1),this.units=n):(this.scale=1,this.units=""),this.precision=i?"Default"===s?i.getPrecision():s:2,this.overlay.updateLineUnits(this.scale,this.units,this.precision)},this.overlay=new Sf(t.camera,t.canvas),this.overlay.attach(),this.line=new Mf(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line);const e=this.viewer.extents.getSize(new Li).length()||1;this.snapper=new yf(t.camera,t.renderer,t.canvas),this.snapper.threshold=e/1e4,this.objects=[],this.updateObjects(),this.updateUnits(),this.viewer.canvas.addEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.addEventListener("pointermove",this.onPointerMove),this.viewer.canvas.addEventListener("pointerup",this.onPointerUp),this.viewer.canvas.addEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.addEventListener("pointerleave",this.onPointerLeave),this.viewer.addEventListener("render",this.renderOverlay),this.viewer.addEventListener("hide",this.updateObjects),this.viewer.addEventListener("isolate",this.updateObjects),this.viewer.addEventListener("show",this.updateObjects),this.viewer.addEventListener("showall",this.updateObjects),this.viewer.addEventListener("changecameramode",this.updateSnapperCamera),this.viewer.addEventListener("optionschange",this.updateUnits)}dispose(){this.viewer.canvas.removeEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.removeEventListener("pointermove",this.onPointerMove),this.viewer.canvas.removeEventListener("pointerup",this.onPointerUp),this.viewer.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.removeEventListener("pointerleave",this.onPointerLeave),this.viewer.removeEventListener("render",this.renderOverlay),this.viewer.removeEventListener("hide",this.updateObjects),this.viewer.removeEventListener("isolate",this.updateObjects),this.viewer.removeEventListener("show",this.updateObjects),this.viewer.removeEventListener("showall",this.updateObjects),this.viewer.removeEventListener("changecameramode",this.updateSnapperCamera),this.viewer.removeEventListener("optionschange",this.updateUnits),this.objects.length=0,this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class Sf{constructor(t,e){this.lines=[],this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this.canvas;i&&n&&(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.width=`${i}px`,this.container.style.height=`${n}px`)},this.camera=t,this.canvas=e,this.projector=new Nf(t,e),this.resizeObserver=new ResizeObserver(this.resizeContainer)}dispose(){this.clear()}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.position="absolute",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement&&(this.canvas.parentElement.appendChild(this.container),this.resizeObserver.observe(this.canvas))}detach(){this.resizeObserver.disconnect(),this.container.remove(),this.container=void 0}clear(){this.lines.forEach(t=>t.dispose()),this.lines.length=0}render(){this.projector.setFromCamera(this.camera),this.lines.forEach(t=>t.render())}update(){this.lines.forEach(t=>t.update())}addLine(t){this.lines.push(t)}removeLine(t){this.lines=this.lines.filter(e=>e!==t)}updateLineUnits(t,e,i){this.lines.forEach(n=>{n.scale=t,n.units=e,n.precision=i})}}const wf=new Li;class Mf{constructor(t,e,i,n){this.id=Ei.generateUUID(),this.size=10,this.lineWidth=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",boxShadow:"0 0 10px rgba(0,0,0,0.5)",color:"white",font:"1rem system-ui"},this.overlay=t,this.scale=e,this.units=i,this.precision=n,this.elementStartPoint=t.container.appendChild(document.createElement("div")),this.elementEndPoint=t.container.appendChild(document.createElement("div")),this.elementLine=t.container.appendChild(document.createElement("div")),this.elementLabel=t.container.appendChild(document.createElement("div")),this.update()}dispose(){this.elementStartPoint.remove(),this.elementEndPoint.remove(),this.elementLine.remove(),this.elementLabel.remove(),this.elementStartPoint=void 0,this.elementEndPoint=void 0,this.elementLine=void 0,this.elementLabel=void 0}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:i}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=i?"block":"none",this.elementStartPoint.style.left=`${e.x}px`,this.elementStartPoint.style.top=`${e.y}px`}else this.elementStartPoint.style.display="none";if(this.endPoint){const{point:e,visible:i}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=i?"block":"none",this.elementEndPoint.style.left=`${e.x}px`,this.elementEndPoint.style.top=`${e.y}px`}else this.elementEndPoint.style.display="none";if(this.startPoint&&this.endPoint){const{point1:e,point2:i,visible:n}=t.projectLine(this.startPoint,this.endPoint);i.sub(e);const s=i.angle(),r=i.length();this.elementLine.style.display=n?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${r}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${s}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){wf.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:i}=t.projectPoint(wf),n=this.getDistance();this.elementLabel.style.display=i&&n>0?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=uf(n,this.units,this.precision)}else this.elementLabel.style.display="none"}update(){this.elementStartPoint.id=`markup-dot-start-${this.id}`,this.elementStartPoint.style.position="absolute",this.elementStartPoint.style.zIndex="2",this.elementStartPoint.style.width=`${this.size}px`,this.elementStartPoint.style.height=`${this.size}px`,this.elementStartPoint.style.border=this.style.border,this.elementStartPoint.style.borderRadius=`${this.size}px`,this.elementStartPoint.style.background=this.style.background,this.elementStartPoint.style.boxShadow=this.style.boxShadow,this.elementStartPoint.style.transform="translate(-50%, -50%)",this.elementEndPoint.id=`markup-dot-end-${this.id}`,this.elementEndPoint.style.position="absolute",this.elementEndPoint.style.zIndex="2",this.elementEndPoint.style.width=`${this.size}px`,this.elementEndPoint.style.height=`${this.size}px`,this.elementEndPoint.style.border=this.style.border,this.elementEndPoint.style.borderRadius=`${this.size}px`,this.elementEndPoint.style.background=this.style.background,this.elementEndPoint.style.boxShadow=this.style.boxShadow,this.elementEndPoint.style.transform="translate(-50%, -50%)",this.elementLine.id=`markup-line-${this.id}`,this.elementLine.style.position="absolute",this.elementLine.style.zIndex="1",this.elementLine.style.height=`${this.lineWidth}px`,this.elementLine.style.background=this.style.background,this.elementLine.style.boxShadow=this.style.boxShadow,this.elementLine.style.transformOrigin=`0px ${this.lineWidth/2}px`,this.elementLabel.id=`markup-label-${this.id}`,this.elementLabel.style.position="absolute",this.elementLabel.style.zIndex="3",this.elementLabel.style.padding="2px",this.elementLabel.style.paddingInline="5px",this.elementLabel.style.borderRadius="5px",this.elementLabel.style.background=this.style.background,this.elementLabel.style.boxShadow=this.style.boxShadow,this.elementLabel.style.color=this.style.color,this.elementLabel.style.font=this.style.font,this.elementLabel.style.transform="translate(-50%, -50%)"}getDistance(){return this.startPoint.distanceTo(this.endPoint)/this.scale}}let Tf,Ef;const Af=new En,Cf=new En,Lf=new Li,Rf=new Yi,If=new Yi,Pf=new Ai,Df=new Ai,Of=new Ai;class Nf{constructor(t,e){this.camera=t,this.canvas=e}setFromCamera(t){this.camera=t,this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();Tf=t.width/2,Ef=t.height/2,Af.copy(this.camera.matrixWorldInverse),Cf.multiplyMatrices(this.camera.projectionMatrix,Af)}projectPoint(t){Lf.copy(t).applyMatrix4(Cf);const e=Lf.z>=-1&&Lf.z<=1;return Pf.x=(Lf.x+1)*Tf,Pf.y=(1-Lf.y)*Ef,{point:Pf,visible:e}}projectLine(t,e){let i;Rf.copy(t).applyMatrix4(Cf),If.copy(e).applyMatrix4(Cf);const n=Rf.z+Rf.w,s=If.z+If.w,r=-Rf.z+Rf.w,a=-If.z+If.w;if(n>=0&&s>=0&&r>=0&&a>=0)i=!0;else if(n<0&&s<0||r<0&&a<0)i=!1;else{let t=0,e=1;n<0?t=Math.max(t,n/(n-s)):s<0&&(e=Math.min(e,n/(n-s))),r<0?t=Math.max(t,r/(r-a)):a<0&&(e=Math.min(e,r/(r-a))),i=e>=t,i&&(Rf.lerp(If,t),If.lerp(Rf,1-e))}return Rf.multiplyScalar(1/Rf.w),If.multiplyScalar(1/If.w),Df.x=(Rf.x+1)*Tf,Df.y=(1-Rf.y)*Ef,Of.x=(If.x+1)*Tf,Of.y=(1-If.y)*Ef,{point1:Df,point2:Of,visible:i}}}class Uf extends nf{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.PAN,MIDDLE:x.PAN,RIGHT:x.PAN}}}class Ff extends pd{constructor(t,e,i){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SKIP_FRAMES=3,this.GROUND_FOLLOWING_SPEED=.4,this.LOOK_SPEED=.1,this.WALK_SPEED_DELIMITER=4,this.WHEEL_SPEED_DELIMITER=15e3,this.movementSpeed=.1,this.multiplier=3,this.groundFollowingSkippedFrames=0,this.moveWheel=0,this.mouseDragOn=!1,this._up=new Li,this._forward=new Li,this._sideways=new Li,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new Ai(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.camera=t,this.groundObjects=i,this.raycaster=new Oc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}},this.moveKeys=new Set,this.moveClock=new rc,this.quaternion=t.quaternion.clone(),this.downPosition=new Ai(0,0),this.rotateDelta=new Ai(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}updateGroundFollowing(){this._up.copy(this.camera.up).negate(),this.raycaster.set(this.object.position,this._up);const t=this.raycaster.intersectObjects(this.groundObjects,!1);if(t.length>0){const e=t[0].point.y+this.EYE_HEIGHT;this.object.position.y=Ei.lerp(this.object.position.y,e,this.GROUND_FOLLOWING_SPEED)}}update(){let t=!1,e=!1;const i=this._forward,n=this._sideways;if(this.moveKeys.size>0){e=!0;const s=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),n.setFromMatrixColumn(this.object.matrix,0),n.y=0,n.normalize(),this.moveKeys.has("KeyW")&&this.object.position.addScaledVector(i,s),this.moveKeys.has("KeyS")&&this.object.position.addScaledVector(i,-s),this.moveKeys.has("KeyA")&&this.object.position.addScaledVector(n,-s),this.moveKeys.has("KeyD")&&this.object.position.addScaledVector(n,s),this.moveKeys.has("KeyQ")&&(this.object.translateY(s),e=!1),this.moveKeys.has("KeyE")&&(this.object.translateY(-s),e=!1);const r=this.LOOK_SPEED+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,-r/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,r/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new Ai(r,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new Ai(-r,0))),this.moveWheel=0,t=!0}if(0!==this.moveWheel){const e=this.moveWheel*this.multiplier*this.movementSpeed/this.WHEEL_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),this.object.position.addScaledVector(i,-e),this.moveWheel+=-1*Math.sign(this.moveWheel),t=!0}this.groundFollowingSkippedFrames++,e&&this.groundFollowingSkippedFrames>=this.GROUND_FOLLOWING_SKIP_FRAMES&&(this.groundFollowingSkippedFrames=0,this.updateGroundFollowing()),t&&this.dispatchEvent({type:"change"}),0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new Ci;n.setFromAxisAngle(this.object.up,e);const s=new Ci;s.setFromAxisAngle(new Li(1,0,0),i);const r=this.quaternion.clone();r.premultiply(n).multiply(s).normalize(),this.object.setRotationFromQuaternion(r)}}class Bf extends pd{constructor(t,e,i,n){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SPEED=.05,this.WALK_SPEED_DELIMITER=4,this.movementSpeed=.1,this.multiplier=3,this.isActive=!1,this.MAX_JOYSTICK_DISTANCE=100,this.INTERNAL_RADIUS=35,this.MAX_MOVE_STICK=40,this.EXTERNAL_RADIUS=65,this.CANVAS_SIZE=200,this.pressed=!1,this.onPointerDown=t=>{t.preventDefault(),this.pressed=!0},this.onPointerMove=t=>{if(t.preventDefault(),!this.pressed)return;let e=t.pageX,i=t.pageY;this.joyStickCanvas.offsetParent&&"BODY"===this.joyStickCanvas.offsetParent.tagName.toUpperCase()?(e-=this.joyStickCanvas.offsetLeft,i-=this.joyStickCanvas.offsetTop):this.joyStickCanvas.offsetParent&&(e-=this.joyStickCanvas.offsetParent.offsetLeft,i-=this.joyStickCanvas.offsetParent.offsetTop);const n=(e-this.centerX)/this.MAX_MOVE_STICK*100,s=(i-this.centerY)/this.MAX_MOVE_STICK*100*-1;Math.sqrt(n*n+s*s)>20?(this.joyStickPosition.set(n,s),this.isActive=!0):(this.joyStickPosition.set(0,0),this.isActive=!1),this.draw(),this.moveClock.start(),this.update()},this.onPointerUp=t=>{t.preventDefault(),this.pressed=!1,this.joyStickPosition.set(0,0),this.isActive=!1,this.moveClock.stop(),this.draw()},this.onResize=()=>{this.updateVisibility(),this.updatePosition()},this.camera=t,this.canvas=i,this.moveClock=new rc(!1),this.joyStickPosition=new Ai(0,0),this.groundObjects=n,this.raycaster=new Oc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.centerX=this.CANVAS_SIZE/2,this.centerY=this.CANVAS_SIZE/2,this.overlayElement=document.createElement("div"),this.overlayElement.id="joyStickDiv",this.overlayElement.style.background="rgba(0,0,0,0)",this.overlayElement.style.position="fixed",this.overlayElement.style.zIndex="0",this.overlayElement.style.touchAction="none",i.parentElement.appendChild(this.overlayElement),this.joyStickCanvas=document.createElement("canvas"),this.joyStickCanvas.id="joyStickCanvas",this.joyStickCanvas.width=this.CANVAS_SIZE,this.joyStickCanvas.height=this.CANVAS_SIZE,this.overlayElement.appendChild(this.joyStickCanvas),this.context=this.joyStickCanvas.getContext("2d"),this.joyStickCanvas.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),window.addEventListener("resize",this.onResize),document.addEventListener("fullscreenchange",this.onResize),this.updateVisibility(),this.updatePosition(),this.draw()}dispose(){this.joyStickCanvas.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("resize",this.onResize),document.removeEventListener("fullscreenchange",this.onResize),this.overlayElement.remove(),super.dispose()}updateVisibility(){const t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),e=window.innerWidth<1024;this.overlayElement.style.display=t||e?"block":"none"}updatePosition(){const t=this.canvas.getBoundingClientRect();this.overlayElement.style.top=t.height-this.CANVAS_SIZE+"px",this.overlayElement.style.left=`${t.left}px`,this.overlayElement.style.width=`${this.CANVAS_SIZE}px`,this.overlayElement.style.height=`${this.CANVAS_SIZE}px`}draw(){this.context.clearRect(0,0,this.CANVAS_SIZE,this.CANVAS_SIZE),this.context.beginPath(),this.context.arc(this.centerX,this.centerY,this.EXTERNAL_RADIUS,0,2*Math.PI,!1),this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.stroke();let t=this.centerX+this.joyStickPosition.x*this.MAX_MOVE_STICK/100,e=this.centerY-this.joyStickPosition.y*this.MAX_MOVE_STICK/100;t=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,t)),e=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,e)),this.context.beginPath(),this.context.arc(t,e,this.INTERNAL_RADIUS,0,2*Math.PI,!1),this.context.fillStyle="#35436E",this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.fill(),this.context.stroke()}updateGroundFollowing(){const t=(new Li).copy(this.camera.up);this.raycaster.set(this.camera.position,t.negate()),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}};const e=this.raycaster.intersectObjects(this.groundObjects,!1);if(e.length>0){const t=e[0].point.y+this.EYE_HEIGHT;this.camera.position.y=Ei.lerp(this.camera.position.y,t,this.GROUND_FOLLOWING_SPEED)}}update(){if(!this.isActive)return;const t=this.joyStickPosition.y/this.MAX_JOYSTICK_DISTANCE,e=this.joyStickPosition.x/this.MAX_JOYSTICK_DISTANCE,i=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER,n=new Li,s=new Li;this.camera.getWorldDirection(n),this.groundObjects.length>0&&(n.y=0),n.normalize(),s.setFromMatrixColumn(this.camera.matrix,0),this.groundObjects.length>0&&(s.y=0),s.normalize(),0!==t&&this.camera.position.addScaledVector(n,i*t),0!==e&&this.camera.position.addScaledVector(s,i*e),0===t&&0===e||(this.groundObjects.length>0&&this.updateGroundFollowing(),this.dispatchEvent({type:"change"}))}}class kf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Li);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2||1,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.walkspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.animate=()=>{this.controls.update()};const e=[];t.models.forEach(t=>t.getVisibleObjects().forEach(t=>{t instanceof Qs&&e.push(t)})),this.controls=new Ff(t.camera,t.canvas,e),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.joyStickControls=new Bf(t.camera,t.canvas,t.canvas,e),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("animate",this.animate),this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("animate",this.animate),this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class zf extends pd{constructor(t,e){super(t,e),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new Ai(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.moveKeys=new Set,this.moveClock=new rc,this.quaternion=t.quaternion.clone(),this.downPosition=new Ai(0,0),this.rotateDelta=new Ai(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}update(){if(this.moveKeys.size>0){const t=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.object.translateZ(-t),this.moveKeys.has("KeyS")&&this.object.translateZ(t),this.moveKeys.has("KeyA")&&this.object.translateX(-t),this.moveKeys.has("KeyD")&&this.object.translateX(t),this.moveKeys.has("KeyQ")&&this.object.translateY(t),this.moveKeys.has("KeyE")&&this.object.translateY(-t);const e=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new Ai(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new Ai(-e,0))),this.moveWheel=0,this.dispatchEvent({type:"change"})}if(0!==this.moveWheel){const t=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.object.translateZ(-t),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent({type:"change"})}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new Ci;n.setFromAxisAngle(this.object.up,e);const s=new Ci;s.setFromAxisAngle(new Li(1,0,0),i);const r=this.quaternion.clone();r.premultiply(n).multiply(s).normalize(),this.object.setRotationFromQuaternion(r)}}class Gf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Li);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2||1,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.flyspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.animate=()=>{this.controls.update()},this.controls=new zf(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("flyspeedchange",this.flyspeedChange),this.joyStickControls=new Bf(t.camera,t.canvas,t.canvas,[]),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("animate",this.animate),this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("animate",this.animate),this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("flyspeedchange",this.flyspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class Hf extends nf{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.DOLLY,MIDDLE:x.PAN,RIGHT:x.PAN}}}const Vf=a("threejs");function Wf(t,e=0){t.models.forEach(t=>t.explode(e)),t.update(),t.emitEvent({type:"explode",data:e})}function jf(t,e){if(e.isEmpty())return;const i=e.getCenter(new Li),n=e.getSize(new Li).length()||1,s=t.renderer.getSize(new Ai),r=s.x/s.y,a=t.camera;if(a.isPerspectiveCamera){const t=new Li(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(n/(2*Math.tan(Ei.degToRad(.5*a.fov))));a.position.copy(t).add(i),a.updateMatrixWorld()}if(a.isOrthographicCamera){a.top=n/2,a.bottom=-n/2,a.left=a.bottom*r,a.right=a.top*r,a.zoom=1,a.updateProjectionMatrix();const e=new Li(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(t.extents.getSize(new Li).length()||1);a.position.copy(e).add(i),a.updateMatrixWorld()}t.target.copy(i),t.update(),t.emitEvent({type:"zoom"})}Vf.registerDragger("Pan",t=>new Uf(t)),Vf.registerDragger("Orbit",t=>new nf(t)),Vf.registerDragger("Zoom",t=>new Hf(t)),Vf.registerDragger("MeasureLine",t=>new bf(t)),Vf.registerDragger("CuttingPlaneXAxis",t=>new rf(t)),Vf.registerDragger("CuttingPlaneYAxis",t=>new af(t)),Vf.registerDragger("CuttingPlaneZAxis",t=>new of(t)),Vf.registerDragger("Walk",t=>new kf(t)),Vf.registerDragger("Fly",t=>new Gf(t));const Xf={front:new Li(0,0,-1),back:new Li(0,0,1),left:new Li(1,0,0),right:new Li(-1,0,0),bottom:new Li(0,-1,0),top:new Li(0,1,0),se:new Li(-1,1,-1).normalize(),sw:new Li(1,1,-1).normalize(),ne:new Li(-1,1,1).normalize(),nw:new Li(1,1,1).normalize()};function Yf(t,e="sw"){const i=t.extents.getCenter(new Li),n=t.extents.getSize(new Li).length()||1,s=new Li(0,1,0),r=Xf[e]||Xf.sw,a=(new Li).copy(t.camera.up),o=(new Ci).setFromUnitVectors(s,a),h=(new Li).copy(r).applyQuaternion(o),l=t.camera;l.position.copy(h).multiplyScalar(n).add(i),l.lookAt(i),l.updateMatrixWorld(),t.target.copy(i),t.update(),t.emit({type:"viewposition",data:e}),jf(t,t.extents)}const qf=n("threejs");qf.registerCommand("applyModelTransform",function(t,e){console.warn("applyModelTransform not implemented")}),qf.registerCommand("clearMarkup",function(t){t.clearOverlay()}),qf.registerCommand("clearSelected",function(t){t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),qf.registerCommand("clearSlices",function(t){t.clearSlices()}),qf.registerCommand("collect",function(t){Wf(t,0)}),qf.registerCommand("getSnapshot",function(t,e,i){var n,s;t.update(!0);const r=null!==(n=null!=e?e:t.options.snapshotMimeType)&&void 0!==n?n:"image/jpeg",a=null!==(s=null!=i?i:t.options.snapshotQuality)&&void 0!==s?s:.25;return t.markup?t.markup.getSnapshot(r,a):t.canvas.toDataURL(r,a)}),qf.registerCommand("explode",Wf),qf.registerCommand("getDefaultViewPositions",function(){return Object.keys(Xf)}),qf.registerCommand("getModels",function(t){return t.models.map(t=>t.id)}),qf.registerCommand("getSelected",function(t){return t.executeCommand("getSelected2").map(t=>t.slice(t.indexOf(":")+1))}),qf.registerCommand("getSelected2",function(t){const e=[];return t.models.forEach(i=>{e.push(i.getHandlesByObjects(t.selected))}),e.flat()}),qf.registerCommand("hideSelected",function(t){t.models.forEach(e=>e.hideObjects(t.selected)),t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),qf.registerCommand("isolateSelected",function(t){t.models.forEach(e=>e.isolateObjects(t.selected)),t.update(),t.emitEvent({type:"isolate"})}),qf.registerCommand("regenerateAll",function(t){t.emit({type:"regenerateall"})}),qf.registerCommand("resetView",function(t){t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.emit({type:"resetview"})}),qf.registerCommand("selectModel",function(t,e){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.filter(t=>t.id===e).forEach(t=>i.select(t.getObjects(),t)),t.update(),t.emitEvent({type:"select",handles:t.getSelected()}),t.emitEvent({type:"select2",handles:t.getSelected2()})}),qf.registerCommand("setActiveDragger",function(t,e=""){t.setActiveDragger(e)}),qf.registerCommand("setDefaultViewPosition",Yf),qf.registerCommand("setMarkupColor",function(t,e=255,i=0,n=0){t.markup.setMarkupColor(e,i,n)}),qf.registerCommand("setSelected",function(t,e=[]){const i=[];e.forEach(e=>{e.includes(":")?i.push(e):t.models.forEach(t=>{i.push(`${t.id}:${e}`)})}),t.executeCommand("setSelected2",i)}),qf.registerCommand("setSelected2",function(t,e=[]){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.forEach(t=>{const n=t.getObjectsByHandles(e);t.showObjects(n),i.select(n,t)}),t.update(),t.emitEvent({type:"show"}),t.emitEvent({type:"select",data:void 0,handles:t.getSelected()}),t.emitEvent({type:"select2",data:void 0,handles:e})}),qf.registerCommand("showAll",function(t){t.models.forEach(t=>t.showAllObjects()),t.update(),t.emitEvent({type:"showall"})}),qf.registerCommand("zoomToExtents",function(t){jf(t,t.extents)}),qf.registerCommand("zoomToObjects",function(t,e=[]){const i=new Qi;t.models.forEach(t=>{t.getObjectsByHandles(e).forEach(t=>i.expandByObject(t))}),i.isEmpty()&&i.copy(t.extents),jf(t,i)}),qf.registerCommand("zoomToSelected",function(t){const e=new Qi;t.selected.forEach(t=>e.expandByObject(t)),e.isEmpty()&&e.copy(t.extents),jf(t,e)}),qf.registerCommand("top",t=>Yf(t,"top")),qf.registerCommand("bottom",t=>Yf(t,"bottom")),qf.registerCommand("left",t=>Yf(t,"left")),qf.registerCommand("right",t=>Yf(t,"right")),qf.registerCommand("front",t=>Yf(t,"front")),qf.registerCommand("back",t=>Yf(t,"back")),qf.registerCommand("sw",t=>Yf(t,"sw")),qf.registerCommand("se",t=>Yf(t,"se")),qf.registerCommand("ne",t=>Yf(t,"ne")),qf.registerCommand("nw",t=>Yf(t,"nw")),qf.registerCommandAlias("clearMarkup","clearOverlay"),qf.registerCommandAlias("clearSelected","unselect"),qf.registerCommandAlias("getSnapshot","createPreview"),qf.registerCommandAlias("zoomToExtents","zoomExtents"),qf.registerCommandAlias("top","k3DViewTop"),qf.registerCommandAlias("bottom","k3DViewBottom"),qf.registerCommandAlias("left","k3DViewLeft"),qf.registerCommandAlias("right","k3DViewRight"),qf.registerCommandAlias("front","k3DViewFront"),qf.registerCommandAlias("back","k3DViewBack"),qf.registerCommandAlias("se","k3DViewSE"),qf.registerCommandAlias("sw","k3DViewSW"),qf.registerCommandAlias("ne","k3DViewNE"),qf.registerCommandAlias("nw","k3DViewNW");class Zf{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215),this.viewer.renderer.setClearColor(this.backgroundColor)},this.viewer=t,this.backgroundColor=new _s(16777215),this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.addEventListener("optionschange",this.syncOptions)}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.background=void 0}}class Kf{constructor(t){this.optionsChange=()=>{this.switchCameraMode(this.viewer.options.cameraMode)},this.geometryEnd=()=>{if(this.viewer.models.length>1)return void this.switchCamera(this.viewer.camera);let t;if(this.viewer.scene.traverse(e=>{e.isCamera&&(t?e.isPerspectiveCamera&&t.isOrthographicCamera&&(t=e):t=e)}),t){t.isDefaultCamera=!0,t.scale.set(1,1,1),this.switchCamera(t);const e=this.getCameraMode(t);this.viewer.options.cameraMode=e,this.viewer.emitEvent({type:"changecameramode",mode:e})}else this.switchCamera(this.viewer.camera),this.viewer.executeCommand("setDefaultViewPosition")},this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("initialize",this.optionsChange)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("initialize",this.optionsChange)}getCameraMode(t){return t.isOrthographicCamera?"orthographic":"perspective"}switchCamera(t){const e=this.viewer.extents.getSize(new Li).length()||1,i=this.viewer.renderer.getSize(new Ai),n=i.x/i.y;t.isPerspectiveCamera&&(t.aspect=n,t.near=e/1e3,t.far=1e3*e),t.isOrthographicCamera&&(t.left=t.bottom*n,t.right=t.top*n,t.near=1e3*-e,t.far=1e3*e),t.updateProjectionMatrix(),this.viewer.camera=t,this.viewer.renderPass.camera=t,this.viewer.helpersPass.camera=t,this.viewer.ssaaRenderPass.camera=t,this.viewer.update()}switchCameraMode(t){if(!t)return;const e=this.viewer.camera;if(t===this.getCameraMode(e))return;const i=this.viewer.target.clone();let n;if(e.isOrthographicCamera){const t=e.userData.fov||45,s=(e.top-e.bottom)/e.zoom/(2*Math.tan(Ei.degToRad(t)/2)),r=(new Li).subVectors(e.position,i).normalize();n=new cr(t),n.position.copy(r).multiplyScalar(s).add(i)}if(e.isPerspectiveCamera){const t=e.fov,s=e.position.distanceTo(i),r=2*Math.tan(Ei.degToRad(.5*t))*s;n=new Bl,n.top=r/2,n.bottom=-r/2,n.position.copy(e.position),n.userData.fov=t}n&&(n.up.copy(e.up),n.quaternion.copy(e.quaternion),this.switchCamera(n),this.viewer.emitEvent({type:"changecameramode",mode:t}))}}class Jf{constructor(t){this.syncExtents=t=>{const e=new Qi;this.viewer.models.forEach(t=>t.getExtents(e)),this.viewer.extents.copy(e),"databasechunk"!==t.type&&"clear"!==t.target||this.viewer.models.length>1||this.viewer.extents.getCenter(this.viewer.target)},this.viewer=t,this.viewer.addEventListener("databasechunk",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents),this.viewer.on("hide",this.syncExtents),this.viewer.on("isolate",this.syncExtents),this.viewer.on("show",this.syncExtents),this.viewer.on("showall",this.syncExtents)}dispose(){this.viewer.removeEventListener("databasechunk",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents),this.viewer.off("hide",this.syncExtents),this.viewer.off("isolate",this.syncExtents),this.viewer.off("show",this.syncExtents),this.viewer.off("showall",this.syncExtents)}}class Qf{constructor(t){this.geometryEnd=()=>{if(this.ambientLight.removeFromParent(),this.directionalLight.removeFromParent(),this.frontLight.removeFromParent(),this.hemisphereLight.removeFromParent(),this.viewer.extents.isEmpty())return;const t=this.viewer.extents.getCenter(new Li),e=this.viewer.extents.getSize(new Li).length()||1,i=new Li(0,1,0),n=new Li(0,0,-1),s=(new Li).copy(this.viewer.camera.up),r=(new Ci).setFromUnitVectors(i,s),a=(new Li).copy(n).applyQuaternion(r).negate();this.directionalLight.position.copy(s).applyAxisAngle(a,30*-Math.PI/180).multiplyScalar(e).add(t),this.directionalLight.target.position.copy(t),this.frontLight.position.copy(a).multiplyScalar(e).add(t),this.frontLight.target.position.copy(t),this.hemisphereLight.position.copy(a).multiplyScalar(1.5*e).add(t),this.viewer.scene.add(this.ambientLight),this.viewer.scene.add(this.directionalLight),this.viewer.scene.add(this.frontLight),this.viewer.scene.add(this.hemisphereLight)},this.viewer=t,this.ambientLight=new Gl(16777215,1.5),this.directionalLight=new zl(16777215,1),this.frontLight=new zl(16777215,1.25),this.hemisphereLight=new Ll(16777215,4473924,1.25),this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("clear",this.geometryEnd)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight.dispose(),this.directionalLight.removeFromParent(),this.directionalLight.dispose(),this.frontLight.removeFromParent(),this.frontLight.dispose(),this.hemisphereLight.removeFromParent(),this.hemisphereLight.dispose(),this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("clear",this.geometryEnd)}}class $f{constructor(t){this.initialize=()=>{try{const t=this.viewer.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");e&&(this.viewer.info.system.webglRenderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL),this.viewer.info.system.webglVendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL))}catch(t){console.error("Error reading WebGL info.",t)}console.log("THREE.WebGLRenderer:",y),console.log("WebGL Renderer:",this.viewer.info.system.webglRenderer),console.log("WebGL Vendor:",this.viewer.info.system.webglVendor),this.resize(),this.optionsChange({data:this.viewer.options})},this.clear=()=>{this.viewer.info.performance.timeToFirstRender=0,this.viewer.info.performance.loadTime=0,this.viewer.info.scene.objects=0,this.viewer.info.scene.triangles=0,this.viewer.info.scene.points=0,this.viewer.info.scene.lines=0,this.viewer.info.scene.edges=0,this.viewer.info.optimizedScene.objects=0,this.viewer.info.optimizedScene.triangles=0,this.viewer.info.optimizedScene.points=0,this.viewer.info.optimizedScene.lines=0,this.viewer.info.optimizedScene.edges=0,this.viewer.info.memory.geometries=0,this.viewer.info.memory.geometryBytes=0,this.viewer.info.memory.textures=0,this.viewer.info.memory.textureBytes=0,this.viewer.info.memory.materials=0,this.viewer.info.memory.totalEstimatedGpuBytes=0,this.viewer.info.memory.usedJSHeapSize=0},this.optionsChange=({data:t})=>{!1===t.antialiasing?this.viewer.info.render.antialiasing="":!0===t.antialiasing?this.viewer.info.render.antialiasing="mxaa":this.viewer.info.render.antialiasing=t.antialiasing},this.geometryStart=()=>{this.startTime=performance.now()},this.databaseChunk=()=>{this.viewer.info.performance.timeToFirstRender+=performance.now()-this.startTime,console.log("Time to first render:",this.viewer.info.performance.timeToFirstRender,"ms")},this.geometryEnd=()=>{const t=this.viewer.models[this.viewer.models.length-1].getInfo();this.viewer.info.scene.objects+=t.scene.objects,this.viewer.info.scene.triangles+=t.scene.triangles,this.viewer.info.scene.points+=t.scene.points,this.viewer.info.scene.lines+=t.scene.lines,this.viewer.info.scene.edges+=t.scene.edges,this.viewer.info.optimizedScene.objects+=t.optimizedScene.objects,this.viewer.info.optimizedScene.triangles+=t.optimizedScene.triangles,this.viewer.info.optimizedScene.points+=t.optimizedScene.points,this.viewer.info.optimizedScene.lines+=t.optimizedScene.lines,this.viewer.info.optimizedScene.edges+=t.optimizedScene.edges,this.viewer.info.memory.geometries+=t.memory.geometries,this.viewer.info.memory.geometryBytes+=t.memory.geometryBytes,this.viewer.info.memory.textures+=t.memory.textures,this.viewer.info.memory.textureBytes+=t.memory.textureBytes,this.viewer.info.memory.materials+=t.memory.materials,this.viewer.info.memory.totalEstimatedGpuBytes+=t.memory.totalEstimatedGpuBytes;const e=performance.memory;e&&(this.viewer.info.memory.usedJSHeapSize=e.usedJSHeapSize),this.viewer.info.performance.loadTime+=performance.now()-this.startTime,console.log("Number of objects:",t.scene.objects),console.log("Number of objects after optimization:",t.optimizedScene.objects),console.log("Total geometry size:",t.memory.totalEstimatedGpuBytes/1048576,"MB"),console.log("File load time:",this.viewer.info.performance.loadTime,"ms")},this.resize=()=>{const{width:t,height:e}=this.viewer.canvas;this.viewer.info.render.viewport.width=t,this.viewer.info.render.viewport.height=e},this.render=()=>{this.viewer.info.render.drawCalls=this.viewer.renderer.info.render.calls,this.viewer.info.render.triangles=this.viewer.renderer.info.render.triangles,this.viewer.info.render.points=this.viewer.renderer.info.render.points,this.viewer.info.render.lines=this.viewer.renderer.info.render.lines},this.animate=()=>{const t=performance.now();this.viewer.info.performance.frameTime=Math.round(t-this.beginTime),this.beginTime=t,this.frames++,t-this.prevTime>=1e3&&(this.viewer.info.performance.fps=Math.round(1e3*this.frames/(t-this.prevTime)),this.prevTime=t,this.frames=0)},this.viewer=t,this.startTime=0,this.beginTime=performance.now(),this.prevTime=performance.now(),this.frames=0,this.viewer.addEventListener("initialize",this.initialize),this.viewer.addEventListener("clear",this.clear),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("geometrystart",this.geometryStart),this.viewer.addEventListener("databasechunk",this.databaseChunk),this.viewer.addEventListener("geometryend",this.geometryEnd),this.viewer.addEventListener("resize",this.resize),this.viewer.addEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}dispose(){this.viewer.removeEventListener("initialize",this.initialize),this.viewer.removeEventListener("clear",this.clear),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("geometrystart",this.geometryStart),this.viewer.removeEventListener("databasechunk",this.databaseChunk),this.viewer.removeEventListener("geometryend",this.geometryEnd),this.viewer.removeEventListener("resize",this.resize),this.viewer.removeEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}}class tg{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this.viewer.setSize(e,i)},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class eg{constructor(t){this.cleanupViewer=t=>{for(const e of t)if("childList"===e.type&&e.removedNodes.length>0)for(const t of e.removedNodes)if(t===this.viewer.canvas||t.contains(this.viewer.canvas))return this.viewer.emitEvent({type:"canvasremoved"}),void this.viewer.dispose()},this.viewer=t,this.mutationObserver=new MutationObserver(this.cleanupViewer),this.mutationObserver.observe(document,{childList:!0,subtree:!0})}dispose(){this.mutationObserver.disconnect(),this.mutationObserver=void 0}}class ig{constructor(t){this.animate=t=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.requestId=requestAnimationFrame(this.animate)}dispose(){cancelAnimationFrame(this.requestId)}}const ng=new Qi,sg=new Li;class rg extends Yl{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new Ps([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new Ps([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new Pc(e,6,1);return this.setAttribute("instanceStart",new wr(i,3,0)),this.setAttribute("instanceEnd",new wr(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new Pc(e,6,1);return this.setAttribute("instanceColorStart",new wr(i,3,0)),this.setAttribute("instanceColorEnd",new wr(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new kh(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Qi);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),ng.setFromBufferAttribute(e),this.boundingBox.union(ng))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new vn),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let s=0,r=t.count;s<r;s++)sg.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(sg)),sg.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(sg));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}_d.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Ai(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},yd.line={uniforms:sr.merge([_d.common,_d.fog,_d.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class ag extends rr{constructor(t){super({type:"LineMaterial",uniforms:sr.clone(yd.line.uniforms),vertexShader:yd.line.vertexShader,fragmentShader:yd.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const og=new Li,hg=new Li,lg=new Yi;class cg extends Qs{constructor(t=new rg,e=new ag({color:16777215*Math.random()})){super(t,e),this.isWireframe=!0,this.type="Wireframe"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*e.count);for(let t=0,s=0,r=e.count;t<r;t++,s+=2)og.fromBufferAttribute(e,t),hg.fromBufferAttribute(i,t),n[s]=0===s?0:n[s-1],n[s+1]=n[s]+og.distanceTo(hg);const s=new Pc(n,2,1);return t.setAttribute("instanceDistanceStart",new wr(s,1,0)),t.setAttribute("instanceDistanceEnd",new wr(s,1,1)),this}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(lg),this.material.uniforms.resolution.value.set(lg.z,lg.w))}}class dg{static isBreak(t,e){return isNaN(t[e])||isNaN(t[e+1])||isNaN(t[e+2])||t[e]===1/0||t[e]===-1/0||t[e+1]===1/0||t[e+1]===-1/0||t[e+2]===1/0||t[e+2]===-1/0}static fromIndexedLine(t,e){const i=new rg,n=[];for(let i=0;i<e.length;i+=2){const s=3*e[i],r=3*e[i+1];-1!==e[i]&&-1!==e[i+1]&&n.push(t[s],t[s+1],t[s+2],t[r],t[r+1],t[r+2])}return 0===n.length?null:(i.setPositions(n),i)}static fromNonIndexedLine(t,e){const i=new rg,n=[];if(e)for(let e=0;e<t.length&&!(e+5>=t.length);e+=6)dg.isBreak(t,e)||dg.isBreak(t,e+3)||n.push(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else{let e=-1;for(let i=0;i<t.length;i+=3)dg.isBreak(t,i)?e=-1:(-1!==e&&n.push(t[e],t[e+1],t[e+2],t[i],t[i+1],t[i+2]),e=i)}return 0===n.length?null:(i.setPositions(n),i)}}class ug{constructor(t){this.geometryEnd=()=>{this.facesMaterial=new Xh({transparent:!0,specular:2236962,shininess:10,reflectivity:.05,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),this.edgesMaterial=new ag({linewidth:1.5,resolution:new Ai(window.innerWidth,window.innerHeight)}),this.lineMaterial=new Ha({transparent:!0,depthTest:!0,depthWrite:!0}),this.lineGlowMaterial=new ag({linewidth:1.5,transparent:!0,opacity:.8,resolution:new Ai(window.innerWidth,window.innerHeight)}),this.syncHighlightColors()},this.optionsChange=()=>{this.syncHighlightColors(),this.viewer.update()},this.viewer=t;if(t.canvas.getContext("webgl2")){const e=t.renderer.getSize(new Ai);this.renderTarget=new Zi(e.x,e.y,{format:Gt,stencilBuffer:!1,samples:4,type:Et})}this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("resize",this.viewerResize),this.geometryEnd()}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("resize",this.viewerResize)}highlight(t){const{edgesVisibility:e}=this.viewer.options;Array.isArray(t)||(t=[t]),0!==t.length&&t.filter(t=>!t.userData.isEdge).forEach(t=>{if(!t.userData.isHighlighted)if(t.isLine||t.isLineSegments){const i=t.geometry.attributes.position.array,n=t.geometry.index?t.geometry.index.array:null,s=n?dg.fromIndexedLine(i,n):dg.fromNonIndexedLine(i,t.isLineSegments),r=new cg(s,this.lineGlowMaterial);r.visible=e,r.userData.isHighlightWireframe=!0,t.add(r),t.userData.highlightWireframe=r,t.userData.originalMaterial=t.material,t.material=this.lineMaterial,t.userData.isHighlighted=!0}else if(t.isMesh){const i=new Eo(t.geometry,89),n=(new rg).fromEdgesGeometry(i),s=new cg(n,this.edgesMaterial);s.visible=e,s.userData.isHighlightWireframe=!0,t.add(s),t.userData.highlightWireframe=s,t.userData.originalMaterial=t.material,t.material=this.facesMaterial,t.userData.isHighlighted=!0}})}unhighlight(t){Array.isArray(t)||(t=[t]),0!==t.length&&t.forEach(t=>{t.userData.isHighlighted&&(t.material=t.userData.originalMaterial,t.userData.highlightWireframe.removeFromParent(),delete t.userData.isHighlighted,delete t.userData.originalMaterial,delete t.userData.highlightWireframe)})}syncHighlightColors(){const t=this.viewer.options.enableCustomHighlight?this.viewer.options:f.defaults(),{facesColor:e,facesTransparancy:i,facesOverlap:n}=t,{edgesColor:s,edgesVisibility:r,edgesOverlap:a}=t;this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-i)/255,this.facesMaterial.depthTest=!n,this.facesMaterial.depthWrite=!n,this.edgesMaterial.color.setRGB(s.r/255,s.g/255,s.b/255),this.edgesMaterial.depthTest=!a,this.edgesMaterial.depthWrite=!a,this.lineMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.lineGlowMaterial.color.setRGB(s.r/255,s.g/255,s.b/255),this.lineGlowMaterial.depthTest=!a,this.lineGlowMaterial.depthWrite=!a,this.viewer.selected.forEach(t=>{const e=t.userData.highlightWireframe;e&&(e.visible=r)})}viewerResize(t){var e,i,n;null===(e=this.renderTarget)||void 0===e||e.setSize(t.width,t.height),null===(i=this.edgesMaterial)||void 0===i||i.resolution.set(t.width,t.height),null===(n=this.lineGlowMaterial)||void 0===n||n.resolution.set(t.width,t.height)}}class pg{constructor(t){this.onPointerDown=t=>{t.isPrimary&&0===t.button&&this.getMousePosition(t,this.downPosition)},this.onPointerUp=t=>{if(!t.isPrimary)return;const e=this.getMousePosition(t,new Ai);if(0!==e.distanceTo(this.downPosition))return;const i=this.viewer.extents.getSize(new Li).length()||1,n=new yf(this.viewer.camera,this.viewer.renderer,this.viewer.canvas);n.threshold=i/1e4;let s=[];if(this.viewer.models.forEach(t=>{const i=t.getVisibleObjects(),r=n.getPointerIntersects(e,i);r.length>0&&s.push({...r[0],model:t})}),s=s.sort((t,e)=>t.distance-e.distance),t.shiftKey||this.clearSelection(),s.length>0){const e=s[0].model,i=e.getHandlesByObjects(s[0].object),n=e.getObjectsByHandles(i);t.shiftKey?this.toggleSelection(n,e):this.select(n,e)}this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()}),this.viewer.emitEvent({type:"select2",data:void 0,handles:this.viewer.getSelected2()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.initHighlighter=()=>{this.highlighter=this.viewer.getComponent("HighlighterComponent")},this.viewer=t,this.downPosition=new Ai,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("initialize",this.initHighlighter)}dispose(){this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("initialize",this.initHighlighter)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}select(t,e){e?(Array.isArray(t)||(t=[t]),0!==t.length&&(e.highlightObjects(t),this.highlighter.highlight(t),t.forEach(t=>this.viewer.selected.push(t)),t.forEach(t=>t.userData.isSelected=!0))):this.viewer.models.forEach(e=>this.select(t,e))}deselect(t,e){e?(Array.isArray(t)||(t=[t]),0!==t.length&&(e.unhighlightObjects(t),this.highlighter.unhighlight(t),this.viewer.selected=this.viewer.selected.filter(e=>!t.includes(e)),t.forEach(t=>t.userData.isSelected=!1))):this.viewer.models.forEach(e=>this.select(t,e))}toggleSelection(t,e){Array.isArray(t)||(t=[t]),0!==t.length&&(t[0].userData.isSelected?this.deselect(t,e):this.select(t,e))}clearSelection(){0!==this.viewer.selected.length&&(this.viewer.models.forEach(t=>t.unhighlightObjects(this.viewer.selected)),this.highlighter.unhighlight(this.viewer.selected),this.viewer.selected.forEach(t=>t.userData.isSelected=!1),this.viewer.selected.length=0)}}class mg extends $n{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new Bl(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new Ss({toneMapped:!1,color:"#dd0000"}),i=new Ss({toneMapped:!1,color:"#00dd00"}),n=new Ss({toneMapped:!1,color:"#0000dd"}),s=this.getSpriteMaterial(e.color,"X"),r=this.getSpriteMaterial(i.color,"Y"),a=this.getSpriteMaterial(n.color,"Z"),o=new _o(.01,.01,1,3);o.translate(0,.5,0);const h=new _o(0,.1,.25,12);h.translate(0,.625,0);const l={X:[[new Qs(h,e),[.5,0,0],[0,0,-Math.PI/2]],[new Qs(o,e),[0,0,0],[0,0,-Math.PI/2]],[new Br(s),[1.55,0,0]]],Y:[[new Qs(h,i),[0,.5,0],null],[new Qs(o,i),null,null],[new Br(r),[0,1.55,0]]],Z:[[new Qs(h,n),[0,0,.5],[Math.PI/2,0,0]],[new Qs(o,n),null,[Math.PI/2,0,0]],[new Br(a),[0,0,1.55]]]};Object.keys(l).forEach(t=>{l[t].forEach(e=>{const i=e[0],n=e[1],s=e[2];i.name=t,n&&i.position.set(n[0],n[1],n[2]),s&&i.rotation.set(s[0],s[1],s[2]),i.updateMatrixWorld(),this.add(i)})})}dispose(){this.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}getSpriteMaterial(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d");n.clearRect(0,0,64,64),n.font="24px Arial",n.textAlign="center",n.fillStyle=t.getStyle(),n.fillText(e,32,41);const s=new uo(i);return s.colorSpace=ze,new Mr({map:s,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.autoClear,i=t.clippingPlanes,n=t.getViewport(new Yi);t.autoClear=!1,t.clippingPlanes=[],t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(n),t.clippingPlanes=i,t.autoClear=e}}class fg{constructor(t){this.geometryEnd=()=>{this.wcsHelper.dispose(),this.wcsHelper=new mg(this.viewer.camera)},this.viewerRender=()=>{this.viewer.options.showWCS&&this.wcsHelper.render(this.viewer.renderer)},this.updateHelperCamera=()=>{this.wcsHelper.camera=this.viewer.camera},this.wcsHelper=new mg(t.camera),this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("drawviewpoint",this.geometryEnd),this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("changecameramode",this.updateHelperCamera)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("drawviewpoint",this.geometryEnd),this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("changecameramode",this.updateHelperCamera),this.wcsHelper.dispose()}}class gg{constructor(t){this.savedCameraPosition=null,this.onDatabaseChunk=()=>{this.savedCameraPosition={position:this.viewer.camera.position.clone(),up:this.viewer.camera.up.clone(),direction:this.viewer.camera.getWorldDirection(new Li)}},this.resetCameraPosition=()=>{this.savedCameraPosition&&(this.viewer.camera.position.copy(this.savedCameraPosition.position),this.viewer.camera.up.copy(this.savedCameraPosition.up),this.viewer.camera.lookAt(this.savedCameraPosition.position.clone().add(this.savedCameraPosition.direction)),this.viewer.camera.updateProjectionMatrix())},this.viewer=t,this.viewer.addEventListener("databasechunk",this.onDatabaseChunk),this.viewer.on("resetview",this.resetCameraPosition)}dispose(){this.viewer.off("resetview",this.resetCameraPosition),this.viewer.removeEventListener("databasechunk",this.onDatabaseChunk)}}const vg=l("threejs");vg.registerComponent("ExtentsComponent",t=>new Jf(t)),vg.registerComponent("CameraComponent",t=>new Kf(t)),vg.registerComponent("BackgroundComponent",t=>new Zf(t)),vg.registerComponent("LightComponent",t=>new Qf(t)),vg.registerComponent("InfoComponent",t=>new $f(t)),vg.registerComponent("CanvasResizeComponent",t=>new tg(t)),vg.registerComponent("CanvasRemoveComponent",t=>new eg(t)),vg.registerComponent("RenderLoopComponent",t=>new ig(t)),vg.registerComponent("HighlighterComponent",t=>new ug(t)),vg.registerComponent("SelectionComponent",t=>new pg(t)),vg.registerComponent("WCSHelperComponent",t=>new fg(t)),vg.registerComponent("ResetComponent",t=>new gg(t));class _g{constructor(t){this.scene=t,this.handleToObjects=new Map,this.originalObjects=new Set,this.scene.traverse(t=>{this.originalObjects.add(t);const e=t.userData.handle;if(!e)return;let i=this.handleToObjects.get(e);i||(i=new Set,this.handleToObjects.set(e,i)),i.add(t)})}dispose(){this.handleToObjects=void 0,this.originalObjects=void 0,this.scene.traverse(function(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach(t=>function(t){t.dispose()}(t)))}),this.scene.clear()}getUnits(){return"Meters"}getUnitScale(){return cf(this.getUnits(),"Meters",1)}getUnitString(){return t=this.getUnits(),(lf[t]||lf.Default).symbol;var t}getPrecision(){return 2}getInfo(){const t=new Set,e=new Set,i=new Set;let n=0,s=0,r=0,a=0,o=0,h=0,l=0;function c(t){if(!t.image)return 0;return(t.image.width||0)*(t.image.height||0)*4*(t.generateMipmaps?1.33:1)}this.scene.traverse(d=>{if(n++,d.geometry){const e=d.geometry;if(!t.has(e)){if(t.add(e),e.attributes)for(const t in e.attributes){const i=e.attributes[t];i&&i.array&&(h+=i.array.byteLength)}e.index&&e.index.array&&(h+=e.index.array.byteLength)}if(e.index){const t=e.index.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?r+=t:s+=t/3}else if(e.attributes&&e.attributes.position){const t=e.attributes.position.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?r+=t:s+=t/3}d.isLineSegments&&e.attributes.position&&(o+=e.attributes.position.count/2)}if(d.material){(Array.isArray(d.material)?d.material:[d.material]).forEach(t=>{e.add(t),t.map&&!i.has(t.map)&&(i.add(t.map),l+=c(t.map));["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","iridescenceMap","sheenColorMap","sheenRoughnessMap","thicknessMap","transmissionMap","anisotropyMap","gradientMap"].forEach(e=>{const n=t[e];n&&!i.has(n)&&(i.add(n),l+=c(n))})})}});const d=new _;return d.scene.objects=n,d.scene.triangles=Math.floor(s),d.scene.points=Math.floor(r),d.scene.lines=Math.floor(a),d.scene.edges=Math.floor(o),d.memory.geometries=t.size,d.memory.geometryBytes=h,d.memory.textures=i.size,d.memory.textureBytes=Math.floor(l),d.memory.materials=e.size,d.memory.totalEstimatedGpuBytes=h+Math.floor(l),d.optimizedScene.objects=d.scene.objects,d.optimizedScene.triangles=d.scene.triangles,d.optimizedScene.points=d.scene.points,d.optimizedScene.lines=d.scene.lines,d.optimizedScene.edges=d.scene.edges,d}getExtents(t){return this.scene.traverseVisible(e=>t.expandByObject(e)),t}getObjects(){return Array.from(this.originalObjects)}getVisibleObjects(){const t=[];return this.scene.traverseVisible(e=>t.push(e)),t.filter(t=>t.userData.handle)}getObjectsByHandles(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(t=>{const i=t.indexOf(":");if(-1!==i){if(t.slice(0,i)!==this.id)return;t=t.slice(i+1)}e.push(t)});const i=new Set(e),n=[];return i.forEach(t=>{n.push(Array.from(this.handleToObjects.get(t)||[]))}),n.flat()}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return t.filter(t=>this.originalObjects.has(t)).forEach(t=>{e.add(`${this.id}:${t.userData.handle}`)}),Array.from(e)}hideObjects(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.visible=!1}),this}hideAllObjects(){return this.isolateObjects([])}isolateObjects(t){Array.isArray(t)||(t=[t]);const e=new Set(t);return t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.traverseAncestors(t=>e.add(t))}),this.scene.traverse(t=>t.visible=e.has(t)),this}showObjects(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.visible=!0,t.traverseAncestors(t=>t.visible=!0)}),this}showAllObjects(){return this.scene.traverse(t=>t.visible=!0),this}highlightObjects(t){return this}unhighlightObjects(t){return this}explode(t=0,e=4){const i=new Map,n=(t,e)=>{const n=(new Qi).setFromObject(t),s=t.userData.handle;if(!s)return n.getCenter(e);const r=i.get(s);if(r)return e.copy(r);return this.getObjectsByHandles(s).forEach(t=>n.expandByObject(t)),n.getCenter(e),i.set(s,e.clone()),e};const s=t/100,r=this.scene;r.userData.explodeDepth||(r.userData.explodeDepth=function t(e,i){let s=i;return e.children.forEach(e=>{const n=t(e,i+1);s<n&&(s=n)}),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=n(e,new Li),s}(r,1));const a=r.userData.explodeDepth,o=s*a+1,h=0|o,l=o-h;return function t(i,n){if(!i.isCamera&&!i.userData.isHighlightWireframe){if(i.position.copy(i.userData.originalPosition),n>0&&n<=h){let t=s*e;n===h&&(t*=l);const r=i.parent.userData.originalCenter,a=i.userData.originalCenter.clone().sub(r).multiplyScalar(t);i.position.add(a)}i.children.forEach(e=>t(e,n+1))}}(r,0),this.scene.updateMatrixWorld(),this}}class yg extends _g{getInfo(){const t=this.gltfLoader.getStats(),e=new _;return e.scene.objects=t.scene.beforeOptimization.objects,e.scene.triangles=t.scene.beforeOptimization.triangles,e.scene.lines=t.scene.beforeOptimization.lines,e.scene.edges=t.scene.beforeOptimization.edges,e.optimizedScene.objects=t.scene.afterOptimization.objects,e.optimizedScene.triangles=t.scene.afterOptimization.triangles,e.optimizedScene.lines=t.scene.afterOptimization.lines,e.optimizedScene.edges=t.scene.afterOptimization.edges,e.memory.geometries=t.memory.geometries.count,e.memory.geometryBytes=t.memory.geometries.bytes,e.memory.textures=t.memory.textures.count,e.memory.materials=t.memory.materials.count,e.memory.totalEstimatedGpuBytes=t.memory.totalEstimatedGpuBytes,e}getExtents(t){return t.union(this.gltfLoader.getTotalGeometryExtent())}getObjects(){const t=[];return this.gltfLoader.originalObjects.forEach(e=>{t.push(e)}),t}getVisibleObjects(){return this.gltfLoader.getOriginalObjectForSelect()}getObjectsByHandles(t){Array.isArray(t)||(t=[t]);const e=new Set(t),i=[];return e.forEach(t=>{i.push(this.gltfLoader.getObjectsByHandle(t))}),i.flat()}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return t.filter(t=>this.gltfLoader.originalObjects.has(t)).forEach(t=>{e.add(t.userData.handle)}),Array.from(e)}hideObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.hideObjects(e),this}isolateObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.isolateObjects(new Set(e)),this}showObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.showObjects(e),this}showAllObjects(){return this.gltfLoader.showAllHiddenObjects(),this}highlightObjects(t){return this.gltfLoader.showOriginalObjects(t),this}unhighlightObjects(t){return this.gltfLoader.hideOriginalObjects(t),this}explode(t=0,e=4){const i=new Map,n=(t,e)=>{const n=(new Qi).setFromObject(t),s=t.userData.handle;if(!s)return n.getCenter(e);const r=i.get(s);if(r)return e.copy(r);return this.getObjectsByHandles(s).forEach(t=>n.expandByObject(t)),n.getCenter(e),i.set(s,e.clone()),e};const s=t/100,r=this.scene.children[0];r.userData.explodeDepth||(r.userData.explodeDepth=function t(e,i){let s=i;return e.children.filter(t=>!t.userData.isOptimized).forEach(e=>{const n=t(e,i+1);s<n&&(s=n)}),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=n(e,new Li),s}(r,1));const a=r.userData.explodeDepth,o=s*a+1,h=0|o,l=o-h,c=new Map;return function t(i,n){if(!i.isCamera&&!i.userData.isHighlightWireframe){if(i.position.copy(i.userData.originalPosition),n>0&&n<=h&&!i.userData.isExplodeLocked){let t=s*e;n===h&&(t*=l);const r=i.parent.userData.originalCenter,a=i.userData.originalCenter.clone().sub(r).multiplyScalar(t);i.position.add(a);const o=(new En).makeTranslation(a.x,a.y,a.z);c.set(i,o)}i.children.filter(t=>!t.userData.isOptimized).forEach(e=>t(e,n+1))}}(r,0),this.scene.updateMatrixWorld(),this.gltfLoader.applyObjectTransforms(c),this}}const xg={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bg=0,Sg=1,wg=2,Mg=3,Tg=4,Eg=5,Ag=6,Cg=31457280;class Lg{constructor(t,e){this.id=`${t}`,this.json=null,this.loadController=e,this.loader=null,this.batchDelay=10,this.maxBatchSize=5242880,this.maxRangesPerRequest=512,this.pendingRequests=[],this.batchTimeout=null,this.textureLoader=new Al,this.materials=new Map,this.textureCache=new Map,this.materialCache=new Map,this.uri="",this._nextObjectId=1,this.loadingAborted=!1,this.criticalError=null}async initialize(t){const e=await this.loadController.loadJson();if(void 0===e.asset||e.asset.version[0]<2)throw new Error("GltfStructure: Unsupported asset. glTF versions >=2.0 are supported.");this.json=e,this.loader=t,this.uri=this.json.buffers[0].uri||""}clear(){this.json=null,this.loadController=null,this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null),this.disposeMaterials(),this.textureCache.clear(),this.materials.clear(),this.activeChunkLoads=0,this.chunkQueue=[],this.loadingAborted=!1,this.criticalError=null}getJson(){return this.json}scheduleRequest(t){return new Promise((e,i)=>{this.loadingAborted?i(this.criticalError||new Error("Structure loading has been aborted due to critical error")):this.pendingRequests.push({...t,_resolve:e,_reject:i})})}isCriticalHttpError(t){if(!t)return!1;const e=t.status||t.statusCode||t.code;if("number"==typeof e)return e>=400&&e<600;if(t.message){const e=t.message.match(/HTTP\s+(\d{3})/i);if(e){const t=parseInt(e[1],10);return t>=400&&t<600}}return!1}abortLoading(t){if(this.loadingAborted)return;this.loadingAborted=!0,this.criticalError=t;const e=[...this.pendingRequests];this.pendingRequests=[];for(const i of e)i._reject&&i._reject(t);throw console.error(`❌ Critical error for structure "${this.id}". All further loading aborted.`,`\n Error: ${t.message||t}`,`\n Rejected ${e.length} pending chunk requests.`),t}async flushBufferRequests(){if(!this.pendingRequests||0===this.pendingRequests.length)return;const t=[...this.pendingRequests];this.pendingRequests=[],t.sort((t,e)=>t.offset-e.offset);const e=[];let i={start:t[0].offset,end:t[0].offset+t[0].length,requests:[t[0]]};for(let n=1;n<t.length;n++){const s=t[n],r=s.offset-i.end,a=Math.max(i.end,s.offset+s.length),o=a-i.start;r<=131072&&o<=Cg?(i.end=a,i.requests.push(s)):(e.push(i),i={start:s.offset,end:s.offset+s.length,requests:[s]})}e.push(i);const n=[];for(const t of e){let{start:e,end:i,requests:s}=t;for(;i-e>Cg;){let t=0;for(let i=0;i<s.length&&!(s[i].offset+s[i].length-e>Cg);i++)t=i;const r=s.slice(0,t+1),a=r[r.length-1].offset+r[r.length-1].length;if(n.push({start:e,end:a,requests:r}),s=s.slice(t+1),s.length>0){e=s[0].offset,i=s[0].offset+s[0].length;for(let t=1;t<s.length;t++)i=Math.max(i,s[t].offset+s[t].length)}}s.length>0&&n.push({start:e,end:i,requests:s})}const s=n.map(async(t,e)=>{if(this.loadingAborted)for(const e of t.requests)e._reject(this.criticalError||new Error("Structure loading aborted"));else{await this.loader.waitForChunkSlot();try{const e=t.end-t.start,i=await this.loadController.loadBinaryData([{offset:t.start,length:e}],this.uri);for(const e of t.requests){const n=e.offset-t.start;try{e._resolve({buffer:i,relOffset:n,length:e.length})}catch(t){e._reject(t)}}}catch(i){for(const e of t.requests)e._reject(i);this.isCriticalHttpError(i)?this.abortLoading(i):console.warn(`Failed to load chunk ${e+1}/${n.length} (${t.start}-${t.end}):`,i)}finally{this.loader.releaseChunkSlot()}}});await Promise.all(s),this.pendingRequests=[]}getBufferView(t,e,i){return this.scheduleRequest({offset:t,length:e,componentType:i})}createTypedArray(t,e,i,n){try{if(!(t&&t instanceof ArrayBuffer))throw new Error("Invalid buffer");let s;switch(n){case 5120:case 5121:s=1;break;case 5122:case 5123:s=2;break;case 5125:case 5126:s=4;break;default:throw new Error(`Unsupported component type: ${n}`)}const r=i/s;if(!Number.isInteger(r))throw new Error(`Invalid length ${i} for component type ${n}`);if(i>t.byteLength)throw new Error(`Buffer too small: need ${i} bytes, but buffer is ${t.byteLength} bytes`);return new(0,xg[n])(t,e,r)}catch(s){throw"AbortError"!==s.name&&console.error("Error creating typed array:",{bufferSize:t?.byteLength,offset:e,length:i,componentType:n,error:s}),s}}async createBufferAttribute(t){if(!this.json)throw new Error("No GLTF structure loaded");const e=this.json,i=e.accessors[t],n=e.bufferViews[i.bufferView];try{const t=(n.byteOffset||0)+(i.byteOffset||0),e=this.getNumComponents(i.type),s=i.count*e*this.getComponentSize(i.componentType),r=await this.getBufferView(t,s,i.componentType),a=new Ls(r,e);return void 0!==i.min&&(a.min=i.min),void 0!==i.max&&(a.max=i.max),a}catch(t){throw"AbortError"!==t.name&&console.error("Error creating buffer attribute:",{error:t,accessor:i,bufferView:n}),t}}getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error(`Unknown component type: ${t}`)}}getNumComponents(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error(`Unknown type: ${t}`)}}async loadTextures(){if(!this.json.textures)return;const t=async t=>{const e=this.json.images[t];if(e.uri){const t=await this.loadController.resolveURL(e.uri);return this.textureLoader.loadAsync(t)}if(void 0!==e.bufferView){const t=this.json.bufferViews[e.bufferView],i=await this.getBufferView(t.byteOffset||0,t.byteLength,5121),n=new Blob([i],{type:e.mimeType}),s=URL.createObjectURL(n),r=await this.textureLoader.loadAsync(s);return URL.revokeObjectURL(s),r.flipY=!1,r}},e=[];for(let i=0;i<this.json.textures.length;i++)e.push(t(this.json.textures[i].source).then(t=>this.textureCache.set(i,t)));await Promise.all(e)}loadMaterials(){if(!this.json.materials)return this.materials;for(let t=0;t<this.json.materials.length;t++){const e=this.json.materials[t],i=`material_${t}`;this.materialCache.set(i,{mesh:this.createMaterial(e,Tg),points:this.createMaterial(e,bg),lines:this.createMaterial(e,Sg)}),this.materialCache.get(i).mesh.name=e.name,this.materialCache.get(i).points.name=e.name,this.materialCache.get(i).lines.name=e.name,this.materials.set(t,this.materialCache.get(i).mesh)}return this.materials}createMaterial(t,e=void 0){const i={};if(t.pbrMetallicRoughness){const e=t.pbrMetallicRoughness;e.baseColorFactor&&(i.color=(new _s).fromArray(e.baseColorFactor),i.opacity=e.baseColorFactor[3],i.opacity<1&&(i.transparent=!0)),e.baseColorTexture&&(i.map=this.textureCache.get(e.baseColorTexture.index))}let n;return t.emissiveFactor&&(i.emissive=(new _s).fromArray(t.emissiveFactor)),"BLEND"===t.alphaMode&&(i.transparent=!0),t.doubleSided&&(i.side=2),e===bg?(i.sizeAttenuation=!1,n=new io(i),n.sizeAttenuation=!1):e===Sg||e===Mg||e===wg?n=new Ha(i):(i.specular=2236962,i.shininess=10,i.reflectivity=.05,i.polygonOffset=!0,i.polygonOffsetFactor=1,i.polygonOffsetUnits=1,t.normalTexture&&(i.normalMap=this.textureCache.get(t.normalTexture.index)),n=new Xh(i)),n}getCachedMaterial(t,e){const i=`material_${t}`,n=this.materialCache.get(i);return n?e===bg?n.points:e===Sg||e===Mg||e===wg?n.lines:n.mesh:null}disposeMaterials(){this.textureCache.forEach(t=>t.dispose()),this.textureCache.clear(),this.materials.forEach(t=>{t.map&&t.map.dispose(),t.lightMap&&t.lightMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.specularMap&&t.specularMap.dispose(),t.envMap&&t.envMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.dispose()}),this.materials.clear(),this.materialCache.forEach(t=>{t.mesh&&(t.mesh.map&&t.mesh.map.dispose(),t.mesh.lightMap&&t.mesh.lightMap.dispose(),t.mesh.bumpMap&&t.mesh.bumpMap.dispose(),t.mesh.normalMap&&t.mesh.normalMap.dispose(),t.mesh.specularMap&&t.mesh.specularMap.dispose(),t.mesh.envMap&&t.mesh.envMap.dispose(),t.mesh.aoMap&&t.mesh.aoMap.dispose(),t.mesh.metalnessMap&&t.mesh.metalnessMap.dispose(),t.mesh.roughnessMap&&t.mesh.roughnessMap.dispose(),t.mesh.emissiveMap&&t.mesh.emissiveMap.dispose(),t.mesh.dispose()),t.points&&(t.points.map&&t.points.map.dispose(),t.points.dispose()),t.lines&&(t.lines.map&&t.lines.map.dispose(),t.lines.dispose())}),this.materialCache.clear()}estimateNodeSize(t){if(!this.json.meshes)return 0;const e=this.json.meshes[t];if(!e||!e.primitives)return 0;let i=0;for(const t of e.primitives){if(t.attributes)for(const[,e]of Object.entries(t.attributes)){if(void 0===e)continue;const t=this.json.accessors[e];if(!t)continue;const n=this.getNumComponents(t.type),s=this.getComponentSize(t.componentType);i+=t.count*n*s}if(void 0!==t.indices){const e=this.json.accessors[t.indices];if(e){const t=this.getComponentSize(e.componentType);i+=e.count*t}}}return i}}function Rg(t,e=!1){const i=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),r={},a={},o=t[0].morphTargetsRelative,h=new zs;let l=0;for(let c=0;c<t.length;++c){const d=t[c];let u=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in d.attributes){if(!n.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===r[t]&&(r[t]=[]),r[t].push(d.attributes[t]),u++}if(u!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in d.morphAttributes){if(!s.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[t]&&(a[t]=[]),a[t].push(d.morphAttributes[t])}if(e){let t;if(i)t=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;t=d.attributes.position.count}h.addGroup(l,t,c),l+=t}}if(i){let e=0;const i=[];for(let n=0;n<t.length;++n){const s=t[n].index;for(let t=0;t<s.count;++t)i.push(s.getX(t)+e);e+=t[n].attributes.position.count}h.setIndex(i)}for(const t in r){const e=Ig(r[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" attribute."),null;h.setAttribute(t,e)}for(const t in a){const e=a[t][0].length;if(0===e)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[t]=[];for(let i=0;i<e;++i){const e=[];for(let n=0;n<a[t].length;++n)e.push(a[t][n][i]);const n=Ig(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" morphAttribute."),null;h.morphAttributes[t].push(n)}}return h}function Ig(t){let e,i,n,s=-1,r=0;for(let a=0;a<t.length;++a){const o=t[a];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===s&&(s=o.gpuType),s!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=o.count*i}const a=new e(r),o=new Ls(a,i,n);let h=0;for(let e=0;e<t.length;++e){const n=t[e];if(n.isInterleavedBufferAttribute){const t=h/i;for(let e=0,s=n.count;e<s;e++)for(let s=0;s<i;s++){const i=n.getComponent(e,s);o.setComponent(e+t,s,i)}}else a.set(n.array,h);h+=n.count*i}return void 0!==s&&(o.gpuType=s),o}class Pg{constructor(t,e,i){this.camera=t,this.scene=e,this.renderer=i,this.eventHandlers={geometryprogress:[],databasechunk:[],geometryend:[],geometryerror:[],update:[],geometrymemory:[],optimizationprogress:[]},this.loadDistance=100,this.unloadDistance=150,this.checkInterval=1e3,this.nodes=new Map,this.loadedMeshes=new Map,this.nodesToLoad=[],this.edgeNodes=[],this.structures=[],this.structureRoots=new Map,this.memoryLimit=this.getAvailableMemory(),this.loadedGeometrySize=0,this.geometryCache=new Map,this.materialCache=new Map,this.textureCache=new Map,this.currentMemoryUsage=0,this.updateMemoryIndicator(),this.loadedMaterials=new Map,this.abortController=new AbortController,this.batchSize=1e4,this.frameDelay=0,this.graphicsObjectLimit=1e4,this.totalLoadedObjects=0,this.handleToObjects=new Map,this.originalObjects=new Set,this.originalObjectsToSelection=new Set,this.optimizedOriginalMap=new Map,this.mergedMesh=new Set,this.mergedLines=new Set,this.mergedLineSegments=new Set,this.mergedPoints=new Set,this.isolatedObjects=[],
|
|
35
|
+
function fd(){let t=null,e=!1,i=null,n=null;function s(e,r){i(e,r),n=t.requestAnimationFrame(s)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(s),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function gd(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const s=e.get(i);if(void 0===s)e.set(i,function(e,i){const n=e.array,s=e.usage,r=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,s),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)o=t.HALF_FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:r}}(i,n));else if(s.version<i.version){if(s.size!==i.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(e,i,n){const s=i.array,r=i.updateRanges;if(t.bindBuffer(n,e),0===r.length)t.bufferSubData(n,0,s);else{r.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<r.length;t++){const i=r[e],n=r[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,r[e]=n)}r.length=e+1;for(let e=0,i=r.length;e<i;e++){const i=r[e];t.bufferSubData(n,i.start*s.BYTES_PER_ELEMENT,s,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(s.buffer,i,n),s.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:y}})),"undefined"!=typeof window&&(window.__THREE__?ui("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=y);const vd={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn v;\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadow = step( depth, dp );\n\t\t\t#else\n\t\t\t\tshadow = step( dp, depth );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},_d={common:{diffuse:{value:new _s(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Pi},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Pi}},envmap:{envMap:{value:null},envMapRotation:{value:new Pi},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Pi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Pi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Pi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Pi},normalScale:{value:new Ai(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Pi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Pi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Pi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Pi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _s(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new _s(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0},uvTransform:{value:new Pi}},sprite:{diffuse:{value:new _s(16777215)},opacity:{value:1},center:{value:new Ai(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pi},alphaMap:{value:null},alphaMapTransform:{value:new Pi},alphaTest:{value:0}}},yd={basic:{uniforms:ir([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.fog]),vertexShader:vd.meshbasic_vert,fragmentShader:vd.meshbasic_frag},lambert:{uniforms:ir([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,_d.lights,{emissive:{value:new _s(0)}}]),vertexShader:vd.meshlambert_vert,fragmentShader:vd.meshlambert_frag},phong:{uniforms:ir([_d.common,_d.specularmap,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,_d.lights,{emissive:{value:new _s(0)},specular:{value:new _s(1118481)},shininess:{value:30}}]),vertexShader:vd.meshphong_vert,fragmentShader:vd.meshphong_frag},standard:{uniforms:ir([_d.common,_d.envmap,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.roughnessmap,_d.metalnessmap,_d.fog,_d.lights,{emissive:{value:new _s(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:vd.meshphysical_vert,fragmentShader:vd.meshphysical_frag},toon:{uniforms:ir([_d.common,_d.aomap,_d.lightmap,_d.emissivemap,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.gradientmap,_d.fog,_d.lights,{emissive:{value:new _s(0)}}]),vertexShader:vd.meshtoon_vert,fragmentShader:vd.meshtoon_frag},matcap:{uniforms:ir([_d.common,_d.bumpmap,_d.normalmap,_d.displacementmap,_d.fog,{matcap:{value:null}}]),vertexShader:vd.meshmatcap_vert,fragmentShader:vd.meshmatcap_frag},points:{uniforms:ir([_d.points,_d.fog]),vertexShader:vd.points_vert,fragmentShader:vd.points_frag},dashed:{uniforms:ir([_d.common,_d.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:vd.linedashed_vert,fragmentShader:vd.linedashed_frag},depth:{uniforms:ir([_d.common,_d.displacementmap]),vertexShader:vd.depth_vert,fragmentShader:vd.depth_frag},normal:{uniforms:ir([_d.common,_d.bumpmap,_d.normalmap,_d.displacementmap,{opacity:{value:1}}]),vertexShader:vd.meshnormal_vert,fragmentShader:vd.meshnormal_frag},sprite:{uniforms:ir([_d.sprite,_d.fog]),vertexShader:vd.sprite_vert,fragmentShader:vd.sprite_frag},background:{uniforms:{uvTransform:{value:new Pi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:vd.background_vert,fragmentShader:vd.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pi}},vertexShader:vd.backgroundCube_vert,fragmentShader:vd.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:vd.cube_vert,fragmentShader:vd.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:vd.equirect_vert,fragmentShader:vd.equirect_frag},distance:{uniforms:ir([_d.common,_d.displacementmap,{referencePosition:{value:new Li},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:vd.distance_vert,fragmentShader:vd.distance_frag},shadow:{uniforms:ir([_d.lights,_d.fog,{color:{value:new _s(0)},opacity:{value:1}}]),vertexShader:vd.shadow_vert,fragmentShader:vd.shadow_frag}};yd.physical={uniforms:ir([yd.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pi},clearcoatNormalScale:{value:new Ai(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Pi},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Pi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Pi},sheen:{value:0},sheenColor:{value:new _s(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Pi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Pi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Pi},transmissionSamplerSize:{value:new Ai},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pi},attenuationDistance:{value:0},attenuationColor:{value:new _s(0)},specularColor:{value:new _s(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pi},anisotropyVector:{value:new Ai},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pi}}]),vertexShader:vd.meshphysical_vert,fragmentShader:vd.meshphysical_frag};const xd={r:0,b:0,g:0},bd=new Un,Sd=new En;function wd(t,e,i,n,s,r,a){const o=new _s(0);let h,l,c=!0===r?0:1,d=null,u=0,p=null;function m(t){let n=!0===t.isScene?t.background:null;if(n&&n.isTexture){n=(t.backgroundBlurriness>0?i:e).get(n)}return n}function f(e,i){e.getRGB(xd,nr(t)),n.buffers.color.setClear(xd.r,xd.g,xd.b,i,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,f(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,f(o,c)},render:function(e){let i=!1;const s=m(e);null===s?f(o,c):s&&s.isColor&&(f(s,1),i=!0);const r=t.xr.getEnvironmentBlendMode();"additive"===r?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===r&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||i)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const n=m(i);n&&(n.isCubeTexture||n.mapping===gt)?(void 0===l&&(l=new Qs(new tr(1,1,1),new rr({name:"BackgroundCubeMaterial",uniforms:er(yd.backgroundCube.uniforms),vertexShader:yd.backgroundCube.vertexShader,fragmentShader:yd.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(l)),bd.copy(i.backgroundRotation),bd.x*=-1,bd.y*=-1,bd.z*=-1,n.isCubeTexture&&!1===n.isRenderTargetTexture&&(bd.y*=-1,bd.z*=-1),l.material.uniforms.envMap.value=n,l.material.uniforms.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Sd.makeRotationFromEuler(bd)),l.material.toneMapped=Ui.getTransfer(n.colorSpace)!==Ve,d===n&&u===n.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):n&&n.isTexture&&(void 0===h&&(h=new Qs(new Ih(2,2),new rr({name:"BackgroundMaterial",uniforms:er(yd.background.uniforms),vertexShader:yd.background.vertexShader,fragmentShader:yd.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(h)),h.material.uniforms.t2D.value=n,h.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,h.material.toneMapped=Ui.getTransfer(n.colorSpace)!==Ve,!0===n.matrixAutoUpdate&&n.updateMatrix(),h.material.uniforms.uvTransform.value.copy(n.matrix),d===n&&u===n.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=n,u=n.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==h&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}}}function Md(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},s=l(null);let r=s,a=!1;function o(e){return t.bindVertexArray(e)}function h(e){return t.deleteVertexArray(e)}function l(t){const e=[],n=[],s=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,s[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:s,object:t,attributes:{},index:null}}function c(){const t=r.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function d(t){u(t,0)}function u(e,i){const n=r.newAttributes,s=r.enabledAttributes,a=r.attributeDivisors;n[e]=1,0===s[e]&&(t.enableVertexAttribArray(e),s[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=r.newAttributes,i=r.enabledAttributes;for(let n=0,s=i.length;n<s;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function m(e,i,n,s,r,a,o){!0===o?t.vertexAttribIPointer(e,i,n,r,a):t.vertexAttribPointer(e,i,n,s,r,a)}function f(){g(),a=!0,r!==s&&(r=s,o(r.object))}function g(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:function(i,s,h,f,g){let v=!1;const _=function(e,i,s){const r=!0===s.wireframe;let a=n[e.id];void 0===a&&(a={},n[e.id]=a);let o=a[i.id];void 0===o&&(o={},a[i.id]=o);let h=o[r];void 0===h&&(h=l(t.createVertexArray()),o[r]=h);return h}(f,h,s);r!==_&&(r=_,o(r.object)),v=function(t,e,i,n){const s=r.attributes,a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){const i=s[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return r.attributesNum!==o||r.index!==n}(i,f,h,g),v&&function(t,e,i,n){const s={},a=e.attributes;let o=0;const h=i.getAttributes();for(const e in h){if(h[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),s[e]=n,o++}}r.attributes=s,r.attributesNum=o,r.index=n}(i,f,h,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(v||a)&&(a=!1,function(i,n,s,r){c();const a=r.attributes,o=s.getAttributes(),h=n.defaultAttributeValues;for(const n in o){const s=o[n];if(s.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,h=e.get(o);if(void 0===h)continue;const l=h.buffer,c=h.type,p=h.bytesPerElement,f=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===Rt;if(o.isInterleavedBufferAttribute){const e=o.data,h=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<s.locationSize;t++)u(s.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<s.locationSize;t++)d(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<s.locationSize;t++)m(s.location+t,a/s.locationSize,c,n,h*p,(g+a/s.locationSize*t)*p,f)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<s.locationSize;t++)u(s.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===r._maxInstanceCount&&(r._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<s.locationSize;t++)d(s.location+t);t.bindBuffer(t.ARRAY_BUFFER,l);for(let t=0;t<s.locationSize;t++)m(s.location+t,a/s.locationSize,c,n,a*p,a/s.locationSize*t*p,f)}}else if(void 0!==h){const e=h[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(s.location,e);break;case 3:t.vertexAttrib3fv(s.location,e);break;case 4:t.vertexAttrib4fv(s.location,e);break;default:t.vertexAttrib1fv(s.location,e)}}}}p()}(i,s,h,f),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:f,resetDefaultState:g,dispose:function(){f();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i)h(i[t].object),delete i[t];delete e[t]}delete n[t.id]},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];if(void 0===i[t.id])continue;const s=i[t.id];for(const t in s)h(s[t].object),delete s[t];delete i[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function Td(t,e,i){let n;function s(e,s,r){0!==r&&(t.drawArraysInstanced(n,e,s,r),i.update(s,n,r))}this.setMode=function(t){n=t},this.render=function(e,s){t.drawArrays(n,e,s),i.update(s,n,1)},this.renderInstances=s,this.renderMultiDraw=function(t,s,r){if(0===r)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,s,0,r);let a=0;for(let t=0;t<r;t++)a+=s[t];i.update(a,n,1)},this.renderMultiDrawInstances=function(t,r,a,o){if(0===a)return;const h=e.get("WEBGL_multi_draw");if(null===h)for(let e=0;e<t.length;e++)s(t[e],r[e],o[e]);else{h.multiDrawArraysInstancedWEBGL(n,t,0,r,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=r[t]*o[t];i.update(e,n,1)}}}function Ed(t,e,i,n){let s;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=r(a);o!==a&&(ui("WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==s)return s;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");s=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s},getMaxPrecision:r,textureFormatReadable:function(e){return e===Gt||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const s=i===Dt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==Et&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==Pt&&!s)},precision:a,logarithmicDepthBuffer:!0===i.logarithmicDepthBuffer,reversedDepthBuffer:!0===i.reversedDepthBuffer&&e.has("EXT_clip_control"),maxTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:t.getParameter(t.MAX_SAMPLES),samples:t.getParameter(t.SAMPLES)}}function Ad(t){const e=this;let i=null,n=0,s=!1,r=!1;const a=new ga,o=new Pi,h={value:null,needsUpdate:!1};function l(t,i,n,s){const r=null!==t?t.length:0;let l=null;if(0!==r){if(l=h.value,!0!==s||null===l){const e=n+4*r,s=i.matrixWorldInverse;o.getNormalMatrix(s),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==r;++e,i+=4)a.copy(t[e]).applyMatrix4(s,o),a.normal.toArray(l,i),l[i+3]=a.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=r,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||s;return s=e,n=t.length,i},this.beginShadows=function(){r=!0,l(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(t,e){i=l(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!s||null===d||0===d.length||r&&!p)r?l(null):function(){h.value!==i&&(h.value=i,h.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=r?0:n,e=4*t;let s=m.clippingState||null;h.value=s,s=l(d,o,e,c);for(let t=0;t!==e;++t)s[t]=i[t];m.clippingState=s,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function Cd(t){let e=new WeakMap;function i(t,e){return e===mt?t.mapping=ut:e===ft&&(t.mapping=pt),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get:function(s){if(s&&s.isTexture){const r=s.mapping;if(r===mt||r===ft){if(e.has(s)){return i(e.get(s).texture,s.mapping)}{const r=s.image;if(r&&r.height>0){const a=new mr(r.height);return a.fromEquirectangularTexture(t,s),e.set(s,a),s.addEventListener("dispose",n),i(a.texture,s.mapping)}return null}}}return s},dispose:function(){e=new WeakMap}}}const Ld=[.125,.215,.35,.446,.526,.582],Rd=20,Id=new Bl,Pd=new _s;let Dd=null,Od=0,Nd=0,Ud=!1;const Fd=new Li;class Bd{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,i=.1,n=100,s={}){const{size:r=256,position:a=Fd}=s;Dd=this._renderer.getRenderTarget(),Od=this._renderer.getActiveCubeFace(),Nd=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,i,n,o,a),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Hd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Gd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Dd,Od,Nd),this._renderer.xr.enabled=Ud,t.scissorTest=!1,zd(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ut||t.mapping===pt?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Dd=this._renderer.getRenderTarget(),Od=this._renderer.getActiveCubeFace(),Nd=this._renderer.getActiveMipmapLevel(),Ud=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:wt,minFilter:wt,generateMipmaps:!1,type:Dt,format:Gt,colorSpace:Ge,depthBuffer:!1},n=kd(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=kd(t,e,i);const{_lodMax:n}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let s=t;const r=t-4+1+Ld.length;for(let a=0;a<r;a++){const r=Math.pow(2,s);e.push(r);let o=1/r;a>t-4?o=Ld[a-t+4-1]:0===a&&(o=0),i.push(o);const h=1/(r-2),l=-h,c=1+h,d=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*u),_=new Float32Array(f*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,m*p*t),_.set(d,f*p*t);const s=[t,t,t,t,t,t];y.set(s,g*p*t)}const x=new zs;x.setAttribute("position",new Ls(v,m)),x.setAttribute("uv",new Ls(_,f)),x.setAttribute("faceIndex",new Ls(y,g)),n.push(new Qs(x,null)),s>4&&s--}return{lodMeshes:n,sizeLods:e,sigmas:i}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(Rd),s=new Li(0,1,0),r=new rr({name:"SphericalGaussianBlur",defines:{n:Rd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Vd(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return r}(n,t,e),this._ggxMaterial=function(t,e,i){const n=new rr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Vd(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 3.2: Transform view direction to hemisphere configuration\n\t\t\t\tvec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tfloat lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n\t\t\t\tvec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(Vh, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + Vh.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return n}(n,t,e)}return n}_compileMaterial(t){const e=new Qs(new zs,t);this._renderer.compile(e,Id)}_sceneToCubeUV(t,e,i,n,s){const r=new cr(90,1,e,i),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],h=this._renderer,l=h.autoClear,c=h.toneMapping;h.getClearColor(Pd),h.toneMapping=0,h.autoClear=!1;h.state.buffers.depth.getReversed()&&(h.setRenderTarget(n),h.clearDepth(),h.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new Qs(new tr,new Ss({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,u=d.material;let p=!1;const m=t.background;m?m.isColor&&(u.color.copy(m),t.background=null,p=!0):(u.color.copy(Pd),p=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(r.up.set(0,a[e],0),r.position.set(s.x,s.y,s.z),r.lookAt(s.x+o[e],s.y,s.z)):1===i?(r.up.set(0,0,a[e]),r.position.set(s.x,s.y,s.z),r.lookAt(s.x,s.y+o[e],s.z)):(r.up.set(0,a[e],0),r.position.set(s.x,s.y,s.z),r.lookAt(s.x,s.y,s.z+o[e]));const l=this._cubeSize;zd(n,i*l,e>2?l:0,l,l),h.setRenderTarget(n),p&&h.render(d,r),h.render(t,r)}h.toneMapping=c,h.autoClear=l,t.background=m}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===ut||t.mapping===pt;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Hd()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Gd());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;s.uniforms.envMap.value=t;const a=this._cubeSize;zd(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(r,Id)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let e=1;e<n;e++)this._applyGGXFilter(t,e-1,e);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[i];a.material=r;const o=r.uniforms,h=i/(this._lodMeshes.length-1),l=e/(this._lodMeshes.length-1),c=Math.sqrt(h*h-l*l)*(0+1.25*h),{_lodMax:d}=this,u=this._sizeLods[i],p=3*u*(i>d-4?i-d+4:0),m=4*(this._cubeSize-u);o.envMap.value=t.texture,o.roughness.value=c,o.mipInt.value=d-e,zd(s,p,m,3*u,2*u),n.setRenderTarget(s),n.render(a,Id),o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=d-i,zd(t,p,m,3*u,2*u),n.setRenderTarget(t),n.render(a,Id)}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==r&&"longitudinal"!==r&&pi("blur direction must be either latitudinal or longitudinal!");const l=this._lodMeshes[n];l.material=h;const c=h.uniforms,d=this._sizeLods[i]-1,u=isFinite(s)?Math.PI/(2*d):2*Math.PI/39,p=s/u,m=isFinite(s)?1+Math.floor(3*p):Rd;m>Rd&&ui(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Rd;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;c.envMap.value=t.texture,c.samples.value=m,c.weights.value=f,c.latitudinal.value="latitudinal"===r,a&&(c.poleAxis.value=a);const{_lodMax:v}=this;c.dTheta.value=u,c.mipInt.value=v-i;const _=this._sizeLods[n];zd(e,3*_*(n>v-4?n-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(e),o.render(l,Id)}}function kd(t,e,i){const n=new Zi(t,e,i);return n.texture.mapping=gt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function zd(t,e,i,n,s){t.viewport.set(e,i,n,s),t.scissor.set(e,i,n,s)}function Gd(){return new rr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Vd(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Hd(){return new rr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Vd(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Vd(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Wd(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get:function(s){if(s&&s.isTexture){const r=s.mapping,a=r===mt||r===ft,o=r===ut||r===pt;if(a||o){let r=e.get(s);const h=void 0!==r?r.texture.pmremVersion:0;if(s.isRenderTargetTexture&&s.pmremVersion!==h)return null===i&&(i=new Bd(t)),r=a?i.fromEquirectangular(s,r):i.fromCubemap(s,r),r.texture.pmremVersion=s.pmremVersion,e.set(s,r),r.texture;if(void 0!==r)return r.texture;{const h=s.image;return a&&h&&h.height>0||o&&h&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(h)?(null===i&&(i=new Bd(t)),r=a?i.fromEquirectangular(s):i.fromCubemap(s),r.texture.pmremVersion=s.pmremVersion,e.set(s,r),s.addEventListener("dispose",n),r.texture):null}}}return s},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function jd(t){const e={};function i(i){if(void 0!==e[i])return e[i];const n=t.getExtension(i);return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&mi("WebGLRenderer: "+t+" extension not supported."),e}}}function Xd(t,e,i,n){const s={},r=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete s[o.id];const h=r.get(o);h&&(e.remove(h),r.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,s=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],s=t[e+1],r=t[e+2];i.push(n,s,s,r,r,n)}}else{if(void 0===s)return;{const t=s.array;a=s.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,s=e+2;i.push(t,n,n,s,s,t)}}}const o=new(ni(i)?Is:Rs)(i,1);o.version=a;const h=r.get(t);h&&e.remove(h),r.set(t,o)}return{get:function(t,e){return!0===s[e.id]||(e.addEventListener("dispose",a),s[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=r.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return r.get(t)}}}function Yd(t,e,i){let n,s,r;function a(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,s,e*r,o),i.update(a,n,o))}this.setMode=function(t){n=t},this.setIndex=function(t){s=t.type,r=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,s,e*r),i.update(a,n,1)},this.renderInstances=a,this.renderMultiDraw=function(t,r,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,r,0,s,t,0,a);let o=0;for(let t=0;t<a;t++)o+=r[t];i.update(o,n,1)},this.renderMultiDrawInstances=function(t,o,h,l){if(0===h)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/r,o[e],l[e]);else{c.multiDrawElementsInstancedWEBGL(n,o,0,s,t,0,l,0,h);let e=0;for(let t=0;t<h;t++)e+=o[t]*l[t];i.update(e,n,1)}}}function qd(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,s){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=s*(i/3);break;case t.LINES:e.lines+=s*(i/2);break;case t.LINE_STRIP:e.lines+=s*(i-1);break;case t.LINE_LOOP:e.lines+=s*i;break;case t.POINTS:e.points+=s*i;break;default:pi("WebGLInfo: Unknown draw mode:",n)}}}}function Zd(t,e,i){const n=new WeakMap,s=new Yi;return{update:function(r,a,o){const h=r.morphTargetInfluences,l=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==l?l.length:0;let d=n.get(a);if(void 0===d||d.count!==c){void 0!==d&&d.texture.dispose();const u=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,m=void 0!==a.morphAttributes.color,f=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],v=a.morphAttributes.color||[];let _=0;!0===u&&(_=1),!0===p&&(_=2),!0===m&&(_=3);let y=a.attributes.position.count*_,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const b=new Float32Array(y*x*4*c),S=new Ki(b,y,x,c);S.type=Pt,S.needsUpdate=!0;const w=4*_;for(let T=0;T<c;T++){const E=f[T],A=g[T],C=v[T],L=y*x*4*T;for(let R=0;R<E.count;R++){const I=R*w;!0===u&&(s.fromBufferAttribute(E,R),b[L+I+0]=s.x,b[L+I+1]=s.y,b[L+I+2]=s.z,b[L+I+3]=0),!0===p&&(s.fromBufferAttribute(A,R),b[L+I+4]=s.x,b[L+I+5]=s.y,b[L+I+6]=s.z,b[L+I+7]=0),!0===m&&(s.fromBufferAttribute(C,R),b[L+I+8]=s.x,b[L+I+9]=s.y,b[L+I+10]=s.z,b[L+I+11]=4===C.itemSize?s.w:1)}}function M(){S.dispose(),n.delete(a),a.removeEventListener("dispose",M)}d={count:c,texture:S,size:new Ai(y,x)},n.set(a,d),a.addEventListener("dispose",M)}if(!0===r.isInstancedMesh&&null!==r.morphTexture)o.getUniforms().setValue(t,"morphTexture",r.morphTexture,i);else{let P=0;for(let O=0;O<h.length;O++)P+=h[O];const D=a.morphTargetsRelative?1:1-P;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",h)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Kd(t,e,i,n){let s=new WeakMap;function r(t){const e=t.target;e.removeEventListener("dispose",r),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(a){const o=n.render.frame,h=a.geometry,l=e.get(a,h);if(s.get(l)!==o&&(e.update(l),s.set(l,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",r)&&a.addEventListener("dispose",r),s.get(a)!==o&&(i.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,t.ARRAY_BUFFER),s.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;s.get(t)!==o&&(t.update(),s.set(t,o))}return l},dispose:function(){s=new WeakMap}}}const Jd={[it]:"LINEAR_TONE_MAPPING",[nt]:"REINHARD_TONE_MAPPING",[st]:"CINEON_TONE_MAPPING",[rt]:"ACES_FILMIC_TONE_MAPPING",[ot]:"AGX_TONE_MAPPING",[ht]:"NEUTRAL_TONE_MAPPING",[at]:"CUSTOM_TONE_MAPPING"};function Qd(t,e,i,n,s){const r=new Zi(e,i,{type:t,depthBuffer:n,stencilBuffer:s}),a=new Zi(e,i,{type:Dt,depthBuffer:!1,stencilBuffer:!1}),o=new zs;o.setAttribute("position",new Ps([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new Ps([0,2,0,0,2,0],2));const h=new Vh({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),l=new Qs(o,h),c=new Bl(-1,1,1,-1,0,1);let d,u=null,p=null,m=!1,f=null,g=[],v=!1;this.setSize=function(t,e){r.setSize(t,e),a.setSize(t,e);for(let i=0;i<g.length;i++){const n=g[i];n.setSize&&n.setSize(t,e)}},this.setEffects=function(t){g=t,v=g.length>0&&!0===g[0].isRenderPass;const e=r.width,i=r.height;for(let t=0;t<g.length;t++){const n=g[t];n.setSize&&n.setSize(e,i)}},this.begin=function(t,e){if(m)return!1;if(0===t.toneMapping&&0===g.length)return!1;if(f=e,null!==e){const t=e.width,i=e.height;r.width===t&&r.height===i||this.setSize(t,i)}return!1===v&&t.setRenderTarget(r),d=t.toneMapping,t.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(t,e){t.toneMapping=d,m=!0;let i=r,n=a;for(let s=0;s<g.length;s++){const r=g[s];if(!1!==r.enabled&&(r.render(t,n,i,e),!1!==r.needsSwap)){const t=i;i=n,n=t}}if(u!==t.outputColorSpace||p!==t.toneMapping){u=t.outputColorSpace,p=t.toneMapping,h.defines={},Ui.getTransfer(u)===Ve&&(h.defines.SRGB_TRANSFER="");const e=Jd[p];e&&(h.defines[e]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=i.texture,t.setRenderTarget(f),t.render(l,c),f=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){r.dispose(),a.dispose(),o.dispose(),h.dispose()}}const $d=new Xi,tu=new po(1,1),eu=new Ki,iu=new Ji,nu=new pr,su=[],ru=[],au=new Float32Array(16),ou=new Float32Array(9),hu=new Float32Array(4);function lu(t,e,i){const n=t[0];if(n<=0||n>0)return t;const s=e*i;let r=su[s];if(void 0===r&&(r=new Float32Array(s),su[s]=r),0!==e){n.toArray(r,0);for(let n=1,s=0;n!==e;++n)s+=i,t[n].toArray(r,s)}return r}function cu(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function du(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function uu(t,e){let i=ru[e];void 0===i&&(i=new Int32Array(e),ru[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function pu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function mu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(cu(i,e))return;t.uniform2fv(this.addr,e),du(i,e)}}function fu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(cu(i,e))return;t.uniform3fv(this.addr,e),du(i,e)}}function gu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(cu(i,e))return;t.uniform4fv(this.addr,e),du(i,e)}}function vu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(cu(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),du(i,e)}else{if(cu(i,n))return;hu.set(n),t.uniformMatrix2fv(this.addr,!1,hu),du(i,n)}}function _u(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(cu(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),du(i,e)}else{if(cu(i,n))return;ou.set(n),t.uniformMatrix3fv(this.addr,!1,ou),du(i,n)}}function yu(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(cu(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),du(i,e)}else{if(cu(i,n))return;au.set(n),t.uniformMatrix4fv(this.addr,!1,au),du(i,n)}}function xu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function bu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(cu(i,e))return;t.uniform2iv(this.addr,e),du(i,e)}}function Su(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(cu(i,e))return;t.uniform3iv(this.addr,e),du(i,e)}}function wu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(cu(i,e))return;t.uniform4iv(this.addr,e),du(i,e)}}function Mu(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Tu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(cu(i,e))return;t.uniform2uiv(this.addr,e),du(i,e)}}function Eu(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(cu(i,e))return;t.uniform3uiv(this.addr,e),du(i,e)}}function Au(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(cu(i,e))return;t.uniform4uiv(this.addr,e),du(i,e)}}function Cu(t,e,i){const n=this.cache,s=i.allocateTextureUnit();let r;n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),this.type===t.SAMPLER_2D_SHADOW?(tu.compareFunction=i.isReversedDepthBuffer()?Je:qe,r=tu):r=$d,i.setTexture2D(e||r,s)}function Lu(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture3D(e||iu,s)}function Ru(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTextureCube(e||nu,s)}function Iu(t,e,i){const n=this.cache,s=i.allocateTextureUnit();n[0]!==s&&(t.uniform1i(this.addr,s),n[0]=s),i.setTexture2DArray(e||eu,s)}function Pu(t,e){t.uniform1fv(this.addr,e)}function Du(t,e){const i=lu(e,this.size,2);t.uniform2fv(this.addr,i)}function Ou(t,e){const i=lu(e,this.size,3);t.uniform3fv(this.addr,i)}function Nu(t,e){const i=lu(e,this.size,4);t.uniform4fv(this.addr,i)}function Uu(t,e){const i=lu(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Fu(t,e){const i=lu(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Bu(t,e){const i=lu(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function ku(t,e){t.uniform1iv(this.addr,e)}function zu(t,e){t.uniform2iv(this.addr,e)}function Gu(t,e){t.uniform3iv(this.addr,e)}function Hu(t,e){t.uniform4iv(this.addr,e)}function Vu(t,e){t.uniform1uiv(this.addr,e)}function Wu(t,e){t.uniform2uiv(this.addr,e)}function ju(t,e){t.uniform3uiv(this.addr,e)}function Xu(t,e){t.uniform4uiv(this.addr,e)}function Yu(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);let a;cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r)),a=this.type===t.SAMPLER_2D_SHADOW?tu:$d;for(let t=0;t!==s;++t)i.setTexture2D(e[t]||a,r[t])}function qu(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r));for(let t=0;t!==s;++t)i.setTexture3D(e[t]||iu,r[t])}function Zu(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r));for(let t=0;t!==s;++t)i.setTextureCube(e[t]||nu,r[t])}function Ku(t,e,i){const n=this.cache,s=e.length,r=uu(i,s);cu(n,r)||(t.uniform1iv(this.addr,r),du(n,r));for(let t=0;t!==s;++t)i.setTexture2DArray(e[t]||eu,r[t])}class Ju{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return pu;case 35664:return mu;case 35665:return fu;case 35666:return gu;case 35674:return vu;case 35675:return _u;case 35676:return yu;case 5124:case 35670:return xu;case 35667:case 35671:return bu;case 35668:case 35672:return Su;case 35669:case 35673:return wu;case 5125:return Mu;case 36294:return Tu;case 36295:return Eu;case 36296:return Au;case 35678:case 36198:case 36298:case 36306:case 35682:return Cu;case 35679:case 36299:case 36307:return Lu;case 35680:case 36300:case 36308:case 36293:return Ru;case 36289:case 36303:case 36311:case 36292:return Iu}}(e.type)}}class Qu{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Pu;case 35664:return Du;case 35665:return Ou;case 35666:return Nu;case 35674:return Uu;case 35675:return Fu;case 35676:return Bu;case 5124:case 35670:return ku;case 35667:case 35671:return zu;case 35668:case 35672:return Gu;case 35669:case 35673:return Hu;case 5125:return Vu;case 36294:return Wu;case 36295:return ju;case 36296:return Xu;case 35678:case 36198:case 36298:case 36306:case 35682:return Yu;case 35679:case 36299:case 36307:return qu;case 35680:case 36300:case 36308:case 36293:return Zu;case 36289:case 36303:case 36311:case 36292:return Ku}}(e.type)}}class $u{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let s=0,r=n.length;s!==r;++s){const r=n[s];r.setValue(t,e[r.id],i)}}}const tp=/(\w+)(\])?(\[|\.)?/g;function ep(t,e){t.seq.push(e),t.map[e.id]=e}function ip(t,e,i){const n=t.name,s=n.length;for(tp.lastIndex=0;;){const r=tp.exec(n),a=tp.lastIndex;let o=r[1];const h="]"===r[2],l=r[3];if(h&&(o|=0),void 0===l||"["===l&&a+2===s){ep(i,void 0===l?new Ju(o,t,e):new Qu(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new $u(o),ep(i,t)),i=t}}}class np{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);ip(i,t.getUniformLocation(e,i.name),this)}const n=[],s=[];for(const e of this.seq)e.type===t.SAMPLER_2D_SHADOW||e.type===t.SAMPLER_CUBE_SHADOW||e.type===t.SAMPLER_2D_ARRAY_SHADOW?n.push(e):s.push(e);n.length>0&&(this.seq=n.concat(s))}setValue(t,e,i,n){const s=this.map[e];void 0!==s&&s.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let s=0,r=e.length;s!==r;++s){const r=e[s],a=i[r.id];!1!==a.needsUpdate&&r.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,s=t.length;n!==s;++n){const s=t[n];s.id in e&&i.push(s)}return i}}function sp(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let rp=0;const ap=new Pi;function op(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(n&&""===s)return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const n=parseInt(r[1]);return i.toUpperCase()+"\n\n"+s+"\n\n"+function(t,e){const i=t.split("\n"),n=[],s=Math.max(e-6,0),r=Math.min(e+6,i.length);for(let t=s;t<r;t++){const s=t+1;n.push(`${s===e?">":" "} ${s}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return s}function hp(t,e){const i=function(t){Ui._getMatrix(ap,Ui.workingColorSpace,t);const e=`mat3( ${ap.elements.map(t=>t.toFixed(4))} )`;switch(Ui.getTransfer(t)){case He:return[e,"LinearTransferOETF"];case Ve:return[e,"sRGBTransferOETF"];default:return ui("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}const lp={[it]:"Linear",[nt]:"Reinhard",[st]:"Cineon",[rt]:"ACESFilmic",[ot]:"AgX",[ht]:"Neutral",[at]:"Custom"};function cp(t,e){const i=lp[e];return void 0===i?(ui("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const dp=new Li;function up(){Ui.getLuminanceCoefficients(dp);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${dp.x.toFixed(4)}, ${dp.y.toFixed(4)}, ${dp.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function pp(t){return""!==t}function mp(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function fp(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const gp=/^[ \t]*#include +<([\w\d./]+)>/gm;function vp(t){return t.replace(gp,yp)}const _p=new Map;function yp(t,e){let i=vd[e];if(void 0===i){const t=_p.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=vd[t],ui('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return vp(i)}const xp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function bp(t){return t.replace(xp,Sp)}function Sp(t,e,i,n){let s="";for(let t=parseInt(e);t<parseInt(i);t++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return s}function wp(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}const Mp={[S]:"SHADOWMAP_TYPE_PCF",[w]:"SHADOWMAP_TYPE_VSM"};const Tp={[ut]:"ENVMAP_TYPE_CUBE",[pt]:"ENVMAP_TYPE_CUBE",[gt]:"ENVMAP_TYPE_CUBE_UV"};const Ep={[pt]:"ENVMAP_MODE_REFRACTION"};const Ap={[$]:"ENVMAP_BLENDING_MULTIPLY",[tt]:"ENVMAP_BLENDING_MIX",[et]:"ENVMAP_BLENDING_ADD"};function Cp(t,e,i,n){const s=t.getContext(),r=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(t){return Mp[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(i),l=function(t){return!1===t.envMap?"ENVMAP_TYPE_CUBE":Tp[t.envMapMode]||"ENVMAP_TYPE_CUBE"}(i),c=function(t){return!1===t.envMap?"ENVMAP_MODE_REFLECTION":Ep[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}(i),d=function(t){return!1===t.envMap?"ENVMAP_BLENDING_NONE":Ap[t.combine]||"ENVMAP_BLENDING_NONE"}(i),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(pp).join("\n")}(i),m=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(r),f=s.createProgram();let g,v,_=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(pp).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m].filter(pp).join("\n"),v.length>0&&(v+="\n")):(g=[wp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(pp).join("\n"),v=[wp(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor||i.batchingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?vd.tonemapping_pars_fragment:"",0!==i.toneMapping?cp("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",vd.colorspace_pars_fragment,hp("linearToOutputTexel",i.outputColorSpace),up(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(pp).join("\n")),a=vp(a),a=mp(a,i),a=fp(a,i),o=vp(o),o=mp(o,i),o=fp(o,i),a=bp(a),o=bp(o),!0!==i.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",i.glslVersion===ti?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ti?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const y=_+g+a,x=_+v+o,b=sp(s,s.VERTEX_SHADER,y),S=sp(s,s.FRAGMENT_SHADER,x);function w(e){if(t.debug.checkShaderErrors){const i=s.getProgramInfoLog(f)||"",n=s.getShaderInfoLog(b)||"",r=s.getShaderInfoLog(S)||"",a=i.trim(),o=n.trim(),h=r.trim();let l=!0,c=!0;if(!1===s.getProgramParameter(f,s.LINK_STATUS))if(l=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(s,f,b,S);else{const t=op(s,b,"vertex"),i=op(s,S,"fragment");pi("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(f,s.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+a+"\n"+t+"\n"+i)}else""!==a?ui("WebGLProgram: Program Info Log:",a):""!==o&&""!==h||(c=!1);c&&(e.diagnostics={runnable:l,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:h,prefix:v}})}s.deleteShader(b),s.deleteShader(S),M=new np(s,f),T=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const n=t.getActiveAttrib(e,s),r=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[r]={type:n.type,location:t.getAttribLocation(e,r),locationSize:a}}return i}(s,f)}let M,T;s.attachShader(f,b),s.attachShader(f,S),void 0!==i.index0AttributeName?s.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(f,0,"position"),s.linkProgram(f),this.getUniforms=function(){return void 0===M&&w(this),M},this.getAttributes=function(){return void 0===T&&w(this),T};let E=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===E&&(E=s.getProgramParameter(f,37297)),E},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=rp++,this.cacheKey=e,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=S,this}let Lp=0;class Rp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),s=this._getShaderStage(i),r=this._getShaderCacheForMaterial(t);return!1===r.has(n)&&(r.add(n),n.usedTimes++),!1===r.has(s)&&(r.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new Ip(t),e.set(t,i)),i}}class Ip{constructor(t){this.id=Lp++,this.code=t,this.usedTimes=0}}function Pp(t,e,i,n,s,r,a){const o=new Fn,h=new Rp,l=new Set,c=[],d=new Map,u=s.logarithmicDepthBuffer;let p=s.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function f(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(r,o,c,d,g){const v=d.fog,_=g.geometry,y=r.isMeshStandardMaterial?d.environment:null,x=(r.isMeshStandardMaterial?i:e).get(r.envMap||y),b=x&&x.mapping===gt?x.image.height:null,S=m[r.type];null!==r.precision&&(p=s.getMaxPrecision(r.precision),p!==r.precision&&ui("WebGLProgram.getParameters:",r.precision,"not supported, using",p,"instead."));const w=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,M=void 0!==w?w.length:0;let T,E,A,C,L=0;if(void 0!==_.morphAttributes.position&&(L=1),void 0!==_.morphAttributes.normal&&(L=2),void 0!==_.morphAttributes.color&&(L=3),S){const t=yd[S];T=t.vertexShader,E=t.fragmentShader}else T=r.vertexShader,E=r.fragmentShader,h.update(r),A=h.getVertexShaderID(r),C=h.getFragmentShaderID(r);const R=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),P=!0===g.isInstancedMesh,D=!0===g.isBatchedMesh,O=!!r.map,N=!!r.matcap,U=!!x,F=!!r.aoMap,B=!!r.lightMap,k=!!r.bumpMap,z=!!r.normalMap,G=!!r.displacementMap,H=!!r.emissiveMap,V=!!r.metalnessMap,W=!!r.roughnessMap,j=r.anisotropy>0,X=r.clearcoat>0,Y=r.dispersion>0,q=r.iridescence>0,Z=r.sheen>0,K=r.transmission>0,J=j&&!!r.anisotropyMap,Q=X&&!!r.clearcoatMap,$=X&&!!r.clearcoatNormalMap,tt=X&&!!r.clearcoatRoughnessMap,et=q&&!!r.iridescenceMap,it=q&&!!r.iridescenceThicknessMap,nt=Z&&!!r.sheenColorMap,st=Z&&!!r.sheenRoughnessMap,rt=!!r.specularMap,at=!!r.specularColorMap,ot=!!r.specularIntensityMap,ht=K&&!!r.transmissionMap,lt=K&&!!r.thicknessMap,ct=!!r.gradientMap,dt=!!r.alphaMap,ut=r.alphaTest>0,pt=!!r.alphaHash,mt=!!r.extensions;let ft=0;r.toneMapped&&(null!==R&&!0!==R.isXRRenderTarget||(ft=t.toneMapping));const vt={shaderID:S,shaderType:r.type,shaderName:r.name,vertexShader:T,fragmentShader:E,defines:r.defines,customVertexShaderID:A,customFragmentShaderID:C,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:p,batching:D,batchingColor:D&&null!==g._colorsTexture,instancing:P,instancingColor:P&&null!==g.instanceColor,instancingMorph:P&&null!==g.morphTexture,outputColorSpace:null===R?t.outputColorSpace:!0===R.isXRRenderTarget?R.texture.colorSpace:Ge,alphaToCoverage:!!r.alphaToCoverage,map:O,matcap:N,envMap:U,envMapMode:U&&x.mapping,envMapCubeUVHeight:b,aoMap:F,lightMap:B,bumpMap:k,normalMap:z,displacementMap:G,emissiveMap:H,normalMapObjectSpace:z&&1===r.normalMapType,normalMapTangentSpace:z&&0===r.normalMapType,metalnessMap:V,roughnessMap:W,anisotropy:j,anisotropyMap:J,clearcoat:X,clearcoatMap:Q,clearcoatNormalMap:$,clearcoatRoughnessMap:tt,dispersion:Y,iridescence:q,iridescenceMap:et,iridescenceThicknessMap:it,sheen:Z,sheenColorMap:nt,sheenRoughnessMap:st,specularMap:rt,specularColorMap:at,specularIntensityMap:ot,transmission:K,transmissionMap:ht,thicknessMap:lt,gradientMap:ct,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:dt,alphaTest:ut,alphaHash:pt,combine:r.combine,mapUv:O&&f(r.map.channel),aoMapUv:F&&f(r.aoMap.channel),lightMapUv:B&&f(r.lightMap.channel),bumpMapUv:k&&f(r.bumpMap.channel),normalMapUv:z&&f(r.normalMap.channel),displacementMapUv:G&&f(r.displacementMap.channel),emissiveMapUv:H&&f(r.emissiveMap.channel),metalnessMapUv:V&&f(r.metalnessMap.channel),roughnessMapUv:W&&f(r.roughnessMap.channel),anisotropyMapUv:J&&f(r.anisotropyMap.channel),clearcoatMapUv:Q&&f(r.clearcoatMap.channel),clearcoatNormalMapUv:$&&f(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&f(r.clearcoatRoughnessMap.channel),iridescenceMapUv:et&&f(r.iridescenceMap.channel),iridescenceThicknessMapUv:it&&f(r.iridescenceThicknessMap.channel),sheenColorMapUv:nt&&f(r.sheenColorMap.channel),sheenRoughnessMapUv:st&&f(r.sheenRoughnessMap.channel),specularMapUv:rt&&f(r.specularMap.channel),specularColorMapUv:at&&f(r.specularColorMap.channel),specularIntensityMapUv:ot&&f(r.specularIntensityMap.channel),transmissionMapUv:ht&&f(r.transmissionMap.channel),thicknessMapUv:lt&&f(r.thicknessMap.channel),alphaMapUv:dt&&f(r.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(z||j),vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!_.attributes.uv&&(O||dt),fog:!!v,useFog:!0===r.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===r.flatShading&&!1===r.wireframe,sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:u,reversedDepthBuffer:I,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:M,morphTextureStride:L,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:ft,decodeVideoTexture:O&&!0===r.map.isVideoTexture&&Ui.getTransfer(r.map.colorSpace)===Ve,decodeVideoTextureEmissive:H&&!0===r.emissiveMap.isVideoTexture&&Ui.getTransfer(r.emissiveMap.colorSpace)===Ve,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:mt&&!0===r.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(mt&&!0===r.extensions.multiDraw||D)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.instancing&&o.enable(0);e.instancingColor&&o.enable(1);e.instancingMorph&&o.enable(2);e.matcap&&o.enable(3);e.envMap&&o.enable(4);e.normalMapObjectSpace&&o.enable(5);e.normalMapTangentSpace&&o.enable(6);e.clearcoat&&o.enable(7);e.iridescence&&o.enable(8);e.alphaTest&&o.enable(9);e.vertexColors&&o.enable(10);e.vertexAlphas&&o.enable(11);e.vertexUv1s&&o.enable(12);e.vertexUv2s&&o.enable(13);e.vertexUv3s&&o.enable(14);e.vertexTangents&&o.enable(15);e.anisotropy&&o.enable(16);e.alphaHash&&o.enable(17);e.batching&&o.enable(18);e.dispersion&&o.enable(19);e.batchingColor&&o.enable(20);e.gradientMap&&o.enable(21);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.reversedDepthBuffer&&o.enable(4);e.skinning&&o.enable(5);e.morphTargets&&o.enable(6);e.morphNormals&&o.enable(7);e.morphColors&&o.enable(8);e.premultipliedAlpha&&o.enable(9);e.shadowMapEnabled&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);e.decodeVideoTextureEmissive&&o.enable(20);e.alphaToCoverage&&o.enable(21);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=m[t.type];let i;if(e){const t=yd[e];i=sr.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n=d.get(i);return void 0!==n?++n.usedTimes:(n=new Cp(t,i,e,r),c.push(n),d.set(i,n)),n},releaseProgram:function(t){if(0===--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),d.delete(t.cacheKey),t.destroy()}},releaseShaderCache:function(t){h.remove(t)},programs:c,dispose:function(){h.dispose()}}}function Dp(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Op(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Np(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Up(){const t=[];let e=0;const i=[],n=[],s=[];function r(i,n,s,r,a,o){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:s,groupOrder:r,renderOrder:i.renderOrder,z:a,group:o},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=s,h.groupOrder=r,h.renderOrder=i.renderOrder,h.z=a,h.group=o),e++,h}return{opaque:i,transmissive:n,transparent:s,init:function(){e=0,i.length=0,n.length=0,s.length=0},push:function(t,e,a,o,h,l){const c=r(t,e,a,o,h,l);a.transmission>0?n.push(c):!0===a.transparent?s.push(c):i.push(c)},unshift:function(t,e,a,o,h,l){const c=r(t,e,a,o,h,l);a.transmission>0?n.unshift(c):!0===a.transparent?s.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||Op),n.length>1&&n.sort(e||Np),s.length>1&&s.sort(e||Np)}}}function Fp(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let s;return void 0===n?(s=new Up,t.set(e,[s])):i>=n.length?(s=new Up,n.push(s)):s=n[i],s},dispose:function(){t=new WeakMap}}}function Bp(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Li,color:new _s};break;case"SpotLight":i={position:new Li,direction:new Li,color:new _s,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Li,color:new _s,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Li,skyColor:new _s,groundColor:new _s};break;case"RectAreaLight":i={color:new _s,position:new Li,halfWidth:new Li,halfHeight:new Li}}return t[e.id]=i,i}}}let kp=0;function zp(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Gp(t){const e=new Bp,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ai};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ai,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)n.probe.push(new Li);const s=new Li,r=new En,a=new En;return{setup:function(s){let r=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let h=0,l=0,c=0,d=0,u=0,p=0,m=0,f=0,g=0,v=0,_=0;s.sort(zp);for(let t=0,y=s.length;t<y;t++){const y=s[t],x=y.color,b=y.intensity,S=y.distance;let w=null;if(y.shadow&&y.shadow.map&&(w=y.shadow.map.texture.format===Xt?y.shadow.map.texture:y.shadow.map.depthTexture||y.shadow.map.texture),y.isAmbientLight)r+=x.r*b,a+=x.g*b,o+=x.b*b;else if(y.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(y.sh.coefficients[t],b);_++}else if(y.isDirectionalLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[h]=e,n.directionalShadowMap[h]=w,n.directionalShadowMatrix[h]=y.shadow.matrix,p++}n.directional[h]=t,h++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(b),t.distance=S,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,n.spot[c]=t;const s=y.shadow;if(y.map&&(n.spotLightMap[g]=y.map,g++,s.updateMatrices(y),y.castShadow&&v++),n.spotLightMatrix[c]=s.matrix,y.castShadow){const t=i.get(y);t.shadowIntensity=s.intensity,t.shadowBias=s.bias,t.shadowNormalBias=s.normalBias,t.shadowRadius=s.radius,t.shadowMapSize=s.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=w,f++}c++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(b),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),n.rectArea[d]=t,d++}else if(y.isPointLight){const t=e.get(y);if(t.color.copy(y.color).multiplyScalar(y.intensity),t.distance=y.distance,t.decay=y.decay,y.castShadow){const t=y.shadow,e=i.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[l]=e,n.pointShadowMap[l]=w,n.pointShadowMatrix[l]=y.shadow.matrix,m++}n.point[l]=t,l++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(b),t.groundColor.copy(y.groundColor).multiplyScalar(b),n.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=_d.LTC_FLOAT_1,n.rectAreaLTC2=_d.LTC_FLOAT_2):(n.rectAreaLTC1=_d.LTC_HALF_1,n.rectAreaLTC2=_d.LTC_HALF_2)),n.ambient[0]=r,n.ambient[1]=a,n.ambient[2]=o;const y=n.hash;y.directionalLength===h&&y.pointLength===l&&y.spotLength===c&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===m&&y.numSpotShadows===f&&y.numSpotMaps===g&&y.numLightProbes===_||(n.directional.length=h,n.spot.length=c,n.rectArea.length=d,n.point.length=l,n.hemi.length=u,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=m,n.pointShadowMap.length=m,n.spotShadow.length=f,n.spotShadowMap.length=f,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=m,n.spotLightMatrix.length=f+g-v,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=v,n.numLightProbes=_,y.directionalLength=h,y.pointLength=l,y.spotLength=c,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=f,y.numSpotMaps=g,y.numLightProbes=_,n.version=kp++)},setupView:function(t,e){let i=0,o=0,h=0,l=0,c=0;const d=e.matrixWorldInverse;for(let e=0,u=t.length;e<u;e++){const u=t[e];if(u.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(u.matrixWorld),s.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(d),i++}else if(u.isSpotLight){const t=n.spot[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),s.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(d),h++}else if(u.isRectAreaLight){const t=n.rectArea[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),r.copy(u.matrixWorld),r.premultiply(d),a.extractRotation(r),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),l++}else if(u.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:n}}function Hp(t){const e=new Gp(t),i=[],n=[];const s={lightsArray:i,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){s.camera=t,i.length=0,n.length=0},state:s,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)}}}function Vp(t){let e=new WeakMap;return{get:function(i,n=0){const s=e.get(i);let r;return void 0===s?(r=new Hp(t),e.set(i,[r])):n>=s.length?(r=new Hp(t),s.push(r)):r=s[n],r},dispose:function(){e=new WeakMap}}}const Wp=[new Li(1,0,0),new Li(-1,0,0),new Li(0,1,0),new Li(0,-1,0),new Li(0,0,1),new Li(0,0,-1)],jp=[new Li(0,-1,0),new Li(0,-1,0),new Li(0,0,1),new Li(0,0,-1),new Li(0,-1,0),new Li(0,-1,0)],Xp=new En,Yp=new Li,qp=new Li;function Zp(t,e,i){let n=new xa;const s=new Ai,r=new Ai,a=new Yi,o=new Kh,h=new Jh,l={},c=i.maxTextureSize,d={[M]:1,[T]:0,[E]:2},u=new rr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ai},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const m=new zs;m.setAttribute("position",new Ls(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Qs(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(i,n){const r=e.update(f);u.defines.VSM_SAMPLES!==i.blurSamples&&(u.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new Zi(s.x,s.y,{format:Xt,type:Dt})),u.uniforms.shadow_pass.value=i.map.depthTexture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,u,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,p,f,null)}function y(e,i,n,s){let r=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)r=a;else if(r=!0===n.isPointLight?h:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0||!0===i.alphaToCoverage){const t=r.uuid,e=i.uuid;let n=l[t];void 0===n&&(n={},l[t]=n);let s=n[e];void 0===s&&(s=r.clone(),n[e]=s,i.addEventListener("dispose",b)),r=s}if(r.visible=i.visible,r.wireframe=i.wireframe,r.side=3===s?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],r.alphaMap=i.alphaMap,r.alphaTest=!0===i.alphaToCoverage?.5:i.alphaTest,r.map=i.map,r.clipShadows=i.clipShadows,r.clippingPlanes=i.clippingPlanes,r.clipIntersection=i.clipIntersection,r.displacementMap=i.displacementMap,r.displacementScale=i.displacementScale,r.displacementBias=i.displacementBias,r.wireframeLinewidth=i.wireframeLinewidth,r.linewidth=i.linewidth,!0===n.isPointLight&&!0===r.isMeshDistanceMaterial){t.properties.get(r).light=n}return r}function x(i,s,r,a,o){if(!1===i.visible)return;if(i.layers.test(s.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,i.matrixWorld);const n=e.update(i),h=i.material;if(Array.isArray(h)){const e=n.groups;for(let l=0,c=e.length;l<c;l++){const c=e[l],d=h[c.materialIndex];if(d&&d.visible){const e=y(i,d,a,o);i.onBeforeShadow(t,i,s,r,n,e,c),t.renderBufferDirect(r,null,n,e,i,c),i.onAfterShadow(t,i,s,r,n,e,c)}}}else if(h.visible){const e=y(i,h,a,o);i.onBeforeShadow(t,i,s,r,n,e,null),t.renderBufferDirect(r,null,n,e,i,null),i.onAfterShadow(t,i,s,r,n,e,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)x(h[t],s,r,a,o)}function b(t){t.target.removeEventListener("dispose",b);for(const e in l){const i=l[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;2===e.type&&(ui("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),e.type=1);const h=t.getRenderTarget(),l=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=v!==this.type;p&&i.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.needsUpdate=!0):t.material.needsUpdate=!0)});for(let h=0,l=e.length;h<l;h++){const l=e[h],d=l.shadow;if(void 0===d){ui("WebGLShadowMap:",l,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;s.copy(d.mapSize);const m=d.getFrameExtents();if(s.multiply(m),r.copy(d.mapSize),(s.x>c||s.y>c)&&(s.x>c&&(r.x=Math.floor(c/m.x),s.x=r.x*m.x,d.mapSize.x=r.x),s.y>c&&(r.y=Math.floor(c/m.y),s.y=r.y*m.y,d.mapSize.y=r.y)),null===d.map||!0===p){if(null!==d.map&&(null!==d.map.depthTexture&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),3===this.type){if(l.isPointLight){ui("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}d.map=new Zi(s.x,s.y,{format:Xt,type:Dt,minFilter:wt,magFilter:wt,generateMipmaps:!1}),d.map.texture.name=l.name+".shadowMap",d.map.depthTexture=new po(s.x,s.y,Pt),d.map.depthTexture.name=l.name+".shadowMapDepth",d.map.depthTexture.format=Ht,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=xt,d.map.depthTexture.magFilter=xt}else{l.isPointLight?(d.map=new mr(s.x),d.map.depthTexture=new mo(s.x,It)):(d.map=new Zi(s.x,s.y),d.map.depthTexture=new po(s.x,s.y,It)),d.map.depthTexture.name=l.name+".shadowMap",d.map.depthTexture.format=Ht;const e=t.state.buffers.depth.getReversed();1===this.type?(d.map.depthTexture.compareFunction=e?Je:qe,d.map.depthTexture.minFilter=wt,d.map.depthTexture.magFilter=wt):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=xt,d.map.depthTexture.magFilter=xt)}d.camera.updateProjectionMatrix()}const f=d.map.isWebGLCubeRenderTarget?6:1;for(let e=0;e<f;e++){if(d.map.isWebGLCubeRenderTarget)t.setRenderTarget(d.map,e),t.clear();else{0===e&&(t.setRenderTarget(d.map),t.clear());const i=d.getViewport(e);a.set(r.x*i.x,r.y*i.y,r.x*i.z,r.y*i.w),u.viewport(a)}if(l.isPointLight){const t=d.camera,i=d.matrix,n=l.distance||t.far;n!==t.far&&(t.far=n,t.updateProjectionMatrix()),Yp.setFromMatrixPosition(l.matrixWorld),t.position.copy(Yp),qp.copy(t.position),qp.add(Wp[e]),t.up.copy(jp[e]),t.lookAt(qp),t.updateMatrixWorld(),i.makeTranslation(-Yp.x,-Yp.y,-Yp.z),Xp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),d._frustum.setFromProjectionMatrix(Xp,t.coordinateSystem,t.reversedDepth)}else d.updateMatrices(l);n=d.getFrustum(),x(i,o,d.camera,l,this.type)}!0!==d.isPointLightShadow&&3===this.type&&_(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,t.setRenderTarget(h,l,d)}}const Kp={[j]:1,[Y]:6,[Z]:7,[q]:5,[X]:0,[J]:2,[Q]:4,[K]:3};function Jp(t,e){const i=new function(){let e=!1;const i=new Yi;let n=null;const s=new Yi(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,r,a,o){!0===o&&(e*=a,n*=a,r*=a),i.set(e,n,r,a),!1===s.equals(i)&&(t.clearColor(e,n,r,a),s.copy(i))},reset:function(){e=!1,n=null,s.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,s=null,r=null,a=null;return{setReversed:function(t){if(n!==t){const i=e.get("EXT_clip_control");t?i.clipControlEXT(i.LOWER_LEFT_EXT,i.ZERO_TO_ONE_EXT):i.clipControlEXT(i.LOWER_LEFT_EXT,i.NEGATIVE_ONE_TO_ONE_EXT),n=t;const s=a;a=null,this.setClear(s)}},getReversed:function(){return n},setTest:function(e){e?st(t.DEPTH_TEST):rt(t.DEPTH_TEST)},setMask:function(e){s===e||i||(t.depthMask(e),s=e)},setFunc:function(e){if(n&&(e=Kp[e]),r!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}r=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(n&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){i=!1,s=null,r=null,a=null,n=!1}}},s=new function(){let e=!1,i=null,n=null,s=null,r=null,a=null,o=null,h=null,l=null;return{setTest:function(i){e||(i?st(t.STENCIL_TEST):rt(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&s===i&&r===a||(t.stencilFunc(e,i,a),n=e,s=i,r=a)},setOp:function(e,i,n){a===e&&o===i&&h===n||(t.stencilOp(e,i,n),a=e,o=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,s=null,r=null,a=null,o=null,h=null,l=null}}},r=new WeakMap,a=new WeakMap;let o={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new _s(0,0,0),b=0,S=!1,w=null,M=null,T=null,E=null,j=null;const X=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const Z=t.getParameter(t.VERSION);-1!==Z.indexOf("WebGL")?(q=parseFloat(/^WebGL (\d)/.exec(Z)[1]),Y=q>=1):-1!==Z.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let K=null,J={};const Q=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),tt=(new Yi).fromArray(Q),et=(new Yi).fromArray($);function it(e,i,n,s){const r=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,s,0,t.RGBA,t.UNSIGNED_BYTE,r):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,r);return a}const nt={};function st(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function rt(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}nt[t.TEXTURE_2D]=it(t.TEXTURE_2D,t.TEXTURE_2D,1),nt[t.TEXTURE_CUBE_MAP]=it(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),nt[t.TEXTURE_2D_ARRAY]=it(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),nt[t.TEXTURE_3D]=it(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),s.setClear(0),st(t.DEPTH_TEST),n.setFunc(3),lt(!1),ct(1),st(t.CULL_FACE),ht(0);const at={[A]:t.FUNC_ADD,[C]:t.FUNC_SUBTRACT,[L]:t.FUNC_REVERSE_SUBTRACT};at[103]=t.MIN,at[104]=t.MAX;const ot={[R]:t.ZERO,[I]:t.ONE,[P]:t.SRC_COLOR,[O]:t.SRC_ALPHA,[z]:t.SRC_ALPHA_SATURATE,[B]:t.DST_COLOR,[U]:t.DST_ALPHA,[D]:t.ONE_MINUS_SRC_COLOR,[N]:t.ONE_MINUS_SRC_ALPHA,[k]:t.ONE_MINUS_DST_COLOR,[F]:t.ONE_MINUS_DST_ALPHA,[G]:t.CONSTANT_COLOR,[H]:t.ONE_MINUS_CONSTANT_COLOR,[V]:t.CONSTANT_ALPHA,[W]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,s,r,a,o,h,l,c){if(0!==e){if(!1===u&&(st(t.BLEND),u=!0),5===e)r=r||i,a=a||n,o=o||s,i===m&&r===v||(t.blendEquationSeparate(at[i],at[r]),m=i,v=r),n===f&&s===g&&a===_&&o===y||(t.blendFuncSeparate(ot[n],ot[s],ot[a],ot[o]),f=n,g=s,_=a,y=o),!1!==h.equals(x)&&l===b||(t.blendColor(h.r,h.g,h.b,l),x.copy(h),b=l),p=e,S=!1;else if(e!==p||c!==S){if(m===A&&v===A||(t.blendEquation(t.FUNC_ADD),m=A,v=A),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:pi("WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:pi("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:pi("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:pi("WebGLState: Invalid blending: ",e)}f=null,g=null,_=null,y=null,x.set(0,0,0),b=0,p=e,S=c}}else!0===u&&(rt(t.BLEND),u=!1)}function lt(e){w!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),w=e)}function ct(e){0!==e?(st(t.CULL_FACE),e!==M&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):rt(t.CULL_FACE),M=e}function dt(e,i,n){e?(st(t.POLYGON_OFFSET_FILL),E===i&&j===n||(t.polygonOffset(i,n),E=i,j=n)):rt(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:s},enable:st,disable:rt,bindFramebuffer:function(e,i){return h[e]!==i&&(t.bindFramebuffer(e,i),h[e]=i,e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=c,s=!1;if(e){n=l.get(i),void 0===n&&(n=[],l.set(i,n));const r=e.textures;if(n.length!==r.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=r.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=r.length,s=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,s=!0);s&&t.drawBuffers(n)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,r){2===e.side?rt(t.CULL_FACE):st(t.CULL_FACE);let a=1===e.side;r&&(a=!a),lt(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;s.setTest(o),o&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?st(t.SAMPLE_ALPHA_TO_COVERAGE):rt(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:lt,setCullFace:ct,setLineWidth:function(e){e!==T&&(Y&&t.lineWidth(e),T=e)},setPolygonOffset:dt,setScissorTest:function(e){e?st(t.SCISSOR_TEST):rt(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+X-1),K!==e&&(t.activeTexture(e),K=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===K?t.TEXTURE0+X-1:K);let s=J[n];void 0===s&&(s={type:void 0,texture:void 0},J[n]=s),s.type===e&&s.texture===i||(K!==n&&(t.activeTexture(n),K=n),t.bindTexture(e,i||nt[e]),s.type=e,s.texture=i)},unbindTexture:function(){const e=J[K];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let s=n.get(e);void 0===s&&(s=t.getUniformBlockIndex(i,e.name),n.set(e,s))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);r.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),r.set(i,n))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){pi("WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){pi("WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){pi("WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){pi("WebGLState:",t)}},scissor:function(e){!1===tt.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),tt.copy(e))},viewport:function(e){!1===et.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),et.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),o={},K=null,J={},h={},l=new WeakMap,c=[],d=null,u=!1,p=null,m=null,f=null,g=null,v=null,_=null,y=null,x=new _s(0,0,0),b=0,S=!1,w=null,M=null,T=null,E=null,j=null,tt.set(0,0,t.canvas.width,t.canvas.height),et.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),s.reset()}}}function Qp(t,e,i,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,h="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),l=new Ai,c=new WeakMap;let d;const u=new WeakMap;let p=!1;try{p="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return p?new OffscreenCanvas(t,e):oi("canvas")}function f(t,e,i){let n=1;const s=V(t);if((s.width>i||s.height>i)&&(n=i/Math.max(s.width,s.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*s.width),r=Math.floor(n*s.height);void 0===d&&(d=m(i,r));const a=e?m(i,r):d;a.width=i,a.height=r;return a.getContext("2d").drawImage(t,0,0,i,r),ui("WebGLRenderer: Texture has been resized from ("+s.width+"x"+s.height+") to ("+i+"x"+r+")."),a}return"data"in t&&ui("WebGLRenderer: Image in DataTexture is too big ("+s.width+"x"+s.height+")."),t}return t}function g(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function _(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(i,n,s,r,a=!1){if(null!==i){if(void 0!==t[i])return t[i];ui("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;if(n===t.RED&&(s===t.FLOAT&&(o=t.R32F),s===t.HALF_FLOAT&&(o=t.R16F),s===t.UNSIGNED_BYTE&&(o=t.R8)),n===t.RED_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.R8UI),s===t.UNSIGNED_SHORT&&(o=t.R16UI),s===t.UNSIGNED_INT&&(o=t.R32UI),s===t.BYTE&&(o=t.R8I),s===t.SHORT&&(o=t.R16I),s===t.INT&&(o=t.R32I)),n===t.RG&&(s===t.FLOAT&&(o=t.RG32F),s===t.HALF_FLOAT&&(o=t.RG16F),s===t.UNSIGNED_BYTE&&(o=t.RG8)),n===t.RG_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RG8UI),s===t.UNSIGNED_SHORT&&(o=t.RG16UI),s===t.UNSIGNED_INT&&(o=t.RG32UI),s===t.BYTE&&(o=t.RG8I),s===t.SHORT&&(o=t.RG16I),s===t.INT&&(o=t.RG32I)),n===t.RGB_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RGB8UI),s===t.UNSIGNED_SHORT&&(o=t.RGB16UI),s===t.UNSIGNED_INT&&(o=t.RGB32UI),s===t.BYTE&&(o=t.RGB8I),s===t.SHORT&&(o=t.RGB16I),s===t.INT&&(o=t.RGB32I)),n===t.RGBA_INTEGER&&(s===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),s===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),s===t.UNSIGNED_INT&&(o=t.RGBA32UI),s===t.BYTE&&(o=t.RGBA8I),s===t.SHORT&&(o=t.RGBA16I),s===t.INT&&(o=t.RGBA32I)),n===t.RGB&&(s===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),s===t.UNSIGNED_INT_10F_11F_11F_REV&&(o=t.R11F_G11F_B10F)),n===t.RGBA){const e=a?He:Ui.getTransfer(r);s===t.FLOAT&&(o=t.RGBA32F),s===t.HALF_FLOAT&&(o=t.RGBA16F),s===t.UNSIGNED_BYTE&&(o=e===Ve?t.SRGB8_ALPHA8:t.RGBA8),s===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),s===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function x(e,i){let n;return e?null===i||i===It||i===Ut?n=t.DEPTH24_STENCIL8:i===Pt?n=t.DEPTH32F_STENCIL8:i===Lt&&(n=t.DEPTH24_STENCIL8,ui("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===It||i===Ut?n=t.DEPTH_COMPONENT24:i===Pt?n=t.DEPTH_COMPONENT32F:i===Lt&&(n=t.DEPTH_COMPONENT16),n}function b(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==xt&&t.minFilter!==wt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function S(t){const e=t.target;e.removeEventListener("dispose",S),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,s=u.get(i);if(s){const n=s[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&M(t),0===Object.keys(s).length&&u.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function w(e){const i=e.target;i.removeEventListener("dispose",w),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const s=e.textures;for(let e=0,i=s.length;e<i;e++){const i=n.get(s[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(s[e])}n.remove(e)}(i)}function M(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const s=e.source;delete u.get(s)[i.__cacheKey],a.memory.textures--}let T=0;function E(e,s){const r=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&r.__version!==e.version){const t=e.image;if(null===t)ui("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(r,e,s);ui("WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(r.__webglTexture=e.sourceTexture?e.sourceTexture:null);i.bindTexture(t.TEXTURE_2D,r.__webglTexture,t.TEXTURE0+s)}const A={[vt]:t.REPEAT,[_t]:t.CLAMP_TO_EDGE,[yt]:t.MIRRORED_REPEAT},C={[xt]:t.NEAREST,[bt]:t.NEAREST_MIPMAP_NEAREST,[St]:t.NEAREST_MIPMAP_LINEAR,[wt]:t.LINEAR,[Mt]:t.LINEAR_MIPMAP_NEAREST,[Tt]:t.LINEAR_MIPMAP_LINEAR},L={[je]:t.NEVER,[Qe]:t.ALWAYS,[Xe]:t.LESS,[qe]:t.LEQUAL,[Ye]:t.EQUAL,[Je]:t.GEQUAL,[Ze]:t.GREATER,[Ke]:t.NOTEQUAL};function R(i,r){if(r.type!==Pt||!1!==e.has("OES_texture_float_linear")||r.magFilter!==wt&&r.magFilter!==Mt&&r.magFilter!==St&&r.magFilter!==Tt&&r.minFilter!==wt&&r.minFilter!==Mt&&r.minFilter!==St&&r.minFilter!==Tt||ui("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,A[r.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,A[r.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,A[r.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[r.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[r.minFilter]),r.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,L[r.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(r.magFilter===xt)return;if(r.minFilter!==St&&r.minFilter!==Tt)return;if(r.type===Pt&&!1===e.has("OES_texture_float_linear"))return;if(r.anisotropy>1||n.get(r).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,s.getMaxAnisotropy())),n.get(r).__currentAnisotropy=r.anisotropy}}}function I(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",S));const s=i.source;let r=u.get(s);void 0===r&&(r={},u.set(s,r));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===r[o]&&(r[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),r[o].usedTimes++;const s=r[e.__cacheKey];void 0!==s&&(r[e.__cacheKey].usedTimes--,0===s.usedTimes&&M(i)),e.__cacheKey=o,e.__webglTexture=r[o].texture}return n}function P(t,e,i){return Math.floor(Math.floor(t/i)/e)}function D(e,a,o){let h=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(h=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(h=t.TEXTURE_3D);const l=I(e,a),c=a.source;i.bindTexture(h,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=Ui.getPrimaries(Ui.workingColorSpace),n=a.colorSpace===ke?null:Ui.getPrimaries(a.colorSpace),u=a.colorSpace===ke||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=f(a.image,!1,s.maxTextureSize);p=H(a,p);const m=r.convert(a.format,a.colorSpace),_=r.convert(a.type);let S,w=y(a.internalFormat,m,_,a.colorSpace,a.isVideoTexture);R(h,a);const M=a.mipmaps,T=!0!==a.isVideoTexture,E=void 0===d.__version||!0===l,A=c.dataReady,C=b(a,p);if(a.isDepthTexture)w=x(a.format===Vt,a.type),E&&(T?i.texStorage2D(t.TEXTURE_2D,1,w,p.width,p.height):i.texImage2D(t.TEXTURE_2D,0,w,p.width,p.height,0,m,_,null));else if(a.isDataTexture)if(M.length>0){T&&E&&i.texStorage2D(t.TEXTURE_2D,C,w,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)S=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,S.width,S.height,m,_,S.data):i.texImage2D(t.TEXTURE_2D,e,w,S.width,S.height,0,m,_,S.data);a.generateMipmaps=!1}else T?(E&&i.texStorage2D(t.TEXTURE_2D,C,w,p.width,p.height),A&&function(e,n,s,r){const a=e.updateRanges;if(0===a.length)i.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,s,r,n.data);else{a.sort((t,e)=>t.start-e.start);let o=0;for(let t=1;t<a.length;t++){const e=a[o],i=a[t],s=e.start+e.count,r=P(i.start,n.width,4),h=P(e.start,n.width,4);i.start<=s+1&&r===h&&P(i.start+i.count-1,n.width,4)===r?e.count=Math.max(e.count,i.start+i.count-e.start):(++o,a[o]=i)}a.length=o+1;const h=t.getParameter(t.UNPACK_ROW_LENGTH),l=t.getParameter(t.UNPACK_SKIP_PIXELS),c=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,n.width);for(let e=0,o=a.length;e<o;e++){const o=a[e],h=Math.floor(o.start/4),l=Math.ceil(o.count/4),c=h%n.width,d=Math.floor(h/n.width),u=l,p=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,c),t.pixelStorei(t.UNPACK_SKIP_ROWS,d),i.texSubImage2D(t.TEXTURE_2D,0,c,d,u,p,s,r,n.data)}e.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,h),t.pixelStorei(t.UNPACK_SKIP_PIXELS,l),t.pixelStorei(t.UNPACK_SKIP_ROWS,c)}}(a,p,m,_)):i.texImage2D(t.TEXTURE_2D,0,w,p.width,p.height,0,m,_,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){T&&E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,w,M[0].width,M[0].height,p.depth);for(let e=0,n=M.length;e<n;e++)if(S=M[e],a.format!==Gt)if(null!==m)if(T){if(A)if(a.layerUpdates.size>0){const n=md(S.width,S.height,a.format,a.type);for(const s of a.layerUpdates){const r=S.data.subarray(s*n/S.data.BYTES_PER_ELEMENT,(s+1)*n/S.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,s,S.width,S.height,1,m,r)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,S.width,S.height,p.depth,m,S.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,w,S.width,S.height,p.depth,0,S.data,0,0);else ui("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,S.width,S.height,p.depth,m,_,S.data):i.texImage3D(t.TEXTURE_2D_ARRAY,e,w,S.width,S.height,p.depth,0,m,_,S.data)}else{T&&E&&i.texStorage2D(t.TEXTURE_2D,C,w,M[0].width,M[0].height);for(let e=0,n=M.length;e<n;e++)S=M[e],a.format!==Gt?null!==m?T?A&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,S.width,S.height,m,S.data):i.compressedTexImage2D(t.TEXTURE_2D,e,w,S.width,S.height,0,S.data):ui("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,S.width,S.height,m,_,S.data):i.texImage2D(t.TEXTURE_2D,e,w,S.width,S.height,0,m,_,S.data)}else if(a.isDataArrayTexture)if(T){if(E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,C,w,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=md(p.width,p.height,a.format,a.type);for(const n of a.layerUpdates){const s=p.data.subarray(n*e/p.data.BYTES_PER_ELEMENT,(n+1)*e/p.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,n,p.width,p.height,1,m,_,s)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,w,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isData3DTexture)T?(E&&i.texStorage3D(t.TEXTURE_3D,C,w,p.width,p.height,p.depth),A&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,_,p.data)):i.texImage3D(t.TEXTURE_3D,0,w,p.width,p.height,p.depth,0,m,_,p.data);else if(a.isFramebufferTexture){if(E)if(T)i.texStorage2D(t.TEXTURE_2D,C,w,p.width,p.height);else{let e=p.width,n=p.height;for(let s=0;s<C;s++)i.texImage2D(t.TEXTURE_2D,s,w,e,n,0,m,_,null),e>>=1,n>>=1}}else if(M.length>0){if(T&&E){const e=V(M[0]);i.texStorage2D(t.TEXTURE_2D,C,w,e.width,e.height)}for(let e=0,n=M.length;e<n;e++)S=M[e],T?A&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,m,_,S):i.texImage2D(t.TEXTURE_2D,e,w,m,_,S);a.generateMipmaps=!1}else if(T){if(E){const e=V(p);i.texStorage2D(t.TEXTURE_2D,C,w,e.width,e.height)}A&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,m,_,p)}else i.texImage2D(t.TEXTURE_2D,0,w,m,_,p);g(a)&&v(h),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function O(e,s,a,h,l,c){const d=r.convert(a.format,a.colorSpace),u=r.convert(a.type),p=y(a.internalFormat,d,u,a.colorSpace),m=n.get(s),f=n.get(a);if(f.__renderTarget=s,!m.__hasExternalTextures){const e=Math.max(1,s.width>>c),n=Math.max(1,s.height>>c);l===t.TEXTURE_3D||l===t.TEXTURE_2D_ARRAY?i.texImage3D(l,c,p,e,n,s.depth,0,d,u,null):i.texImage2D(l,c,p,e,n,0,d,u,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),G(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,h,l,f.__webglTexture,0,z(s)):(l===t.TEXTURE_2D||l>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,h,l,f.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function N(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const s=i.depthTexture,r=s&&s.isDepthTexture?s.type:null,a=x(i.stencilBuffer,r),h=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,z(i),a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,z(i),a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,h,t.RENDERBUFFER,e)}else{const e=i.textures;for(let s=0;s<e.length;s++){const a=e[s],h=r.convert(a.format,a.colorSpace),l=r.convert(a.type),c=y(a.internalFormat,h,l,a.colorSpace);G(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,z(i),c,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,z(i),c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e,s,a){const h=!0===s.isWebGLCubeRenderTarget;if(i.bindFramebuffer(t.FRAMEBUFFER,e),!s.depthTexture||!s.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const l=n.get(s.depthTexture);if(l.__renderTarget=s,l.__webglTexture&&s.depthTexture.image.width===s.width&&s.depthTexture.image.height===s.height||(s.depthTexture.image.width=s.width,s.depthTexture.image.height=s.height,s.depthTexture.needsUpdate=!0),h){if(void 0===l.__webglInit&&(l.__webglInit=!0,s.depthTexture.addEventListener("dispose",S)),void 0===l.__webglTexture){l.__webglTexture=t.createTexture(),i.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),R(t.TEXTURE_CUBE_MAP,s.depthTexture);const e=r.convert(s.depthTexture.format),n=r.convert(s.depthTexture.type);let a;s.depthTexture.format===Ht?a=t.DEPTH_COMPONENT24:s.depthTexture.format===Vt&&(a=t.DEPTH24_STENCIL8);for(let i=0;i<6;i++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,a,s.width,s.height,0,e,n,null)}}else E(s.depthTexture,0);const c=l.__webglTexture,d=z(s),u=h?t.TEXTURE_CUBE_MAP_POSITIVE_X+a:t.TEXTURE_2D,p=s.depthTexture.format===Vt?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(s.depthTexture.format===Ht)G(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,c,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,c,0);else{if(s.depthTexture.format!==Vt)throw new Error("Unknown depthTexture format");G(s)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,u,c,0,d):t.framebufferTexture2D(t.FRAMEBUFFER,p,u,c,0)}}function F(e){const s=n.get(e),r=!0===e.isWebGLCubeRenderTarget;if(s.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(s.__depthDisposeCallback&&s.__depthDisposeCallback(),t){const e=()=>{delete s.__boundDepthTexture,delete s.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),s.__depthDisposeCallback=e}s.__boundDepthTexture=t}if(e.depthTexture&&!s.__autoAllocateDepthBuffer)if(r)for(let t=0;t<6;t++)U(s.__webglFramebuffer[t],e,t);else{const t=e.texture.mipmaps;t&&t.length>0?U(s.__webglFramebuffer[0],e,0):U(s.__webglFramebuffer,e,0)}else if(r){s.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer[n]),void 0===s.__webglDepthbuffer[n])s.__webglDepthbuffer[n]=t.createRenderbuffer(),N(s.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,r=s.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,r)}}else{const n=e.texture.mipmaps;if(n&&n.length>0?i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer[0]):i.bindFramebuffer(t.FRAMEBUFFER,s.__webglFramebuffer),void 0===s.__webglDepthbuffer)s.__webglDepthbuffer=t.createRenderbuffer(),N(s.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=s.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}}i.bindFramebuffer(t.FRAMEBUFFER,null)}const B=[],k=[];function z(t){return Math.min(s.maxSamples,t.samples)}function G(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function H(t,e){const i=t.colorSpace,n=t.format,s=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==Ge&&i!==ke&&(Ui.getTransfer(i)===Ve?n===Gt&&s===Et||ui("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):pi("WebGLTextures: Unsupported texture color space:",i)),e}function V(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(l.width=t.naturalWidth||t.width,l.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(l.width=t.displayWidth,l.height=t.displayHeight):(l.width=t.width,l.height=t.height),l}this.allocateTextureUnit=function(){const t=T;return t>=s.maxTextures&&ui("WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+s.maxTextures),T+=1,t},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(e,s){const r=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&r.__version!==e.version?D(r,e,s):(e.isExternalTexture&&(r.__webglTexture=e.sourceTexture?e.sourceTexture:null),i.bindTexture(t.TEXTURE_2D_ARRAY,r.__webglTexture,t.TEXTURE0+s))},this.setTexture3D=function(e,s){const r=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&r.__version!==e.version?D(r,e,s):i.bindTexture(t.TEXTURE_3D,r.__webglTexture,t.TEXTURE0+s)},this.setTextureCube=function(e,a){const o=n.get(e);!0!==e.isCubeDepthTexture&&e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const h=I(e,a),l=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(l);if(l.version!==c.__version||!0===h){i.activeTexture(t.TEXTURE0+o);const e=Ui.getPrimaries(Ui.workingColorSpace),n=a.colorSpace===ke?null:Ui.getPrimaries(a.colorSpace),d=a.colorSpace===ke||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=u||p?p?a.image[t].image:a.image[t]:f(a.image[t],!0,s.maxCubemapSize),m[t]=H(a,m[t]);const _=m[0],x=r.convert(a.format,a.colorSpace),S=r.convert(a.type),w=y(a.internalFormat,x,S,a.colorSpace),M=!0!==a.isVideoTexture,T=void 0===c.__version||!0===h,E=l.dataReady;let A,C=b(a,_);if(R(t.TEXTURE_CUBE_MAP,a),u){M&&T&&i.texStorage2D(t.TEXTURE_CUBE_MAP,C,w,_.width,_.height);for(let e=0;e<6;e++){A=m[e].mipmaps;for(let n=0;n<A.length;n++){const s=A[n];a.format!==Gt?null!==x?M?E&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,x,s.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,w,s.width,s.height,0,s.data):ui("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,s.width,s.height,x,S,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,w,s.width,s.height,0,x,S,s.data)}}}else{if(A=a.mipmaps,M&&T){A.length>0&&C++;const e=V(m[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,C,w,e.width,e.height)}for(let e=0;e<6;e++)if(p){M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,x,S,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,w,m[e].width,m[e].height,0,x,S,m[e].data);for(let n=0;n<A.length;n++){const s=A[n].image[e].image;M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,s.width,s.height,x,S,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,w,s.width,s.height,0,x,S,s.data)}}else{M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,S,m[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,w,x,S,m[e]);for(let n=0;n<A.length;n++){const s=A[n];M?E&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,x,S,s.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,w,x,S,s.image[e])}}}g(a)&&v(t.TEXTURE_CUBE_MAP),c.__version=l.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,s){const r=n.get(e);void 0!==i&&O(r.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==s&&F(e)},this.setupRenderTarget=function(e){const s=e.texture,o=n.get(e),h=n.get(s);e.addEventListener("dispose",w);const l=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=l.length>1;if(d||(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=s.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(s.mipmaps&&s.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i<s.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(s.mipmaps&&s.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<s.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,i=l.length;e<i;e++){const i=n.get(l[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===G(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<l.length;i++){const n=l[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const s=r.convert(n.format,n.colorSpace),a=r.convert(n.type),h=y(n.internalFormat,s,a,n.colorSpace,!0===e.isXRRenderTarget),c=z(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,h,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),N(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),R(t.TEXTURE_CUBE_MAP,s);for(let i=0;i<6;i++)if(s.mipmaps&&s.mipmaps.length>0)for(let n=0;n<s.mipmaps.length;n++)O(o.__webglFramebuffer[i][n],e,s,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else O(o.__webglFramebuffer[i],e,s,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);g(s)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){for(let s=0,r=l.length;s<r;s++){const r=l[s],a=n.get(r);let h=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(h=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(h,a.__webglTexture),R(h,r),O(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0+s,h,0),g(r)&&v(h)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,h.__webglTexture),R(n,s),s.mipmaps&&s.mipmaps.length>0)for(let i=0;i<s.mipmaps.length;i++)O(o.__webglFramebuffer[i],e,s,t.COLOR_ATTACHMENT0,n,i);else O(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0,n,0);g(s)&&v(n),i.unbindTexture()}e.depthBuffer&&F(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let s=0,r=e.length;s<r;s++){const r=e[s];if(g(r)){const e=_(t),s=n.get(r).__webglTexture;i.bindTexture(e,s),v(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===G(e)){const s=e.textures,r=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),d=s.length>1;if(d)for(let e=0;e<s.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);const u=e.texture.mipmaps;u&&u.length>0?i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<s.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),d){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(s[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,r,a,0,0,r,a,o,t.NEAREST),!0===h&&(B.length=0,k.length=0,B.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(B.push(l),k.push(l),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,k)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<s.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const r=n.get(s[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,r,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&h){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=F,this.setupFrameBufferTexture=O,this.useMultisampledRTT=G,this.isReversedDepthBuffer=function(){return i.buffers.depth.getReversed()}}function $p(t,e){return{convert:function(i,n=""){let s;const r=Ui.getTransfer(n);if(i===Et)return t.UNSIGNED_BYTE;if(i===Ot)return t.UNSIGNED_SHORT_4_4_4_4;if(i===Nt)return t.UNSIGNED_SHORT_5_5_5_1;if(i===Ft)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===Bt)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===At)return t.BYTE;if(i===Ct)return t.SHORT;if(i===Lt)return t.UNSIGNED_SHORT;if(i===Rt)return t.INT;if(i===It)return t.UNSIGNED_INT;if(i===Pt)return t.FLOAT;if(i===Dt)return t.HALF_FLOAT;if(i===kt)return t.ALPHA;if(i===zt)return t.RGB;if(i===Gt)return t.RGBA;if(i===Ht)return t.DEPTH_COMPONENT;if(i===Vt)return t.DEPTH_STENCIL;if(i===Wt)return t.RED;if(i===jt)return t.RED_INTEGER;if(i===Xt)return t.RG;if(i===Yt)return t.RG_INTEGER;if(i===qt)return t.RGBA_INTEGER;if(i===Zt||i===Kt||i===Jt||i===Qt)if(r===Ve){if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===s)return null;if(i===Zt)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Kt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Jt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Qt)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(s=e.get("WEBGL_compressed_texture_s3tc"),null===s)return null;if(i===Zt)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Kt)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Jt)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Qt)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===$t||i===te||i===ee||i===ie){if(s=e.get("WEBGL_compressed_texture_pvrtc"),null===s)return null;if(i===$t)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===te)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ee)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ie)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===ne||i===se||i===re||i===ae||i===oe||i===he||i===le){if(s=e.get("WEBGL_compressed_texture_etc"),null===s)return null;if(i===ne||i===se)return r===Ve?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===re)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===ae)return s.COMPRESSED_R11_EAC;if(i===oe)return s.COMPRESSED_SIGNED_R11_EAC;if(i===he)return s.COMPRESSED_RG11_EAC;if(i===le)return s.COMPRESSED_SIGNED_RG11_EAC}if(i===ce||i===de||i===ue||i===pe||i===me||i===fe||i===ge||i===ve||i===_e||i===ye||i===xe||i===be||i===Se||i===we){if(s=e.get("WEBGL_compressed_texture_astc"),null===s)return null;if(i===ce)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===de)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ue)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===pe)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===me)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===fe)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===ge)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ve)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===_e)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ye)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===xe)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===be)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Se)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===we)return r===Ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===Me||i===Te||i===Ee){if(s=e.get("EXT_texture_compression_bptc"),null===s)return null;if(i===Me)return r===Ve?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Te)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ee)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===Ae||i===Ce||i===Le||i===Re){if(s=e.get("EXT_texture_compression_rgtc"),null===s)return null;if(i===Ae)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Ce)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Le)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Re)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Ut?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class tm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const i=new fo(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new rr({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Qs(new Ih(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class em extends fi{constructor(t,e){super();const i=this;let n=null,s=1,r=null,a="local-floor",o=1,h=null,l=null,c=null,d=null,u=null,p=null;const m="undefined"!=typeof XRWebGLBinding,f=new tm,g={},v=e.getContextAttributes();let _=null,y=null;const x=[],b=[],S=new Ai;let w=null;const M=new cr;M.viewport=new Yi;const T=new cr;T.viewport=new Yi;const E=[M,T],A=new sc;let C=null,L=null;function R(t){const e=b.indexOf(t.inputSource);if(-1===e)return;const i=x[e];void 0!==i&&(i.update(t.inputSource,t.frame,h||r),i.dispatchEvent({type:t.type,data:t.inputSource}))}function I(){n.removeEventListener("select",R),n.removeEventListener("selectstart",R),n.removeEventListener("selectend",R),n.removeEventListener("squeeze",R),n.removeEventListener("squeezestart",R),n.removeEventListener("squeezeend",R),n.removeEventListener("end",I),n.removeEventListener("inputsourceschange",P);for(let t=0;t<x.length;t++){const e=b[t];null!==e&&(b[t]=null,x[t].disconnect(e))}C=null,L=null,f.reset();for(const t in g)delete g[t];t.setRenderTarget(_),u=null,d=null,c=null,n=null,y=null,F.stop(),i.isPresenting=!1,t.setPixelRatio(w),t.setSize(S.width,S.height,!1),i.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=b.indexOf(i);n>=0&&(b[n]=null,x[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=b.indexOf(i);if(-1===n){for(let t=0;t<x.length;t++){if(t>=b.length){b.push(i),n=t;break}if(null===b[t]){b[t]=i,n=t;break}}if(-1===n)break}const s=x[n];s&&s.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=x[t];return void 0===e&&(e=new vr,x[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=x[t];return void 0===e&&(e=new vr,x[t]=e),e.getGripSpace()},this.getHand=function(t){let e=x[t];return void 0===e&&(e=new vr,x[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){s=t,!0===i.isPresenting&&ui("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&ui("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||r},this.setReferenceSpace=function(t){h=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return null===c&&m&&(c=new XRWebGLBinding(n,e)),c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){_=t.getRenderTarget(),n.addEventListener("select",R),n.addEventListener("selectstart",R),n.addEventListener("selectend",R),n.addEventListener("squeeze",R),n.addEventListener("squeezestart",R),n.addEventListener("squeezeend",R),n.addEventListener("end",I),n.addEventListener("inputsourceschange",P),!0!==v.xrCompatible&&await e.makeXRCompatible(),w=t.getPixelRatio(),t.getSize(S);if(m&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,r=null,a=null;v.depth&&(a=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=v.stencil?Vt:Ht,r=v.stencil?Ut:It);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:s};c=this.getBinding(),d=c.createProjectionLayer(o),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Zi(d.textureWidth,d.textureHeight,{format:Gt,type:Et,depthTexture:new po(d.textureWidth,d.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{const i={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new Zi(u.framebufferWidth,u.framebufferHeight,{format:Gt,type:Et,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(o),h=null,r=await n.requestReferenceSpace(a),F.setContext(n),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new Li,O=new Li;function N(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(i=f.depthFar)),A.near=T.near=M.near=e,A.far=T.far=M.far=i,C===A.near&&L===A.far||(n.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,L=A.far),A.layers.mask=6|t.layers.mask,M.layers.mask=3&A.layers.mask,T.layers.mask=5&A.layers.mask;const s=t.parent,r=A.cameras;N(A,s);for(let t=0;t<r.length;t++)N(r[t],s);2===r.length?function(t,e,i){D.setFromMatrixPosition(e.matrixWorld),O.setFromMatrixPosition(i.matrixWorld);const n=D.distanceTo(O),s=e.projectionMatrix.elements,r=i.projectionMatrix.elements,a=s[14]/(s[10]-1),o=s[14]/(s[10]+1),h=(s[9]+1)/s[5],l=(s[9]-1)/s[5],c=(s[8]-1)/s[0],d=(r[8]+1)/r[0],u=a*c,p=a*d,m=n/(-c+d),f=m*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===s[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+m,i=o+m,s=u-f,r=p+(n-f),c=h*o/i*e,d=l*o/i*e;t.projectionMatrix.makePerspective(s,r,c,d,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,M,T):A.projectionMatrix.copy(M.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*yi*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,s)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==d||null!==u)return o},this.setFoveation=function(t){o=t,null!==d&&(d.fixedFoveation=t),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==f.texture},this.getDepthSensingMesh=function(){return f.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let U=null;const F=new fd;F.setAnimationLoop(function(e,s){if(l=s.getViewerPose(h||r),p=s,null!==l){const e=l.views;null!==u&&(t.setRenderTargetFramebuffer(y,u.framebuffer),t.setRenderTarget(y));let s=!1;e.length!==A.cameras.length&&(A.cameras.length=0,s=!0);for(let i=0;i<e.length;i++){const n=e[i];let r=null;if(null!==u)r=u.getViewport(n);else{const e=c.getViewSubImage(d,n);r=e.viewport,0===i&&(t.setRenderTargetTextures(y,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(y))}let a=E[i];void 0===a&&(a=new cr,a.layers.enable(i),a.viewport=new Yi,E[i]=a),a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(n.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(r.x,r.y,r.width,r.height),0===i&&(A.matrix.copy(a.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===s&&A.cameras.push(a)}const r=n.enabledFeatures;if(r&&r.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&m){c=i.getBinding();const t=c.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&f.init(t,n.renderState)}if(r&&r.includes("camera-access")&&m){t.state.unbindTexture(),c=i.getBinding();for(let t=0;t<e.length;t++){const i=e[t].camera;if(i){let t=g[i];t||(t=new fo,g[i]=t);const e=c.getCameraImage(i);t.sourceTexture=e}}}}for(let t=0;t<x.length;t++){const e=b[t],i=x[t];null!==e&&void 0!==i&&i.update(e,s,h||r)}U&&U(e,s),s.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:s}),p=null}),this.setAnimationLoop=function(t){U=t},this.dispose=function(){}}}const im=new Un,nm=new En;function sm(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const s=e.get(n),r=s.envMap,a=s.envMapRotation;r&&(t.envMap.value=r,im.copy(a),im.x*=-1,im.y*=-1,im.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(im.y*=-1,im.z*=-1),t.envMapRotation.value.setFromMatrix4(nm.makeRotationFromEuler(im)),t.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,nr(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,s,r,a,o){s.isMeshBasicMaterial||s.isMeshLambertMaterial?n(t,s):s.isMeshToonMaterial?(n(t,s),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,s)):s.isMeshPhongMaterial?(n(t,s),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,s)):s.isMeshStandardMaterial?(n(t,s),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,s),s.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,s,o)):s.isMeshMatcapMaterial?(n(t,s),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,s)):s.isMeshDepthMaterial?n(t,s):s.isMeshDistanceMaterial?(n(t,s),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,s)):s.isMeshNormalMaterial?n(t,s):s.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,s),s.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,s)):s.isPointsMaterial?function(t,e,n,s){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*s,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s,r,a):s.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,s):s.isShadowMaterial?(t.color.value.copy(s.color),t.opacity.value=s.opacity):s.isShaderMaterial&&(s.uniformsNeedUpdate=!1)}}}function rm(t,e,i,n){let s={},r={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function h(t,e,i,n){const s=t.value,r=e+"_"+i;if(void 0===n[r])return n[r]="number"==typeof s||"boolean"==typeof s?s:s.clone(),!0;{const t=n[r];if("number"==typeof s||"boolean"==typeof s){if(t!==s)return n[r]=s,!0}else if(!1===t.equals(s))return t.copy(s),!0}return!1}function l(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?ui("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ui("WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const i=e.target;i.removeEventListener("dispose",c);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(s[i.id]),delete s[i.id],delete r[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,d){let u=s[i.id];void 0===u&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,s=e.length;t<s;t++){const s=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=s.length;t<e;t++){const e=s[t],r=Array.isArray(e.value)?e.value:[e.value];for(let t=0,s=r.length;t<s;t++){const s=l(r[t]),a=i%n,o=a%s.boundary,h=a+o;i+=o,0!==h&&n-h<s.storage&&(i+=n-h),e.__data=new Float32Array(s.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=s.storage}}}const s=i%n;s>0&&(i+=n-s);t.__size=i,t.__cache={}}(i),u=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return pi("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),s=e.__size,r=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,s,r),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),s[i.id]=u,i.addEventListener("dispose",c));const p=d.program;n.updateUBOMapping(i,p);const m=e.render.frame;r[i.id]!==m&&(!function(e){const i=s[e.id],n=e.uniforms,r=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let e=0,i=n.length;e<i;e++){const i=Array.isArray(n[e])?n[e]:[n[e]];for(let n=0,s=i.length;n<s;n++){const s=i[n];if(!0===h(s,e,n,r)){const e=s.__offset,i=Array.isArray(s.value)?s.value:[s.value];let n=0;for(let r=0;r<i.length;r++){const a=i[r],o=l(a);"number"==typeof a||"boolean"==typeof a?(s.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+n,s.__data)):a.isMatrix3?(s.__data[0]=a.elements[0],s.__data[1]=a.elements[1],s.__data[2]=a.elements[2],s.__data[3]=0,s.__data[4]=a.elements[3],s.__data[5]=a.elements[4],s.__data[6]=a.elements[5],s.__data[7]=0,s.__data[8]=a.elements[6],s.__data[9]=a.elements[7],s.__data[10]=a.elements[8],s.__data[11]=0):(a.toArray(s.__data,n),n+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,s.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),r[i.id]=m)},dispose:function(){for(const e in s)t.deleteBuffer(s[e]);a=[],s={},r={}}}}const am=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let om=null;class hm{constructor(t={}){const{canvas:e=hi(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:h=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:c=!1,reversedDepthBuffer:d=!1,outputBufferType:u=Et}=t;let p;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const m=u,f=new Set([qt,Yt,jt]),g=new Set([Et,It,Lt,Ut,Ot,Nt]),v=new Uint32Array(4),_=new Int32Array(4);let x=null,b=null;const S=[],w=[];let M=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let E=!1;this._outputColorSpace=ze;let A=0,C=0,L=null,R=-1,I=null;const P=new Yi,D=new Yi;let O=null;const N=new _s(0);let U=0,F=e.width,B=e.height,k=1,z=null,G=null;const H=new Yi(0,0,F,B),V=new Yi(0,0,F,B);let W=!1;const j=new xa;let X=!1,Y=!1;const q=new En,Z=new Li,K=new Yi,J={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Q=!1;function $(){return null===L?k:1}let tt,et,it,nt,st,rt,at,ot,ht,lt,ct,dt,ut,pt,mt,ft,gt,vt,yt,xt,bt,St,Mt,At,Ct=i;function Rt(t,i){return e.getContext(t,i)}try{const t={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${y}`),e.addEventListener("webglcontextlost",Bt,!1),e.addEventListener("webglcontextrestored",kt,!1),e.addEventListener("webglcontextcreationerror",zt,!1),null===Ct){const e="webgl2";if(Ct=Rt(e,t),null===Ct)throw Rt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw pi("WebGLRenderer: "+t.message),t}function Pt(){tt=new jd(Ct),tt.init(),St=new $p(Ct,tt),et=new Ed(Ct,tt,t,St),it=new Jp(Ct,tt),et.reversedDepthBuffer&&d&&it.buffers.depth.setReversed(!0),nt=new qd(Ct),st=new Dp,rt=new Qp(Ct,tt,it,st,et,St,nt),at=new Cd(T),ot=new Wd(T),ht=new gd(Ct),Mt=new Md(Ct,ht),lt=new Xd(Ct,ht,nt,Mt),ct=new Kd(Ct,lt,ht,nt),yt=new Zd(Ct,et,rt),ft=new Ad(st),dt=new Pp(T,at,ot,tt,et,Mt,ft),ut=new sm(T,st),pt=new Fp,mt=new Vp(tt),vt=new wd(T,at,ot,it,ct,p,o),gt=new Zp(T,ct,et),At=new rm(Ct,nt,et,it),xt=new Td(Ct,tt,nt),bt=new Yd(Ct,tt,nt),nt.programs=dt.programs,T.capabilities=et,T.extensions=tt,T.properties=st,T.renderLists=pt,T.shadowMap=gt,T.state=it,T.info=nt}Pt(),m!==Et&&(M=new Qd(m,e.width,e.height,n,s));const Ft=new em(T,Ct);function Bt(t){t.preventDefault(),di("WebGLRenderer: Context Lost."),E=!0}function kt(){di("WebGLRenderer: Context Restored."),E=!1;const t=nt.autoReset,e=gt.enabled,i=gt.autoUpdate,n=gt.needsUpdate,s=gt.type;Pt(),nt.autoReset=t,gt.enabled=e,gt.autoUpdate=i,gt.needsUpdate=n,gt.type=s}function zt(t){pi("WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Gt(t){const e=t.target;e.removeEventListener("dispose",Gt),function(t){(function(t){const e=st.get(t).programs;void 0!==e&&(e.forEach(function(t){dt.releaseProgram(t)}),t.isShaderMaterial&&dt.releaseShaderCache(t))})(t),st.remove(t)}(e)}function Ht(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,ie(t,e,i),t.side=0,t.needsUpdate=!0,ie(t,e,i),t.side=2):ie(t,e,i)}this.xr=Ft,this.getContext=function(){return Ct},this.getContextAttributes=function(){return Ct.getContextAttributes()},this.forceContextLoss=function(){const t=tt.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=tt.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(t){void 0!==t&&(k=t,this.setSize(F,B,!1))},this.getSize=function(t){return t.set(F,B)},this.setSize=function(t,i,n=!0){Ft.isPresenting?ui("WebGLRenderer: Can't change size while VR device is presenting."):(F=t,B=i,e.width=Math.floor(t*k),e.height=Math.floor(i*k),!0===n&&(e.style.width=t+"px",e.style.height=i+"px"),null!==M&&M.setSize(e.width,e.height),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return t.set(F*k,B*k).floor()},this.setDrawingBufferSize=function(t,i,n){F=t,B=i,k=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.setEffects=function(t){if(m!==Et){if(t)for(let e=0;e<t.length;e++)if(!0===t[e].isOutputPass){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}M.setEffects(t||[])}else console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(t){return t.copy(P)},this.getViewport=function(t){return t.copy(H)},this.setViewport=function(t,e,i,n){t.isVector4?H.set(t.x,t.y,t.z,t.w):H.set(t,e,i,n),it.viewport(P.copy(H).multiplyScalar(k).round())},this.getScissor=function(t){return t.copy(V)},this.setScissor=function(t,e,i,n){t.isVector4?V.set(t.x,t.y,t.z,t.w):V.set(t,e,i,n),it.scissor(D.copy(V).multiplyScalar(k).round())},this.getScissorTest=function(){return W},this.setScissorTest=function(t){it.setScissorTest(W=t)},this.setOpaqueSort=function(t){z=t},this.setTransparentSort=function(t){G=t},this.getClearColor=function(t){return t.copy(vt.getClearColor())},this.setClearColor=function(){vt.setClearColor(...arguments)},this.getClearAlpha=function(){return vt.getClearAlpha()},this.setClearAlpha=function(){vt.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==L){const e=L.texture.format;t=f.has(e)}if(t){const t=L.texture.type,e=g.has(t),i=vt.getClearColor(),n=vt.getClearAlpha(),s=i.r,r=i.g,a=i.b;e?(v[0]=s,v[1]=r,v[2]=a,v[3]=n,Ct.clearBufferuiv(Ct.COLOR,0,v)):(_[0]=s,_[1]=r,_[2]=a,_[3]=n,Ct.clearBufferiv(Ct.COLOR,0,_))}else n|=Ct.COLOR_BUFFER_BIT}e&&(n|=Ct.DEPTH_BUFFER_BIT),i&&(n|=Ct.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Ct.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Bt,!1),e.removeEventListener("webglcontextrestored",kt,!1),e.removeEventListener("webglcontextcreationerror",zt,!1),vt.dispose(),pt.dispose(),mt.dispose(),st.dispose(),at.dispose(),ot.dispose(),ct.dispose(),Mt.dispose(),At.dispose(),dt.dispose(),Ft.dispose(),Ft.removeEventListener("sessionstart",Wt),Ft.removeEventListener("sessionend",Zt),Kt.stop()},this.renderBufferDirect=function(t,e,i,n,s,r){null===e&&(e=J);const a=s.isMesh&&s.matrixWorld.determinant()<0,o=function(t,e,i,n,s){!0!==e.isScene&&(e=J);rt.resetTextureUnits();const r=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===L?T.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Ge,h=(n.isMeshStandardMaterial?ot:at).get(n.envMap||a),l=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,p=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(m=T.toneMapping));const f=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,g=void 0!==f?f.length:0,v=st.get(n),_=b.state.lights;if(!0===X&&(!0===Y||t!==I)){const e=t===I&&n.id===R;ft.setState(n,t,e)}let y=!1;n.version===v.__version?v.needsLights&&v.lightsStateVersion!==_.state.version||v.outputColorSpace!==o||s.isBatchedMesh&&!1===v.batching?y=!0:s.isBatchedMesh||!0!==v.batching?s.isBatchedMesh&&!0===v.batchingColor&&null===s.colorTexture||s.isBatchedMesh&&!1===v.batchingColor&&null!==s.colorTexture||s.isInstancedMesh&&!1===v.instancing?y=!0:s.isInstancedMesh||!0!==v.instancing?s.isSkinnedMesh&&!1===v.skinning?y=!0:s.isSkinnedMesh||!0!==v.skinning?s.isInstancedMesh&&!0===v.instancingColor&&null===s.instanceColor||s.isInstancedMesh&&!1===v.instancingColor&&null!==s.instanceColor||s.isInstancedMesh&&!0===v.instancingMorph&&null===s.morphTexture||s.isInstancedMesh&&!1===v.instancingMorph&&null!==s.morphTexture||v.envMap!==h||!0===n.fog&&v.fog!==r?y=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===ft.numPlanes&&v.numIntersection===ft.numIntersection?(v.vertexAlphas!==l||v.vertexTangents!==c||v.morphTargets!==d||v.morphNormals!==u||v.morphColors!==p||v.toneMapping!==m||v.morphTargetsCount!==g)&&(y=!0):y=!0:y=!0:y=!0:y=!0:(y=!0,v.__version=n.version);let x=v.currentProgram;!0===y&&(x=ie(n,e,s));let S=!1,w=!1,M=!1;const E=x.getUniforms(),A=v.uniforms;it.useProgram(x.program)&&(S=!0,w=!0,M=!0);n.id!==R&&(R=n.id,w=!0);if(S||I!==t){it.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),E.setValue(Ct,"projectionMatrix",t.projectionMatrix),E.setValue(Ct,"viewMatrix",t.matrixWorldInverse);const e=E.map.cameraPosition;void 0!==e&&e.setValue(Ct,Z.setFromMatrixPosition(t.matrixWorld)),et.logarithmicDepthBuffer&&E.setValue(Ct,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&E.setValue(Ct,"isOrthographic",!0===t.isOrthographicCamera),I!==t&&(I=t,w=!0,M=!0)}v.needsLights&&(_.state.directionalShadowMap.length>0&&E.setValue(Ct,"directionalShadowMap",_.state.directionalShadowMap,rt),_.state.spotShadowMap.length>0&&E.setValue(Ct,"spotShadowMap",_.state.spotShadowMap,rt),_.state.pointShadowMap.length>0&&E.setValue(Ct,"pointShadowMap",_.state.pointShadowMap,rt));if(s.isSkinnedMesh){E.setOptional(Ct,s,"bindMatrix"),E.setOptional(Ct,s,"bindMatrixInverse");const t=s.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),E.setValue(Ct,"boneTexture",t.boneTexture,rt))}s.isBatchedMesh&&(E.setOptional(Ct,s,"batchingTexture"),E.setValue(Ct,"batchingTexture",s._matricesTexture,rt),E.setOptional(Ct,s,"batchingIdTexture"),E.setValue(Ct,"batchingIdTexture",s._indirectTexture,rt),E.setOptional(Ct,s,"batchingColorTexture"),null!==s._colorsTexture&&E.setValue(Ct,"batchingColorTexture",s._colorsTexture,rt));const C=i.morphAttributes;void 0===C.position&&void 0===C.normal&&void 0===C.color||yt.update(s,i,x);(w||v.receiveShadow!==s.receiveShadow)&&(v.receiveShadow=s.receiveShadow,E.setValue(Ct,"receiveShadow",s.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(A.envMap.value=h,A.flipEnvMap.value=h.isCubeTexture&&!1===h.isRenderTargetTexture?-1:1);n.isMeshStandardMaterial&&null===n.envMap&&null!==e.environment&&(A.envMapIntensity.value=e.environmentIntensity);void 0!==A.dfgLUT&&(A.dfgLUT.value=(null===om&&(om=new ta(am,16,16,Xt,Dt),om.name="DFG_LUT",om.minFilter=wt,om.magFilter=wt,om.wrapS=_t,om.wrapT=_t,om.generateMipmaps=!1,om.needsUpdate=!0),om));w&&(E.setValue(Ct,"toneMappingExposure",T.toneMappingExposure),v.needsLights&&(D=M,(P=A).ambientLightColor.needsUpdate=D,P.lightProbe.needsUpdate=D,P.directionalLights.needsUpdate=D,P.directionalLightShadows.needsUpdate=D,P.pointLights.needsUpdate=D,P.pointLightShadows.needsUpdate=D,P.spotLights.needsUpdate=D,P.spotLightShadows.needsUpdate=D,P.rectAreaLights.needsUpdate=D,P.hemisphereLights.needsUpdate=D),r&&!0===n.fog&&ut.refreshFogUniforms(A,r),ut.refreshMaterialUniforms(A,n,k,B,b.state.transmissionRenderTarget[t.id]),np.upload(Ct,ne(v),A,rt));var P,D;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(np.upload(Ct,ne(v),A,rt),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&E.setValue(Ct,"center",s.center);if(E.setValue(Ct,"modelViewMatrix",s.modelViewMatrix),E.setValue(Ct,"normalMatrix",s.normalMatrix),E.setValue(Ct,"modelMatrix",s.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++){const i=t[e];At.update(i,x),At.bind(i,x)}}return x}(t,e,i,n,s);it.setMaterial(n,a);let h=i.index,l=1;if(!0===n.wireframe){if(h=lt.getWireframeAttribute(i),void 0===h)return;l=2}const c=i.drawRange,d=i.attributes.position;let u=c.start*l,p=(c.start+c.count)*l;null!==r&&(u=Math.max(u,r.start*l),p=Math.min(p,(r.start+r.count)*l)),null!==h?(u=Math.max(u,0),p=Math.min(p,h.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const m=p-u;if(m<0||m===1/0)return;let f;Mt.setup(s,n,o,i,h);let g=xt;if(null!==h&&(f=ht.get(h),g=bt,g.setIndex(f)),s.isMesh)!0===n.wireframe?(it.setLineWidth(n.wireframeLinewidth*$()),g.setMode(Ct.LINES)):g.setMode(Ct.TRIANGLES);else if(s.isLine){let t=n.linewidth;void 0===t&&(t=1),it.setLineWidth(t*$()),s.isLineSegments?g.setMode(Ct.LINES):s.isLineLoop?g.setMode(Ct.LINE_LOOP):g.setMode(Ct.LINE_STRIP)}else s.isPoints?g.setMode(Ct.POINTS):s.isSprite&&g.setMode(Ct.TRIANGLES);if(s.isBatchedMesh)if(null!==s._multiDrawInstances)mi("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),g.renderMultiDrawInstances(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount,s._multiDrawInstances);else if(tt.get("WEBGL_multi_draw"))g.renderMultiDraw(s._multiDrawStarts,s._multiDrawCounts,s._multiDrawCount);else{const t=s._multiDrawStarts,e=s._multiDrawCounts,i=s._multiDrawCount,r=h?ht.get(h).bytesPerElement:1,a=st.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(Ct,"_gl_DrawID",n),g.render(t[n]/r,e[n])}else if(s.isInstancedMesh)g.renderInstances(u,m,s.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);g.renderInstances(u,m,e)}else g.render(u,m)},this.compile=function(t,e,i=null){null===i&&(i=t),b=mt.get(i),b.init(e),w.push(b),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(b.pushLight(t),t.castShadow&&b.pushShadow(t))}),b.setupLights();const n=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let s=0;s<e.length;s++){const r=e[s];Ht(r,i,t),n.add(r)}else Ht(e,i,t),n.add(e)}),b=w.pop(),n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(e=>{function i(){n.forEach(function(t){st.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==tt.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let Vt=null;function Wt(){Kt.stop()}function Zt(){Kt.start()}const Kt=new fd;function Jt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)b.pushLight(t),t.castShadow&&b.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||j.intersectsSprite(t)){n&&K.setFromMatrixPosition(t.matrixWorld).applyMatrix4(q);const e=ct.update(t),s=t.material;s.visible&&x.push(t,e,s,i,K.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||j.intersectsObject(t))){const e=ct.update(t),s=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),K.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),K.copy(e.boundingSphere.center)),K.applyMatrix4(t.matrixWorld).applyMatrix4(q)),Array.isArray(s)){const n=e.groups;for(let r=0,a=n.length;r<a;r++){const a=n[r],o=s[a.materialIndex];o&&o.visible&&x.push(t,e,o,i,K.z,a)}}else s.visible&&x.push(t,e,s,i,K.z,null)}const s=t.children;for(let t=0,r=s.length;t<r;t++)Jt(s[t],e,i,n)}function Qt(t,e,i,n){const{opaque:s,transmissive:r,transparent:a}=t;b.setupLightsView(i),!0===X&&ft.setGlobalState(T.clippingPlanes,i),n&&it.viewport(P.copy(n)),s.length>0&&te(s,e,i),r.length>0&&te(r,e,i),a.length>0&&te(a,e,i),it.buffers.depth.setTest(!0),it.buffers.depth.setMask(!0),it.buffers.color.setMask(!0),it.setPolygonOffset(!1)}function $t(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;if(void 0===b.state.transmissionRenderTarget[n.id]){const t=tt.has("EXT_color_buffer_half_float")||tt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[n.id]=new Zi(1,1,{generateMipmaps:!0,type:t?Dt:Et,minFilter:Tt,samples:et.samples,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ui.workingColorSpace})}const r=b.state.transmissionRenderTarget[n.id],a=n.viewport||P;r.setSize(a.z*T.transmissionResolutionScale,a.w*T.transmissionResolutionScale);const o=T.getRenderTarget(),h=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(r),T.getClearColor(N),U=T.getClearAlpha(),U<1&&T.setClearColor(16777215,.5),T.clear(),Q&&vt.render(i);const c=T.toneMapping;T.toneMapping=0;const d=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),b.setupLightsView(n),!0===X&&ft.setGlobalState(T.clippingPlanes,n),te(t,i,n),rt.updateMultisampleRenderTarget(r),rt.updateRenderTargetMipmap(r),!1===tt.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let s=0,r=e.length;s<r;s++){const r=e[s],{object:a,geometry:o,material:h,group:l}=r;if(2===h.side&&a.layers.test(n.layers)){const e=h.side;h.side=1,h.needsUpdate=!0,ee(a,i,n,o,h,l),h.side=e,h.needsUpdate=!0,t=!0}}!0===t&&(rt.updateMultisampleRenderTarget(r),rt.updateRenderTargetMipmap(r))}T.setRenderTarget(o,h,l),T.setClearColor(N,U),void 0!==d&&(n.viewport=d),T.toneMapping=c}function te(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let s=0,r=t.length;s<r;s++){const r=t[s],{object:a,geometry:o,group:h}=r;let l=r.material;!0===l.allowOverride&&null!==n&&(l=n),a.layers.test(i.layers)&&ee(a,e,i,o,l,h)}}function ee(t,e,i,n,s,r){t.onBeforeRender(T,e,i,n,s,r),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),s.onBeforeRender(T,e,i,n,t,r),!0===s.transparent&&2===s.side&&!1===s.forceSinglePass?(s.side=1,s.needsUpdate=!0,T.renderBufferDirect(i,e,n,s,t,r),s.side=0,s.needsUpdate=!0,T.renderBufferDirect(i,e,n,s,t,r),s.side=2):T.renderBufferDirect(i,e,n,s,t,r),t.onAfterRender(T,e,i,n,s,r)}function ie(t,e,i){!0!==e.isScene&&(e=J);const n=st.get(t),s=b.state.lights,r=b.state.shadowsArray,a=s.state.version,o=dt.getParameters(t,s.state,r,e,i),h=dt.getProgramCacheKey(o);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=(t.isMeshStandardMaterial?ot:at).get(t.envMap||n.environment),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===l&&(t.addEventListener("dispose",Gt),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===a)return se(t,o),c}else o.uniforms=dt.getUniforms(t),t.onBeforeCompile(o,T),c=dt.acquireProgram(o,h),l.set(h,c),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=ft.uniform),se(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(d.ambientLightColor.value=s.state.ambient,d.lightProbe.value=s.state.probe,d.directionalLights.value=s.state.directional,d.directionalLightShadows.value=s.state.directionalShadow,d.spotLights.value=s.state.spot,d.spotLightShadows.value=s.state.spotShadow,d.rectAreaLights.value=s.state.rectArea,d.ltc_1.value=s.state.rectAreaLTC1,d.ltc_2.value=s.state.rectAreaLTC2,d.pointLights.value=s.state.point,d.pointLightShadows.value=s.state.pointShadow,d.hemisphereLights.value=s.state.hemi,d.directionalShadowMap.value=s.state.directionalShadowMap,d.directionalShadowMatrix.value=s.state.directionalShadowMatrix,d.spotShadowMap.value=s.state.spotShadowMap,d.spotLightMatrix.value=s.state.spotLightMatrix,d.spotLightMap.value=s.state.spotLightMap,d.pointShadowMap.value=s.state.pointShadowMap,d.pointShadowMatrix.value=s.state.pointShadowMatrix),n.currentProgram=c,n.uniformsList=null,c}function ne(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=np.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function se(t,e){const i=st.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}Kt.setAnimationLoop(function(t){Vt&&Vt(t)}),"undefined"!=typeof self&&Kt.setContext(self),this.setAnimationLoop=function(t){Vt=t,Ft.setAnimationLoop(t),null===t?Kt.stop():Kt.start()},Ft.addEventListener("sessionstart",Wt),Ft.addEventListener("sessionend",Zt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void pi("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===E)return;const i=!0===Ft.enabled&&!0===Ft.isPresenting,n=null!==M&&(null===L||i)&&M.begin(T,L);if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0!==Ft.enabled||!0!==Ft.isPresenting||null!==M&&!1!==M.isCompositing()||(!0===Ft.cameraAutoUpdate&&Ft.updateCamera(e),e=Ft.getCamera()),!0===t.isScene&&t.onBeforeRender(T,t,e,L),b=mt.get(t,w.length),b.init(e),w.push(b),q.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),j.setFromProjectionMatrix(q,ei,e.reversedDepth),Y=this.localClippingEnabled,X=ft.init(this.clippingPlanes,Y),x=pt.get(t,S.length),x.init(),S.push(x),!0===Ft.enabled&&!0===Ft.isPresenting){const t=T.xr.getDepthSensingMesh();null!==t&&Jt(t,e,-1/0,T.sortObjects)}Jt(t,e,0,T.sortObjects),x.finish(),!0===T.sortObjects&&x.sort(z,G),Q=!1===Ft.enabled||!1===Ft.isPresenting||!1===Ft.hasDepthSensing(),Q&&vt.addToRenderList(x,t),this.info.render.frame++,!0===X&&ft.beginShadows();const s=b.state.shadowsArray;gt.render(s,t,e),!0===X&&ft.endShadows(),!0===this.info.autoReset&&this.info.reset();if(!1===(n&&M.hasRenderPass())){const i=x.opaque,n=x.transmissive;if(b.setupLights(),e.isArrayCamera){const s=e.cameras;if(n.length>0)for(let e=0,r=s.length;e<r;e++){$t(i,n,t,s[e])}Q&&vt.render(t);for(let e=0,i=s.length;e<i;e++){const i=s[e];Qt(x,t,i,i.viewport)}}else n.length>0&&$t(i,n,t,e),Q&&vt.render(t),Qt(x,t,e)}null!==L&&0===C&&(rt.updateMultisampleRenderTarget(L),rt.updateRenderTargetMipmap(L)),n&&M.end(T),!0===t.isScene&&t.onAfterRender(T,t,e),Mt.resetDefaultState(),R=-1,I=null,w.pop(),w.length>0?(b=w[w.length-1],!0===X&&ft.setGlobalState(T.clippingPlanes,b.state.camera)):b=null,S.pop(),x=S.length>0?S[S.length-1]:null},this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return L},this.setRenderTargetTextures=function(t,e,i){const n=st.get(t);n.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===n.__autoAllocateDepthBuffer&&(n.__useRenderToTexture=!1),st.get(t.texture).__webglTexture=e,st.get(t.depthTexture).__webglTexture=n.__autoAllocateDepthBuffer?void 0:i,n.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const i=st.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e};const re=Ct.createFramebuffer();this.setRenderTarget=function(t,e=0,i=0){L=t,A=e,C=i;let n=null,s=!1,r=!1;if(t){const a=st.get(t);if(void 0!==a.__useDefaultFramebuffer)return it.bindFramebuffer(Ct.FRAMEBUFFER,a.__webglFramebuffer),P.copy(t.viewport),D.copy(t.scissor),O=t.scissorTest,it.viewport(P),it.scissor(D),it.setScissorTest(O),void(R=-1);if(void 0===a.__webglFramebuffer)rt.setupRenderTarget(t);else if(a.__hasExternalTextures)rt.rebindTextures(t,st.get(t.texture).__webglTexture,st.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(a.__boundDepthTexture!==e){if(null!==e&&st.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");rt.setupDepthRenderbuffer(t)}}const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(r=!0);const h=st.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=Array.isArray(h[e])?h[e][i]:h[e],s=!0):n=t.samples>0&&!1===rt.useMultisampledRTT(t)?st.get(t).__webglMultisampledFramebuffer:Array.isArray(h)?h[i]:h,P.copy(t.viewport),D.copy(t.scissor),O=t.scissorTest}else P.copy(H).multiplyScalar(k).floor(),D.copy(V).multiplyScalar(k).floor(),O=W;0!==i&&(n=re);if(it.bindFramebuffer(Ct.FRAMEBUFFER,n)&&it.drawBuffers(t,n),it.viewport(P),it.scissor(D),it.setScissorTest(O),s){const n=st.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(r){const n=e;for(let e=0;e<t.textures.length;e++){const s=st.get(t.textures[e]);Ct.framebufferTextureLayer(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0+e,s.__webglTexture,i,n)}}else if(null!==t&&0!==i){const e=st.get(t.texture);Ct.framebufferTexture2D(Ct.FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,e.__webglTexture,i)}R=-1},this.readRenderTargetPixels=function(t,e,i,n,s,r,a,o=0){if(!t||!t.isWebGLRenderTarget)return void pi("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=st.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){it.bindFramebuffer(Ct.FRAMEBUFFER,h);try{const a=t.textures[o],h=a.format,l=a.type;if(!et.textureFormatReadable(h))return void pi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(l))return void pi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-s&&(t.textures.length>1&&Ct.readBuffer(Ct.COLOR_ATTACHMENT0+o),Ct.readPixels(e,i,n,s,St.convert(h),St.convert(l),r))}finally{const t=null!==L?st.get(L).__webglFramebuffer:null;it.bindFramebuffer(Ct.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,s,r,a,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=st.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(h=h[a]),h){if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-s){it.bindFramebuffer(Ct.FRAMEBUFFER,h);const a=t.textures[o],l=a.format,c=a.type;if(!et.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=Ct.createBuffer();Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,d),Ct.bufferData(Ct.PIXEL_PACK_BUFFER,r.byteLength,Ct.STREAM_READ),t.textures.length>1&&Ct.readBuffer(Ct.COLOR_ATTACHMENT0+o),Ct.readPixels(e,i,n,s,St.convert(l),St.convert(c),0);const u=null!==L?st.get(L).__webglFramebuffer:null;it.bindFramebuffer(Ct.FRAMEBUFFER,u);const p=Ct.fenceSync(Ct.SYNC_GPU_COMMANDS_COMPLETE,0);return Ct.flush(),await function(t,e,i){return new Promise(function(n,s){setTimeout(function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:s();break;case t.TIMEOUT_EXPIRED:setTimeout(r,i);break;default:n()}},i)})}(Ct,p,4),Ct.bindBuffer(Ct.PIXEL_PACK_BUFFER,d),Ct.getBufferSubData(Ct.PIXEL_PACK_BUFFER,0,r),Ct.deleteBuffer(d),Ct.deleteSync(p),r}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){const n=Math.pow(2,-i),s=Math.floor(t.image.width*n),r=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;rt.setTexture2D(t,0),Ct.copyTexSubImage2D(Ct.TEXTURE_2D,i,0,0,a,o,s,r),it.unbindTexture()};const ae=Ct.createFramebuffer(),oe=Ct.createFramebuffer();this.copyTextureToTexture=function(t,e,i=null,n=null,s=0,r=null){let a,o,h,l,c,d,u,p,m;null===r&&(0!==s?(mi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),r=s,s=0):r=0);const f=t.isCompressedTexture?t.mipmaps[r]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,h=i.isBox3?i.max.z-i.min.z:1,l=i.min.x,c=i.min.y,d=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-s);a=Math.floor(f.width*e),o=Math.floor(f.height*e),h=t.isDataArrayTexture?f.depth:t.isData3DTexture?Math.floor(f.depth*e):1,l=0,c=0,d=0}null!==n?(u=n.x,p=n.y,m=n.z):(u=0,p=0,m=0);const g=St.convert(e.format),v=St.convert(e.type);let _;e.isData3DTexture?(rt.setTexture3D(e,0),_=Ct.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(rt.setTexture2DArray(e,0),_=Ct.TEXTURE_2D_ARRAY):(rt.setTexture2D(e,0),_=Ct.TEXTURE_2D),Ct.pixelStorei(Ct.UNPACK_FLIP_Y_WEBGL,e.flipY),Ct.pixelStorei(Ct.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Ct.pixelStorei(Ct.UNPACK_ALIGNMENT,e.unpackAlignment);const y=Ct.getParameter(Ct.UNPACK_ROW_LENGTH),x=Ct.getParameter(Ct.UNPACK_IMAGE_HEIGHT),b=Ct.getParameter(Ct.UNPACK_SKIP_PIXELS),S=Ct.getParameter(Ct.UNPACK_SKIP_ROWS),w=Ct.getParameter(Ct.UNPACK_SKIP_IMAGES);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,f.width),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,f.height),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,l),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,c),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,d);const M=t.isDataArrayTexture||t.isData3DTexture,T=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=st.get(t),n=st.get(e),f=st.get(i.__renderTarget),g=st.get(n.__renderTarget);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,f.__webglFramebuffer),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<h;i++)M&&(Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,st.get(t).__webglTexture,s,d+i),Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,st.get(e).__webglTexture,r,m+i)),Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.DEPTH_BUFFER_BIT,Ct.NEAREST);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else if(0!==s||t.isRenderTargetTexture||st.has(t)){const i=st.get(t),n=st.get(e);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,ae),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,oe);for(let t=0;t<h;t++)M?Ct.framebufferTextureLayer(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,i.__webglTexture,s,d+t):Ct.framebufferTexture2D(Ct.READ_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,i.__webglTexture,s),T?Ct.framebufferTextureLayer(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,n.__webglTexture,r,m+t):Ct.framebufferTexture2D(Ct.DRAW_FRAMEBUFFER,Ct.COLOR_ATTACHMENT0,Ct.TEXTURE_2D,n.__webglTexture,r),0!==s?Ct.blitFramebuffer(l,c,a,o,u,p,a,o,Ct.COLOR_BUFFER_BIT,Ct.NEAREST):T?Ct.copyTexSubImage3D(_,r,u,p,m+t,l,c,a,o):Ct.copyTexSubImage2D(_,r,u,p,l,c,a,o);it.bindFramebuffer(Ct.READ_FRAMEBUFFER,null),it.bindFramebuffer(Ct.DRAW_FRAMEBUFFER,null)}else T?t.isDataTexture||t.isData3DTexture?Ct.texSubImage3D(_,r,u,p,m,a,o,h,g,v,f.data):e.isCompressedArrayTexture?Ct.compressedTexSubImage3D(_,r,u,p,m,a,o,h,g,f.data):Ct.texSubImage3D(_,r,u,p,m,a,o,h,g,v,f):t.isDataTexture?Ct.texSubImage2D(Ct.TEXTURE_2D,r,u,p,a,o,g,v,f.data):t.isCompressedTexture?Ct.compressedTexSubImage2D(Ct.TEXTURE_2D,r,u,p,f.width,f.height,g,f.data):Ct.texSubImage2D(Ct.TEXTURE_2D,r,u,p,a,o,g,v,f);Ct.pixelStorei(Ct.UNPACK_ROW_LENGTH,y),Ct.pixelStorei(Ct.UNPACK_IMAGE_HEIGHT,x),Ct.pixelStorei(Ct.UNPACK_SKIP_PIXELS,b),Ct.pixelStorei(Ct.UNPACK_SKIP_ROWS,S),Ct.pixelStorei(Ct.UNPACK_SKIP_IMAGES,w),0===r&&e.generateMipmaps&&Ct.generateMipmap(_),it.unbindTexture()},this.initRenderTarget=function(t){void 0===st.get(t).__webglFramebuffer&&rt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?rt.setTextureCube(t,0):t.isData3DTexture?rt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?rt.setTexture2DArray(t,0):rt.setTexture2D(t,0),it.unbindTexture()},this.resetState=function(){A=0,C=0,L=null,it.reset(),Mt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ei}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Ui._getDrawingBufferColorSpace(t),e.unpackColorSpace=Ui._getUnpackColorSpace()}}var lm=Object.freeze({__proto__:null,ACESFilmicToneMapping:4,AddEquation:A,AddOperation:2,AdditiveAnimationBlendMode:Be,AdditiveBlending:2,AgXToneMapping:6,AlphaFormat:kt,AlwaysCompare:519,AlwaysDepth:1,AlwaysStencilFunc:519,AmbientLight:Gl,AnimationAction:Cc,AnimationClip:gl,AnimationLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Ml(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(i){try{e(s.parse(JSON.parse(i)))}catch(e){n?n(e):pi(e),s.manager.itemError(t)}},i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=gl.parse(t[i]);e.push(n)}return e}},AnimationMixer:class extends fi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,r=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==s;++t){const s=n[t],h=s.name;let c=l[h];if(void 0!==c)++c.referenceCount,r[t]=c;else{if(c=r[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new gc(Ac.create(i,h,n),s.ValueTypeName,s.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),r[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let r=s[e];if(void 0===r)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=r;else{const e=r.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),r.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,r=this._actionsByClip,a=r[s],o=a.knownActions,h=o[o.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,o[l]=h,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete r[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0===--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let r=n[e];void 0===r&&(r={},n[e]=r),r[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,r=this._bindingsByRootAndName,a=r[n],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[s],0===Object.keys(a).length&&delete r[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new al(new Float32Array(2),new Float32Array(2),1,Lc),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let r="string"==typeof t?gl.findByName(n,t):t;const a=null!==r?r.uuid:t,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==r?r.blendMode:Fe),void 0!==o){const t=o.actionByRoot[s];if(void 0!==t&&t.blendMode===i)return t;h=o.knownActions[0],null===r&&(r=h._clip)}if(null===r)return null;const l=new Cc(this,r,e,i);return this._bindAction(l,h),this._addInactiveAction(l,a,s),l}existingAction(t,e){const i=e||this._root,n=i.uuid,s="string"==typeof t?gl.findByName(i,t):t,r=s?s.uuid:t,a=this._actionsByClip[r];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,s,r)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(r);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(void 0!==s){const t=s.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const s=n._cacheIndex,r=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,r._cacheIndex=s,e[s]=r,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},AnimationObjectGroup:class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=xi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,s=this._bindings,r=s.length;let a,o=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],d=c.uuid;let u=e[d];if(void 0===u){u=o++,e[d]=u,t.push(c);for(let t=0,e=r;t!==e;++t)s[t].push(new Ac(c,i[t],n[t]))}else if(u<h){a=t[u];const o=--h,l=t[o];e[l.uuid]=u,t[u]=l,e[d]=o,t[o]=c;for(let t=0,e=r;t!==e;++t){const e=s[t],r=e[o];let a=e[u];e[u]=r,void 0===a&&(a=new Ac(c,i[t],n[t])),e[o]=a}}else t[u]!==a&&pi("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_;for(let r=0,a=arguments.length;r!==a;++r){const a=arguments[r],o=a.uuid,h=e[o];if(void 0!==h&&h>=s){const r=s++,l=t[r];e[l.uuid]=h,t[h]=l,e[o]=r,t[r]=a;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[r],s=e[h];e[h]=n,e[r]=s}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_,r=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h<s){const a=--s,o=t[a],l=--r,c=t[l];e[o.uuid]=h,t[h]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[a],s=e[l];e[h]=n,e[a]=s,e.pop()}}else{const s=--r,a=t[s];s>0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[h]=e[s],e.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const s=this._bindings;if(void 0!==n)return s[n];const r=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);n=s.length,i[t]=n,r.push(t),a.push(e),s.push(c);for(let i=l,n=o.length;i!==n;++i){const n=o[i];c[i]=new Ac(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,s=this._parsedPaths,r=this._bindings,a=r.length-1,o=r[a];e[t[a]]=i,r[i]=o,r.pop(),s[i]=s[a],s.pop(),n[i]=n[a],n.pop()}}},AnimationUtils:class{static convertArray(t,e){return tl(t,e)}static isTypedArray(t){return ai(t)}static getKeyframeOrder(t){return el(t)}static sortedArray(t,e,i){return il(t,e,i)}static flattenJSON(t,e,i,n){nl(t,e,i,n)}static subclip(t,e,i,n,s=30){return function(t,e,i,n,s=30){const r=t.clone();r.name=e;const a=[];for(let t=0;t<r.tracks.length;++t){const e=r.tracks[t],o=e.getValueSize(),h=[],l=[];for(let t=0;t<e.times.length;++t){const r=e.times[t]*s;if(!(r<i||r>=n)){h.push(e.times[t]);for(let i=0;i<o;++i)l.push(e.values[t*o+i])}}0!==h.length&&(e.times=tl(h,e.times.constructor),e.values=tl(l,e.values.constructor),a.push(e))}r.tracks=a;let o=1/0;for(let t=0;t<r.tracks.length;++t)o>r.tracks[t].times[0]&&(o=r.tracks[t].times[0]);for(let t=0;t<r.tracks.length;++t)r.tracks[t].shift(-1*o);return r.resetDuration(),r}(t,e,i,n,s)}static makeClipAdditive(t,e=0,i=t,n=30){return function(t,e=0,i=t,n=30){n<=0&&(n=30);const s=i.tracks.length,r=e/n;for(let e=0;e<s;++e){const n=i.tracks[e],s=n.ValueTypeName;if("bool"===s||"string"===s)continue;const a=t.tracks.find(function(t){return t.name===n.name&&t.ValueTypeName===s});if(void 0===a)continue;let o=0;const h=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=h/3);let l=0;const c=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=c/3);const d=n.times.length-1;let u;if(r<=n.times[0]){const t=o,e=h-o;u=n.values.slice(t,e)}else if(r>=n.times[d]){const t=d*h+o,e=t+h-o;u=n.values.slice(t,e)}else{const t=n.createInterpolant(),e=o,i=h-o;t.evaluate(r),u=t.resultBuffer.slice(e,i)}"quaternion"===s&&(new Ci).fromArray(u).normalize().conjugate().toArray(u);const p=a.times.length;for(let t=0;t<p;++t){const e=t*c+l;if("quaternion"===s)Ci.multiplyQuaternionsFlat(a.values,e,u,0,a.values,e);else{const t=c-2*l;for(let i=0;i<t;++i)a.values[e+i]-=u[i]}}}return t.blendMode=Be,t}(t,e,i,n)}},ArcCurve:Lo,ArrayCamera:sc,ArrowHelper:class extends $n{constructor(t=new Li(0,0,1),e=new Li(0,0,0),i=1,n=16776960,s=.2*i,r=.2*s){super(),this.type="ArrowHelper",void 0===dd&&(dd=new zs,dd.setAttribute("position",new Ps([0,0,0,0,1,0],3)),ud=new yo(.5,1,5,1),ud.translate(0,-.5,0)),this.position.copy(e),this.line=new Ka(dd,new Ha({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Qs(ud,new Ss({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,s,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{cd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(cd,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},AttachedBindMode:lt,Audio:dc,AudioAnalyser:class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}},AudioContext:tc,AudioListener:class extends $n{constructor(){super(),this.type="AudioListener",this.context=tc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new rc}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ac,oc,hc),lc.set(0,0,-1).applyQuaternion(oc),cc.set(0,1,0).applyQuaternion(oc),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ac.x,t),e.positionY.linearRampToValueAtTime(ac.y,t),e.positionZ.linearRampToValueAtTime(ac.z,t),e.forwardX.linearRampToValueAtTime(lc.x,t),e.forwardY.linearRampToValueAtTime(lc.y,t),e.forwardZ.linearRampToValueAtTime(lc.z,t),e.upX.linearRampToValueAtTime(cc.x,t),e.upY.linearRampToValueAtTime(cc.y,t),e.upZ.linearRampToValueAtTime(cc.z,t)}else e.setPosition(ac.x,ac.y,ac.z),e.setOrientation(lc.x,lc.y,lc.z,cc.x,cc.y,cc.z)}},AudioLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new Ml(this.manager);function a(e){n?n(e):pi(e),s.manager.itemError(t)}r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(t){try{const i=t.slice(0);tc.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(t){a(t)}},i,n)}},AxesHelper:class extends to{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new zs;i.setAttribute("position",new Ps(e,3)),i.setAttribute("color",new Ps([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new Ha({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const n=new _s,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(i),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BackSide:1,BasicDepthPacking:3200,BasicShadowMap:0,BatchedMesh:Ga,Bone:$r,BooleanKeyframeTrack:ll,Box2:class{constructor(t=new Ai(1/0,1/0),e=new Ai(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=zc.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,zc).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Box3:Qi,Box3Helper:class extends to{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new zs;n.setIndex(new Ls(i,1)),n.setAttribute("position",new Ps([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new Ha({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:tr,BoxHelper:class extends to{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),s=new zs;s.setIndex(new Ls(i,1)),s.setAttribute("position",new Ls(n,3)),super(s,new Ha({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&ld.setFromObject(this.object),ld.isEmpty())return;const t=ld.min,e=ld.max,i=this.geometry.attributes.position,n=i.array;n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=t.x,n[4]=e.y,n[5]=e.z,n[6]=t.x,n[7]=t.y,n[8]=e.z,n[9]=e.x,n[10]=t.y,n[11]=e.z,n[12]=e.x,n[13]=e.y,n[14]=t.z,n[15]=t.x,n[16]=e.y,n[17]=t.z,n[18]=t.x,n[19]=t.y,n[20]=t.z,n[21]=e.x,n[22]=t.y,n[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:Ls,BufferGeometry:zs,BufferGeometryLoader:ql,ByteType:At,Cache:_l,Camera:ar,CameraHelper:class extends to{constructor(t){const e=new zs,i=new Ha({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],r={};function a(t,e){o(t),o(e)}function o(t){n.push(0,0,0),s.push(0,0,0),void 0===r[t]&&(r[t]=[]),r[t].push(n.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new Ps(n,3)),e.setAttribute("color",new Ps(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update();const h=new _s(16755200),l=new _s(16711680),c=new _s(43775),d=new _s(16777215),u=new _s(3355443);this.setColors(h,l,c,d,u)}setColors(t,e,i,n,s){const r=this.geometry.getAttribute("color");return r.setXYZ(0,t.r,t.g,t.b),r.setXYZ(1,t.r,t.g,t.b),r.setXYZ(2,t.r,t.g,t.b),r.setXYZ(3,t.r,t.g,t.b),r.setXYZ(4,t.r,t.g,t.b),r.setXYZ(5,t.r,t.g,t.b),r.setXYZ(6,t.r,t.g,t.b),r.setXYZ(7,t.r,t.g,t.b),r.setXYZ(8,t.r,t.g,t.b),r.setXYZ(9,t.r,t.g,t.b),r.setXYZ(10,t.r,t.g,t.b),r.setXYZ(11,t.r,t.g,t.b),r.setXYZ(12,t.r,t.g,t.b),r.setXYZ(13,t.r,t.g,t.b),r.setXYZ(14,t.r,t.g,t.b),r.setXYZ(15,t.r,t.g,t.b),r.setXYZ(16,t.r,t.g,t.b),r.setXYZ(17,t.r,t.g,t.b),r.setXYZ(18,t.r,t.g,t.b),r.setXYZ(19,t.r,t.g,t.b),r.setXYZ(20,t.r,t.g,t.b),r.setXYZ(21,t.r,t.g,t.b),r.setXYZ(22,t.r,t.g,t.b),r.setXYZ(23,t.r,t.g,t.b),r.setXYZ(24,e.r,e.g,e.b),r.setXYZ(25,e.r,e.g,e.b),r.setXYZ(26,e.r,e.g,e.b),r.setXYZ(27,e.r,e.g,e.b),r.setXYZ(28,e.r,e.g,e.b),r.setXYZ(29,e.r,e.g,e.b),r.setXYZ(30,e.r,e.g,e.b),r.setXYZ(31,e.r,e.g,e.b),r.setXYZ(32,i.r,i.g,i.b),r.setXYZ(33,i.r,i.g,i.b),r.setXYZ(34,i.r,i.g,i.b),r.setXYZ(35,i.r,i.g,i.b),r.setXYZ(36,i.r,i.g,i.b),r.setXYZ(37,i.r,i.g,i.b),r.setXYZ(38,n.r,n.g,n.b),r.setXYZ(39,n.r,n.g,n.b),r.setXYZ(40,s.r,s.g,s.b),r.setXYZ(41,s.r,s.g,s.b),r.setXYZ(42,s.r,s.g,s.b),r.setXYZ(43,s.r,s.g,s.b),r.setXYZ(44,s.r,s.g,s.b),r.setXYZ(45,s.r,s.g,s.b),r.setXYZ(46,s.r,s.g,s.b),r.setXYZ(47,s.r,s.g,s.b),r.setXYZ(48,s.r,s.g,s.b),r.setXYZ(49,s.r,s.g,s.b),r.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap;let i,n;if(od.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)i=1,n=0;else if(this.camera.coordinateSystem===ei)i=-1,n=1;else{if(this.camera.coordinateSystem!==ii)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);i=0,n=1}hd("c",e,t,od,0,0,i),hd("t",e,t,od,0,0,n),hd("n1",e,t,od,-1,-1,i),hd("n2",e,t,od,1,-1,i),hd("n3",e,t,od,-1,1,i),hd("n4",e,t,od,1,1,i),hd("f1",e,t,od,-1,-1,n),hd("f2",e,t,od,1,-1,n),hd("f3",e,t,od,-1,1,n),hd("f4",e,t,od,1,1,n),hd("u1",e,t,od,.7,1.1,i),hd("u2",e,t,od,-.7,1.1,i),hd("u3",e,t,od,0,2,i),hd("cf1",e,t,od,-1,0,n),hd("cf2",e,t,od,1,0,n),hd("cf3",e,t,od,0,-1,n),hd("cf4",e,t,od,0,1,n),hd("cn1",e,t,od,-1,0,i),hd("cn2",e,t,od,1,0,i),hd("cn3",e,t,od,0,-1,i),hd("cn4",e,t,od,0,1,i),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:uo,CapsuleGeometry:go,CatmullRomCurve3:No,CineonToneMapping:3,CircleGeometry:vo,ClampToEdgeWrapping:_t,Clock:rc,Color:_s,ColorKeyframeTrack:cl,ColorManagement:Ui,CompressedArrayTexture:class extends co{constructor(t,e,i,n,s,r){super(t,e,i,s,r),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=_t,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},CompressedCubeTexture:class extends co{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,ut),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},CompressedTexture:co,CompressedTextureLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=[],a=new co,o=new Ml(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials);let h=0;function l(l){o.load(t[l],function(t){const i=s.parse(t,!0);r[l]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},h+=1,6===h&&(1===i.mipmapCount&&(a.minFilter=wt),a.image=r,a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)l(e);else o.load(t,function(t){const i=s.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){r[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)r[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),r[e].format=i.format,r[e].width=i.width,r[e].height=i.height}a.image=r}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=wt),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,n);return a}},ConeGeometry:yo,ConstantAlphaFactor:213,ConstantColorFactor:211,Controls:pd,CubeCamera:ur,CubeDepthTexture:mo,CubeReflectionMapping:ut,CubeRefractionMapping:pt,CubeTexture:pr,CubeTextureLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=new pr;s.colorSpace=ze;const r=new El(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);let a=0;function o(i){r.load(t[i],function(t){s.images[i]=t,a++,6===a&&(s.needsUpdate=!0,e&&e(s))},void 0,n)}for(let e=0;e<t.length;++e)o(e);return s}},CubeUVReflectionMapping:gt,CubicBezierCurve:ko,CubicBezierCurve3:zo,CubicInterpolant:rl,CullFaceBack:1,CullFaceFront:2,CullFaceFrontBack:3,CullFaceNone:0,Curve:Ao,CurvePath:Yo,CustomBlending:5,CustomToneMapping:5,CylinderGeometry:_o,Cylindrical:class{constructor(t=1,e=0,i=0){this.radius=t,this.theta=e,this.y=i}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},Data3DTexture:Ji,DataArrayTexture:Ki,DataTexture:ta,DataTextureLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new ta,a=new Ml(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(t){let i;try{i=s.parse(t)}catch(t){if(void 0===n)return void t(t);n(t)}void 0!==i.image?r.image=i.image:void 0!==i.data&&(r.image.width=i.width,r.image.height=i.height,r.image.data=i.data),r.wrapS=void 0!==i.wrapS?i.wrapS:_t,r.wrapT=void 0!==i.wrapT?i.wrapT:_t,r.magFilter=void 0!==i.magFilter?i.magFilter:wt,r.minFilter=void 0!==i.minFilter?i.minFilter:wt,r.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace&&(r.colorSpace=i.colorSpace),void 0!==i.flipY&&(r.flipY=i.flipY),void 0!==i.format&&(r.format=i.format),void 0!==i.type&&(r.type=i.type),void 0!==i.mipmaps&&(r.mipmaps=i.mipmaps,r.minFilter=Tt),1===i.mipmapCount&&(r.minFilter=wt),void 0!==i.generateMipmaps&&(r.generateMipmaps=i.generateMipmaps),r.needsUpdate=!0,e&&e(r,i)},i,n),r}},DataUtils:class{static toHalfFloat(t){return Ms(t)}static fromHalfFloat(t){return Ts(t)}},DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:xl,DepthFormat:Ht,DepthStencilFormat:Vt,DepthTexture:po,DetachedBindMode:ct,DirectionalLight:zl,DirectionalLightHelper:class extends $n{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new zs;n.setAttribute("position",new Ps([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new Ha({fog:!1,toneMapped:!1});this.lightPlane=new Ka(n,s),this.add(this.lightPlane),n=new zs,n.setAttribute("position",new Ps([0,0,0,0,0,1],3)),this.targetLine=new Ka(n,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),nd.setFromMatrixPosition(this.light.matrixWorld),sd.setFromMatrixPosition(this.light.target.matrixWorld),rd.subVectors(sd,nd),this.lightPlane.lookAt(sd),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(sd),this.targetLine.scale.z=rd.length()}},DiscreteInterpolant:ol,DodecahedronGeometry:bo,DoubleSide:2,DstAlphaFactor:206,DstColorFactor:208,DynamicCopyUsage:35050,DynamicDrawUsage:35048,DynamicReadUsage:35049,EdgesGeometry:Eo,EllipseCurve:Co,EqualCompare:514,EqualDepth:4,EqualStencilFunc:514,EquirectangularReflectionMapping:mt,EquirectangularRefractionMapping:ft,Euler:Un,EventDispatcher:fi,ExternalTexture:fo,ExtrudeGeometry:Eh,FileLoader:Ml,Float16BufferAttribute:class extends Ls{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=Ts(this.array[t*this.itemSize]);return this.normalized&&(e=Mi(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize]=Ms(e),this}getY(t){let e=Ts(this.array[t*this.itemSize+1]);return this.normalized&&(e=Mi(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize+1]=Ms(e),this}getZ(t){let e=Ts(this.array[t*this.itemSize+2]);return this.normalized&&(e=Mi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize+2]=Ms(e),this}getW(t){let e=Ts(this.array[t*this.itemSize+3]);return this.normalized&&(e=Mi(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ti(e,this.array)),this.array[t*this.itemSize+3]=Ms(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Ti(e,this.array),i=Ti(i,this.array)),this.array[t+0]=Ms(e),this.array[t+1]=Ms(i),this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Ti(e,this.array),i=Ti(i,this.array),n=Ti(n,this.array)),this.array[t+0]=Ms(e),this.array[t+1]=Ms(i),this.array[t+2]=Ms(n),this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=Ti(e,this.array),i=Ti(i,this.array),n=Ti(n,this.array),s=Ti(s,this.array)),this.array[t+0]=Ms(e),this.array[t+1]=Ms(i),this.array[t+2]=Ms(n),this.array[t+3]=Ms(s),this}},Float32BufferAttribute:Ps,FloatType:Pt,Fog:yr,FogExp2:_r,FramebufferTexture:class extends Xi{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=xt,this.minFilter=xt,this.generateMipmaps=!1,this.needsUpdate=!0}},FrontSide:0,Frustum:xa,FrustumArray:wa,GLBufferAttribute:class{constructor(t,e,i,n,s,r=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=s,this.normalized=r,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},GLSL1:"100",GLSL3:ti,GreaterCompare:516,GreaterDepth:6,GreaterEqualCompare:Je,GreaterEqualDepth:5,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:class extends to{constructor(t=10,e=10,i=4473924,n=8947848){i=new _s(i),n=new _s(n);const s=e/2,r=t/e,a=t/2,o=[],h=[];for(let t=0,l=0,c=-a;t<=e;t++,c+=r){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===s?i:n;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new zs;l.setAttribute("position",new Ps(o,3)),l.setAttribute("color",new Ps(h,3));super(l,new Ha({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Group:fr,HalfFloatType:Dt,HemisphereLight:Ll,HemisphereLightHelper:class extends $n{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const n=new Rh(e);n.rotateY(.5*Math.PI),this.material=new Ss({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const s=n.getAttribute("position"),r=new Float32Array(3*s.count);n.setAttribute("color",new Ls(r,3)),this.add(new Qs(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");ed.copy(this.light.color),id.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?ed:id;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(td.setFromMatrixPosition(this.light.matrixWorld).negate())}},IcosahedronGeometry:Ch,ImageBitmapLoader:class extends bl{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&ui("ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&ui("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=_l.get(`image-bitmap:${t}`);if(void 0!==r)return s.manager.itemStart(t),r.then?void r.then(i=>{if(!0!==Ql.has(r))return e&&e(i),s.manager.itemEnd(t),i;n&&n(Ql.get(r)),s.manager.itemError(t),s.manager.itemEnd(t)}):(setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0),r);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(i){return _l.add(`image-bitmap:${t}`,i),e&&e(i),s.manager.itemEnd(t),i}).catch(function(e){n&&n(e),Ql.set(o,e),_l.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});_l.add(`image-bitmap:${t}`,o),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ImageLoader:El,ImageUtils:zi,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:sa,InstancedBufferGeometry:Yl,InstancedInterleavedBuffer:Pc,InstancedMesh:ua,Int16BufferAttribute:class extends Ls{constructor(t,e,i){super(new Int16Array(t),e,i)}},Int32BufferAttribute:class extends Ls{constructor(t,e,i){super(new Int32Array(t),e,i)}},Int8BufferAttribute:class extends Ls{constructor(t,e,i){super(new Int8Array(t),e,i)}},IntType:Rt,InterleavedBuffer:br,InterleavedBufferAttribute:wr,Interpolant:sl,InterpolateDiscrete:Ie,InterpolateLinear:Pe,InterpolateSmooth:De,InterpolationSamplingMode:{NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},InterpolationSamplingType:{PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},InvertStencilOp:5386,KeepStencilOp:We,KeyframeTrack:hl,LOD:Hr,LatheGeometry:Lh,Layers:Fn,LessCompare:513,LessDepth:2,LessEqualCompare:qe,LessEqualDepth:3,LessEqualStencilFunc:515,LessStencilFunc:513,Light:Cl,LightProbe:Wl,Line:Ka,Line3:qc,LineBasicMaterial:Ha,LineCurve:Go,LineCurve3:Ho,LineDashedMaterial:$h,LineLoop:eo,LineSegments:to,LinearFilter:wt,LinearInterpolant:al,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:Tt,LinearMipmapNearestFilter:Mt,LinearSRGBColorSpace:Ge,LinearToneMapping:1,LinearTransfer:He,Loader:bl,LoaderUtils:Xl,LoadingManager:yl,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,MOUSE:x,Material:bs,MaterialLoader:jl,MathUtils:Ei,Matrix2:kc,Matrix3:Pi,Matrix4:En,MaxEquation:104,Mesh:Qs,MeshBasicMaterial:Ss,MeshDepthMaterial:Kh,MeshDistanceMaterial:Jh,MeshLambertMaterial:Zh,MeshMatcapMaterial:Qh,MeshNormalMaterial:qh,MeshPhongMaterial:Xh,MeshPhysicalMaterial:jh,MeshStandardMaterial:Wh,MeshToonMaterial:Yh,MinEquation:103,MirroredRepeatWrapping:yt,MixOperation:1,MultiplyBlending:4,MultiplyOperation:0,NearestFilter:xt,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:St,NearestMipmapNearestFilter:bt,NeutralToneMapping:7,NeverCompare:512,NeverDepth:0,NeverStencilFunc:512,NoBlending:0,NoColorSpace:ke,NoNormalPacking:"",NoToneMapping:0,NormalAnimationBlendMode:Fe,NormalBlending:1,NormalGAPacking:"ga",NormalRGPacking:"rg",NotEqualCompare:517,NotEqualDepth:7,NotEqualStencilFunc:517,NumberKeyframeTrack:dl,Object3D:$n,ObjectLoader:class extends bl{constructor(t){super(t)}load(t,e,i,n){const s=this,r=""===this.path?Xl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new Ml(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(i){let r=null;try{r=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void e("ObjectLoader: Can't parse "+t+".",e.message)}const a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==n&&n(new Error("THREE.ObjectLoader: Can't load "+t)),void pi("ObjectLoader: Can't load "+t);s.parse(r,e)},i,n)}async loadAsync(t,e){const i=""===this.path?Xl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const n=new Ml(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const s=await n.loadAsync(t,e),r=JSON.parse(s),a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(r)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,n),r=this.parseImages(t.images,function(){void 0!==e&&e(h)}),a=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,s,o,a,i),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),this.bindLightTargets(h),void 0!==e){let t=!1;for(const e in r)if(r[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,i),s=await this.parseImagesAsync(t.images),r=this.parseTextures(t.textures,s),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,n,a,r,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new Zo).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse(function(t){t.isBone&&(n[t.uuid]=t)}),void 0!==t)for(let e=0,s=t.length;e<s;e++){const s=(new na).fromJSON(t[e],n);i[s.uuid]=s}return i}parseGeometries(t,e){const i={};if(void 0!==t){const n=new ql;for(let s=0,r=t.length;s<r;s++){let r;const a=t[s];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":r=n.parse(a);break;default:a.type in Gh?r=Gh[a.type].fromJSON(a,e):ui(`ObjectLoader: Unsupported geometry type "${a.type}"`)}r.uuid=a.uuid,void 0!==a.name&&(r.name=a.name),void 0!==a.userData&&(r.userData=a.userData),i[a.uuid]=r}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const s=new jl;s.setTextures(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0===i[r.uuid]&&(i[r.uuid]=s.parse(r)),n[r.uuid]=i[r.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],s=gl.parse(n);e[s.uuid]=s}return e}parseImages(t,e){const i=this,n={};let s;function r(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),s.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemError(t),i.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new yl(e);s=new El(i),s.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],s=i.url;if(Array.isArray(s)){const t=[];for(let e=0,i=s.length;e<i;e++){const i=r(s[e]);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new ta(i.data,i.width,i.height)))}n[i.uuid]=new Hi(t)}else{const t=r(i.url);n[i.uuid]=new Hi(t)}}}return n}async parseImagesAsync(t){const e=this,i={};let n;async function s(t){if("string"==typeof t){const i=t,s=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:e.resourcePath+i;return await n.loadAsync(s)}return t.data?{data:ri(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){n=new El(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.url;if(Array.isArray(r)){const t=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],n=await s(i);null!==n&&(n instanceof HTMLImageElement?t.push(n):t.push(new ta(n.data,n.width,n.height)))}i[n.uuid]=new Hi(t)}else{const t=await s(n.url);i[n.uuid]=new Hi(t)}}}return i}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(ui("ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let s=0,r=t.length;s<r;s++){const r=t[s];void 0===r.image&&ui('ObjectLoader: No "image" specified for',r.uuid),void 0===e[r.image]&&ui("ObjectLoader: Undefined image",r.image);const a=e[r.image],o=a.data;let h;Array.isArray(o)?(h=new pr,6===o.length&&(h.needsUpdate=!0)):(h=o&&o.data?new ta:new Xi,o&&(h.needsUpdate=!0)),h.source=a,h.uuid=r.uuid,void 0!==r.name&&(h.name=r.name),void 0!==r.mapping&&(h.mapping=i(r.mapping,Zl)),void 0!==r.channel&&(h.channel=r.channel),void 0!==r.offset&&h.offset.fromArray(r.offset),void 0!==r.repeat&&h.repeat.fromArray(r.repeat),void 0!==r.center&&h.center.fromArray(r.center),void 0!==r.rotation&&(h.rotation=r.rotation),void 0!==r.wrap&&(h.wrapS=i(r.wrap[0],Kl),h.wrapT=i(r.wrap[1],Kl)),void 0!==r.format&&(h.format=r.format),void 0!==r.internalFormat&&(h.internalFormat=r.internalFormat),void 0!==r.type&&(h.type=r.type),void 0!==r.colorSpace&&(h.colorSpace=r.colorSpace),void 0!==r.minFilter&&(h.minFilter=i(r.minFilter,Jl)),void 0!==r.magFilter&&(h.magFilter=i(r.magFilter,Jl)),void 0!==r.anisotropy&&(h.anisotropy=r.anisotropy),void 0!==r.flipY&&(h.flipY=r.flipY),void 0!==r.generateMipmaps&&(h.generateMipmaps=r.generateMipmaps),void 0!==r.premultiplyAlpha&&(h.premultiplyAlpha=r.premultiplyAlpha),void 0!==r.unpackAlignment&&(h.unpackAlignment=r.unpackAlignment),void 0!==r.compareFunction&&(h.compareFunction=r.compareFunction),void 0!==r.userData&&(h.userData=r.userData),n[r.uuid]=h}return n}parseObject(t,e,i,n,s){let r,a,o;function h(t){return void 0===e[t]&&ui("ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,s=t.length;n<s;n++){const s=t[n];void 0===i[s]&&ui("ObjectLoader: Undefined material",s),e.push(i[s])}return e}return void 0===i[t]&&ui("ObjectLoader: Undefined material",t),i[t]}}function c(t){return void 0===n[t]&&ui("ObjectLoader: Undefined texture",t),n[t]}switch(t.type){case"Scene":r=new xr,void 0!==t.background&&(Number.isInteger(t.background)?r.background=new _s(t.background):r.background=c(t.background)),void 0!==t.environment&&(r.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new yr(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new _r(t.fog.color,t.fog.density)),""!==t.fog.name&&(r.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(r.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(r.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&r.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(r.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&r.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":r=new cr(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new Bl(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new Gl(t.color,t.intensity);break;case"DirectionalLight":r=new zl(t.color,t.intensity),r.target=t.target||"";break;case"PointLight":r=new Fl(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new Hl(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new Nl(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),r.target=t.target||"";break;case"HemisphereLight":r=new Ll(t.color,t.groundColor,t.intensity);break;case"LightProbe":const e=(new Vl).fromArray(t.sh);r=new Wl(e,t.intensity);break;case"SkinnedMesh":a=h(t.geometry),o=l(t.material),r=new Qr(a,o),void 0!==t.bindMode&&(r.bindMode=t.bindMode),void 0!==t.bindMatrix&&r.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(r.skeleton=t.skeleton);break;case"Mesh":a=h(t.geometry),o=l(t.material),r=new Qs(a,o);break;case"InstancedMesh":a=h(t.geometry),o=l(t.material);const i=t.count,n=t.instanceMatrix,s=t.instanceColor;r=new ua(a,o,i),r.instanceMatrix=new sa(new Float32Array(n.array),16),void 0!==s&&(r.instanceColor=new sa(new Float32Array(s.array),s.itemSize));break;case"BatchedMesh":a=h(t.geometry),o=l(t.material),r=new Ga(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),r.geometry=a,r.perObjectFrustumCulled=t.perObjectFrustumCulled,r.sortObjects=t.sortObjects,r._drawRanges=t.drawRanges,r._reservedRanges=t.reservedRanges,r._geometryInfo=t.geometryInfo.map(t=>{let e=null,i=null;return void 0!==t.boundingBox&&(e=(new Qi).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=(new vn).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}}),r._instanceInfo=t.instanceInfo,r._availableInstanceIds=t._availableInstanceIds,r._availableGeometryIds=t._availableGeometryIds,r._nextIndexStart=t.nextIndexStart,r._nextVertexStart=t.nextVertexStart,r._geometryCount=t.geometryCount,r._maxInstanceCount=t.maxInstanceCount,r._maxVertexCount=t.maxVertexCount,r._maxIndexCount=t.maxIndexCount,r._geometryInitialized=t.geometryInitialized,r._matricesTexture=c(t.matricesTexture.uuid),r._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(r._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(r.boundingSphere=(new vn).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(r.boundingBox=(new Qi).fromJSON(t.boundingBox));break;case"LOD":r=new Hr;break;case"Line":r=new Ka(h(t.geometry),l(t.material));break;case"LineLoop":r=new eo(h(t.geometry),l(t.material));break;case"LineSegments":r=new to(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":r=new oo(h(t.geometry),l(t.material));break;case"Sprite":r=new Br(l(t.material));break;case"Group":r=new fr;break;case"Bone":r=new $r;break;default:r=new $n}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.up&&r.up.fromArray(t.up),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(r.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)r.add(this.parseObject(a[t],e,i,n,s))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];r.animations.push(s[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(r.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=r.getObjectByProperty("uuid",i.object);void 0!==n&&r.addLevel(n,i.distance,i.hysteresis)}}return r}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?ui("ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,n=t.getObjectByProperty("uuid",i);e.target=void 0!==n?n:new $n}})}},ObjectSpaceNormalMap:1,OctahedronGeometry:Rh,OneFactor:201,OneMinusConstantAlphaFactor:214,OneMinusConstantColorFactor:212,OneMinusDstAlphaFactor:207,OneMinusDstColorFactor:209,OneMinusSrcAlphaFactor:N,OneMinusSrcColorFactor:203,OrthographicCamera:Bl,PCFShadowMap:1,PCFSoftShadowMap:2,PMREMGenerator:Bd,Path:qo,PerspectiveCamera:cr,Plane:ga,PlaneGeometry:Ih,PlaneHelper:class extends Ka{constructor(t,e=1,i=16776960){const n=i,s=new zs;s.setAttribute("position",new Ps([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),s.computeBoundingSphere(),super(s,new Ha({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const r=new zs;r.setAttribute("position",new Ps([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Qs(r,new Ss({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},PointLight:Fl,PointLightHelper:class extends Qs{constructor(t,e,i){super(new Oh(e,4,2),new Ss({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:oo,PointsMaterial:io,PolarGridHelper:class extends to{constructor(t=10,e=16,i=8,n=64,s=4473924,r=8947848){s=new _s(s),r=new _s(r);const a=[],o=[];if(e>1)for(let i=0;i<e;i++){const n=i/e*(2*Math.PI),h=Math.sin(n)*t,l=Math.cos(n)*t;a.push(0,0,0),a.push(h,0,l);const c=1&i?s:r;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<i;e++){const h=1&e?s:r,l=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*l,s=Math.cos(e)*l;a.push(i,0,s),o.push(h.r,h.g,h.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*l,s=Math.cos(e)*l,a.push(i,0,s),o.push(h.r,h.g,h.b)}}const h=new zs;h.setAttribute("position",new Ps(a,3)),h.setAttribute("color",new Ps(o,3));super(h,new Ha({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},PolyhedronGeometry:xo,PositionalAudio:class extends dc{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(uc,pc,mc),fc.set(0,0,1).applyQuaternion(pc);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(uc.x,t),e.positionY.linearRampToValueAtTime(uc.y,t),e.positionZ.linearRampToValueAtTime(uc.z,t),e.orientationX.linearRampToValueAtTime(fc.x,t),e.orientationY.linearRampToValueAtTime(fc.y,t),e.orientationZ.linearRampToValueAtTime(fc.z,t)}else e.setPosition(uc.x,uc.y,uc.z),e.setOrientation(fc.x,fc.y,fc.z)}},PropertyBinding:Ac,PropertyMixer:gc,QuadraticBezierCurve:Vo,QuadraticBezierCurve3:Wo,Quaternion:Ci,QuaternionKeyframeTrack:pl,QuaternionLinearInterpolant:ul,R11_EAC_Format:ae,RED_GREEN_RGTC2_Format:Le,RED_RGTC1_Format:Ae,REVISION:y,RG11_EAC_Format:he,RGBADepthPacking:3201,RGBAFormat:Gt,RGBAIntegerFormat:qt,RGBA_ASTC_10x10_Format:be,RGBA_ASTC_10x5_Format:_e,RGBA_ASTC_10x6_Format:ye,RGBA_ASTC_10x8_Format:xe,RGBA_ASTC_12x10_Format:Se,RGBA_ASTC_12x12_Format:we,RGBA_ASTC_4x4_Format:ce,RGBA_ASTC_5x4_Format:de,RGBA_ASTC_5x5_Format:ue,RGBA_ASTC_6x5_Format:pe,RGBA_ASTC_6x6_Format:me,RGBA_ASTC_8x5_Format:fe,RGBA_ASTC_8x6_Format:ge,RGBA_ASTC_8x8_Format:ve,RGBA_BPTC_Format:Me,RGBA_ETC2_EAC_Format:re,RGBA_PVRTC_2BPPV1_Format:ie,RGBA_PVRTC_4BPPV1_Format:ee,RGBA_S3TC_DXT1_Format:Kt,RGBA_S3TC_DXT3_Format:Jt,RGBA_S3TC_DXT5_Format:Qt,RGBDepthPacking:3202,RGBFormat:zt,RGBIntegerFormat:1032,RGB_BPTC_SIGNED_Format:Te,RGB_BPTC_UNSIGNED_Format:Ee,RGB_ETC1_Format:ne,RGB_ETC2_Format:se,RGB_PVRTC_2BPPV1_Format:te,RGB_PVRTC_4BPPV1_Format:$t,RGB_S3TC_DXT1_Format:Zt,RGDepthPacking:3203,RGFormat:Xt,RGIntegerFormat:Yt,RawShaderMaterial:Vh,Ray:Tn,Raycaster:Oc,RectAreaLight:Hl,RedFormat:Wt,RedIntegerFormat:jt,ReinhardToneMapping:2,RenderTarget:qi,RenderTarget3D:class extends qi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isRenderTarget3D=!0,this.depth=i,this.texture=new Ji(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},RepeatWrapping:vt,ReplaceStencilOp:7681,ReverseSubtractEquation:102,RingGeometry:Ph,SIGNED_R11_EAC_Format:oe,SIGNED_RED_GREEN_RGTC2_Format:Re,SIGNED_RED_RGTC1_Format:Ce,SIGNED_RG11_EAC_Format:le,SRGBColorSpace:ze,SRGBTransfer:Ve,Scene:xr,ShaderChunk:vd,ShaderLib:yd,ShaderMaterial:rr,ShadowMaterial:Hh,Shape:Zo,ShapeGeometry:Dh,ShapePath:class{constructor(){this.type="ShapePath",this.color=new _s,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new qo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,s,r){return this.currentPath.bezierCurveTo(t,e,i,n,s,r),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let n=!1;for(let s=i-1,r=0;r<i;s=r++){let i=e[s],a=e[r],o=a.x-i.x,h=a.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=e[r],o=-o,a=e[s],h=-h),t.y<i.y||t.y>a.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return n}const i=wh.isClockWise,n=this.subPaths;if(0===n.length)return[];let s,r,a;const o=[];if(1===n.length)return r=n[0],a=new Zo,a.curves=r.curves,o.push(a),o;let h=!i(n[0].getPoints());h=t?!h:h;const l=[],c=[];let d,u,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=n.length;e<a;e++)r=n[e],d=r.getPoints(),s=i(d),s=t?!s:s,s?(!h&&c[m]&&m++,c[m]={s:new Zo,p:d},c[m].s.curves=r.curves,h&&m++,p[m]=[]):p[m].push({h:r,p:d[0]});if(!c[0])return function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],s=new Zo;s.curves=n.curves,e.push(s)}return e}(n);if(c.length>1){let t=!1,i=0;for(let t=0,e=c.length;t<e;t++)l[t]=[];for(let n=0,s=c.length;n<s;n++){const s=p[n];for(let r=0;r<s.length;r++){const a=s[r];let o=!0;for(let s=0;s<c.length;s++)e(a.p,c[s].p)&&(n!==s&&i++,o?(o=!1,l[s].push(a)):t=!0);o&&l[n].push(a)}}i>0&&!1===t&&(p=l)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),u=p[t];for(let t=0,e=u.length;t<e;t++)a.holes.push(u[t].h)}return o}},ShapeUtils:wh,ShortType:Ct,Skeleton:na,SkeletonHelper:class extends to{constructor(t){const e=$c(t),i=new zs,n=[],s=[];for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),s.push(0,0,0),s.push(0,0,0))}i.setAttribute("position",new Ps(n,3)),i.setAttribute("color",new Ps(s,3));super(i,new Ha({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const r=new _s(255),a=new _s(65280);this.setColors(r,a)}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");Qc.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const s=e[t];s.parent&&s.parent.isBone&&(Jc.multiplyMatrices(Qc,s.matrixWorld),Kc.setFromMatrixPosition(Jc),n.setXYZ(i,Kc.x,Kc.y,Kc.z),Jc.multiplyMatrices(Qc,s.parent.matrixWorld),Kc.setFromMatrixPosition(Jc),n.setXYZ(i+1,Kc.x,Kc.y,Kc.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const i=this.geometry.getAttribute("color");for(let n=0;n<i.count;n+=2)i.setXYZ(n,t.r,t.g,t.b),i.setXYZ(n+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},SkinnedMesh:Qr,Source:Hi,Sphere:vn,SphereGeometry:Oh,Spherical:Bc,SphericalHarmonics3:Vl,SplineCurve:jo,SpotLight:Nl,SpotLightHelper:class extends $n{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new zs,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const s=t/i*Math.PI*2,r=e/i*Math.PI*2;n.push(Math.cos(s),Math.sin(s),1,Math.cos(r),Math.sin(r),1)}i.setAttribute("position",new Ps(n,3));const s=new Ha({fog:!1,toneMapped:!1});this.cone=new to(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Zc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Zc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:Br,SpriteMaterial:Mr,SrcAlphaFactor:O,SrcAlphaSaturateFactor:210,SrcColorFactor:202,StaticCopyUsage:35046,StaticDrawUsage:$e,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new cr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new cr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,nc.copy(t.projectionMatrix);const i=e.eyeSep/2,n=i*e.near/e.focus,s=e.near*Math.tan(_i*e.fov*.5)/e.zoom;let r,a;ic.elements[12]=-i,ec.elements[12]=i,r=-s*e.aspect+n,a=s*e.aspect+n,nc.elements[0]=2*e.near/(a-r),nc.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(nc),r=-s*e.aspect-n,a=s*e.aspect-n,nc.elements[0]=2*e.near/(a-r),nc.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(nc)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(ic),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(ec)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:ml,SubtractEquation:101,SubtractiveBlending:3,TOUCH:b,TangentSpaceNormalMap:0,TetrahedronGeometry:Nh,Texture:Xi,TextureLoader:Al,TextureUtils:class{static contain(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,i,n){return md(t,e,i,n)}},Timer:class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=Fc.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}},TimestampQuery:{COMPUTE:"compute",RENDER:"render"},TorusGeometry:Uh,TorusKnotGeometry:Fh,Triangle:ps,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeGeometry:Bh,UVMapping:dt,Uint16BufferAttribute:Rs,Uint32BufferAttribute:Is,Uint8BufferAttribute:class extends Ls{constructor(t,e,i){super(new Uint8Array(t),e,i)}},Uint8ClampedBufferAttribute:class extends Ls{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}},Uniform:Rc,UniformsGroup:class extends fi{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Ic++}),this.name="",this.usage=$e,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,i=e.length;t<i;t++){const i=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<i.length;t++)this.uniforms.push(i[t].clone())}return this}clone(){return(new this.constructor).copy(this)}},UniformsLib:_d,UniformsUtils:sr,UnsignedByteType:Et,UnsignedInt101111Type:Bt,UnsignedInt248Type:Ut,UnsignedInt5999Type:Ft,UnsignedIntType:It,UnsignedShort4444Type:Ot,UnsignedShort5551Type:Nt,UnsignedShortType:Lt,VSMShadowMap:3,Vector2:Ai,Vector3:Li,Vector4:Yi,VectorKeyframeTrack:fl,VideoFrameTexture:class extends lo{constructor(t,e,i,n,s,r,a,o){super({},t,e,i,n,s,r,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},VideoTexture:lo,WebGL3DRenderTarget:class extends Zi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new Ji(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLArrayRenderTarget:class extends Zi{constructor(t=1,e=1,i=1,n={}){super(t,e,n),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Ki(null,t,e,i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}},WebGLCoordinateSystem:ei,WebGLCubeRenderTarget:mr,WebGLRenderTarget:Zi,WebGLRenderer:hm,WebGLUtils:$p,WebGPUCoordinateSystem:ii,WebXRController:vr,WireframeGeometry:kh,WrapAroundEnding:Ue,ZeroCurvatureEnding:Oe,ZeroFactor:200,ZeroSlopeEnding:Ne,ZeroStencilOp:0,createCanvasElement:hi,error:pi,getConsoleFunction:function(){return ci},log:di,setConsoleFunction:function(t){ci=t},warn:ui,warnOnce:mi});const cm=new Oc,dm=new Li,um=new Li,pm=new Ci,mm={X:new Li(1,0,0),Y:new Li(0,1,0),Z:new Li(0,0,1)},fm={type:"change"},gm={type:"mouseDown",mode:null},vm={type:"mouseUp",mode:null},_m={type:"objectChange"};class ym extends pd{constructor(t,e=null){super(void 0,e);const i=new zm(this);this._root=i;const n=new Gm;this._gizmo=n,i.add(n);const s=new Hm;this._plane=s,i.add(s);const r=this;function a(t,e){let i=e;Object.defineProperty(r,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,s[t]=e,n[t]=e,r.dispatchEvent({type:t+"-changed",value:e}),r.dispatchEvent(fm))}}),r[t]=e,s[t]=e,n[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new Li,h=new Li,l=new Ci,c=new Ci,d=new Li,u=new Ci,p=new Li,m=new Li,f=new Li,g=new Li;a("worldPosition",o),a("worldPositionStart",h),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",m),a("rotationAxis",f),a("rotationAngle",0),a("eye",g),this._offset=new Li,this._startNorm=new Li,this._endNorm=new Li,this._cameraScale=new Li,this._parentPosition=new Li,this._parentQuaternion=new Ci,this._parentQuaternionInv=new Ci,this._parentScale=new Li,this._worldScaleStart=new Li,this._worldQuaternionInv=new Ci,this._worldScale=new Li,this._positionStart=new Li,this._quaternionStart=new Ci,this._scaleStart=new Li,this._getPointer=xm.bind(this),this._onPointerDown=Sm.bind(this),this._onPointerHover=bm.bind(this),this._onPointerMove=wm.bind(this),this._onPointerUp=Mm.bind(this),null!==e&&this.connect(e)}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&cm.setFromCamera(t,this.camera);const e=Tm(this._gizmo.picker[this.mode],cm);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&cm.setFromCamera(t,this.camera);const e=Tm(this._plane,cm,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,gm.mode=this.mode,this.dispatchEvent(gm)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let s=this.space;if("scale"===i?s="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(s="world"),void 0===n||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&cm.setFromCamera(t,this.camera);const r=Tm(this._plane,cm,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===s&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===s&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===s&&(n.position.applyQuaternion(pm.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===s&&(n.parent&&n.position.add(dm.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(dm.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),um.set(t,t,t)}else dm.copy(this.pointStart),um.copy(this.pointEnd),dm.applyQuaternion(this._worldQuaternionInv),um.applyQuaternion(this._worldQuaternionInv),um.divide(dm),-1===e.search("X")&&(um.x=1),-1===e.search("Y")&&(um.y=1),-1===e.search("Z")&&(um.z=1);n.scale.copy(this._scaleStart).multiply(um),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(dm.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(dm.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(mm[e]),dm.copy(mm[e]),"local"===s&&dm.applyQuaternion(this.worldQuaternion),dm.cross(this.eye),0===dm.length()?i=!0:this.rotationAngle=this._offset.dot(dm.normalize())*t),("E"===e||i)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===s&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(pm.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(pm.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(fm),this.dispatchEvent(_m)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(vm.mode=this.mode,this.dispatchEvent(vm)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(fm),this.dispatchEvent(_m),this.pointStart.copy(this.pointEnd))}getRaycaster(){return cm}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}setColors(t,e,i,n){const s=this._gizmo.materialLib;s.xAxis.color.set(t),s.yAxis.color.set(e),s.zAxis.color.set(i),s.active.color.set(n),s.xAxisTransparent.color.set(t),s.yAxisTransparent.color.set(e),s.zAxisTransparent.color.set(i),s.activeTransparent.color.set(n),s.xAxis._color&&s.xAxis._color.set(t),s.yAxis._color&&s.yAxis._color.set(e),s.zAxis._color&&s.zAxis._color.set(i),s.active._color&&s.active._color.set(n),s.xAxisTransparent._color&&s.xAxisTransparent._color.set(t),s.yAxisTransparent._color&&s.yAxisTransparent._color.set(e),s.zAxisTransparent._color&&s.zAxisTransparent._color.set(i),s.activeTransparent._color&&s.activeTransparent._color.set(n)}}function xm(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function bm(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Sm(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function wm(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Mm(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Tm(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}const Em=new Un,Am=new Li(0,1,0),Cm=new Li(0,0,0),Lm=new En,Rm=new Ci,Im=new Ci,Pm=new Li,Dm=new En,Om=new Li(1,0,0),Nm=new Li(0,1,0),Um=new Li(0,0,1),Fm=new Li,Bm=new Li,km=new Li;class zm extends $n{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class Gm extends $n{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new Ss({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Ha({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const n=e.clone();n.opacity=.5;const s=t.clone();s.color.setHex(16711680);const r=t.clone();r.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const l=t.clone();l.color.setHex(255),l.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;const u=t.clone();u.color.setHex(16776960);const p=t.clone();p.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:r,zAxis:a,active:u,xAxisTransparent:o,yAxisTransparent:h,zAxisTransparent:l,activeTransparent:d};const m=new _o(0,.04,.1,12);m.translate(0,.05,0);const f=new tr(.08,.08,.08);f.translate(0,.04,0);const g=new zs;g.setAttribute("position",new Ps([0,0,0,1,0,0],3));const v=new _o(.0075,.0075,.5,3);function _(t,e){const i=new Uh(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}v.translate(0,.25,0);const y={X:[[new Qs(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new Qs(m,s),[-.5,0,0],[0,0,Math.PI/2]],[new Qs(v,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Qs(m,r),[0,.5,0]],[new Qs(m,r),[0,-.5,0],[Math.PI,0,0]],[new Qs(v,r)]],Z:[[new Qs(m,a),[0,0,.5],[Math.PI/2,0,0]],[new Qs(m,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Qs(v,a),null,[Math.PI/2,0,0]]],XYZ:[[new Qs(new Rh(.1,0),c),[0,0,0]]],XY:[[new Qs(new tr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Qs(new tr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},x={X:[[new Qs(new _o(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Qs(new _o(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Qs(new _o(.2,0,.6,4),i),[0,.3,0]],[new Qs(new _o(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Qs(new _o(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Qs(new _o(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Qs(new Rh(.2,0),i)]],XY:[[new Qs(new tr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Qs(new tr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},b={START:[[new Qs(new Rh(.01,2),n),null,null,null,"helper"]],END:[[new Qs(new Rh(.01,2),n),null,null,null,"helper"]],DELTA:[[new Ka(function(){const t=new zs;return t.setAttribute("position",new Ps([0,0,0,1,1,1],3)),t}(),n),null,null,null,"helper"]],X:[[new Ka(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ka(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ka(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},S={XYZE:[[new Qs(_(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new Qs(_(.5,.5),s)]],Y:[[new Qs(_(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new Qs(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Qs(_(.75,1),d),null,[0,Math.PI/2,0]]]},w={AXIS:[[new Ka(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new Qs(new Oh(.25,10,8),i)]],X:[[new Qs(new Uh(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Qs(new Uh(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Qs(new Uh(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Qs(new Uh(.75,.1,2,24),i)]]},T={X:[[new Qs(f,s),[.5,0,0],[0,0,-Math.PI/2]],[new Qs(v,s),[0,0,0],[0,0,-Math.PI/2]],[new Qs(f,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Qs(f,r),[0,.5,0]],[new Qs(v,r)],[new Qs(f,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Qs(f,a),[0,0,.5],[Math.PI/2,0,0]],[new Qs(v,a),[0,0,0],[Math.PI/2,0,0]],[new Qs(f,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Qs(new tr(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new Qs(new tr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Qs(new tr(.1,.1,.1),c)]]},E={X:[[new Qs(new _o(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Qs(new _o(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Qs(new _o(.2,0,.6,4),i),[0,.3,0]],[new Qs(new _o(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Qs(new _o(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Qs(new _o(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Qs(new tr(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Qs(new tr(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Qs(new tr(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Qs(new tr(.2,.2,.2),i),[0,0,0]]]},A={X:[[new Ka(g,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Ka(g,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Ka(g,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(t){const e=new $n;for(const i in t)for(let n=t[i].length;n--;){const s=t[i][n][0].clone(),r=t[i][n][1],a=t[i][n][2],o=t[i][n][3],h=t[i][n][4];s.name=i,s.tag=h,r&&s.position.set(r[0],r[1],r[2]),a&&s.rotation.set(a[0],a[1],a[2]),o&&s.scale.set(o[0],o[1],o[2]),s.updateMatrix();const l=s.geometry.clone();l.applyMatrix4(s.matrix),s.geometry=l,s.renderOrder=1/0,s.position.set(0,0,0),s.rotation.set(0,0,0),s.scale.set(1,1,1),e.add(s)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(y)),this.add(this.gizmo.rotate=C(S)),this.add(this.gizmo.scale=C(T)),this.add(this.picker.translate=C(x)),this.add(this.picker.rotate=C(M)),this.add(this.picker.scale=C(E)),this.add(this.helper.translate=C(b)),this.add(this.helper.rotate=C(w)),this.add(this.helper.scale=C(A)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Im;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let s;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),s=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(s*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(Am.copy(Om).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(Am.copy(Nm).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(Am.copy(Um).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(Am.copy(Um).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(Am.copy(Om).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(Am.copy(Nm).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(Rm.copy(e),Am.copy(this.eye).applyQuaternion(pm.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(Lm.lookAt(this.eye,Cm,Nm)),"X"===n.name&&(pm.setFromAxisAngle(Om,Math.atan2(-Am.y,Am.z)),pm.multiplyQuaternions(Rm,pm),n.quaternion.copy(pm)),"Y"===n.name&&(pm.setFromAxisAngle(Nm,Math.atan2(Am.x,Am.z)),pm.multiplyQuaternions(Rm,pm),n.quaternion.copy(pm)),"Z"===n.name&&(pm.setFromAxisAngle(Um,Math.atan2(Am.y,Am.x)),pm.multiplyQuaternions(Rm,pm),n.quaternion.copy(pm)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(t){return n.name===t}))&&(n.material.color.copy(this.materialLib.active.color),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.visible=!!this.axis,"X"===this.axis&&(pm.setFromEuler(Em.set(0,0,0)),n.quaternion.copy(e).multiply(pm),Math.abs(Am.copy(Om).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(pm.setFromEuler(Em.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(pm),Math.abs(Am.copy(Nm).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(pm.setFromEuler(Em.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(pm),Math.abs(Am.copy(Um).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(pm.setFromEuler(Em.set(0,Math.PI/2,0)),Am.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(Lm.lookAt(Cm,Am,Nm)),n.quaternion.multiply(pm),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),dm.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),dm.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(dm),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}class Hm extends Qs{constructor(){super(new Ih(1e5,1e5,2,2),new Ss({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),Fm.copy(Om).applyQuaternion("local"===e?this.worldQuaternion:Im),Bm.copy(Nm).applyQuaternion("local"===e?this.worldQuaternion:Im),km.copy(Um).applyQuaternion("local"===e?this.worldQuaternion:Im),Am.copy(Bm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Am.copy(this.eye).cross(Fm),Pm.copy(Fm).cross(Am);break;case"Y":Am.copy(this.eye).cross(Bm),Pm.copy(Bm).cross(Am);break;case"Z":Am.copy(this.eye).cross(km),Pm.copy(km).cross(Am);break;case"XY":Pm.copy(km);break;case"YZ":Pm.copy(Fm);break;case"XZ":Am.copy(km),Pm.copy(Bm);break;case"XYZ":case"E":Pm.set(0,0,0)}break;default:Pm.set(0,0,0)}0===Pm.length()?this.quaternion.copy(this.cameraQuaternion):(Dm.lookAt(dm.set(0,0,0),Pm,Am),this.quaternion.setFromRotationMatrix(Dm)),super.updateMatrixWorld(t)}}class Vm extends Ka{constructor(t,e=1,i=16776960,n=new Li){const s=new zs;s.setAttribute("position",new Ps([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),s.computeBoundingSphere(),super(s,new Ha({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=n;const r=new zs;r.setAttribute("position",new Ps([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.helper=new Qs(r,new Ss({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1,side:2})),this.add(this.helper)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}updateMatrixWorld(t){this.position.set(0,0,0),this.lookAt(this.plane.normal),this.position.copy(this.offset),this.translateZ(-(this.offset.dot(this.plane.normal)+this.plane.constant)),this.scale.set(.5*this.size,.5*this.size,1),super.updateMatrixWorld(t)}}const Wm={type:"change"},jm={type:"start"},Xm={type:"end"},Ym=-1,qm=0,Zm=1,Km=2,Jm=3,Qm=4,$m=5,tf=6;class ef extends fi{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Li,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.DOLLY,RIGHT:x.PAN},this.touches={ONE:b.ROTATE,TWO:b.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",C),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",C),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(Wm),i.update(),i.state=Ym},this.update=function(){const e=new Li,a=(new Ci).setFromUnitVectors(t.up,new Li(0,1,0)),h=a.clone().invert(),l=new Li,c=new Ci,d=new Li,u=2*Math.PI;return function(){const t=i.object.position;e.copy(t).sub(i.target),e.applyQuaternion(a),s.setFromVector3(e),i.autoRotate&&i.state===Ym&&o(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(s.theta+=r.theta*i.dampingFactor,s.phi+=r.phi*i.dampingFactor):(s.theta+=r.theta,s.phi+=r.phi);let p=i.minAzimuthAngle,m=i.maxAzimuthAngle;return isFinite(p)&&isFinite(m)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),m<-Math.PI?m+=u:m>Math.PI&&(m-=u),s.theta=p<=m?Math.max(p,Math.min(m,s.theta)):s.theta>(p+m)/2?Math.max(p,s.theta):Math.min(m,s.theta)),s.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,s.phi)),s.makeSafe(),s.radius*=i.scale,s.radius=Math.max(i.minDistance,Math.min(i.maxDistance,s.radius)),!0===i.enableDamping?i.target.addScaledVector(i.panOffset,i.dampingFactor):i.target.add(i.panOffset),e.setFromSpherical(s),e.applyQuaternion(h),t.copy(i.target).add(e),i.object.lookAt(i.target),!0===i.enableDamping?(r.theta*=1-i.dampingFactor,r.phi*=1-i.dampingFactor,i.panOffset.multiplyScalar(1-i.dampingFactor)):(r.set(0,0,0),i.panOffset.set(0,0,0)),i.scale=1,!!(i.zoomChanged||l.distanceToSquared(i.object.position)>n||8*(1-c.dot(i.object.quaternion))>n||d.distanceToSquared(i.target)>0)&&(i.dispatchEvent(Wm),l.copy(i.object.position),c.copy(i.object.quaternion),d.copy(i.target),i.zoomChanged=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",L),i.domElement.removeEventListener("pointerdown",M),i.domElement.removeEventListener("pointercancel",E),i.domElement.removeEventListener("wheel",A),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",C),i._domElementKeyEvents=null)};const i=this;i.state=Ym;const n=1e-6,s=new Bc,r=new Bc;function a(){return Math.pow(.95,i.zoomSpeed)}function o(t){r.theta-=t}function h(t){r.phi-=t}i.scale=1,i.panOffset=new Li,i.zoomChanged=!1,i.rotateStart=new Ai,i.rotateEnd=new Ai,i.rotateDelta=new Ai,i.panStart=new Ai,i.panEnd=new Ai,i.panDelta=new Ai,i.dollyStart=new Ai,i.dollyEnd=new Ai,i.dollyDelta=new Ai,i.dollyScale=0,i.pointers=[],i.pointerPositions={};const l=function(){const t=new Li;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),i.panOffset.add(t)}}(),c=function(){const t=new Li;return function(e,n){!0===i.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(i.object.up,t)),t.multiplyScalar(e),i.panOffset.add(t)}}(),d=function(){const t=new Li;return function(e,n){const s=i.domElement;if(i.object.isPerspectiveCamera){const r=i.object.position;t.copy(r).sub(i.target);let a=t.length();a*=Math.tan(i.object.fov/2*Math.PI/180),l(2*e*a/s.clientHeight,i.object.matrix),c(2*n*a/s.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(l(e*(i.object.right-i.object.left)/i.object.zoom/s.clientWidth,i.object.matrix),c(n*(i.object.top-i.object.bottom)/i.object.zoom/s.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function u(t){i.object.isPerspectiveCamera?i.scale/=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function p(t){i.object.isPerspectiveCamera?i.scale*=t:i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/t)),i.object.updateProjectionMatrix(),i.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function m(t){i.rotateStart.set(t.clientX,t.clientY)}function f(t){i.panStart.set(t.clientX,t.clientY)}function g(){if(1===i.pointers.length)i.rotateStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.rotateStart.set(t,e)}}function v(){if(1===i.pointers.length)i.panStart.set(i.pointers[0].pageX,i.pointers[0].pageY);else{const t=.5*(i.pointers[0].pageX+i.pointers[1].pageX),e=.5*(i.pointers[0].pageY+i.pointers[1].pageY);i.panStart.set(t,e)}}function _(){const t=i.pointers[0].pageX-i.pointers[1].pageX,e=i.pointers[0].pageY-i.pointers[1].pageY,n=Math.sqrt(t*t+e*e);i.dollyStart.set(0,n)}function y(t){if(1==i.pointers.length)i.rotateEnd.set(t.pageX,t.pageY);else{const e=I(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);i.rotateEnd.set(n,s)}i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd)}function S(t){if(1===i.pointers.length)i.panEnd.set(t.pageX,t.pageY);else{const e=I(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);i.panEnd.set(n,s)}i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd)}function w(t){const e=I(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);i.dollyEnd.set(0,r),i.dollyDelta.set(0,Math.pow(i.dollyEnd.y/i.dollyStart.y,i.zoomSpeed)),u(i.dollyDelta.y),i.dollyStart.copy(i.dollyEnd)}function M(t){!1!==i.enabled&&(0===i.pointers.length&&(i.domElement.setPointerCapture(t.pointerId),i.domElement.addEventListener("pointermove",T),i.domElement.addEventListener("pointerup",E)),function(t){i.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(R(t),i.pointers.length){case 1:switch(i.touches.ONE){case b.ROTATE:if(!1===i.enableRotate)return;g(),i.state=Jm;break;case b.PAN:if(!1===i.enablePan)return;v(),i.state=Qm;break;default:i.state=Ym}break;case 2:switch(i.touches.TWO){case b.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&_(),i.enablePan&&v(),i.state=$m;break;case b.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&_(),i.enableRotate&&g(),i.state=tf;break;default:i.state=Ym}break;default:i.state=Ym}i.state!==Ym&&i.dispatchEvent(jm)}(t):function(t){let e;switch(t.button){case 0:e=i.mouseButtons.LEFT;break;case 1:e=i.mouseButtons.MIDDLE;break;case 2:e=i.mouseButtons.RIGHT;break;default:e=-1}switch(e){case x.DOLLY:if(!1===i.enableZoom)return;!function(t){i.dollyStart.set(t.clientX,t.clientY)}(t),i.state=Zm;break;case x.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enablePan)return;f(t),i.state=Km}else{if(!1===i.enableRotate)return;m(t),i.state=qm}break;case x.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===i.enableRotate)return;m(t),i.state=qm}else{if(!1===i.enablePan)return;f(t),i.state=Km}break;default:i.state=Ym}i.state!==Ym&&i.dispatchEvent(jm)}(t))}function T(t){!1!==i.enabled&&("touch"===t.pointerType?function(t){switch(R(t),i.state){case Jm:if(!1===i.enableRotate)return;y(t),i.update();break;case Qm:if(!1===i.enablePan)return;S(t),i.update();break;case $m:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(t){i.enableZoom&&w(t),i.enablePan&&S(t)}(t),i.update();break;case tf:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(t){i.enableZoom&&w(t),i.enableRotate&&y(t)}(t),i.update();break;default:i.state=Ym}}(t):function(t){switch(i.state){case qm:if(!1===i.enableRotate)return;!function(t){i.rotateEnd.set(t.clientX,t.clientY),i.rotateDelta.subVectors(i.rotateEnd,i.rotateStart).multiplyScalar(i.rotateSpeed);const e=i.domElement;o(2*Math.PI*i.rotateDelta.x/e.clientHeight),h(2*Math.PI*i.rotateDelta.y/e.clientHeight),i.rotateStart.copy(i.rotateEnd),i.update()}(t);break;case Zm:if(!1===i.enableZoom)return;!function(t){i.dollyEnd.set(t.clientX,t.clientY),i.dollyDelta.subVectors(i.dollyEnd,i.dollyStart),i.dollyDelta.y<0?(i.dollyScale=1/a(),u(a())):i.dollyDelta.y>0&&(i.dollyScale=a(),p(a())),i.dollyStart.copy(i.dollyEnd),i.update()}(t);break;case Km:if(!1===i.enablePan)return;!function(t){i.panEnd.set(t.clientX,t.clientY),i.panDelta.subVectors(i.panEnd,i.panStart).multiplyScalar(i.panSpeed),d(i.panDelta.x,i.panDelta.y),i.panStart.copy(i.panEnd),i.update()}(t)}}(t))}function E(t){!function(t){delete i.pointerPositions[t.pointerId];for(let e=0;e<i.pointers.length;e++)if(i.pointers[e].pointerId==t.pointerId)return void i.pointers.splice(e,1)}(t),0===i.pointers.length&&(i.domElement.releasePointerCapture(t.pointerId),i.domElement.removeEventListener("pointermove",T),i.domElement.removeEventListener("pointerup",E)),i.dispatchEvent(Xm),i.state=Ym}function A(t){!1!==i.enabled&&!1!==i.enableZoom&&i.state===Ym&&(t.preventDefault(),i.dispatchEvent(jm),function(t){i.dollyEnd.set(i.domElement.clientWidth/2,i.domElement.clientHeight/2),i.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(i.dollyScale=1/a(),p(a())):t.deltaY>0&&(i.dollyScale=a(),u(a())),i.dollyStart.copy(i.dollyEnd),i.update(),0!==t.deltaY&&(i.state=Zm,i.dispatchEvent(Wm),i.state=Ym)}(t),i.dispatchEvent(Xm))}function C(t){!1!==i.enabled&&!1!==i.enablePan&&function(t){let e=!1;switch(t.code){case i.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?h(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,i.keyPanSpeed),e=!0;break;case i.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?h(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(0,-i.keyPanSpeed),e=!0;break;case i.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(i.keyPanSpeed,0),e=!0;break;case i.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):d(-i.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),i.update())}(t)}function L(t){!1!==i.enabled&&t.preventDefault()}function R(t){let e=i.pointerPositions[t.pointerId];void 0===e&&(e=new Ai,i.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function I(t){const e=t.pointerId===i.pointers[0].pointerId?i.pointers[1]:i.pointers[0];return i.pointerPositions[e.pointerId]}i.domElement.addEventListener("contextmenu",L),i.domElement.addEventListener("pointerdown",M),i.domElement.addEventListener("pointercancel",E),i.domElement.addEventListener("wheel",A,{passive:!1}),this.update()}}class nf{constructor(t){this.updateControls=()=>{this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.updateControlsCamera=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.object=this.viewer.camera,this.orbit.update()},this.optionsChange=({data:t})=>{this.orbit.zoomSpeed=Math.abs(this.orbit.zoomSpeed)*(t.reverseZoomWheel?-1:1)},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case qm:case Jm:this.viewer.emitEvent({type:"orbit"});break;case Km:case Qm:this.viewer.emitEvent({type:"pan",x:this.orbit.panEnd.x,y:this.orbit.panEnd.y,dX:this.orbit.panDelta.x,dY:this.orbit.panDelta.y});break;case Zm:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.viewer.emitEvent({type:"changecamera"}),this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new ef(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:x.ROTATE,MIDDLE:x.PAN,RIGHT:x.PAN},this.orbit.touches={ONE:b.ROTATE,TWO:b.DOLLY_PAN},this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.33,this.orbit.addEventListener("start",this.controlsStart),this.orbit.addEventListener("change",this.controlsChange),this.changed=!1,this.viewer=t,this.viewer.addEventListener("databasechunk",this.updateControls),this.viewer.addEventListener("clear",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.addEventListener("zoom",this.updateControls),this.viewer.addEventListener("drawviewpoint",this.updateControls),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("contextmenu",this.stopContextMenu),this.updateControls(),this.updateControlsCamera()}dispose(){this.viewer.removeEventListener("databasechunk",this.updateControls),this.viewer.removeEventListener("clear",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.removeEventListener("zoom",this.updateControls),this.viewer.removeEventListener("drawviewpoint",this.updateControls),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("start",this.controlsStart),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class sf extends nf{constructor(t,e,i){super(t),this.transformChange=()=>{this.plane.constant=-this.planeCenter.position.dot(this.plane.normal),this.viewer.update()},this.transformDrag=t=>{this.orbit.enabled=!t.value},this.updatePlaneSize=()=>{this.planeHelper.size=this.viewer.extents.getSize(new Li).length()||1,this.viewer.update()},this.updateTransformCamera=()=>{this.transform.camera=this.viewer.camera},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const n=t.extents.getSize(new Li).length()||1,s=t.extents.getCenter(new Li),r=-s.dot(e);this.plane=new ga(e,r),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new Vm(this.plane,n,i,s),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new $n,this.planeCenter.position.copy(s),this.viewer.helpers.add(this.planeCenter),this.transform=new ym(t.camera,t.canvas),this.transform.showX=!!e.x,this.transform.showY=!!e.y,this.transform.showZ=!!e.z,this.transform.attach(this.planeCenter),this.transform.addEventListener("change",this.transformChange),this.transform.addEventListener("dragging-changed",this.transformDrag),this.viewer.helpers.add(this.transform.getHelper()),this.viewer.addEventListener("explode",this.updatePlaneSize),this.viewer.addEventListener("show",this.updatePlaneSize),this.viewer.addEventListener("showall",this.updatePlaneSize),this.viewer.addEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.removeEventListener("explode",this.updatePlaneSize),this.viewer.removeEventListener("show",this.updatePlaneSize),this.viewer.removeEventListener("showall",this.updatePlaneSize),this.viewer.removeEventListener("changecameramode",this.updateTransformCamera),this.viewer.canvas.removeEventListener("dblclick",this.onDoubleClick,!0),this.transform.removeEventListener("change",this.transformChange),this.transform.removeEventListener("dragging-changed",this.transformDrag),this.transform.getHelper().removeFromParent(),this.transform.detach(),this.transform.dispose(),this.planeHelper.removeFromParent(),this.planeHelper.dispose(),this.planeCenter.removeFromParent(),super.dispose()}}class rf extends sf{constructor(t){super(t,new Li(1,0,0),16711680)}}class af extends sf{constructor(t){super(t,new Li(0,1,0),65280)}}class of extends sf{constructor(t){super(t,new Li(0,0,1),255)}}const hf={Meters:{name:"Meters",symbol:"m",scale:1},Centimeters:{name:"Centimeters",symbol:"cm",scale:.01},Millimeters:{name:"Millimeters",symbol:"mm",scale:.001},Feet:{name:"Feet",symbol:"ft",scale:.3048},Inches:{name:"Inches",symbol:"in",scale:.0254},Yards:{name:"Yards",symbol:"yd",scale:.9144},Kilometers:{name:"Kilometers",symbol:"km",scale:1e3},Miles:{name:"Miles",symbol:"mi",scale:1609.344},Micrometers:{name:"Micrometers",symbol:"µm",scale:1e-6},Mils:{name:"Mils",symbol:"mil",scale:254e-7},MicroInches:{name:"Micro-inches",symbol:"µin",scale:2.54e-8},Default:{name:"File units",symbol:"",scale:1}},lf={Default:{name:"",symbol:"",scale:1}};function cf(t,e,i){return i*(1/(lf[t]||lf.Default).scale)*((lf[e]||lf.Default).scale||1)}function df(t,e,i){let n=t.toFixed(e);return"Auto"===i&&(n=n.replace(/\.0+$/,"").replace(/\.$/,"")),+n!==t&&(n="~ "+n),n}function uf(t,e,i=2){let n;return n="Auto"===i?function(t){const e=Math.abs(t);return e>=1e3?0:e>=10?1:e>=.1?2:e>=.001?3:e>0?Math.floor(-Math.log10(e))+1:2}(t):Number.isFinite(i)?i:parseFloat(i),Number.isFinite(n)?n<0?n=0:n>10&&(n=10):n=2,lf[e]?df(t,n,i)+" "+lf[e].symbol:e?df(t,n,i)+" "+e:df(t,n,i)}Object.keys(hf).forEach(t=>lf[t]=hf[t]),Object.keys(hf).forEach(t=>lf[hf[t].symbol]=hf[t]);const pf=new Li,mf=new Li,ff=new Li,gf=new qc,vf=new Li,_f=new Li;class yf{constructor(t,e,i){this.camera=t,this.renderer=e,this.canvas=i,this.threshold=1e-4,this.raycaster=new Oc,this.detectRadiusInPixels=this.isMobile()?50:10,this.edgesCache=new WeakMap}isMobile(){return"undefined"!=typeof navigator&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t,e){const i=this.canvas.getBoundingClientRect(),n=(t.x-i.left)/i.width*2-1,s=-(t.y-i.top)/i.height*2+1,r=new Ai(n,s);this.raycaster.setFromCamera(r,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:this.threshold},Line2:{threshold:this.threshold},LOD:{},Points:{threshold:this.threshold},Sprite:{}};let a=this.raycaster.intersectObjects(e,!1);return(this.renderer.clippingPlanes||[]).forEach(t=>{a=a.filter(e=>t.distanceToPoint(e.point)>=0)}),a}getDetectRadius(t){const e=this.camera;if(e.isOrthographicCamera){const t=(e.top-e.bottom)/e.zoom/this.canvas.height;return this.detectRadiusInPixels*t}if(e.isPerspectiveCamera){const i=e.position.distanceTo(t),n=2*Math.tan(Ei.degToRad(.5*e.fov))*i/this.canvas.height;return this.detectRadiusInPixels*n}return.1}getSnapPoint(t,e){const i=this.getPointerIntersects(t,e);if(0===i.length)return;const n=i[0].object,s=i[0].point,r=n.worldToLocal(s.clone());let a,o=this.getDetectRadius(s);const h=n.geometry,l=h.attributes.position.array;for(let t=0;t<l.length;t+=3){pf.set(l[t],l[t+1],l[t+2]);const e=pf.distanceTo(r);e<o&&(o=e,a=pf.clone())}if(a)return n.localToWorld(a);let c=this.edgesCache.get(h);c||(c=new Eo(h),this.edgesCache.set(h,c));const d=c.attributes.position.array;for(let t=0;t<d.length;t+=6){mf.set(d[t],d[t+1],d[t+2]),ff.set(d[t+3],d[t+4],d[t+5]),gf.set(mf,ff),gf.getCenter(vf);const e=vf.distanceTo(r);if(e<o){o=e,a=vf.clone();continue}gf.closestPointToPoint(r,!0,_f);const i=_f.distanceTo(r);i<o&&(o=i,a=_f.clone())}return a?n.localToWorld(a):s.clone()}}const xf=new Ai;class bf extends nf{constructor(t){super(t),this.scale=1,this.units="",this.precision=2,this.onPointerDown=t=>{if(0!==t.button)return;const e=this.snapper.getMousePosition(t,xf);this.line.startPoint=this.snapper.getSnapPoint(e,this.objects),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint},this.onPointerMove=t=>{if(this.orbit.enabled&&-1!==this.orbit.state)return;const e=this.snapper.getMousePosition(t,xf),i=this.snapper.getSnapPoint(e,this.objects);i&&this.line.endPoint&&i.equals(this.line.endPoint)||(this.line.endPoint=i,this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>0?(this.line=new Mf(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)):(this.line.startPoint=void 0,this.line.endPoint=void 0,this.line.render()),this.viewer.canvas.releasePointerCapture(t.pointerId),this.orbit.enabled=!0},this.onPointerCancel=t=>{this.viewer.canvas.dispatchEvent(new PointerEvent("pointerup",t))},this.onPointerLeave=()=>{this.line.endPoint=void 0,this.line.render()},this.clearOverlay=()=>{this.overlay.clear(),this.line=new Mf(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line)},this.renderOverlay=()=>{this.overlay.render()},this.updateObjects=()=>{this.objects.length=0,this.viewer.models.forEach(t=>{t.getVisibleObjects().forEach(t=>this.objects.push(t))})},this.updateSnapperCamera=()=>{this.snapper.camera=this.viewer.camera,this.overlay.camera=this.viewer.camera},this.updateUnits=()=>{var t,e;const i=this.viewer.models[0],n=null!==(t=this.viewer.options.rulerUnit)&&void 0!==t?t:"Default",s=null!==(e=this.viewer.options.rulerPrecision)&&void 0!==e?e:"Default";i?"Default"===n?(this.scale=i.getUnitScale(),this.units=i.getUnitString()):(this.scale=cf(i.getUnits(),n,1),this.units=n):(this.scale=1,this.units=""),this.precision=i?"Default"===s?i.getPrecision():s:2,this.overlay.updateLineUnits(this.scale,this.units,this.precision)},this.overlay=new Sf(t.camera,t.canvas),this.overlay.attach(),this.line=new Mf(this.overlay,this.scale,this.units,this.precision),this.overlay.addLine(this.line);const e=this.viewer.extents.getSize(new Li).length()||1;this.snapper=new yf(t.camera,t.renderer,t.canvas),this.snapper.threshold=e/1e4,this.objects=[],this.updateObjects(),this.updateUnits(),this.viewer.canvas.addEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.addEventListener("pointermove",this.onPointerMove),this.viewer.canvas.addEventListener("pointerup",this.onPointerUp),this.viewer.canvas.addEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.addEventListener("pointerleave",this.onPointerLeave),this.viewer.addEventListener("render",this.renderOverlay),this.viewer.addEventListener("hide",this.updateObjects),this.viewer.addEventListener("isolate",this.updateObjects),this.viewer.addEventListener("show",this.updateObjects),this.viewer.addEventListener("showall",this.updateObjects),this.viewer.addEventListener("changecameramode",this.updateSnapperCamera),this.viewer.addEventListener("optionschange",this.updateUnits)}dispose(){this.viewer.canvas.removeEventListener("pointerdown",this.onPointerDown),this.viewer.canvas.removeEventListener("pointermove",this.onPointerMove),this.viewer.canvas.removeEventListener("pointerup",this.onPointerUp),this.viewer.canvas.removeEventListener("pointercancel",this.onPointerCancel),this.viewer.canvas.removeEventListener("pointerleave",this.onPointerLeave),this.viewer.removeEventListener("render",this.renderOverlay),this.viewer.removeEventListener("hide",this.updateObjects),this.viewer.removeEventListener("isolate",this.updateObjects),this.viewer.removeEventListener("show",this.updateObjects),this.viewer.removeEventListener("showall",this.updateObjects),this.viewer.removeEventListener("changecameramode",this.updateSnapperCamera),this.viewer.removeEventListener("optionschange",this.updateUnits),this.objects.length=0,this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class Sf{constructor(t,e){this.lines=[],this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this.canvas;i&&n&&(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.width=`${i}px`,this.container.style.height=`${n}px`)},this.camera=t,this.canvas=e,this.projector=new Nf(t,e),this.resizeObserver=new ResizeObserver(this.resizeContainer)}dispose(){this.clear()}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.position="absolute",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement&&(this.canvas.parentElement.appendChild(this.container),this.resizeObserver.observe(this.canvas))}detach(){this.resizeObserver.disconnect(),this.container.remove(),this.container=void 0}clear(){this.lines.forEach(t=>t.dispose()),this.lines.length=0}render(){this.projector.setFromCamera(this.camera),this.lines.forEach(t=>t.render())}update(){this.lines.forEach(t=>t.update())}addLine(t){this.lines.push(t)}removeLine(t){this.lines=this.lines.filter(e=>e!==t)}updateLineUnits(t,e,i){this.lines.forEach(n=>{n.scale=t,n.units=e,n.precision=i})}}const wf=new Li;class Mf{constructor(t,e,i,n){this.id=Ei.generateUUID(),this.size=10,this.lineWidth=2,this.style={border:"2px solid #FFFFFF",background:"#009bff",boxShadow:"0 0 10px rgba(0,0,0,0.5)",color:"white",font:"1rem system-ui"},this.overlay=t,this.scale=e,this.units=i,this.precision=n,this.elementStartPoint=t.container.appendChild(document.createElement("div")),this.elementEndPoint=t.container.appendChild(document.createElement("div")),this.elementLine=t.container.appendChild(document.createElement("div")),this.elementLabel=t.container.appendChild(document.createElement("div")),this.update()}dispose(){this.elementStartPoint.remove(),this.elementEndPoint.remove(),this.elementLine.remove(),this.elementLabel.remove(),this.elementStartPoint=void 0,this.elementEndPoint=void 0,this.elementLine=void 0,this.elementLabel=void 0}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:i}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=i?"block":"none",this.elementStartPoint.style.left=`${e.x}px`,this.elementStartPoint.style.top=`${e.y}px`}else this.elementStartPoint.style.display="none";if(this.endPoint){const{point:e,visible:i}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=i?"block":"none",this.elementEndPoint.style.left=`${e.x}px`,this.elementEndPoint.style.top=`${e.y}px`}else this.elementEndPoint.style.display="none";if(this.startPoint&&this.endPoint){const{point1:e,point2:i,visible:n}=t.projectLine(this.startPoint,this.endPoint);i.sub(e);const s=i.angle(),r=i.length();this.elementLine.style.display=n?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${r}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${s}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){wf.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:i}=t.projectPoint(wf),n=this.getDistance();this.elementLabel.style.display=i&&n>0?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=uf(n,this.units,this.precision)}else this.elementLabel.style.display="none"}update(){this.elementStartPoint.id=`markup-dot-start-${this.id}`,this.elementStartPoint.style.position="absolute",this.elementStartPoint.style.zIndex="2",this.elementStartPoint.style.width=`${this.size}px`,this.elementStartPoint.style.height=`${this.size}px`,this.elementStartPoint.style.border=this.style.border,this.elementStartPoint.style.borderRadius=`${this.size}px`,this.elementStartPoint.style.background=this.style.background,this.elementStartPoint.style.boxShadow=this.style.boxShadow,this.elementStartPoint.style.transform="translate(-50%, -50%)",this.elementEndPoint.id=`markup-dot-end-${this.id}`,this.elementEndPoint.style.position="absolute",this.elementEndPoint.style.zIndex="2",this.elementEndPoint.style.width=`${this.size}px`,this.elementEndPoint.style.height=`${this.size}px`,this.elementEndPoint.style.border=this.style.border,this.elementEndPoint.style.borderRadius=`${this.size}px`,this.elementEndPoint.style.background=this.style.background,this.elementEndPoint.style.boxShadow=this.style.boxShadow,this.elementEndPoint.style.transform="translate(-50%, -50%)",this.elementLine.id=`markup-line-${this.id}`,this.elementLine.style.position="absolute",this.elementLine.style.zIndex="1",this.elementLine.style.height=`${this.lineWidth}px`,this.elementLine.style.background=this.style.background,this.elementLine.style.boxShadow=this.style.boxShadow,this.elementLine.style.transformOrigin=`0px ${this.lineWidth/2}px`,this.elementLabel.id=`markup-label-${this.id}`,this.elementLabel.style.position="absolute",this.elementLabel.style.zIndex="3",this.elementLabel.style.padding="2px",this.elementLabel.style.paddingInline="5px",this.elementLabel.style.borderRadius="5px",this.elementLabel.style.background=this.style.background,this.elementLabel.style.boxShadow=this.style.boxShadow,this.elementLabel.style.color=this.style.color,this.elementLabel.style.font=this.style.font,this.elementLabel.style.transform="translate(-50%, -50%)"}getDistance(){return this.startPoint.distanceTo(this.endPoint)/this.scale}}let Tf,Ef;const Af=new En,Cf=new En,Lf=new Li,Rf=new Yi,If=new Yi,Pf=new Ai,Df=new Ai,Of=new Ai;class Nf{constructor(t,e){this.camera=t,this.canvas=e}setFromCamera(t){this.camera=t,this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();Tf=t.width/2,Ef=t.height/2,Af.copy(this.camera.matrixWorldInverse),Cf.multiplyMatrices(this.camera.projectionMatrix,Af)}projectPoint(t){Lf.copy(t).applyMatrix4(Cf);const e=Lf.z>=-1&&Lf.z<=1;return Pf.x=(Lf.x+1)*Tf,Pf.y=(1-Lf.y)*Ef,{point:Pf,visible:e}}projectLine(t,e){let i;Rf.copy(t).applyMatrix4(Cf),If.copy(e).applyMatrix4(Cf);const n=Rf.z+Rf.w,s=If.z+If.w,r=-Rf.z+Rf.w,a=-If.z+If.w;if(n>=0&&s>=0&&r>=0&&a>=0)i=!0;else if(n<0&&s<0||r<0&&a<0)i=!1;else{let t=0,e=1;n<0?t=Math.max(t,n/(n-s)):s<0&&(e=Math.min(e,n/(n-s))),r<0?t=Math.max(t,r/(r-a)):a<0&&(e=Math.min(e,r/(r-a))),i=e>=t,i&&(Rf.lerp(If,t),If.lerp(Rf,1-e))}return Rf.multiplyScalar(1/Rf.w),If.multiplyScalar(1/If.w),Df.x=(Rf.x+1)*Tf,Df.y=(1-Rf.y)*Ef,Of.x=(If.x+1)*Tf,Of.y=(1-If.y)*Ef,{point1:Df,point2:Of,visible:i}}}class Uf extends nf{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.PAN,MIDDLE:x.PAN,RIGHT:x.PAN}}}class Ff extends pd{constructor(t,e,i){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SKIP_FRAMES=3,this.GROUND_FOLLOWING_SPEED=.4,this.LOOK_SPEED=.1,this.WALK_SPEED_DELIMITER=4,this.WHEEL_SPEED_DELIMITER=15e3,this.movementSpeed=.1,this.multiplier=3,this.groundFollowingSkippedFrames=0,this.moveWheel=0,this.mouseDragOn=!1,this._up=new Li,this._forward=new Li,this._sideways=new Li,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new Ai(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"walkspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.camera=t,this.groundObjects=i,this.raycaster=new Oc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}},this.moveKeys=new Set,this.moveClock=new rc,this.quaternion=t.quaternion.clone(),this.downPosition=new Ai(0,0),this.rotateDelta=new Ai(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}updateGroundFollowing(){this._up.copy(this.camera.up).negate(),this.raycaster.set(this.object.position,this._up);const t=this.raycaster.intersectObjects(this.groundObjects,!1);if(t.length>0){const e=t[0].point.y+this.EYE_HEIGHT;this.object.position.y=Ei.lerp(this.object.position.y,e,this.GROUND_FOLLOWING_SPEED)}}update(){let t=!1,e=!1;const i=this._forward,n=this._sideways;if(this.moveKeys.size>0){e=!0;const s=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),n.setFromMatrixColumn(this.object.matrix,0),n.y=0,n.normalize(),this.moveKeys.has("KeyW")&&this.object.position.addScaledVector(i,s),this.moveKeys.has("KeyS")&&this.object.position.addScaledVector(i,-s),this.moveKeys.has("KeyA")&&this.object.position.addScaledVector(n,-s),this.moveKeys.has("KeyD")&&this.object.position.addScaledVector(n,s),this.moveKeys.has("KeyQ")&&(this.object.translateY(s),e=!1),this.moveKeys.has("KeyE")&&(this.object.translateY(-s),e=!1);const r=this.LOOK_SPEED+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,-r/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,r/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new Ai(r,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new Ai(-r,0))),this.moveWheel=0,t=!0}if(0!==this.moveWheel){const e=this.moveWheel*this.multiplier*this.movementSpeed/this.WHEEL_SPEED_DELIMITER;this.object.getWorldDirection(i),i.y=0,i.normalize(),this.object.position.addScaledVector(i,-e),this.moveWheel+=-1*Math.sign(this.moveWheel),t=!0}this.groundFollowingSkippedFrames++,e&&this.groundFollowingSkippedFrames>=this.GROUND_FOLLOWING_SKIP_FRAMES&&(this.groundFollowingSkippedFrames=0,this.updateGroundFollowing()),t&&this.dispatchEvent({type:"change"}),0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new Ci;n.setFromAxisAngle(this.object.up,e);const s=new Ci;s.setFromAxisAngle(new Li(1,0,0),i);const r=this.quaternion.clone();r.premultiply(n).multiply(s).normalize(),this.object.setRotationFromQuaternion(r)}}class Bf extends pd{constructor(t,e,i,n){super(t,e),this.EYE_HEIGHT=1.7,this.FAILING_DISTANCE=2,this.GROUND_FOLLOWING_SPEED=.05,this.WALK_SPEED_DELIMITER=4,this.movementSpeed=.1,this.multiplier=3,this.isActive=!1,this.MAX_JOYSTICK_DISTANCE=100,this.INTERNAL_RADIUS=35,this.MAX_MOVE_STICK=40,this.EXTERNAL_RADIUS=65,this.CANVAS_SIZE=200,this.pressed=!1,this.onPointerDown=t=>{t.preventDefault(),this.pressed=!0},this.onPointerMove=t=>{if(t.preventDefault(),!this.pressed)return;let e=t.pageX,i=t.pageY;this.joyStickCanvas.offsetParent&&"BODY"===this.joyStickCanvas.offsetParent.tagName.toUpperCase()?(e-=this.joyStickCanvas.offsetLeft,i-=this.joyStickCanvas.offsetTop):this.joyStickCanvas.offsetParent&&(e-=this.joyStickCanvas.offsetParent.offsetLeft,i-=this.joyStickCanvas.offsetParent.offsetTop);const n=(e-this.centerX)/this.MAX_MOVE_STICK*100,s=(i-this.centerY)/this.MAX_MOVE_STICK*100*-1;Math.sqrt(n*n+s*s)>20?(this.joyStickPosition.set(n,s),this.isActive=!0):(this.joyStickPosition.set(0,0),this.isActive=!1),this.draw(),this.moveClock.start(),this.update()},this.onPointerUp=t=>{t.preventDefault(),this.pressed=!1,this.joyStickPosition.set(0,0),this.isActive=!1,this.moveClock.stop(),this.draw()},this.onResize=()=>{this.updateVisibility(),this.updatePosition()},this.camera=t,this.canvas=i,this.moveClock=new rc(!1),this.joyStickPosition=new Ai(0,0),this.groundObjects=n,this.raycaster=new Oc,this.raycaster.near=0,this.raycaster.far=this.EYE_HEIGHT+this.FAILING_DISTANCE,this.centerX=this.CANVAS_SIZE/2,this.centerY=this.CANVAS_SIZE/2,this.overlayElement=document.createElement("div"),this.overlayElement.id="joyStickDiv",this.overlayElement.style.background="rgba(0,0,0,0)",this.overlayElement.style.position="fixed",this.overlayElement.style.zIndex="0",this.overlayElement.style.touchAction="none",i.parentElement.appendChild(this.overlayElement),this.joyStickCanvas=document.createElement("canvas"),this.joyStickCanvas.id="joyStickCanvas",this.joyStickCanvas.width=this.CANVAS_SIZE,this.joyStickCanvas.height=this.CANVAS_SIZE,this.overlayElement.appendChild(this.joyStickCanvas),this.context=this.joyStickCanvas.getContext("2d"),this.joyStickCanvas.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),window.addEventListener("resize",this.onResize),document.addEventListener("fullscreenchange",this.onResize),this.updateVisibility(),this.updatePosition(),this.draw()}dispose(){this.joyStickCanvas.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("resize",this.onResize),document.removeEventListener("fullscreenchange",this.onResize),this.overlayElement.remove(),super.dispose()}updateVisibility(){const t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),e=window.innerWidth<1024;this.overlayElement.style.display=t||e?"block":"none"}updatePosition(){const t=this.canvas.getBoundingClientRect();this.overlayElement.style.top=t.height-this.CANVAS_SIZE+"px",this.overlayElement.style.left=`${t.left}px`,this.overlayElement.style.width=`${this.CANVAS_SIZE}px`,this.overlayElement.style.height=`${this.CANVAS_SIZE}px`}draw(){this.context.clearRect(0,0,this.CANVAS_SIZE,this.CANVAS_SIZE),this.context.beginPath(),this.context.arc(this.centerX,this.centerY,this.EXTERNAL_RADIUS,0,2*Math.PI,!1),this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.stroke();let t=this.centerX+this.joyStickPosition.x*this.MAX_MOVE_STICK/100,e=this.centerY-this.joyStickPosition.y*this.MAX_MOVE_STICK/100;t=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,t)),e=Math.max(this.MAX_MOVE_STICK,Math.min(this.CANVAS_SIZE-this.MAX_MOVE_STICK,e)),this.context.beginPath(),this.context.arc(t,e,this.INTERNAL_RADIUS,0,2*Math.PI,!1),this.context.fillStyle="#35436E",this.context.lineWidth=2,this.context.strokeStyle="#35436E",this.context.globalAlpha=.5,this.context.fill(),this.context.stroke()}updateGroundFollowing(){const t=(new Li).copy(this.camera.up);this.raycaster.set(this.camera.position,t.negate()),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:0},Line2:{threshold:0},LOD:{threshold:0},Points:{threshold:0},Sprite:{threshold:0}};const e=this.raycaster.intersectObjects(this.groundObjects,!1);if(e.length>0){const t=e[0].point.y+this.EYE_HEIGHT;this.camera.position.y=Ei.lerp(this.camera.position.y,t,this.GROUND_FOLLOWING_SPEED)}}update(){if(!this.isActive)return;const t=this.joyStickPosition.y/this.MAX_JOYSTICK_DISTANCE,e=this.joyStickPosition.x/this.MAX_JOYSTICK_DISTANCE,i=this.moveClock.getDelta()*this.multiplier*this.movementSpeed/this.WALK_SPEED_DELIMITER,n=new Li,s=new Li;this.camera.getWorldDirection(n),this.groundObjects.length>0&&(n.y=0),n.normalize(),s.setFromMatrixColumn(this.camera.matrix,0),this.groundObjects.length>0&&(s.y=0),s.normalize(),0!==t&&this.camera.position.addScaledVector(n,i*t),0!==e&&this.camera.position.addScaledVector(s,i*e),0===t&&0===e||(this.groundObjects.length>0&&this.updateGroundFollowing(),this.dispatchEvent({type:"change"}))}}class kf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Li);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2||1,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.walkspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.animate=()=>{this.controls.update()};const e=[];t.models.forEach(t=>t.getVisibleObjects().forEach(t=>{t instanceof Qs&&e.push(t)})),this.controls=new Ff(t.camera,t.canvas,e),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.joyStickControls=new Bf(t.camera,t.canvas,t.canvas,e),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("animate",this.animate),this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("animate",this.animate),this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class zf extends pd{constructor(t,e){super(t,e),this.movementSpeed=.2,this.lookSpeed=5,this.multiplier=5,this.moveWheel=0,this.mouseDragOn=!1,this.onPointerDown=t=>{0===t.button&&(this.domElement.setPointerCapture(t.pointerId),this.downPosition.set(t.clientX,t.clientY),this.quaternion.copy(this.object.quaternion),this.mouseDragOn=!0)},this.onPointerMove=t=>{if(!this.mouseDragOn)return;const e=new Ai(t.clientX,t.clientY);0!==this.downPosition.distanceTo(e)&&(this.rotateDelta.copy(this.downPosition).sub(e),this.rotateCamera(this.rotateDelta),this.dispatchEvent({type:"change"}))},this.onPointerUp=t=>{this.domElement.releasePointerCapture(t.pointerId),this.mouseDragOn=!1},this.onPointerCancel=t=>{this.domElement.dispatchEvent(new PointerEvent("pointerup",t))},this.onWheel=t=>{this.moveWheel=t.deltaY,this.update()},this.onKeyDown=t=>{switch(t.code){case"NumpadSubtract":case"Minus":this.multiplier>1&&(this.multiplier=this.multiplier-1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"NumpadAdd":case"Equal":this.multiplier<10&&(this.multiplier=this.multiplier+1,this.dispatchEvent({type:"flyspeedchange",data:this.multiplier}));break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"KeyW":case"KeyS":case"KeyA":case"KeyD":case"KeyQ":case"KeyE":this.moveKeys.add(t.code),this.update()}},this.onKeyUp=t=>{this.moveKeys.delete(t.code)&&this.update()},this.moveKeys=new Set,this.moveClock=new rc,this.quaternion=t.quaternion.clone(),this.downPosition=new Ai(0,0),this.rotateDelta=new Ai(0,0),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onWheel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),super.dispose()}update(){if(this.moveKeys.size>0){const t=this.moveClock.getDelta()*this.movementSpeed*this.multiplier;this.moveKeys.has("KeyW")&&this.object.translateZ(-t),this.moveKeys.has("KeyS")&&this.object.translateZ(t),this.moveKeys.has("KeyA")&&this.object.translateX(-t),this.moveKeys.has("KeyD")&&this.object.translateX(t),this.moveKeys.has("KeyQ")&&this.object.translateY(t),this.moveKeys.has("KeyE")&&this.object.translateY(-t);const e=this.lookSpeed+(this.multiplier-1);this.moveKeys.has("ArrowUp")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new Ai(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new Ai(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new Ai(-e,0))),this.moveWheel=0,this.dispatchEvent({type:"change"})}if(0!==this.moveWheel){const t=1e-4*this.moveWheel*this.movementSpeed*this.multiplier;this.object.translateZ(-t),this.moveWheel+=-1*Math.sign(this.moveWheel),this.dispatchEvent({type:"change"})}0===this.moveKeys.size&&0===this.moveWheel&&(this.moveClock.stop(),this.moveClock.autoStart=!0)}rotateCamera(t){const e=Math.PI*t.x/this.domElement.clientWidth,i=Math.PI*t.y/this.domElement.clientHeight,n=new Ci;n.setFromAxisAngle(this.object.up,e);const s=new Ci;s.setFromAxisAngle(new Li(1,0,0),i);const r=this.quaternion.clone();r.premultiply(n).multiply(s).normalize(),this.object.setRotationFromQuaternion(r)}}class Gf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Li);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2||1,this.joyStickControls.movementSpeed=this.controls.movementSpeed,this.joyStickControls.multiplier=this.controls.multiplier},this.updateControlsCamera=()=>{this.controls.object=this.viewer.camera},this.controlsChange=()=>{this.viewer.update(),this.viewer.emitEvent({type:"changecamera"})},this.flyspeedChange=t=>{this.viewer.emitEvent(t),this.joyStickControls.multiplier=this.controls.multiplier},this.viewerRender=()=>{this.joyStickControls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.animate=()=>{this.controls.update()},this.controls=new zf(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("flyspeedchange",this.flyspeedChange),this.joyStickControls=new Bf(t.camera,t.canvas,t.canvas,[]),this.joyStickControls.addEventListener("change",this.controlsChange),this.viewer=t,this.viewer.addEventListener("animate",this.animate),this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("zoom",this.viewerZoom),this.viewer.addEventListener("changecameramode",this.updateControlsCamera),this.updateControls()}dispose(){this.viewer.removeEventListener("animate",this.animate),this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("zoom",this.viewerZoom),this.viewer.removeEventListener("changecameramode",this.updateControlsCamera),this.controls.removeEventListener("flyspeedchange",this.flyspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose(),this.joyStickControls.removeEventListener("change",this.controlsChange),this.joyStickControls.dispose()}}class Hf extends nf{constructor(t){super(t),this.orbit.mouseButtons={LEFT:x.DOLLY,MIDDLE:x.PAN,RIGHT:x.PAN}}}const Vf=a("threejs");function Wf(t,e=0){t.models.forEach(t=>t.explode(e)),t.update(),t.emitEvent({type:"explode",data:e})}function jf(t,e){if(e.isEmpty())return;const i=e.getCenter(new Li),n=e.getSize(new Li).length()||1,s=t.renderer.getSize(new Ai),r=s.x/s.y,a=t.camera;if(a.isPerspectiveCamera){const t=new Li(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(n/(2*Math.tan(Ei.degToRad(.5*a.fov))));a.position.copy(t).add(i),a.updateMatrixWorld()}if(a.isOrthographicCamera){a.top=n/2,a.bottom=-n/2,a.left=a.bottom*r,a.right=a.top*r,a.zoom=1,a.updateProjectionMatrix();const e=new Li(0,0,1).applyQuaternion(a.quaternion).multiplyScalar(t.extents.getSize(new Li).length()||1);a.position.copy(e).add(i),a.updateMatrixWorld()}t.target.copy(i),t.update(),t.emitEvent({type:"zoom"})}Vf.registerDragger("Pan",t=>new Uf(t)),Vf.registerDragger("Orbit",t=>new nf(t)),Vf.registerDragger("Zoom",t=>new Hf(t)),Vf.registerDragger("MeasureLine",t=>new bf(t)),Vf.registerDragger("CuttingPlaneXAxis",t=>new rf(t)),Vf.registerDragger("CuttingPlaneYAxis",t=>new af(t)),Vf.registerDragger("CuttingPlaneZAxis",t=>new of(t)),Vf.registerDragger("Walk",t=>new kf(t)),Vf.registerDragger("Fly",t=>new Gf(t));const Xf={front:new Li(0,0,-1),back:new Li(0,0,1),left:new Li(1,0,0),right:new Li(-1,0,0),bottom:new Li(0,-1,0),top:new Li(0,1,0),se:new Li(-1,1,-1).normalize(),sw:new Li(1,1,-1).normalize(),ne:new Li(-1,1,1).normalize(),nw:new Li(1,1,1).normalize()};function Yf(t,e="sw"){const i=t.extents.getCenter(new Li),n=t.extents.getSize(new Li).length()||1,s=new Li(0,1,0),r=Xf[e]||Xf.sw,a=(new Li).copy(t.camera.up),o=(new Ci).setFromUnitVectors(s,a),h=(new Li).copy(r).applyQuaternion(o),l=t.camera;l.position.copy(h).multiplyScalar(n).add(i),l.lookAt(i),l.updateMatrixWorld(),t.target.copy(i),t.update(),t.emit({type:"viewposition",data:e}),jf(t,t.extents)}const qf=n("threejs");qf.registerCommand("applyModelTransform",function(t,e){console.warn("applyModelTransform not implemented")}),qf.registerCommand("clearMarkup",function(t){t.clearOverlay()}),qf.registerCommand("clearSelected",function(t){t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),qf.registerCommand("clearSlices",function(t){t.clearSlices()}),qf.registerCommand("collect",function(t){Wf(t,0)}),qf.registerCommand("getSnapshot",function(t,e,i){var n,s;t.update(!0);const r=null!==(n=null!=e?e:t.options.snapshotMimeType)&&void 0!==n?n:"image/jpeg",a=null!==(s=null!=i?i:t.options.snapshotQuality)&&void 0!==s?s:.25;return t.markup?t.markup.getSnapshot(r,a):t.canvas.toDataURL(r,a)}),qf.registerCommand("explode",Wf),qf.registerCommand("getDefaultViewPositions",function(){return Object.keys(Xf)}),qf.registerCommand("getModels",function(t){return t.models.map(t=>t.id)}),qf.registerCommand("getSelected",function(t){return t.executeCommand("getSelected2").map(t=>t.slice(t.indexOf(":")+1))}),qf.registerCommand("getSelected2",function(t){const e=[];return t.models.forEach(i=>{e.push(i.getHandlesByObjects(t.selected))}),e.flat()}),qf.registerCommand("hideSelected",function(t){t.models.forEach(e=>e.hideObjects(t.selected)),t.getComponent("SelectionComponent").clearSelection(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",handles:[]}),t.emitEvent({type:"select2",handles:[]})}),qf.registerCommand("isolateSelected",function(t){t.models.forEach(e=>e.isolateObjects(t.selected)),t.update(),t.emitEvent({type:"isolate"})}),qf.registerCommand("regenerateAll",function(t){t.emit({type:"regenerateall"})}),qf.registerCommand("resetView",function(t){t.executeCommand("setActiveDragger"),t.executeCommand("clearSlices"),t.executeCommand("clearOverlay"),t.executeCommand("setMarkupColor"),t.executeCommand("clearSelected"),t.executeCommand("showAll"),t.executeCommand("explode",0),t.executeCommand("zoomToExtents",!0),t.emit({type:"resetview"})}),qf.registerCommand("selectModel",function(t,e){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.filter(t=>t.id===e).forEach(t=>i.select(t.getObjects(),t)),t.update(),t.emitEvent({type:"select",handles:t.getSelected()}),t.emitEvent({type:"select2",handles:t.getSelected2()})}),qf.registerCommand("setActiveDragger",function(t,e=""){t.setActiveDragger(e)}),qf.registerCommand("setDefaultViewPosition",Yf),qf.registerCommand("setMarkupColor",function(t,e=255,i=0,n=0){t.markup.setMarkupColor(e,i,n)}),qf.registerCommand("setSelected",function(t,e=[]){const i=[];e.forEach(e=>{e.includes(":")?i.push(e):t.models.forEach(t=>{i.push(`${t.id}:${e}`)})}),t.executeCommand("setSelected2",i)}),qf.registerCommand("setSelected2",function(t,e=[]){const i=t.getComponent("SelectionComponent");i.clearSelection(),t.models.forEach(t=>{const n=t.getObjectsByHandles(e);t.showObjects(n),i.select(n,t)}),t.update(),t.emitEvent({type:"show"}),t.emitEvent({type:"select",data:void 0,handles:t.getSelected()}),t.emitEvent({type:"select2",data:void 0,handles:e})}),qf.registerCommand("showAll",function(t){t.models.forEach(t=>t.showAllObjects()),t.update(),t.emitEvent({type:"showall"})}),qf.registerCommand("zoomToExtents",function(t){jf(t,t.extents)}),qf.registerCommand("zoomToObjects",function(t,e=[]){const i=new Qi;t.models.forEach(t=>{t.getObjectsByHandles(e).forEach(t=>i.expandByObject(t))}),i.isEmpty()&&i.copy(t.extents),jf(t,i)}),qf.registerCommand("zoomToSelected",function(t){const e=new Qi;t.selected.forEach(t=>e.expandByObject(t)),e.isEmpty()&&e.copy(t.extents),jf(t,e)}),qf.registerCommand("top",t=>Yf(t,"top")),qf.registerCommand("bottom",t=>Yf(t,"bottom")),qf.registerCommand("left",t=>Yf(t,"left")),qf.registerCommand("right",t=>Yf(t,"right")),qf.registerCommand("front",t=>Yf(t,"front")),qf.registerCommand("back",t=>Yf(t,"back")),qf.registerCommand("sw",t=>Yf(t,"sw")),qf.registerCommand("se",t=>Yf(t,"se")),qf.registerCommand("ne",t=>Yf(t,"ne")),qf.registerCommand("nw",t=>Yf(t,"nw")),qf.registerCommandAlias("clearMarkup","clearOverlay"),qf.registerCommandAlias("clearSelected","unselect"),qf.registerCommandAlias("getSnapshot","createPreview"),qf.registerCommandAlias("zoomToExtents","zoomExtents"),qf.registerCommandAlias("top","k3DViewTop"),qf.registerCommandAlias("bottom","k3DViewBottom"),qf.registerCommandAlias("left","k3DViewLeft"),qf.registerCommandAlias("right","k3DViewRight"),qf.registerCommandAlias("front","k3DViewFront"),qf.registerCommandAlias("back","k3DViewBack"),qf.registerCommandAlias("se","k3DViewSE"),qf.registerCommandAlias("sw","k3DViewSW"),qf.registerCommandAlias("ne","k3DViewNE"),qf.registerCommandAlias("nw","k3DViewNW");class Zf{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215),this.viewer.renderer.setClearColor(this.backgroundColor)},this.viewer=t,this.backgroundColor=new _s(16777215),this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.addEventListener("optionschange",this.syncOptions)}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.background=void 0}}class Kf{constructor(t){this.optionsChange=()=>{this.switchCameraMode(this.viewer.options.cameraMode)},this.geometryEnd=()=>{if(this.viewer.models.length>1)return void this.switchCamera(this.viewer.camera);let t;if(this.viewer.scene.traverse(e=>{e.isCamera&&(t?e.isPerspectiveCamera&&t.isOrthographicCamera&&(t=e):t=e)}),t){t.userData.isDefaultCamera=!0,t.scale.set(1,1,1),this.switchCamera(t);const e=this.getCameraMode(t);this.viewer.options.cameraMode=e,this.viewer.emitEvent({type:"changecameramode",mode:e})}else this.switchCamera(this.viewer.camera),this.viewer.executeCommand("setDefaultViewPosition")},this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("initialize",this.optionsChange)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("initialize",this.optionsChange)}getCameraMode(t){return t.isOrthographicCamera?"orthographic":"perspective"}switchCamera(t){const e=this.viewer.extents.getSize(new Li).length()||1,i=this.viewer.renderer.getSize(new Ai),n=i.x/i.y;t.isPerspectiveCamera&&(t.aspect=n,t.near=e/1e3,t.far=1e3*e),t.isOrthographicCamera&&(t.left=t.bottom*n,t.right=t.top*n,t.near=1e3*-e,t.far=1e3*e),t.updateProjectionMatrix(),this.viewer.camera=t,this.viewer.renderPass.camera=t,this.viewer.helpersPass.camera=t,this.viewer.ssaaRenderPass.camera=t,this.viewer.update()}switchCameraMode(t){if(!t)return;const e=this.viewer.camera;if(t===this.getCameraMode(e))return;const i=this.viewer.target.clone();let n;if(e.isOrthographicCamera){const t=e.userData.fov||45,s=(e.top-e.bottom)/e.zoom/(2*Math.tan(Ei.degToRad(t)/2)),r=(new Li).subVectors(e.position,i).normalize();n=new cr(t),n.position.copy(r).multiplyScalar(s).add(i)}if(e.isPerspectiveCamera){const t=e.fov,s=e.position.distanceTo(i),r=2*Math.tan(Ei.degToRad(.5*t))*s;n=new Bl,n.top=r/2,n.bottom=-r/2,n.position.copy(e.position),n.userData.fov=t}n&&(n.up.copy(e.up),n.quaternion.copy(e.quaternion),this.switchCamera(n),this.viewer.emitEvent({type:"changecameramode",mode:t}))}}class Jf{constructor(t){this.syncExtents=t=>{const e=new Qi;this.viewer.models.forEach(t=>t.getExtents(e)),this.viewer.extents.copy(e),"databasechunk"!==t.type&&"clear"!==t.target||this.viewer.models.length>1||this.viewer.extents.getCenter(this.viewer.target)},this.viewer=t,this.viewer.addEventListener("databasechunk",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents),this.viewer.on("hide",this.syncExtents),this.viewer.on("isolate",this.syncExtents),this.viewer.on("show",this.syncExtents),this.viewer.on("showall",this.syncExtents)}dispose(){this.viewer.removeEventListener("databasechunk",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents),this.viewer.off("hide",this.syncExtents),this.viewer.off("isolate",this.syncExtents),this.viewer.off("show",this.syncExtents),this.viewer.off("showall",this.syncExtents)}}class Qf{constructor(t){this.geometryEnd=()=>{if(this.ambientLight.removeFromParent(),this.directionalLight.removeFromParent(),this.frontLight.removeFromParent(),this.hemisphereLight.removeFromParent(),this.viewer.extents.isEmpty())return;const t=this.viewer.extents.getCenter(new Li),e=this.viewer.extents.getSize(new Li).length()||1,i=new Li(0,1,0),n=new Li(0,0,-1),s=(new Li).copy(this.viewer.camera.up),r=(new Ci).setFromUnitVectors(i,s),a=(new Li).copy(n).applyQuaternion(r).negate();this.directionalLight.position.copy(s).applyAxisAngle(a,30*-Math.PI/180).multiplyScalar(e).add(t),this.directionalLight.target.position.copy(t),this.frontLight.position.copy(a).multiplyScalar(e).add(t),this.frontLight.target.position.copy(t),this.hemisphereLight.position.copy(a).multiplyScalar(1.5*e).add(t),this.viewer.scene.add(this.ambientLight),this.viewer.scene.add(this.directionalLight),this.viewer.scene.add(this.frontLight),this.viewer.scene.add(this.hemisphereLight)},this.viewer=t,this.ambientLight=new Gl(16777215,1.5),this.directionalLight=new zl(16777215,1),this.frontLight=new zl(16777215,1.25),this.hemisphereLight=new Ll(16777215,4473924,1.25),this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("clear",this.geometryEnd)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight.dispose(),this.directionalLight.removeFromParent(),this.directionalLight.dispose(),this.frontLight.removeFromParent(),this.frontLight.dispose(),this.hemisphereLight.removeFromParent(),this.hemisphereLight.dispose(),this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("clear",this.geometryEnd)}}class $f{constructor(t){this.initialize=()=>{try{const t=this.viewer.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");e&&(this.viewer.info.system.webglRenderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL),this.viewer.info.system.webglVendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL))}catch(t){console.error("Error reading WebGL info.",t)}console.log("THREE.WebGLRenderer:",y),console.log("WebGL Renderer:",this.viewer.info.system.webglRenderer),console.log("WebGL Vendor:",this.viewer.info.system.webglVendor),this.resize(),this.optionsChange({data:this.viewer.options})},this.clear=()=>{this.viewer.info.performance.timeToFirstRender=0,this.viewer.info.performance.loadTime=0,this.viewer.info.scene.objects=0,this.viewer.info.scene.triangles=0,this.viewer.info.scene.points=0,this.viewer.info.scene.lines=0,this.viewer.info.scene.edges=0,this.viewer.info.optimizedScene.objects=0,this.viewer.info.optimizedScene.triangles=0,this.viewer.info.optimizedScene.points=0,this.viewer.info.optimizedScene.lines=0,this.viewer.info.optimizedScene.edges=0,this.viewer.info.memory.geometries=0,this.viewer.info.memory.geometryBytes=0,this.viewer.info.memory.optimizedGeometryBytes=0,this.viewer.info.memory.textures=0,this.viewer.info.memory.textureBytes=0,this.viewer.info.memory.materials=0,this.viewer.info.memory.totalEstimatedGpuBytes=0,this.viewer.info.memory.usedJSHeapSize=0},this.optionsChange=({data:t})=>{!1===t.antialiasing?this.viewer.info.render.antialiasing="":!0===t.antialiasing?this.viewer.info.render.antialiasing="mxaa":this.viewer.info.render.antialiasing=t.antialiasing},this.geometryStart=()=>{this.startTime=performance.now()},this.databaseChunk=()=>{this.viewer.info.performance.timeToFirstRender+=performance.now()-this.startTime,console.log("Time to first render:",this.viewer.info.performance.timeToFirstRender,"ms")},this.geometryEnd=()=>{const t=this.viewer.models[this.viewer.models.length-1].getInfo();this.viewer.info.scene.objects+=t.scene.objects,this.viewer.info.scene.triangles+=t.scene.triangles,this.viewer.info.scene.points+=t.scene.points,this.viewer.info.scene.lines+=t.scene.lines,this.viewer.info.scene.edges+=t.scene.edges,this.viewer.info.optimizedScene.objects+=t.optimizedScene.objects,this.viewer.info.optimizedScene.triangles+=t.optimizedScene.triangles,this.viewer.info.optimizedScene.points+=t.optimizedScene.points,this.viewer.info.optimizedScene.lines+=t.optimizedScene.lines,this.viewer.info.optimizedScene.edges+=t.optimizedScene.edges,this.viewer.info.memory.geometries+=t.memory.geometries,this.viewer.info.memory.geometryBytes+=t.memory.geometryBytes,this.viewer.info.memory.optimizedGeometryBytes+=t.memory.optimizedGeometryBytes,this.viewer.info.memory.textures+=t.memory.textures,this.viewer.info.memory.textureBytes+=t.memory.textureBytes,this.viewer.info.memory.materials+=t.memory.materials,this.viewer.info.memory.totalEstimatedGpuBytes+=t.memory.totalEstimatedGpuBytes;const e=performance.memory;e&&(this.viewer.info.memory.usedJSHeapSize=e.usedJSHeapSize),this.viewer.info.performance.loadTime+=performance.now()-this.startTime,console.log("Number of objects:",t.scene.objects),console.log("Number of objects after optimization:",t.optimizedScene.objects),console.log("Geometry size:",t.memory.geometryBytes/1048576,"MB"),console.log("Optimized geometry size:",t.memory.optimizedGeometryBytes/1048576,"MB"),console.log("Estimated GPU used:",t.memory.totalEstimatedGpuBytes/1048576,"MB"),console.log("File load time:",this.viewer.info.performance.loadTime,"ms")},this.resize=()=>{const{width:t,height:e}=this.viewer.canvas;this.viewer.info.render.viewport.width=t,this.viewer.info.render.viewport.height=e},this.render=()=>{this.viewer.info.render.drawCalls=this.viewer.renderer.info.render.calls,this.viewer.info.render.triangles=this.viewer.renderer.info.render.triangles,this.viewer.info.render.points=this.viewer.renderer.info.render.points,this.viewer.info.render.lines=this.viewer.renderer.info.render.lines},this.animate=()=>{const t=performance.now();this.viewer.info.performance.frameTime=Math.round(t-this.beginTime),this.beginTime=t,this.frames++,t-this.prevTime>=1e3&&(this.viewer.info.performance.fps=Math.round(1e3*this.frames/(t-this.prevTime)),this.prevTime=t,this.frames=0)},this.viewer=t,this.startTime=0,this.beginTime=performance.now(),this.prevTime=performance.now(),this.frames=0,this.viewer.addEventListener("initialize",this.initialize),this.viewer.addEventListener("clear",this.clear),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("geometrystart",this.geometryStart),this.viewer.addEventListener("databasechunk",this.databaseChunk),this.viewer.addEventListener("geometryend",this.geometryEnd),this.viewer.addEventListener("resize",this.resize),this.viewer.addEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}dispose(){this.viewer.removeEventListener("initialize",this.initialize),this.viewer.removeEventListener("clear",this.clear),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("geometrystart",this.geometryStart),this.viewer.removeEventListener("databasechunk",this.databaseChunk),this.viewer.removeEventListener("geometryend",this.geometryEnd),this.viewer.removeEventListener("resize",this.resize),this.viewer.removeEventListener("render",this.render),this.viewer.addEventListener("animate",this.animate)}}class tg{constructor(t){this.resizeViewer=t=>{const{width:e,height:i}=t[0].contentRect;e&&i&&this.viewer.setSize(e,i)},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class eg{constructor(t){this.cleanupViewer=t=>{for(const e of t)if("childList"===e.type&&e.removedNodes.length>0)for(const t of e.removedNodes)if(t===this.viewer.canvas||t.contains(this.viewer.canvas))return this.viewer.emitEvent({type:"canvasremoved"}),void this.viewer.dispose()},this.viewer=t,this.mutationObserver=new MutationObserver(this.cleanupViewer),this.mutationObserver.observe(document,{childList:!0,subtree:!0})}dispose(){this.mutationObserver.disconnect(),this.mutationObserver=void 0}}class ig{constructor(t){this.animate=t=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t),this.viewer.emitEvent({type:"animate",time:t})},this.viewer=t,this.requestId=requestAnimationFrame(this.animate)}dispose(){cancelAnimationFrame(this.requestId)}}const ng=new Qi,sg=new Li;class rg extends Yl{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new Ps([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new Ps([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new Pc(e,6,1);return this.setAttribute("instanceStart",new wr(i,3,0)),this.setAttribute("instanceEnd",new wr(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new Pc(e,6,1);return this.setAttribute("instanceColorStart",new wr(i,3,0)),this.setAttribute("instanceColorEnd",new wr(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new kh(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Qi);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),ng.setFromBufferAttribute(e),this.boundingBox.union(ng))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new vn),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let n=0;for(let s=0,r=t.count;s<r;s++)sg.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(sg)),sg.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(sg));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}_d.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Ai(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},yd.line={uniforms:sr.merge([_d.common,_d.fog,_d.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat alpha = opacity;\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class ag extends rr{constructor(t){super({type:"LineMaterial",uniforms:sr.clone(yd.line.uniforms),vertexShader:yd.line.vertexShader,fragmentShader:yd.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const og=new Li,hg=new Li,lg=new Yi;class cg extends Qs{constructor(t=new rg,e=new ag({color:16777215*Math.random()})){super(t,e),this.isWireframe=!0,this.type="Wireframe"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,n=new Float32Array(2*e.count);for(let t=0,s=0,r=e.count;t<r;t++,s+=2)og.fromBufferAttribute(e,t),hg.fromBufferAttribute(i,t),n[s]=0===s?0:n[s-1],n[s+1]=n[s]+og.distanceTo(hg);const s=new Pc(n,2,1);return t.setAttribute("instanceDistanceStart",new wr(s,1,0)),t.setAttribute("instanceDistanceEnd",new wr(s,1,1)),this}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(lg),this.material.uniforms.resolution.value.set(lg.z,lg.w))}}class dg{static isBreak(t,e){return isNaN(t[e])||isNaN(t[e+1])||isNaN(t[e+2])||t[e]===1/0||t[e]===-1/0||t[e+1]===1/0||t[e+1]===-1/0||t[e+2]===1/0||t[e+2]===-1/0}static fromIndexedLine(t,e){const i=new rg,n=[];for(let i=0;i<e.length;i+=2){const s=3*e[i],r=3*e[i+1];-1!==e[i]&&-1!==e[i+1]&&n.push(t[s],t[s+1],t[s+2],t[r],t[r+1],t[r+2])}return 0===n.length?null:(i.setPositions(n),i)}static fromNonIndexedLine(t,e){const i=new rg,n=[];if(e)for(let e=0;e<t.length&&!(e+5>=t.length);e+=6)dg.isBreak(t,e)||dg.isBreak(t,e+3)||n.push(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else{let e=-1;for(let i=0;i<t.length;i+=3)dg.isBreak(t,i)?e=-1:(-1!==e&&n.push(t[e],t[e+1],t[e+2],t[i],t[i+1],t[i+2]),e=i)}return 0===n.length?null:(i.setPositions(n),i)}}class ug{constructor(t){this.geometryEnd=()=>{this.facesMaterial=new Xh({transparent:!0,specular:2236962,shininess:10,reflectivity:.05,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),this.edgesMaterial=new ag({linewidth:1.5,resolution:new Ai(window.innerWidth,window.innerHeight)}),this.lineMaterial=new Ha({transparent:!0,depthTest:!0,depthWrite:!0}),this.lineGlowMaterial=new ag({linewidth:1.5,transparent:!0,opacity:.8,resolution:new Ai(window.innerWidth,window.innerHeight)}),this.syncHighlightColors()},this.optionsChange=()=>{this.syncHighlightColors(),this.viewer.update()},this.viewer=t;if(t.canvas.getContext("webgl2")){const e=t.renderer.getSize(new Ai);this.renderTarget=new Zi(e.x,e.y,{format:Gt,stencilBuffer:!1,samples:4,type:Et})}this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("optionschange",this.optionsChange),this.viewer.addEventListener("resize",this.viewerResize),this.geometryEnd()}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("optionschange",this.optionsChange),this.viewer.removeEventListener("resize",this.viewerResize)}highlight(t){const{edgesVisibility:e}=this.viewer.options;Array.isArray(t)||(t=[t]),0!==t.length&&t.filter(t=>!t.userData.isEdge).forEach(t=>{if(!t.userData.isHighlighted)if(t.isLine||t.isLineSegments){const i=t.geometry.attributes.position.array,n=t.geometry.index?t.geometry.index.array:null,s=n?dg.fromIndexedLine(i,n):dg.fromNonIndexedLine(i,t.isLineSegments),r=new cg(s,this.lineGlowMaterial);r.visible=e,r.userData.isHighlightWireframe=!0,t.add(r),t.userData.highlightWireframe=r,t.userData.originalMaterial=t.material,t.material=this.lineMaterial,t.userData.isHighlighted=!0}else if(t.isMesh){const i=new Eo(t.geometry,89),n=(new rg).fromEdgesGeometry(i),s=new cg(n,this.edgesMaterial);s.visible=e,s.userData.isHighlightWireframe=!0,t.add(s),t.userData.highlightWireframe=s,t.userData.originalMaterial=t.material,t.material=this.facesMaterial,t.userData.isHighlighted=!0}})}unhighlight(t){Array.isArray(t)||(t=[t]),0!==t.length&&t.forEach(t=>{t.userData.isHighlighted&&(t.material=t.userData.originalMaterial,t.userData.highlightWireframe.removeFromParent(),delete t.userData.isHighlighted,delete t.userData.originalMaterial,delete t.userData.highlightWireframe)})}syncHighlightColors(){const t=this.viewer.options.enableCustomHighlight?this.viewer.options:f.defaults(),{facesColor:e,facesTransparancy:i,facesOverlap:n}=t,{edgesColor:s,edgesVisibility:r,edgesOverlap:a}=t;this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-i)/255,this.facesMaterial.depthTest=!n,this.facesMaterial.depthWrite=!n,this.edgesMaterial.color.setRGB(s.r/255,s.g/255,s.b/255),this.edgesMaterial.depthTest=!a,this.edgesMaterial.depthWrite=!a,this.lineMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.lineGlowMaterial.color.setRGB(s.r/255,s.g/255,s.b/255),this.lineGlowMaterial.depthTest=!a,this.lineGlowMaterial.depthWrite=!a,this.viewer.selected.forEach(t=>{const e=t.userData.highlightWireframe;e&&(e.visible=r)})}viewerResize(t){var e,i,n;null===(e=this.renderTarget)||void 0===e||e.setSize(t.width,t.height),null===(i=this.edgesMaterial)||void 0===i||i.resolution.set(t.width,t.height),null===(n=this.lineGlowMaterial)||void 0===n||n.resolution.set(t.width,t.height)}}class pg{constructor(t){this.onPointerDown=t=>{t.isPrimary&&0===t.button&&this.getMousePosition(t,this.downPosition)},this.onPointerUp=t=>{if(!t.isPrimary)return;const e=this.getMousePosition(t,new Ai);if(0!==e.distanceTo(this.downPosition))return;const i=this.viewer.extents.getSize(new Li).length()||1,n=new yf(this.viewer.camera,this.viewer.renderer,this.viewer.canvas);n.threshold=i/1e4;let s=[];if(this.viewer.models.forEach(t=>{const i=t.getVisibleObjects(),r=n.getPointerIntersects(e,i);r.length>0&&s.push({...r[0],model:t})}),s=s.sort((t,e)=>t.distance-e.distance),t.shiftKey||this.clearSelection(),s.length>0){const e=s[0].model,i=e.getHandlesByObjects(s[0].object),n=e.getObjectsByHandles(i);t.shiftKey?this.toggleSelection(n,e):this.select(n,e)}this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()}),this.viewer.emitEvent({type:"select2",data:void 0,handles:this.viewer.getSelected2()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.initHighlighter=()=>{this.highlighter=this.viewer.getComponent("HighlighterComponent")},this.viewer=t,this.downPosition=new Ai,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("initialize",this.initHighlighter)}dispose(){this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("initialize",this.initHighlighter)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}select(t,e){e?(Array.isArray(t)||(t=[t]),0!==t.length&&(e.highlightObjects(t),this.highlighter.highlight(t),t.forEach(t=>this.viewer.selected.push(t)),t.forEach(t=>t.userData.isSelected=!0))):this.viewer.models.forEach(e=>this.select(t,e))}deselect(t,e){e?(Array.isArray(t)||(t=[t]),0!==t.length&&(e.unhighlightObjects(t),this.highlighter.unhighlight(t),this.viewer.selected=this.viewer.selected.filter(e=>!t.includes(e)),t.forEach(t=>t.userData.isSelected=!1))):this.viewer.models.forEach(e=>this.select(t,e))}toggleSelection(t,e){Array.isArray(t)||(t=[t]),0!==t.length&&(t[0].userData.isSelected?this.deselect(t,e):this.select(t,e))}clearSelection(){0!==this.viewer.selected.length&&(this.viewer.models.forEach(t=>t.unhighlightObjects(this.viewer.selected)),this.highlighter.unhighlight(this.viewer.selected),this.viewer.selected.forEach(t=>t.userData.isSelected=!1),this.viewer.selected.length=0)}}class mg extends $n{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new Bl(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new Ss({toneMapped:!1,color:"#dd0000"}),i=new Ss({toneMapped:!1,color:"#00dd00"}),n=new Ss({toneMapped:!1,color:"#0000dd"}),s=this.getSpriteMaterial(e.color,"X"),r=this.getSpriteMaterial(i.color,"Y"),a=this.getSpriteMaterial(n.color,"Z"),o=new _o(.01,.01,1,3);o.translate(0,.5,0);const h=new _o(0,.1,.25,12);h.translate(0,.625,0);const l={X:[[new Qs(h,e),[.5,0,0],[0,0,-Math.PI/2]],[new Qs(o,e),[0,0,0],[0,0,-Math.PI/2]],[new Br(s),[1.55,0,0]]],Y:[[new Qs(h,i),[0,.5,0],null],[new Qs(o,i),null,null],[new Br(r),[0,1.55,0]]],Z:[[new Qs(h,n),[0,0,.5],[Math.PI/2,0,0]],[new Qs(o,n),null,[Math.PI/2,0,0]],[new Br(a),[0,0,1.55]]]};Object.keys(l).forEach(t=>{l[t].forEach(e=>{const i=e[0],n=e[1],s=e[2];i.name=t,n&&i.position.set(n[0],n[1],n[2]),s&&i.rotation.set(s[0],s[1],s[2]),i.updateMatrixWorld(),this.add(i)})})}dispose(){this.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}getSpriteMaterial(t,e){const i=document.createElement("canvas");i.width=64,i.height=64;const n=i.getContext("2d");n.clearRect(0,0,64,64),n.font="24px Arial",n.textAlign="center",n.fillStyle=t.getStyle(),n.fillText(e,32,41);const s=new uo(i);return s.colorSpace=ze,new Mr({map:s,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.autoClear,i=t.clippingPlanes,n=t.getViewport(new Yi);t.autoClear=!1,t.clippingPlanes=[],t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(n),t.clippingPlanes=i,t.autoClear=e}}class fg{constructor(t){this.geometryEnd=()=>{this.wcsHelper.dispose(),this.wcsHelper=new mg(this.viewer.camera)},this.viewerRender=()=>{this.viewer.options.showWCS&&this.wcsHelper.render(this.viewer.renderer)},this.updateHelperCamera=()=>{this.wcsHelper.camera=this.viewer.camera},this.wcsHelper=new mg(t.camera),this.viewer=t,this.viewer.addEventListener("databasechunk",this.geometryEnd),this.viewer.addEventListener("drawviewpoint",this.geometryEnd),this.viewer.addEventListener("render",this.viewerRender),this.viewer.addEventListener("changecameramode",this.updateHelperCamera)}dispose(){this.viewer.removeEventListener("databasechunk",this.geometryEnd),this.viewer.removeEventListener("drawviewpoint",this.geometryEnd),this.viewer.removeEventListener("render",this.viewerRender),this.viewer.removeEventListener("changecameramode",this.updateHelperCamera),this.wcsHelper.dispose()}}class gg{constructor(t){this.savedCameraPosition=null,this.onDatabaseChunk=()=>{this.savedCameraPosition={position:this.viewer.camera.position.clone(),up:this.viewer.camera.up.clone(),direction:this.viewer.camera.getWorldDirection(new Li)}},this.resetCameraPosition=()=>{this.savedCameraPosition&&(this.viewer.camera.position.copy(this.savedCameraPosition.position),this.viewer.camera.up.copy(this.savedCameraPosition.up),this.viewer.camera.lookAt(this.savedCameraPosition.position.clone().add(this.savedCameraPosition.direction)),this.viewer.camera.updateProjectionMatrix())},this.viewer=t,this.viewer.addEventListener("databasechunk",this.onDatabaseChunk),this.viewer.on("resetview",this.resetCameraPosition)}dispose(){this.viewer.off("resetview",this.resetCameraPosition),this.viewer.removeEventListener("databasechunk",this.onDatabaseChunk)}}const vg=l("threejs");vg.registerComponent("ExtentsComponent",t=>new Jf(t)),vg.registerComponent("CameraComponent",t=>new Kf(t)),vg.registerComponent("BackgroundComponent",t=>new Zf(t)),vg.registerComponent("LightComponent",t=>new Qf(t)),vg.registerComponent("InfoComponent",t=>new $f(t)),vg.registerComponent("CanvasResizeComponent",t=>new tg(t)),vg.registerComponent("CanvasRemoveComponent",t=>new eg(t)),vg.registerComponent("RenderLoopComponent",t=>new ig(t)),vg.registerComponent("HighlighterComponent",t=>new ug(t)),vg.registerComponent("SelectionComponent",t=>new pg(t)),vg.registerComponent("WCSHelperComponent",t=>new fg(t)),vg.registerComponent("ResetComponent",t=>new gg(t));class _g{constructor(t){this.scene=t,this.handleToObjects=new Map,this.originalObjects=new Set,this.scene.traverse(t=>{this.originalObjects.add(t);const e=t.userData.handle;if(!e)return;let i=this.handleToObjects.get(e);i||(i=new Set,this.handleToObjects.set(e,i)),i.add(t)})}dispose(){this.handleToObjects=void 0,this.originalObjects=void 0,this.scene.traverse(function(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach(t=>function(t){t.dispose()}(t)))}),this.scene.clear()}getUnits(){return"Meters"}getUnitScale(){return cf(this.getUnits(),"Meters",1)}getUnitString(){return t=this.getUnits(),(lf[t]||lf.Default).symbol;var t}getPrecision(){return 2}getInfo(){const t=new Set,e=new Set,i=new Set;let n=0,s=0,r=0,a=0,o=0,h=0,l=0;function c(t){if(!t.image)return 0;return(t.image.width||0)*(t.image.height||0)*4*(t.generateMipmaps?1.33:1)}this.scene.traverse(d=>{if(n++,d.geometry){const e=d.geometry;if(!t.has(e)){if(t.add(e),e.attributes)for(const t in e.attributes){const i=e.attributes[t];i&&i.array&&(h+=i.array.byteLength)}e.index&&e.index.array&&(h+=e.index.array.byteLength)}if(e.index){const t=e.index.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?r+=t:s+=t/3}else if(e.attributes&&e.attributes.position){const t=e.attributes.position.count;d.isLine||d.isLineSegments?a+=t/2:d.isPoints?r+=t:s+=t/3}d.isLineSegments&&e.attributes.position&&(o+=e.attributes.position.count/2)}if(d.material){(Array.isArray(d.material)?d.material:[d.material]).forEach(t=>{e.add(t),t.map&&!i.has(t.map)&&(i.add(t.map),l+=c(t.map));["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","iridescenceMap","sheenColorMap","sheenRoughnessMap","thicknessMap","transmissionMap","anisotropyMap","gradientMap"].forEach(e=>{const n=t[e];n&&!i.has(n)&&(i.add(n),l+=c(n))})})}});const d=new _;return d.scene.objects=n,d.scene.triangles=Math.floor(s),d.scene.points=Math.floor(r),d.scene.lines=Math.floor(a),d.scene.edges=Math.floor(o),d.memory.geometries=t.size,d.memory.geometryBytes=h,d.memory.optimizedGeometryBytes=0,d.memory.textures=i.size,d.memory.textureBytes=Math.floor(l),d.memory.materials=e.size,d.memory.totalEstimatedGpuBytes=h+Math.floor(l),d.optimizedScene.objects=d.scene.objects,d.optimizedScene.triangles=d.scene.triangles,d.optimizedScene.points=d.scene.points,d.optimizedScene.lines=d.scene.lines,d.optimizedScene.edges=d.scene.edges,d}getExtents(t){return this.scene.traverseVisible(e=>t.expandByObject(e)),t}getObjects(){return Array.from(this.originalObjects)}getVisibleObjects(){const t=[];return this.scene.traverseVisible(e=>t.push(e)),t.filter(t=>t.userData.handle)}getObjectsByHandles(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(t=>{const i=t.indexOf(":");if(-1!==i){if(t.slice(0,i)!==this.id)return;t=t.slice(i+1)}e.push(t)});const i=new Set(e),n=[];return i.forEach(t=>{n.push(Array.from(this.handleToObjects.get(t)||[]))}),n.flat()}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return t.filter(t=>this.originalObjects.has(t)).forEach(t=>{e.add(`${this.id}:${t.userData.handle}`)}),Array.from(e)}hideObjects(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.visible=!1}),this}hideAllObjects(){return this.isolateObjects([])}isolateObjects(t){Array.isArray(t)||(t=[t]);const e=new Set(t);return t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.traverseAncestors(t=>e.add(t))}),this.scene.traverse(t=>t.visible=e.has(t)),this}showObjects(t){return Array.isArray(t)||(t=[t]),t.filter(t=>this.originalObjects.has(t)).forEach(t=>{t.visible=!0,t.traverseAncestors(t=>t.visible=!0)}),this}showAllObjects(){return this.scene.traverse(t=>t.visible=!0),this}highlightObjects(t){return this}unhighlightObjects(t){return this}explode(t=0,e=4){const i=new Map,n=(t,e)=>{const n=(new Qi).setFromObject(t),s=t.userData.handle;if(!s)return n.getCenter(e);const r=i.get(s);if(r)return e.copy(r);return this.getObjectsByHandles(s).forEach(t=>n.expandByObject(t)),n.getCenter(e),i.set(s,e.clone()),e};const s=t/100,r=this.scene;r.userData.explodeDepth||(r.userData.explodeDepth=function t(e,i){let s=i;return e.children.forEach(e=>{const n=t(e,i+1);s<n&&(s=n)}),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=n(e,new Li),s}(r,1));const a=r.userData.explodeDepth,o=s*a+1,h=0|o,l=o-h;return function t(i,n){if(!i.isCamera&&!i.userData.isHighlightWireframe){if(i.position.copy(i.userData.originalPosition),n>0&&n<=h){let t=s*e;n===h&&(t*=l);const r=i.parent.userData.originalCenter,a=i.userData.originalCenter.clone().sub(r).multiplyScalar(t);i.position.add(a)}i.children.forEach(e=>t(e,n+1))}}(r,0),this.scene.updateMatrixWorld(),this}}class yg extends _g{getInfo(){const t=this.gltfLoader.getStats(),e=new _;return e.scene.objects=t.scene.beforeOptimization.objects,e.scene.triangles=t.scene.beforeOptimization.triangles,e.scene.lines=t.scene.beforeOptimization.lines,e.scene.edges=t.scene.beforeOptimization.edges,e.optimizedScene.objects=t.scene.afterOptimization.objects,e.optimizedScene.triangles=t.scene.afterOptimization.triangles,e.optimizedScene.lines=t.scene.afterOptimization.lines,e.optimizedScene.edges=t.scene.afterOptimization.edges,e.memory.geometries=t.memory.geometries.count,e.memory.geometryBytes=t.memory.geometries.bytes,e.memory.optimizedGeometryBytes=t.memory.geometries.optimizedBytes,e.memory.textures=t.memory.textures.count,e.memory.materials=t.memory.materials.count,e.memory.totalEstimatedGpuBytes=t.memory.totalEstimatedGpuBytes,e}getExtents(t){return t.union(this.gltfLoader.getTotalGeometryExtent())}getObjects(){const t=[];return this.gltfLoader.originalObjects.forEach(e=>{t.push(e)}),t}getVisibleObjects(){return this.gltfLoader.getOriginalObjectForSelect()}getObjectsByHandles(t){Array.isArray(t)||(t=[t]);const e=new Set(t),i=[];return e.forEach(t=>{i.push(this.gltfLoader.getObjectsByHandle(t))}),i.flat()}getHandlesByObjects(t){Array.isArray(t)||(t=[t]);const e=new Set;return t.filter(t=>this.gltfLoader.originalObjects.has(t)).forEach(t=>{e.add(t.userData.handle)}),Array.from(e)}hideObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.hideObjects(e),this}isolateObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.isolateObjects(new Set(e)),this}showObjects(t){const e=this.getHandlesByObjects(t);return this.gltfLoader.showObjects(e),this}showAllObjects(){return this.gltfLoader.showAllHiddenObjects(),this}highlightObjects(t){return this.gltfLoader.showOriginalObjects(t),this}unhighlightObjects(t){return this.gltfLoader.hideOriginalObjects(t),this}explode(t=0,e=4){const i=new Map,n=(t,e)=>{const n=(new Qi).setFromObject(t),s=t.userData.handle;if(!s)return n.getCenter(e);const r=i.get(s);if(r)return e.copy(r);return this.getObjectsByHandles(s).forEach(t=>n.expandByObject(t)),n.getCenter(e),i.set(s,e.clone()),e};const s=t/100,r=this.scene.children[0];r.userData.explodeDepth||(r.userData.explodeDepth=function t(e,i){let s=i;return e.children.filter(t=>!t.userData.isOptimized).forEach(e=>{const n=t(e,i+1);s<n&&(s=n)}),e.userData.originalPosition=e.position.clone(),e.userData.originalCenter=n(e,new Li),s}(r,1));const a=r.userData.explodeDepth,o=s*a+1,h=0|o,l=o-h,c=new Map;return function t(i,n){if(!i.isCamera&&!i.userData.isHighlightWireframe){if(i.position.copy(i.userData.originalPosition),n>0&&n<=h&&!i.userData.isExplodeLocked){let t=s*e;n===h&&(t*=l);const r=i.parent.userData.originalCenter,a=i.userData.originalCenter.clone().sub(r).multiplyScalar(t);i.position.add(a);const o=(new En).makeTranslation(a.x,a.y,a.z);c.set(i,o)}i.children.filter(t=>!t.userData.isOptimized).forEach(e=>t(e,n+1))}}(r,0),this.scene.updateMatrixWorld(),this.gltfLoader.applyObjectTransforms(c),this}}const xg={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bg=0,Sg=1,wg=2,Mg=3,Tg=4,Eg=5,Ag=6,Cg=31457280;class Lg{constructor(t,e){this.id=`${t}`,this.json=null,this.loadController=e,this.loader=null,this.batchDelay=10,this.maxBatchSize=5242880,this.maxRangesPerRequest=512,this.pendingRequests=[],this.batchTimeout=null,this.textureLoader=new Al,this.materials=new Map,this.textureCache=new Map,this.materialCache=new Map,this.uri="",this._nextObjectId=1,this.loadingAborted=!1,this.criticalError=null}async initialize(t){const e=await this.loadController.loadJson();if(void 0===e.asset||e.asset.version[0]<2)throw new Error("GltfStructure: Unsupported asset. glTF versions >=2.0 are supported.");this.json=e,this.loader=t,this.uri=this.json.buffers[0].uri||""}clear(){this.json=null,this.loadController=null,this.pendingRequests=[],this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=null),this.disposeMaterials(),this.textureCache.clear(),this.materials.clear(),this.activeChunkLoads=0,this.chunkQueue=[],this.loadingAborted=!1,this.criticalError=null}getJson(){return this.json}scheduleRequest(t){return new Promise((e,i)=>{this.loadingAborted?i(this.criticalError||new Error("Structure loading has been aborted due to critical error")):this.pendingRequests.push({...t,_resolve:e,_reject:i})})}isCriticalHttpError(t){if(!t)return!1;const e=t.status||t.statusCode||t.code;if("number"==typeof e)return e>=400&&e<600;if(t.message){const e=t.message.match(/HTTP\s+(\d{3})/i);if(e){const t=parseInt(e[1],10);return t>=400&&t<600}}return!1}abortLoading(t){if(this.loadingAborted)return;this.loadingAborted=!0,this.criticalError=t;const e=[...this.pendingRequests];this.pendingRequests=[];for(const i of e)i._reject&&i._reject(t);throw console.error(`❌ Critical error for structure "${this.id}". All further loading aborted.`,`\n Error: ${t.message||t}`,`\n Rejected ${e.length} pending chunk requests.`),t}async flushBufferRequests(){if(!this.pendingRequests||0===this.pendingRequests.length)return;const t=[...this.pendingRequests];this.pendingRequests=[],t.sort((t,e)=>t.offset-e.offset);const e=[];let i={start:t[0].offset,end:t[0].offset+t[0].length,requests:[t[0]]};for(let n=1;n<t.length;n++){const s=t[n],r=s.offset-i.end,a=Math.max(i.end,s.offset+s.length),o=a-i.start;r<=131072&&o<=Cg?(i.end=a,i.requests.push(s)):(e.push(i),i={start:s.offset,end:s.offset+s.length,requests:[s]})}e.push(i);const n=[];for(const t of e){let{start:e,end:i,requests:s}=t;for(;i-e>Cg;){let t=0;for(let i=0;i<s.length&&!(s[i].offset+s[i].length-e>Cg);i++)t=i;const r=s.slice(0,t+1),a=r[r.length-1].offset+r[r.length-1].length;if(n.push({start:e,end:a,requests:r}),s=s.slice(t+1),s.length>0){e=s[0].offset,i=s[0].offset+s[0].length;for(let t=1;t<s.length;t++)i=Math.max(i,s[t].offset+s[t].length)}}s.length>0&&n.push({start:e,end:i,requests:s})}const s=n.map(async(t,e)=>{if(this.loadingAborted)for(const e of t.requests)e._reject(this.criticalError||new Error("Structure loading aborted"));else{await this.loader.waitForChunkSlot();try{const e=t.end-t.start,i=await this.loadController.loadBinaryData([{offset:t.start,length:e}],this.uri);for(const e of t.requests){const n=e.offset-t.start;try{e._resolve({buffer:i,relOffset:n,length:e.length})}catch(t){e._reject(t)}}}catch(i){for(const e of t.requests)e._reject(i);this.isCriticalHttpError(i)?this.abortLoading(i):console.warn(`Failed to load chunk ${e+1}/${n.length} (${t.start}-${t.end}):`,i)}finally{this.loader.releaseChunkSlot()}}});await Promise.all(s),this.pendingRequests=[]}getBufferView(t,e,i){return this.scheduleRequest({offset:t,length:e,componentType:i})}createTypedArray(t,e,i,n){try{if(!(t&&t instanceof ArrayBuffer))throw new Error("Invalid buffer");let s;switch(n){case 5120:case 5121:s=1;break;case 5122:case 5123:s=2;break;case 5125:case 5126:s=4;break;default:throw new Error(`Unsupported component type: ${n}`)}const r=i/s;if(!Number.isInteger(r))throw new Error(`Invalid length ${i} for component type ${n}`);if(i>t.byteLength)throw new Error(`Buffer too small: need ${i} bytes, but buffer is ${t.byteLength} bytes`);return new(0,xg[n])(t,e,r)}catch(s){throw"AbortError"!==s.name&&console.error("Error creating typed array:",{bufferSize:t?.byteLength,offset:e,length:i,componentType:n,error:s}),s}}async createBufferAttribute(t){if(!this.json)throw new Error("No GLTF structure loaded");const e=this.json,i=e.accessors[t],n=e.bufferViews[i.bufferView];try{const t=(n.byteOffset||0)+(i.byteOffset||0),e=this.getNumComponents(i.type),s=i.count*e*this.getComponentSize(i.componentType),r=await this.getBufferView(t,s,i.componentType),a=new Ls(r,e);return void 0!==i.min&&(a.min=i.min),void 0!==i.max&&(a.max=i.max),a}catch(t){throw"AbortError"!==t.name&&console.error("Error creating buffer attribute:",{error:t,accessor:i,bufferView:n}),t}}getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error(`Unknown component type: ${t}`)}}getNumComponents(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error(`Unknown type: ${t}`)}}async loadTextures(){if(!this.json.textures)return;const t=async t=>{const e=this.json.images[t];if(e.uri){const t=await this.loadController.resolveURL(e.uri);return this.textureLoader.loadAsync(t)}if(void 0!==e.bufferView){const t=this.json.bufferViews[e.bufferView],i=await this.getBufferView(t.byteOffset||0,t.byteLength,5121),n=new Blob([i],{type:e.mimeType}),s=URL.createObjectURL(n),r=await this.textureLoader.loadAsync(s);return URL.revokeObjectURL(s),r.flipY=!1,r}},e=[];for(let i=0;i<this.json.textures.length;i++)e.push(t(this.json.textures[i].source).then(t=>this.textureCache.set(i,t)));await Promise.all(e)}loadMaterials(){if(!this.json.materials)return this.materials;for(let t=0;t<this.json.materials.length;t++){const e=this.json.materials[t],i=`material_${t}`;this.materialCache.set(i,{mesh:this.createMaterial(e,Tg),points:this.createMaterial(e,bg),lines:this.createMaterial(e,Sg)}),this.materialCache.get(i).mesh.name=e.name,this.materialCache.get(i).points.name=e.name,this.materialCache.get(i).lines.name=e.name,this.materials.set(t,this.materialCache.get(i).mesh)}return this.materials}createMaterial(t,e=void 0){const i={};if(t.pbrMetallicRoughness){const e=t.pbrMetallicRoughness;e.baseColorFactor&&(i.color=(new _s).fromArray(e.baseColorFactor),i.opacity=e.baseColorFactor[3],i.opacity<1&&(i.transparent=!0)),e.baseColorTexture&&(i.map=this.textureCache.get(e.baseColorTexture.index))}let n;return t.emissiveFactor&&(i.emissive=(new _s).fromArray(t.emissiveFactor)),"BLEND"===t.alphaMode&&(i.transparent=!0),t.doubleSided&&(i.side=2),e===bg?(i.sizeAttenuation=!1,n=new io(i),n.sizeAttenuation=!1):e===Sg||e===Mg||e===wg?n=new Ha(i):(i.specular=2236962,i.shininess=10,i.reflectivity=.05,i.polygonOffset=!0,i.polygonOffsetFactor=1,i.polygonOffsetUnits=1,t.normalTexture&&(i.normalMap=this.textureCache.get(t.normalTexture.index)),n=new Xh(i)),n}getCachedMaterial(t,e){const i=`material_${t}`,n=this.materialCache.get(i);return n?e===bg?n.points:e===Sg||e===Mg||e===wg?n.lines:n.mesh:null}disposeMaterials(){this.textureCache.forEach(t=>t.dispose()),this.textureCache.clear(),this.materials.forEach(t=>{t.map&&t.map.dispose(),t.lightMap&&t.lightMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.specularMap&&t.specularMap.dispose(),t.envMap&&t.envMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.dispose()}),this.materials.clear(),this.materialCache.forEach(t=>{t.mesh&&(t.mesh.map&&t.mesh.map.dispose(),t.mesh.lightMap&&t.mesh.lightMap.dispose(),t.mesh.bumpMap&&t.mesh.bumpMap.dispose(),t.mesh.normalMap&&t.mesh.normalMap.dispose(),t.mesh.specularMap&&t.mesh.specularMap.dispose(),t.mesh.envMap&&t.mesh.envMap.dispose(),t.mesh.aoMap&&t.mesh.aoMap.dispose(),t.mesh.metalnessMap&&t.mesh.metalnessMap.dispose(),t.mesh.roughnessMap&&t.mesh.roughnessMap.dispose(),t.mesh.emissiveMap&&t.mesh.emissiveMap.dispose(),t.mesh.dispose()),t.points&&(t.points.map&&t.points.map.dispose(),t.points.dispose()),t.lines&&(t.lines.map&&t.lines.map.dispose(),t.lines.dispose())}),this.materialCache.clear()}estimateNodeSize(t){if(!this.json.meshes)return 0;const e=this.json.meshes[t];if(!e||!e.primitives)return 0;let i=0;for(const t of e.primitives){if(t.attributes)for(const[,e]of Object.entries(t.attributes)){if(void 0===e)continue;const t=this.json.accessors[e];if(!t)continue;const n=this.getNumComponents(t.type),s=this.getComponentSize(t.componentType);i+=t.count*n*s}if(void 0!==t.indices){const e=this.json.accessors[t.indices];if(e){const t=this.getComponentSize(e.componentType);i+=e.count*t}}}return i}}function Rg(t,e=!1){const i=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),r={},a={},o=t[0].morphTargetsRelative,h=new zs;let l=0;for(let c=0;c<t.length;++c){const d=t[c];let u=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in d.attributes){if(!n.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===r[t]&&(r[t]=[]),r[t].push(d.attributes[t]),u++}if(u!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in d.morphAttributes){if(!s.has(t))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[t]&&(a[t]=[]),a[t].push(d.morphAttributes[t])}if(e){let t;if(i)t=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;t=d.attributes.position.count}h.addGroup(l,t,c),l+=t}}if(i){let e=0;const i=[];for(let n=0;n<t.length;++n){const s=t[n].index;for(let t=0;t<s.count;++t)i.push(s.getX(t)+e);e+=t[n].attributes.position.count}h.setIndex(i)}for(const t in r){const e=Ig(r[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" attribute."),null;h.setAttribute(t,e)}for(const t in a){const e=a[t][0].length;if(0===e)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[t]=[];for(let i=0;i<e;++i){const e=[];for(let n=0;n<a[t].length;++n)e.push(a[t][n][i]);const n=Ig(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+t+" morphAttribute."),null;h.morphAttributes[t].push(n)}}return h}function Ig(t){let e,i,n,s=-1,r=0;for(let a=0;a<t.length;++a){const o=t[a];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===s&&(s=o.gpuType),s!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=o.count*i}const a=new e(r),o=new Ls(a,i,n);let h=0;for(let e=0;e<t.length;++e){const n=t[e];if(n.isInterleavedBufferAttribute){const t=h/i;for(let e=0,s=n.count;e<s;e++)for(let s=0;s<i;s++){const i=n.getComponent(e,s);o.setComponent(e+t,s,i)}}else a.set(n.array,h);h+=n.count*i}return void 0!==s&&(o.gpuType=s),o}class Pg{constructor(t,e,i){this.camera=t,this.scene=e,this.renderer=i,this.eventHandlers={geometryprogress:[],databasechunk:[],geometryend:[],geometryerror:[],update:[],geometrymemory:[],optimizationprogress:[]},this.loadDistance=100,this.unloadDistance=150,this.checkInterval=1e3,this.nodes=new Map,this.loadedMeshes=new Map,this.nodesToLoad=[],this.edgeNodes=[],this.structures=[],this.structureRoots=new Map,this.memoryLimit=this.getAvailableMemory(),this.optimizationMemoryMultiplier=5,this.memoryEstimationFactor=1.7,this.loadedGeometrySize=0,this.geometryCache=new Map,this.materialCache=new Map,this.textureCache=new Map,this.currentMemoryUsage=0,this.pendingMemoryUsage=0,this.updateMemoryIndicator(),this.loadedMaterials=new Map,this.abortController=new AbortController,this.batchSize=1e4,this.frameDelay=0,this.graphicsObjectLimit=1e4,this.totalLoadedObjects=0,this.handleToObjects=new Map,this.originalObjects=new Set,this.originalObjectsToSelection=new Set,this.optimizedOriginalMap=new Map,this.mergedMesh=new Set,this.mergedLines=new Set,this.mergedLineSegments=new Set,this.mergedPoints=new Set,this.isolatedObjects=[],
|
|
36
36
|
//!!window.WebGL2RenderingContext && this.renderer.getContext() instanceof WebGL2RenderingContext
|
|
37
|
-
this.useVAO=!1,this.visibleEdges=!0,this.handleToOptimizedObjects=new Map,this.hiddenHandles=new Set,this.newOptimizedObjects=new Set,this.oldOptimizeObjects=new Set,this.objectTransforms=new Map,this.transformedGeometries=new Map,this.activeChunkLoads=0,this.chunkQueue=[],this.objectIdToIndex=new Map,this.maxObjectId=0,this.objectVisibility=new Float32Array,this.maxConcurrentChunks=6,this.mergedObjectMap=new Map,this.mergedGeometryVisibility=new Map,this._webglInfoCache=null}setVisibleEdges(t){this.visibleEdges=t}getAvailableMemory(){let t=6442450944;try{if(navigator.deviceMemory)t=1024*navigator.deviceMemory*1024*1024;else if(performance.memory){const e=performance.memory.jsHeapSizeLimit;e&&(t=Math.min(t,e))}t=Math.min(t,17179869184),t=Math.max(t,2147483648),console.log(`Available memory set to ${Math.round(t/1073741824)}GB`)}catch(t){console.warn("Error detecting available memory:",t)}return t/3}getAbortController(){return this.abortController}abortLoading(){this.abortController.abort()}updateMemoryIndicator(){this.dispatchEvent("geometrymemory",{currentUsage:this.currentMemoryUsage,limit:this.memoryLimit})}setMemoryLimit(t){}estimateGeometrySize(t){let e=0;return t.traverse(t=>{if(t.geometry){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=t.geometry;i.attributes&&Object.values(i.attributes).forEach(t=>{t&&t.array&&(e+=t.array.byteLength)}),i.index&&i.index.array&&(e+=i.index.array.byteLength)}}),e}recalculateScene(){const t=[];if(this.scene.traverse(e=>{if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");if(e.geometry&&!this.geometryCache.has(e.geometry.uuid)){const i=this.estimateGeometrySize(e);this.geometryCache.set(e.geometry.uuid,i),t.push({object:e,size:i,distance:e.position.distanceTo(this.camera.position)})}}),this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");t.sort((t,e)=>e.distance-t.distance);let e=0;for(const i of t)e+=i.size;if(e>this.memoryLimit){console.log(`Memory usage (${Math.round(e/1048576)}MB) exceeds limit`);for(const i of t){if(e<=this.memoryLimit)break;if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=i.object;t.geometry&&(e-=i.size,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose(),t.visible=!1)}}this.currentMemoryUsage=e,this.updateMemoryIndicator(),console.log(`Final memory usage: ${Math.round(e/1048576)}MB`)}getStats(){let t=0,e=0,i=0,n=0,s=0,r=0,a=0,o=0;this.scene.traverse(h=>{t++;const l=h.geometry;if(!l)return;let c=0;l.index?c=Math.floor(l.index.count/3):l.attributes&&l.attributes.position&&(c=Math.floor(l.attributes.position.count/3)),i+=c;let d=0;l.index?d=Math.floor(l.index.count/2):l.attributes&&l.attributes.position&&(d=Math.floor(l.attributes.position.count/2)),"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?a+=d:s+=d),!1!==h.visible&&(h.isMesh||h.isLine||h.isPoints)&&(e++,h.isMesh?n+=c:"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?o+=d:r+=d))});const h=this.geometryCache?this.geometryCache.size:0,l=Array.from(this.geometryCache?.values?.()||[]).reduce((t,e)=>t+e,0),c=new Set,d=new Set;if(Array.isArray(this.structures))for(const t of this.structures)try{for(const e of t.materialCache.values())e?.mesh?.uuid&&c.add(e.mesh.uuid),e?.points?.uuid&&c.add(e.points.uuid),e?.lines?.uuid&&c.add(e.lines.uuid)}catch(t){console.error("Error adding material to uniqueMaterialIds",t)}const u=c.size,p=d.size,m=l;if(!this._webglInfoCache)try{const t=this.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");if(e){const i=t.getParameter(e.UNMASKED_RENDERER_WEBGL),n=t.getParameter(e.UNMASKED_VENDOR_WEBGL);this._webglInfoCache={renderer:i,vendor:n}}else this._webglInfoCache={renderer:null,vendor:null}}catch(t){console.error("Error getting webgl info",t),this._webglInfoCache={renderer:null,vendor:null}}const f=new Ai;return this.renderer&&this.renderer.getSize&&this.renderer.getSize(f),{scene:{beforeOptimization:{objects:t-e,triangles:i-n,lines:s-r,edges:a-o},afterOptimization:{objects:e,triangles:n,lines:r,edges:o}},memory:{geometries:{count:h,bytes:l},textures:{count:p},materials:{count:u},totalEstimatedGpuBytes:m},system:{webglRenderer:this._webglInfoCache?.renderer||"",webglVendor:this._webglInfoCache?.vendor||"",viewport:{width:f.x||0,height:f.y||0}}}}async loadNode(t,e){const i=this.nodes.get(t);if(!i||i.loaded||i.loading)return;i.loading=!0;const n=i.structure.getJson().meshes[i.meshIndex];try{const t=[],s=new Map;for(let e=0;e<n.primitives.length;e++){const r=n.primitives[e],a=[];if(void 0!==r.attributes.POSITION){const t=r.attributes.POSITION,n=i.structure.json.accessors[t],s=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:s,length:h,componentType:n.componentType,accessorIndex:t,type:"position",primIdx:e})}if(void 0!==r.attributes.NORMAL){const t=r.attributes.NORMAL,n=i.structure.json.accessors[t],s=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:s,length:h,componentType:n.componentType,accessorIndex:t,type:"normal",primIdx:e})}if(void 0!==r.attributes.TEXCOORD_0){const t=r.attributes.TEXCOORD_0,n=i.structure.json.accessors[t],s=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:s,length:h,componentType:n.componentType,accessorIndex:t,type:"uv",primIdx:e})}if(void 0!==r.indices){const t=r.indices,n=i.structure.json.accessors[t],s=(i.structure.json.bufferViews[n.bufferView].byteOffset||0)+(n.byteOffset||0),o=i.structure.getNumComponents(n.type),h=n.count*o*i.structure.getComponentSize(n.componentType);a.push({offset:s,length:h,componentType:n.componentType,accessorIndex:t,type:"index",primIdx:e})}s.set(e,a),t.push(...a)}if(0===t.length)return i.loaded=!0,void(i.loading=!1);t.sort((t,e)=>t.offset-e.offset);const r=t[0].offset,a=Math.max(...t.map(t=>t.offset+t.length))-r,{buffer:o,relOffset:h}=await i.structure.scheduleRequest({offset:r,length:a,componentType:null});for(const e of t){const t=e.offset-r;e.data=i.structure.createTypedArray(o,h+t,e.length,e.componentType)}for(let t=0;t<n.primitives.length;t++){const e=n.primitives[t],r=new zs,a=s.get(t);if(void 0!==e.attributes.POSITION){const t=a.find(t=>"position"===t.type&&t.accessorIndex===e.attributes.POSITION),n=i.structure.json.accessors[e.attributes.POSITION],s=i.structure.getNumComponents(n.type);r.setAttribute("position",new Ls(t.data,s))}if(void 0!==e.attributes.NORMAL){const t=a.find(t=>"normal"===t.type&&t.accessorIndex===e.attributes.NORMAL),n=i.structure.json.accessors[e.attributes.NORMAL],s=i.structure.getNumComponents(n.type);r.setAttribute("normal",new Ls(t.data,s))}if(void 0!==e.attributes.TEXCOORD_0){const t=a.find(t=>"uv"===t.type&&t.accessorIndex===e.attributes.TEXCOORD_0),n=i.structure.json.accessors[e.attributes.TEXCOORD_0],s=i.structure.getNumComponents(n.type);r.setAttribute("uv",new Ls(t.data,s))}if(void 0!==e.indices){const t=a.find(t=>"index"===t.type&&t.accessorIndex===e.indices);r.setIndex(new Ls(t.data,1))}let o,h;if(void 0!==e.material){if(o=i.structure.getCachedMaterial(e.material,e.mode),!o){const t=i.structure.json.materials[e.material];o=i.structure.createMaterial(t,e.mode)}}else o=this.createDefaultMaterial(e.mode);e.mode===bg?h=new oo(r,o):e.mode===Tg||e.mode===Eg||e.mode===Ag||void 0===e.mode?(h=new Qs(r,o),e.mode===Eg?h.drawMode=1:e.mode===Ag&&(h.drawMode=2)):e.mode===Sg?h=new to(r,o):e.mode===Mg?h=new Ka(r,o):e.mode===wg&&(h=new eo(r,o)),i.extras&&(h.userData={...h.userData,...i.extras}),n.extras&&(h.userData={...h.userData,...n.extras}),e.extras&&(h.userData={...h.userData,...e.extras}),i.handle?h.userData.handle=i.handle:h.userData.handle=this.getFullHandle(i.structure.id,h.userData.handle),"edges"===h.material.name?h.userData.isEdge=!0:h.userData.isEdge=!1,this.registerObjectWithHandle(h,h.userData.handle),h.position.copy(i.position),r.attributes.normal||r.computeVertexNormals(),o.aoMap&&r.attributes.uv&&r.setAttribute("uv2",r.attributes.uv),i.group?i.group.add(h):this.scene.add(h),i.object=h,this.totalLoadedObjects++,h.visible=this.totalLoadedObjects<this.graphicsObjectLimit}i.loaded=!0,i.loading=!1;const l=this.estimateGeometrySize(i.object);this.geometryCache.set(i.object.uuid,l),this.currentMemoryUsage+=l,e&&e()}catch(e){if(i.loading=!1,"AbortError"===e.name)return;if(i.structure&&i.structure.loadingAborted)return;console.error(`Error loading node ${t}:`,e)}}unloadNode(t){const e=this.nodes.get(t);e&&e.loaded&&e.object&&(e.object.parent?e.object.parent.remove(e.object):this.scene.remove(e.object),e.object.traverse(t=>{if(t.geometry){const e=this.geometryCache.get(t.geometry.uuid)||0;this.currentMemoryUsage-=e,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose()}}),e.object=null,e.loaded=!1,this.updateMemoryIndicator(),console.log(`Unloaded node: ${t}`))}checkDistances(){const t=this.camera.position;this.nodes.forEach((e,i)=>{const n=t.distanceTo(e.position);e.loaded?n>this.unloadDistance&&this.unloadNode(i):e.loading||n<this.loadDistance&&this.loadNode(i)})}async loadStructure(t){this.clear();const e=Array.isArray(t)?t:[t];for(const t of e)await t.initialize(this),this.structures.push(t);for(const t of this.structures)try{await t.loadTextures(),await t.loadMaterials()}catch(t){throw console.error("Error loading materials:",t),t}await this.processSceneHierarchy()}async processSceneHierarchy(){if(0===this.structures.length)throw new Error("No GLTF structures loaded");this.nodesToLoad=[];let t=0;for(const e of this.structures){const i=e.getJson();if(!i.scenes||!i.scenes.length){console.warn("No scenes found in GLTF structure");continue}t+=i.buffers[0].byteLength;const n=new fr;n.name=`structure_${e.id}_root`,this.scene.add(n),this.structureRoots.set(e.id,n);const s=i.scenes[i.scene||0];for(const t of s.nodes)await this.processNodeHierarchy(e,t,n)}const e=2*t>this.memoryLimit;this.nodesToLoad.sort((t,e)=>{const i=this.nodes.get(t),n=this.nodes.get(e);if(!i?.geometryExtents||!n?.geometryExtents)return 0;const s=i.geometryExtents.getSize(new Li),r=n.geometryExtents.getSize(new Li),a=s.x*s.y*s.z;return r.x*r.y*r.z-a}),!e&&this.visibleEdges&&this.nodesToLoad.push(...this.edgeNodes),this.dispatchEvent("databasechunk",{totalNodes:this.nodesToLoad.length,structures:this.structures.map(t=>({id:t.id,nodeCount:this.nodesToLoad.filter(e=>e.startsWith(t.id)).length}))})}getFullHandle(t,e){return`${t}:${e}`}async processNodeHierarchy(t,e,i){const n=t.json.nodes[e];let s=null,r=null;if(n.extras?.handle&&(r=this.getFullHandle(t.id,n.extras.handle)),void 0!==n.camera){const e=this.loadCamera(t,n.camera,n);return n.extras&&(e.userData={...e.userData,...n.extras}),void this.scene.add(e)}if(this.needsGroupForNode(t,n)){if(s=new fr,s.name=n.name||`node_${e}`,n.extras&&(s.userData={...n.extras},s.userData.handle&&(s.userData.handle=this.getFullHandle(t.id,s.userData.handle))),n.matrix)s.matrix.fromArray(n.matrix),s.matrixAutoUpdate=!1;else if(n.translation||n.rotation||n.scale){const t=n.translation?(new Li).fromArray(n.translation):new Li,e=n.rotation?(new Ci).fromArray(n.rotation):new Ci,i=n.scale?(new Li).fromArray(n.scale):new Li(1,1,1);s.matrix.compose(t,e,i),s.matrixAutoUpdate=!1}i&&i.add(s)}if(void 0!==n.mesh){const a=new En,o=`${t.id}_${e}`,h=t.json.meshes[n.mesh],l=new Qi;for(const e of h.primitives){const i=t.json.accessors[e.attributes.POSITION];if(i&&i.min&&i.max){const t=new Qi((new Li).fromArray(i.min),(new Li).fromArray(i.max));l.union(t)}}let c=!1;if(void 0!==h.primitives[0].material){const e=t.json.materials[h.primitives[0].material];"edges"===e?.name&&(c=!0)}c?this.edgeNodes.push(o):this.nodesToLoad.push(o),h.extras&&h.extras.handle&&(r=this.getFullHandle(t.id,h.extras.handle)),this.nodes.set(o,{position:s?s.position.clone():(new Li).setFromMatrixPosition(a),nodeIndex:e,meshIndex:n.mesh,loaded:!1,loading:!1,object:null,group:s||i,structure:t,extras:n.extras,geometryExtents:l,handle:r||this.getFullHandle(t.id,t._nextObjectId++)})}if(n.children)for(const e of n.children)await this.processNodeHierarchy(t,e,s||i);return s}needsGroupForNode(t,e){const i=e.matrix||e.translation||e.rotation||e.scale,n=void 0!==e.mesh&&t.json.meshes[e.mesh].primitives.length>1;return void 0!==i||n}async processNodes(){const t=this.nodesToLoad;let e=0,i=0;const n=t.length,s=async()=>{e++,e-i>1e3&&(i=e,this.updateMemoryIndicator(),this.dispatchEvent("geometryprogress",{percentage:Math.round(e/n*100),loaded:e,total:n}),this.dispatchEvent("update"),await new Promise(t=>{setTimeout(t,0)}))};try{const i=[];for(const n of t){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=await this.estimateNodeSize(n);if(this.currentMemoryUsage+t>this.memoryLimit)return console.log(`Memory limit reached after loading ${e} nodes`),this.dispatchEvent("geometryerror",{message:"Memory limit reached"}),this.dispatchEvent("update"),e;i.push(this.loadNode(n,s))}for(const t of this.structures)i.push(t.flushBufferRequests());return await Promise.all(i),this.dispatchEvent("geometryend",{totalLoaded:e,totalNodes:n}),e}catch(t){throw this.dispatchEvent("geometryerror",{error:t}),t}}async loadNodes(){console.time("Process nodes"),await this.processNodes(),console.timeEnd("Process nodes"),console.time("Optimize scene"),await this.optimizeScene(),console.timeEnd("Optimize scene")}cleanupPartialLoad(){this.nodesToLoad.forEach(t=>{const e=this.nodes.get(t);e&&e.loading&&this.unloadNode(t)})}createDefaultMaterial(t=void 0){return t===bg?new io({color:new _s(8421504),size:.05,sizeAttenuation:!1,alphaTest:.5,transparent:!0,vertexColors:!1,blending:1,depthWrite:!1,depthTest:!0}):t===Sg||t===Mg||t===wg?new Ha({color:8421504,linewidth:1,alphaTest:.1,depthTest:!0,depthWrite:!0,transparent:!0,opacity:1}):new Xh({color:8421504,specular:2236962,shininess:10,side:2})}async estimateNodeSize(t){const e=this.nodes.get(t);return e?await e.structure.estimateNodeSize(e.meshIndex):0}getTotalGeometryExtent(){const t=new Qi;for(const e of this.nodes.values()){if(!e.geometryExtents)continue;if(e.object&&this.hiddenHandles.has(e.object.userData.handle))continue;const i=e.geometryExtents.clone(),n=e.structure?this.structureRoots.get(e.structure.id):null;if(e.group){const t=new En;let s=e.group;for(;s&&s!==n;)t.premultiply(s.matrix),s=s.parent;t.equals(new En)||i.applyMatrix4(t)}n&&n.matrix&&i.applyMatrix4(n.matrix);const s=this.objectTransforms.get(e.object);s&&i.applyMatrix4(s),t.union(i)}return this.scene&&this.scene.matrix&&!t.isEmpty()&&t.applyMatrix4(this.scene.matrix),t}loadCamera(t,e,i){const n=t.getJson().cameras[e],s=n[n.type];let r;return"perspective"===n.type?r=new cr(Ei.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===n.type&&(r=new Bl(s.xmag/-2,s.xmag/2,s.ymag/2,s.ymag/-2,s.znear,s.zfar)),i.matrix?(r.matrix.fromArray(i.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)):(i.translation&&r.position.fromArray(i.translation),i.rotation&&r.quaternion.fromArray(i.rotation),i.scale&&r.scale.fromArray(i.scale)),r}clearNodesToLoad(){this.nodesToLoad=[]}removeOptimization(){this.originalObjects.forEach(t=>t.visible=!0);const t=t=>{t.parent&&t.parent.remove(t),t.geometry&&t.geometry.dispose()};if(this.structureGroups)for(const e of this.structureGroups.values())e.meshes.forEach(t),e.lines.forEach(t),e.lineSegments.forEach(t),e.meshes.clear(),e.lines.clear(),e.lineSegments.clear();this.optimizedOriginalMap.clear(),this.mergedMesh.clear(),this.mergedLines.clear(),this.mergedLineSegments.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear()}initializeObjectVisibility(){if(this.maxObjectId>0){this.objectVisibility=new Float32Array(this.maxObjectId);for(let t=0;t<this.maxObjectId;t++)this.objectVisibility[t]=1}}createVisibilityMaterial(t){return t.onBeforeCompile=t=>{t.vertexShader=t.vertexShader.replace("#include <common>","\n #include <common>\n attribute float visibility;\n varying float vVisibility;\n "),t.fragmentShader=t.fragmentShader.replace("#include <common>","\n #include <common>\n varying float vVisibility;\n "),t.vertexShader=t.vertexShader.replace("void main() {","\n void main() {\n vVisibility = visibility;\n "),t.fragmentShader=t.fragmentShader.replace("void main() {","\n void main() {\n if (vVisibility < 0.5) discard;\n ")},t.needsUpdate=!0,t}clear(){this.chunkQueue=[],this.structures.forEach(t=>{t&&t.clear()}),this.structures=[],this.nodes.forEach(t=>{t.object&&(t.object.parent&&t.object.parent.remove(t.object),t.object.geometry&&t.object.geometry.dispose(),t.object.material&&(Array.isArray(t.object.material)?t.object.material.forEach(t=>t.dispose()):t.object.material.dispose()))}),this.nodes.clear(),this.loadedMeshes.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),this.loadedMeshes.clear(),this.structureRoots.forEach(t=>{t&&(t.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),t.parent&&t.parent.remove(t))}),this.structureRoots.clear(),this.mergedMesh.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose()),t.parent&&t.parent.remove(t)}),this.mergedMesh.clear(),this.mergedLines.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLines.clear(),this.mergedLineSegments.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLineSegments.clear(),this.mergedPoints.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedPoints.clear(),this.geometryCache.clear(),this.materialCache.clear(),this.textureCache.clear(),this.loadedMaterials.clear(),this.nodesToLoad=[],this.handleToObjects.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear(),this.optimizedOriginalMap.clear(),this.handleToOptimizedObjects.clear(),this.hiddenHandles.clear(),this.newOptimizedObjects.clear(),this.oldOptimizeObjects.clear(),this.isolatedObjects=[],this.objectTransforms.clear(),this.transformedGeometries.clear(),this.totalLoadedObjects=0,this.currentMemoryUsage=0,this.loadedGeometrySize=0,this.abortController=new AbortController,this.updateMemoryIndicator(),this.objectIdToIndex.clear(),this.maxObjectId=0,this.objectVisibility=new Float32Array}setStructureTransform(t,e){const i=this.structureRoots.get(t);return!!i&&(i.matrix.copy(e),i.matrix.decompose(i.position,i.quaternion,i.scale),!0)}getStructureRootGroup(t){return this.structureRoots.get(t)}addEventListener(t,e){this.eventHandlers[t]&&this.eventHandlers[t].push(e)}removeEventListener(t,e){this.eventHandlers[t]&&(this.eventHandlers[t]=this.eventHandlers[t].filter(t=>t!==e))}dispatchEvent(t,e){this.eventHandlers[t]&&this.eventHandlers[t].forEach(t=>t(e))}registerObjectWithHandle(t,e){if(!e)return;const i=t.userData.handle;this.handleToObjects.has(i)||this.handleToObjects.set(i,new Set),this.handleToObjects.get(i).add(t),t.userData.structureId=t.userData.handle.split(":")[0]}getObjectsByHandle(t){return t?Array.from(this.handleToObjects.get(t)||[]):[]}getHandlesByObjects(t){if(!t.length)return[];const e=new Set;return t.forEach(t=>{this.originalObjects.has(t)&&e.add(t.userData.handle)}),Array.from(e)}getMaterialId(t,e){const i={type:t.type,color:t.color?.getHex(),map:t.map?.uuid,transparent:t.transparent,opacity:t.opacity,side:t.side,index:e?1:0};return JSON.stringify(i)}addToMaterialGroup(t,e,i){const n=t.geometry.attributes.position.count,s=t.geometry.index?t.geometry.index.count:0,r=t.material;let a,o=this.getMaterialId(r,null!==t.geometry.index);if(e.has(o))if(a=e.get(o),a.totalVertices+n>1e5||a.totalIndices+s>1e5){const a={material:r,objects:[t],totalVertices:n,totalIndices:s};o=this.getMaterialId(r,null!==t.geometry.index),e.set(o,a),i.push(a)}else a.objects.push(t),a.totalVertices+=n,a.totalIndices+=s;else a={material:r,objects:[t],totalVertices:n,totalIndices:s},e.set(o,a),i.push(a);this.originalObjects.add(t)}yieldToUI(){return new Promise(t=>{setTimeout(t,0)})}async optimizeScene(){console.log("Starting scene optimization..."),this.dispatchEvent("optimizationprogress",{phase:"start",progress:0,message:"Starting optimization..."}),this.originalObjects.clear(),this.originalObjectsToSelection.clear();const t=new Map;this.dispatchEvent("optimizationprogress",{phase:"collecting",progress:5,message:"Collecting scene objects..."}),this.scene.traverse(e=>{if(e.userData.structureId){const i=e.userData.structureId;t.has(i)||t.set(i,{mapMeshes:new Map,mapLines:new Map,mapLineSegments:new Map,mapPoints:new Map,meshes:[],lines:[],lineSegments:[],points:[],rootGroup:this.structureRoots.get(i)});const n=t.get(i);e instanceof Qs?this.addToMaterialGroup(e,n.mapMeshes,n.meshes):e instanceof to?this.addToMaterialGroup(e,n.mapLineSegments,n.lineSegments):e instanceof Ka?this.addToMaterialGroup(e,n.mapLines,n.lines):e instanceof oo&&this.addToMaterialGroup(e,n.mapPoints,n.points)}});let e=0;const i=t.size;this.dispatchEvent("optimizationprogress",{phase:"merging",progress:10,message:`Merging ${i} structure groups...`,current:0,total:i});for(const n of t.values()){n.mapMeshes.clear(),n.mapLines.clear(),n.mapLineSegments.clear(),n.mapPoints.clear(),await this.mergeMeshGroups(n.meshes,n.rootGroup),await this.yieldToUI(),await this.mergeLineGroups(n.lines,n.rootGroup),await this.yieldToUI(),await this.mergeLineSegmentGroups(n.lineSegments,n.rootGroup),await this.yieldToUI(),await this.mergePointsGroups(n.points,n.rootGroup),e++;const t=10+Math.round(e/i*80);this.dispatchEvent("optimizationprogress",{phase:"merging",progress:t,message:`Processing structure ${e}/${i}...`,current:e,total:i}),console.log(`Optimization progress: ${e}/${i} structure groups processed (${t}%)`),await this.yieldToUI()}this.dispatchEvent("optimizationprogress",{phase:"finalizing",progress:95,message:"Finalizing optimization..."}),this.originalObjects.forEach(t=>{t.visible=!1,t instanceof oo||t.userData.isEdge||this.originalObjectsToSelection.add(t)}),this.initializeObjectVisibility(),console.log(`Optimization complete. Total objects: ${this.maxObjectId}`),this.dispatchEvent("optimizationprogress",{phase:"complete",progress:100,message:`Optimization complete! ${this.maxObjectId} objects processed.`}),this.dispatchEvent("update")}async mergeMeshGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],s=new Set,r=[],a=new Map;let o=0;for(const i of n.objects){const n=i.geometry.clone(),h=new En;let l=i;for(;l&&l!==e;)h.premultiply(l.matrix),l=l.parent;h.equals(new En)||n.applyMatrix4(h);const c=i.userData.handle;this.objectIdToIndex.has(c)||this.objectIdToIndex.set(c,this.maxObjectId++);const d=this.objectIdToIndex.get(c),u=n.attributes.position.count,p=new Float32Array(u);for(let t=0;t<u;t++)p[t]=d;n.setAttribute("objectId",new Ls(p,1)),a.set(i,{geometry:n,startVertexIndex:o,vertexCount:n.attributes.position.count}),o+=n.attributes.position.count,t.push(n),r.push(i),s.add(i.userData.handle)}const h=[];if(t.length>0){const i=Rg(t),s=i.attributes.position.count,o=new Float32Array(s);for(let t=0;t<s;t++)o[t]=1;i.setAttribute("visibility",new Ls(o,1)),this.useVAO&&this.createVAO(i);const l=this.createVisibilityMaterial(n.material),c=new Qs(i,l);c.userData.isOptimized=!0,e.add(c),this.mergedMesh.add(c),this.optimizedOriginalMap.set(c,r),this.mergedObjectMap.set(c.uuid,{objectMapping:a,visibilityArray:o,totalVertices:s}),this.mergedGeometryVisibility.set(c,o),h.push(c),t.forEach(t=>{t.dispose()})}s.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...h),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,h)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.error("Failed to merge meshes for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping mesh group with null material")}async mergeLineGroups(t,e){let i=0;for(const n of t){if(0===n.objects.length)continue;if(!n.material){console.warn("Skipping line group with null material");continue}const t=new Set;let s=0;const r=new Map;let a=0;n.objects.map(e=>{t.add(e.userData.handle),s+=e.geometry.attributes.position.count});const o=new Float32Array(3*s);let h=0;const l=[];let c=0,d=!1;n.objects.forEach(t=>{d=t.userData.isEdge;const i=t.geometry.clone(),n=new En;let s=t;for(;s&&s!==e;)n.premultiply(s.matrix),s=s.parent;n.equals(new En)||i.applyMatrix4(n);const u=i.attributes.position,p=u.count,m=t.userData.handle;this.objectIdToIndex.has(m)||this.objectIdToIndex.set(m,this.maxObjectId++),r.set(t,{startVertexIndex:a,vertexCount:p}),a+=p;const f=new Li;for(let t=0;t<p;t++)f.fromBufferAttribute(u,t),o[h++]=f.x,o[h++]=f.y,o[h++]=f.z;for(let t=0;t<p-1;t++)l.push(c+t,c+t+1);c+=p,i.dispose()});const u=new zs;u.setAttribute("position",new Ls(o,3)),u.setIndex(l),u.computeBoundingSphere(),u.computeBoundingBox();const p=new Float32Array(s);let m=0;n.objects.forEach(t=>{const e=t.geometry.attributes.position.count,i=t.userData.handle,n=this.objectIdToIndex.get(i);for(let t=0;t<e;t++)p[m++]=n}),u.setAttribute("objectId",new Ls(p,1));const f=new Float32Array(s);for(let t=0;t<s;t++)f[t]=1;u.setAttribute("visibility",new Ls(f,1));const g=this.createVisibilityMaterial(n.material),v=new to(u,g);v.userData.isEdge=d,v.userData.isOptimized=!0;const _=[v];this.useVAO&&this.createVAO(v),e.add(v),this.mergedLines.add(v),this.optimizedOriginalMap.set(v,n.objects),this.mergedObjectMap.set(v.uuid,{objectMapping:r,visibilityArray:f,totalVertices:s}),this.mergedGeometryVisibility.set(v,f),t.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(..._),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,_)}),i++,i%5==0&&await this.yieldToUI()}}async mergeLineSegmentGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],s=[],r=new Set,a=new Map;let o=0,h=!1;for(const i of n.objects){h=i.userData.isEdge;const n=i.geometry.clone(),l=new En;let c=i;for(;c&&c!==e;)l.premultiply(c.matrix),c=c.parent;l.equals(new En)||n.applyMatrix4(l);const d=i.userData.handle;this.objectIdToIndex.has(d)||this.objectIdToIndex.set(d,this.maxObjectId++);const u=this.objectIdToIndex.get(d),p=n.attributes.position.count,m=new Float32Array(p);for(let t=0;t<p;t++)m[t]=u;n.setAttribute("objectId",new Ls(m,1)),a.set(i,{geometry:n,startVertexIndex:o,vertexCount:n.attributes.position.count}),o+=n.attributes.position.count,t.push(n),s.push(i),r.add(i.userData.handle)}const l=[];if(t.length>0){const i=Rg(t,!1),r=i.attributes.position.count,o=new Float32Array(r);for(let t=0;t<r;t++)o[t]=1;i.setAttribute("visibility",new Ls(o,1));const c=this.createVisibilityMaterial(n.material),d=new to(i,c);d.userData.isEdge=h,d.userData.isOptimized=!0,this.useVAO&&this.createVAO(d),e.add(d),this.mergedLineSegments.add(d),this.optimizedOriginalMap.set(d,s),this.mergedObjectMap.set(d.uuid,{objectMapping:a,visibilityArray:o,totalVertices:r}),this.mergedGeometryVisibility.set(d,o),l.push(d),t.forEach(t=>{t.dispose()})}r.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...l),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,l)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge line segments for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping line segment group with null material")}async mergePointsGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],s=[],r=new Set;for(const i of n.objects){const n=i.geometry.clone(),a=new En;let o=i;for(;o&&o!==e;)a.premultiply(o.matrix),o=o.parent;a.equals(new En)||n.applyMatrix4(a),t.push(n),s.push(i),r.add(i.userData.handle)}const a=[];if(t.length>0){const i=Rg(t,!1),r=new oo(i,n.material);r.userData.isOptimized=!0,this.useVAO&&this.createVAO(r),e.add(r),this.mergedPoints.add(r),this.optimizedOriginalMap.set(r,s),a.push(r),t.forEach(t=>{t.dispose()})}r.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...a),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,a)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge points for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping points group with null material")}mergeInSingleSegment(t,e){const i=[...this.mergedLineSegments,...this.mergedLines].filter(e=>e.userData.structureId===t);if(0!==i.length)try{const n=[],s=i.some(t=>void 0!==t.geometry.attributes.normal);i.forEach(t=>{const e=t.geometry.clone();e.applyMatrix4(t.matrixWorld),s&&!e.attributes.normal&&e.computeVertexNormals(),!s&&e.attributes.normal&&e.deleteAttribute("normal");const i=new Float32Array(3*e.attributes.position.count);for(let e=0;e<i.length;e+=3)i[e]=t.material.color.r,i[e+1]=t.material.color.g,i[e+2]=t.material.color.b;if(e.setAttribute("color",new Ls(i,3)),!e.index){const t=[],i=e.attributes.position.count;for(let e=0;e<i-1;e+=2)t.push(e,e+1);e.setIndex(t)}n.push(e)});const r=Rg(n,!1),a=new Ha({vertexColors:!0});this.useVAO&&this.createVAO(r);const o=new to(r,a);o.userData.structureId=t,o.userData.isOptimized=!0,e.add(o),this.mergedLineSegments.add(o),i.forEach(t=>{t.parent&&t.parent.remove(t),t.geometry.dispose()})}catch(t){console.error("Failed to merge geometries:",t),i.forEach(t=>{t.visible=!0,e.add(t)})}}showOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!0)})}hideOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!1)})}createVAO(t){if(!this.useVAO)return;if(t.attributes?.position?.count<1e3)return;const e=this.renderer.getContext(),i=e.createVertexArray();e.bindVertexArray(i);for(const i in t.attributes){const n=t.attributes[i],s=this.renderer.properties.get(n).buffer;e.bindBuffer(e.ARRAY_BUFFER,s),e.enableVertexAttribArray(n.itemSize),e.vertexAttribPointer(n.itemSize,n.itemSize,e.FLOAT,!1,0,0)}if(t.index){const i=this.renderer.properties.get(t.index).buffer;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i)}e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),t.vao=i}getOriginalObjectForSelect(){const t=[];for(const e of this.originalObjectsToSelection)this.hiddenHandles.has(e.userData.handle)||t.push(e);return t}isolateObjects(t){0!==this.hiddenHandles.size&&(this.hiddenHandles.clear(),this.syncHiddenObjects());for(const e of this.handleToOptimizedObjects.keys())t.has(e)||this.hiddenHandles.add(e);this.syncHiddenObjects()}showAllHiddenObjects(){this.hiddenHandles.clear(),this.syncHiddenObjects()}hideObjects(t){t.forEach(t=>{this.hiddenHandles.add(t)}),this.syncHiddenObjects()}showObjects(t){t.forEach(t=>{this.hiddenHandles.delete(t)}),this.syncHiddenObjects()}_updateVisibilityAttribute(t){if(t.geometry&&t.geometry.attributes.visibility&&t.geometry.attributes.objectId){const e=t.geometry.attributes.visibility.array,i=t.geometry.attributes.objectId.array;for(let t=0;t<e.length;t++){const n=i[t];n<this.objectVisibility.length&&(e[t]=this.objectVisibility[n])}t.geometry.attributes.visibility.needsUpdate=!0}}applyObjectTransforms(t){if(0!==this.mergedObjectMap.size){this.objectTransforms=new Map(t);for(const t of this.mergedMesh)this._applyTransformToMergedObject(t);for(const t of this.mergedLines)this._applyTransformToMergedObject(t);for(const t of this.mergedLineSegments)this._applyTransformToMergedObject(t);for(const t of this.mergedPoints)this._applyTransformToMergedObject(t)}else console.warn("No merged objects to transform")}createExplodeTransforms(t=null,e=null,i=1.5){const n=new Map;if(!e){e=new Li;const t=this.getTotalGeometryExtent();t.isEmpty()||t.getCenter(e)}const s=t?Array.isArray(t)?t:Array.from(t):Array.from(this.originalObjects);for(const t of s){if(!t.geometry||!t.geometry.attributes.position)continue;const s=(new Qi).setFromBufferAttribute(t.geometry.attributes.position);if(t.matrixWorld&&s.applyMatrix4(t.matrixWorld),s.isEmpty())continue;const r=new Li;s.getCenter(r);const a=r.clone().sub(e),o=a.length();if(o>0){a.normalize();const e=a.multiplyScalar(o*(i-1)),s=(new En).makeTranslation(e.x,e.y,e.z);n.set(t,s)}}return n}clearTransforms(){this.objectTransforms.clear();for(const t of this.mergedMesh)this._restoreOriginalGeometry(t);for(const t of this.mergedLines)this._restoreOriginalGeometry(t);for(const t of this.mergedLineSegments)this._restoreOriginalGeometry(t);for(const t of this.mergedPoints)this._restoreOriginalGeometry(t)}clearHandleTransforms(){this.clearTransforms()}_applyTransformToMergedObject(t){const e=this.mergedObjectMap.get(t.uuid);if(!e||!e.objectMapping)return;const i=t.geometry;if(!i||!i.attributes.position)return;const n=i.attributes.position,s=n.array;this.transformedGeometries.has(t.uuid)||this.transformedGeometries.set(t.uuid,new Float32Array(s));const r=this.transformedGeometries.get(t.uuid),a=new Li;for(const[t,i]of e.objectMapping){const e=this.objectTransforms.get(t);if(!e){const t=3*i.startVertexIndex,e=3*(i.startVertexIndex+i.vertexCount);for(let i=t;i<e;i++)s[i]=r[i];continue}const n=i.startVertexIndex,o=i.vertexCount;for(let t=0;t<o;t++){const i=3*(n+t);a.set(r[i],r[i+1],r[i+2]),a.applyMatrix4(e),s[i]=a.x,s[i+1]=a.y,s[i+2]=a.z}}i.attributes.normal&&this._updateNormalsForTransform(i,e,r),n.needsUpdate=!0,i.computeBoundingSphere(),i.computeBoundingBox()}_updateNormalsForTransform(t,e,i){const n=t.attributes.normal;if(!n)return;const s=n.array,r=new Li,a=new En,o=`${t.uuid}_normals`;this.transformedGeometries.has(o)||this.transformedGeometries.set(o,new Float32Array(s));const h=this.transformedGeometries.get(o);for(const[t,i]of e.objectMapping){const e=this.objectTransforms.get(t);if(!e){const t=3*i.startVertexIndex,e=3*(i.startVertexIndex+i.vertexCount);for(let i=t;i<e;i++)s[i]=h[i];continue}a.copy(e).invert().transpose();const n=i.startVertexIndex,o=i.vertexCount;for(let t=0;t<o;t++){const e=3*(n+t);r.set(h[e],h[e+1],h[e+2]),r.applyMatrix4(a).normalize(),s[e]=r.x,s[e+1]=r.y,s[e+2]=r.z}}n.needsUpdate=!0}_restoreOriginalGeometry(t){const e=t.geometry;if(!e||!e.attributes.position)return;const i=this.transformedGeometries.get(t.uuid);if(i){e.attributes.position.array.set(i),e.attributes.position.needsUpdate=!0}const n=`${e.uuid}_normals`,s=this.transformedGeometries.get(n);if(s&&e.attributes.normal){e.attributes.normal.array.set(s),e.attributes.normal.needsUpdate=!0}e.computeBoundingSphere(),e.computeBoundingBox()}syncHiddenObjects(){if(0!==this.mergedObjectMap.size){if(this.objectVisibility.length>0){for(let t=0;t<this.objectVisibility.length;t++)this.objectVisibility[t]=1;this.hiddenHandles.forEach(t=>{const e=this.objectIdToIndex.get(t);void 0!==e&&e<this.objectVisibility.length&&(this.objectVisibility[e]=0)})}for(const t of this.mergedMesh)this._updateVisibilityAttribute(t);for(const t of this.mergedLines)this._updateVisibilityAttribute(t);for(const t of this.mergedLineSegments)this._updateVisibilityAttribute(t);for(const t of this.mergedPoints)this._updateVisibilityAttribute(t)}else console.log("No merged objects to sync")}getStructureGeometryExtent(t){const e=new Qi,i=this.structureRoots.get(t);for(const[n,s]of this.nodes.entries()){if(!s.geometryExtents)continue;if(!n.startsWith(t+"_"))continue;if(s.object&&this.hiddenHandles&&this.hiddenHandles.has(s.object.userData.handle))continue;const r=s.geometryExtents.clone();if(s.group){const t=[];let e=s.group;for(;e&&e!==i;)e.matrix&&!1===e.matrixAutoUpdate&&t.unshift(e.matrix),e=e.parent;for(const e of t)r.applyMatrix4(e)}i&&i.matrix&&r.applyMatrix4(i.matrix),e.union(r)}return this.scene&&this.scene.matrix&&!e.isEmpty()&&e.applyMatrix4(this.scene.matrix),e}setMaxConcurrentChunks(t){t<1?console.warn("Max concurrent chunks must be at least 1"):this.maxConcurrentChunks=t}waitForChunkSlot(){return this.activeChunkLoads<this.maxConcurrentChunks?(this.activeChunkLoads++,Promise.resolve()):new Promise(t=>{this.chunkQueue.push(t)})}releaseChunkSlot(){if(this.activeChunkLoads--,this.chunkQueue.length>0){const t=this.chunkQueue.shift();this.activeChunkLoads++,t()}}}class Dg extends yl{constructor(t,e={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=e.path||"";const i=e.externalFiles||new Map;"string"==typeof t?(this.fileURL=t,this.resourcePath=Xl.extractUrlBase(t)):(i.forEach((e,i)=>this.fileURL=e===t?i:this.fileURL),i.set(this.fileURL,t)),i.forEach((t,e)=>{let i;i="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,i)}),this.setURLModifier(t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),i=this.dataURLs.get(e);return null!=i?i:t})}dispose(){this.dataURLs.forEach(t=>URL.revokeObjectURL(t))}}const Og=1313821514,Ng=5130562;class Ug{constructor(t){const e=new DataView(t,0),i=(new TextDecoder).decode(new Uint8Array(t,0,Math.min(4,t.byteLength)));if("glTF"!==i)return void(this.content=new Uint8Array(t));if(this.header={magic:i,version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.length!==t.byteLength)throw new Error("GLTFBinaryParser: Invalid binary file header.");if(this.header.version<2)throw new Error("GLTFBinaryParser: Legacy binary file detected.");let n=12;for(;n<this.header.length;){const i=e.getUint32(n,!0);n+=4;const s=e.getUint32(n,!0);n+=4,s===Og?this.content=new Uint8Array(t,n,i):s===Ng&&(this.body=t.slice(n,n+i)),n+=i}if(void 0===this.content)throw new Error("GLTFBinaryParser: JSON content not found.");if(void 0===this.body)throw new Error("GLTFBinaryParser: Binary buffer chunk not found or type not supported.")}}var Fg;!function(t){t[t.BACKSPACE=8]="BACKSPACE",t[t.FORM_FEED=12]="FORM_FEED",t[t.NEWLINE=10]="NEWLINE",t[t.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",t[t.TAB=9]="TAB",t[t.SPACE=32]="SPACE",t[t.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",t[t.QUOTATION_MARK=34]="QUOTATION_MARK",t[t.NUMBER_SIGN=35]="NUMBER_SIGN",t[t.DOLLAR_SIGN=36]="DOLLAR_SIGN",t[t.PERCENT_SIGN=37]="PERCENT_SIGN",t[t.AMPERSAND=38]="AMPERSAND",t[t.APOSTROPHE=39]="APOSTROPHE",t[t.LEFT_PARENTHESIS=40]="LEFT_PARENTHESIS",t[t.RIGHT_PARENTHESIS=41]="RIGHT_PARENTHESIS",t[t.ASTERISK=42]="ASTERISK",t[t.PLUS_SIGN=43]="PLUS_SIGN",t[t.COMMA=44]="COMMA",t[t.HYPHEN_MINUS=45]="HYPHEN_MINUS",t[t.FULL_STOP=46]="FULL_STOP",t[t.SOLIDUS=47]="SOLIDUS",t[t.DIGIT_ZERO=48]="DIGIT_ZERO",t[t.DIGIT_ONE=49]="DIGIT_ONE",t[t.DIGIT_TWO=50]="DIGIT_TWO",t[t.DIGIT_THREE=51]="DIGIT_THREE",t[t.DIGIT_FOUR=52]="DIGIT_FOUR",t[t.DIGIT_FIVE=53]="DIGIT_FIVE",t[t.DIGIT_SIX=54]="DIGIT_SIX",t[t.DIGIT_SEVEN=55]="DIGIT_SEVEN",t[t.DIGIT_EIGHT=56]="DIGIT_EIGHT",t[t.DIGIT_NINE=57]="DIGIT_NINE",t[t.COLON=58]="COLON",t[t.SEMICOLON=59]="SEMICOLON",t[t.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",t[t.EQUALS_SIGN=61]="EQUALS_SIGN",t[t.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",t[t.QUESTION_MARK=63]="QUESTION_MARK",t[t.COMMERCIAL_AT=64]="COMMERCIAL_AT",t[t.LATIN_CAPITAL_LETTER_A=65]="LATIN_CAPITAL_LETTER_A",t[t.LATIN_CAPITAL_LETTER_B=66]="LATIN_CAPITAL_LETTER_B",t[t.LATIN_CAPITAL_LETTER_C=67]="LATIN_CAPITAL_LETTER_C",t[t.LATIN_CAPITAL_LETTER_D=68]="LATIN_CAPITAL_LETTER_D",t[t.LATIN_CAPITAL_LETTER_E=69]="LATIN_CAPITAL_LETTER_E",t[t.LATIN_CAPITAL_LETTER_F=70]="LATIN_CAPITAL_LETTER_F",t[t.LATIN_CAPITAL_LETTER_G=71]="LATIN_CAPITAL_LETTER_G",t[t.LATIN_CAPITAL_LETTER_H=72]="LATIN_CAPITAL_LETTER_H",t[t.LATIN_CAPITAL_LETTER_I=73]="LATIN_CAPITAL_LETTER_I",t[t.LATIN_CAPITAL_LETTER_J=74]="LATIN_CAPITAL_LETTER_J",t[t.LATIN_CAPITAL_LETTER_K=75]="LATIN_CAPITAL_LETTER_K",t[t.LATIN_CAPITAL_LETTER_L=76]="LATIN_CAPITAL_LETTER_L",t[t.LATIN_CAPITAL_LETTER_M=77]="LATIN_CAPITAL_LETTER_M",t[t.LATIN_CAPITAL_LETTER_N=78]="LATIN_CAPITAL_LETTER_N",t[t.LATIN_CAPITAL_LETTER_O=79]="LATIN_CAPITAL_LETTER_O",t[t.LATIN_CAPITAL_LETTER_P=80]="LATIN_CAPITAL_LETTER_P",t[t.LATIN_CAPITAL_LETTER_Q=81]="LATIN_CAPITAL_LETTER_Q",t[t.LATIN_CAPITAL_LETTER_R=82]="LATIN_CAPITAL_LETTER_R",t[t.LATIN_CAPITAL_LETTER_S=83]="LATIN_CAPITAL_LETTER_S",t[t.LATIN_CAPITAL_LETTER_T=84]="LATIN_CAPITAL_LETTER_T",t[t.LATIN_CAPITAL_LETTER_U=85]="LATIN_CAPITAL_LETTER_U",t[t.LATIN_CAPITAL_LETTER_V=86]="LATIN_CAPITAL_LETTER_V",t[t.LATIN_CAPITAL_LETTER_W=87]="LATIN_CAPITAL_LETTER_W",t[t.LATIN_CAPITAL_LETTER_X=88]="LATIN_CAPITAL_LETTER_X",t[t.LATIN_CAPITAL_LETTER_Y=89]="LATIN_CAPITAL_LETTER_Y",t[t.LATIN_CAPITAL_LETTER_Z=90]="LATIN_CAPITAL_LETTER_Z",t[t.LEFT_SQUARE_BRACKET=91]="LEFT_SQUARE_BRACKET",t[t.REVERSE_SOLIDUS=92]="REVERSE_SOLIDUS",t[t.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",t[t.CIRCUMFLEX_ACCENT=94]="CIRCUMFLEX_ACCENT",t[t.LOW_LINE=95]="LOW_LINE",t[t.GRAVE_ACCENT=96]="GRAVE_ACCENT",t[t.LATIN_SMALL_LETTER_A=97]="LATIN_SMALL_LETTER_A",t[t.LATIN_SMALL_LETTER_B=98]="LATIN_SMALL_LETTER_B",t[t.LATIN_SMALL_LETTER_C=99]="LATIN_SMALL_LETTER_C",t[t.LATIN_SMALL_LETTER_D=100]="LATIN_SMALL_LETTER_D",t[t.LATIN_SMALL_LETTER_E=101]="LATIN_SMALL_LETTER_E",t[t.LATIN_SMALL_LETTER_F=102]="LATIN_SMALL_LETTER_F",t[t.LATIN_SMALL_LETTER_G=103]="LATIN_SMALL_LETTER_G",t[t.LATIN_SMALL_LETTER_H=104]="LATIN_SMALL_LETTER_H",t[t.LATIN_SMALL_LETTER_I=105]="LATIN_SMALL_LETTER_I",t[t.LATIN_SMALL_LETTER_J=106]="LATIN_SMALL_LETTER_J",t[t.LATIN_SMALL_LETTER_K=107]="LATIN_SMALL_LETTER_K",t[t.LATIN_SMALL_LETTER_L=108]="LATIN_SMALL_LETTER_L",t[t.LATIN_SMALL_LETTER_M=109]="LATIN_SMALL_LETTER_M",t[t.LATIN_SMALL_LETTER_N=110]="LATIN_SMALL_LETTER_N",t[t.LATIN_SMALL_LETTER_O=111]="LATIN_SMALL_LETTER_O",t[t.LATIN_SMALL_LETTER_P=112]="LATIN_SMALL_LETTER_P",t[t.LATIN_SMALL_LETTER_Q=113]="LATIN_SMALL_LETTER_Q",t[t.LATIN_SMALL_LETTER_R=114]="LATIN_SMALL_LETTER_R",t[t.LATIN_SMALL_LETTER_S=115]="LATIN_SMALL_LETTER_S",t[t.LATIN_SMALL_LETTER_T=116]="LATIN_SMALL_LETTER_T",t[t.LATIN_SMALL_LETTER_U=117]="LATIN_SMALL_LETTER_U",t[t.LATIN_SMALL_LETTER_V=118]="LATIN_SMALL_LETTER_V",t[t.LATIN_SMALL_LETTER_W=119]="LATIN_SMALL_LETTER_W",t[t.LATIN_SMALL_LETTER_X=120]="LATIN_SMALL_LETTER_X",t[t.LATIN_SMALL_LETTER_Y=121]="LATIN_SMALL_LETTER_Y",t[t.LATIN_SMALL_LETTER_Z=122]="LATIN_SMALL_LETTER_Z",t[t.LEFT_CURLY_BRACKET=123]="LEFT_CURLY_BRACKET",t[t.VERTICAL_LINE=124]="VERTICAL_LINE",t[t.RIGHT_CURLY_BRACKET=125]="RIGHT_CURLY_BRACKET",t[t.TILDE=126]="TILDE"}(Fg||(Fg={}));const Bg={[Fg.QUOTATION_MARK]:Fg.QUOTATION_MARK,[Fg.REVERSE_SOLIDUS]:Fg.REVERSE_SOLIDUS,[Fg.SOLIDUS]:Fg.SOLIDUS,[Fg.LATIN_SMALL_LETTER_B]:Fg.BACKSPACE,[Fg.LATIN_SMALL_LETTER_F]:Fg.FORM_FEED,[Fg.LATIN_SMALL_LETTER_N]:Fg.NEWLINE,[Fg.LATIN_SMALL_LETTER_R]:Fg.CARRIAGE_RETURN,[Fg.LATIN_SMALL_LETTER_T]:Fg.TAB};class kg{constructor(){this.decoder=new TextDecoder("utf-8"),this.strings=[],this.byteLength=0}appendChar(t){this.strings.push(String.fromCharCode(t)),this.byteLength+=1}appendBuf(t,e=0,i=t.length){this.strings.push(this.decoder.decode(t.subarray(e,i))),this.byteLength+=i-e}reset(){this.strings=[],this.byteLength=0}toString(){return this.strings.join("")}}class zg{constructor(t){this.decoder=new TextDecoder("utf-8"),this.bufferOffset=0,this.string="",this.byteLength=0,this.buffer=new Uint8Array(t)}appendChar(t){this.bufferOffset>=this.buffer.length&&this.flushStringBuffer(),this.buffer[this.bufferOffset++]=t,this.byteLength+=1}appendBuf(t,e=0,i=t.length){const n=i-e;this.bufferOffset+n>this.buffer.length&&this.flushStringBuffer(),this.buffer.set(t.subarray(e,i),this.bufferOffset),this.bufferOffset+=n,this.byteLength+=n}flushStringBuffer(){this.string+=this.decoder.decode(this.buffer.subarray(0,this.bufferOffset)),this.bufferOffset=0}reset(){this.string="",this.bufferOffset=0,this.byteLength=0}toString(){return this.flushStringBuffer(),this.string}}var Gg;!function(t){t[t.LEFT_BRACE=0]="LEFT_BRACE",t[t.RIGHT_BRACE=1]="RIGHT_BRACE",t[t.LEFT_BRACKET=2]="LEFT_BRACKET",t[t.RIGHT_BRACKET=3]="RIGHT_BRACKET",t[t.COLON=4]="COLON",t[t.COMMA=5]="COMMA",t[t.TRUE=6]="TRUE",t[t.FALSE=7]="FALSE",t[t.NULL=8]="NULL",t[t.STRING=9]="STRING",t[t.NUMBER=10]="NUMBER",t[t.SEPARATOR=11]="SEPARATOR"}(Gg||(Gg={}));var Hg,Vg=Gg;function Wg(t){return["START","ENDED","ERROR","TRUE1","TRUE2","TRUE3","FALSE1","FALSE2","FALSE3","FALSE4","NULL1","NULL2","NULL3","STRING_DEFAULT","STRING_AFTER_BACKSLASH","STRING_UNICODE_DIGIT_1","STRING_UNICODE_DIGIT_2","STRING_UNICODE_DIGIT_3","STRING_UNICODE_DIGIT_4","STRING_INCOMPLETE_CHAR","NUMBER_AFTER_INITIAL_MINUS","NUMBER_AFTER_INITIAL_ZERO","NUMBER_AFTER_INITIAL_NON_ZERO","NUMBER_AFTER_FULL_STOP","NUMBER_AFTER_DECIMAL","NUMBER_AFTER_E","NUMBER_AFTER_E_AND_SIGN","NUMBER_AFTER_E_AND_DIGIT","SEPARATOR","BOM_OR_START","BOM"][t]}!function(t){t[t.START=0]="START",t[t.ENDED=1]="ENDED",t[t.ERROR=2]="ERROR",t[t.TRUE1=3]="TRUE1",t[t.TRUE2=4]="TRUE2",t[t.TRUE3=5]="TRUE3",t[t.FALSE1=6]="FALSE1",t[t.FALSE2=7]="FALSE2",t[t.FALSE3=8]="FALSE3",t[t.FALSE4=9]="FALSE4",t[t.NULL1=10]="NULL1",t[t.NULL2=11]="NULL2",t[t.NULL3=12]="NULL3",t[t.STRING_DEFAULT=13]="STRING_DEFAULT",t[t.STRING_AFTER_BACKSLASH=14]="STRING_AFTER_BACKSLASH",t[t.STRING_UNICODE_DIGIT_1=15]="STRING_UNICODE_DIGIT_1",t[t.STRING_UNICODE_DIGIT_2=16]="STRING_UNICODE_DIGIT_2",t[t.STRING_UNICODE_DIGIT_3=17]="STRING_UNICODE_DIGIT_3",t[t.STRING_UNICODE_DIGIT_4=18]="STRING_UNICODE_DIGIT_4",t[t.STRING_INCOMPLETE_CHAR=19]="STRING_INCOMPLETE_CHAR",t[t.NUMBER_AFTER_INITIAL_MINUS=20]="NUMBER_AFTER_INITIAL_MINUS",t[t.NUMBER_AFTER_INITIAL_ZERO=21]="NUMBER_AFTER_INITIAL_ZERO",t[t.NUMBER_AFTER_INITIAL_NON_ZERO=22]="NUMBER_AFTER_INITIAL_NON_ZERO",t[t.NUMBER_AFTER_FULL_STOP=23]="NUMBER_AFTER_FULL_STOP",t[t.NUMBER_AFTER_DECIMAL=24]="NUMBER_AFTER_DECIMAL",t[t.NUMBER_AFTER_E=25]="NUMBER_AFTER_E",t[t.NUMBER_AFTER_E_AND_SIGN=26]="NUMBER_AFTER_E_AND_SIGN",t[t.NUMBER_AFTER_E_AND_DIGIT=27]="NUMBER_AFTER_E_AND_DIGIT",t[t.SEPARATOR=28]="SEPARATOR",t[t.BOM_OR_START=29]="BOM_OR_START",t[t.BOM=30]="BOM"}(Hg||(Hg={}));const jg={stringBufferSize:0,numberBufferSize:0,separator:void 0,emitPartialTokens:!1};class Xg extends Error{constructor(t){super(t),Object.setPrototypeOf(this,Xg.prototype)}}class Yg{constructor(t){this.state=Hg.BOM_OR_START,this.bomIndex=0,this.separatorIndex=0,this.escapedCharsByteLength=0,this.bytes_remaining=0,this.bytes_in_sequence=0,this.char_split_buffer=new Uint8Array(4),this.encoder=new TextEncoder,this.offset=-1,t=Object.assign(Object.assign({},jg),t),this.emitPartialTokens=!0===t.emitPartialTokens,this.bufferedString=t.stringBufferSize&&t.stringBufferSize>4?new zg(t.stringBufferSize):new kg,this.bufferedNumber=t.numberBufferSize&&t.numberBufferSize>0?new zg(t.numberBufferSize):new kg,this.separator=t.separator,this.separatorBytes=t.separator?this.encoder.encode(t.separator):void 0}get isEnded(){return this.state===Hg.ENDED}write(t){try{let e;if(t instanceof Uint8Array)e=t;else if("string"==typeof t)e=this.encoder.encode(t);else if(Array.isArray(t))e=Uint8Array.from(t);else{if(!ArrayBuffer.isView(t))throw new TypeError("Unexpected type. The `write` function only accepts Arrays, TypedArrays and Strings.");e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}for(let i=0;i<e.length;i+=1){const n=e[i];switch(this.state){case Hg.BOM_OR_START:if(t instanceof Uint8Array&&239===n){this.bom=[239,187,191],this.bomIndex+=1,this.state=Hg.BOM;continue}if(t instanceof Uint16Array){if(254===n){this.bom=[254,255],this.bomIndex+=1,this.state=Hg.BOM;continue}if(255===n){this.bom=[255,254],this.bomIndex+=1,this.state=Hg.BOM;continue}}if(t instanceof Uint32Array){if(0===n){this.bom=[0,0,254,255],this.bomIndex+=1,this.state=Hg.BOM;continue}if(255===n){this.bom=[255,254,0,0],this.bomIndex+=1,this.state=Hg.BOM;continue}}case Hg.START:if(this.offset+=1,this.separatorBytes&&n===this.separatorBytes[0]){if(1===this.separatorBytes.length){this.state=Hg.START,this.onToken({token:Vg.SEPARATOR,value:this.separator,offset:this.offset+this.separatorBytes.length-1});continue}this.state=Hg.SEPARATOR;continue}if(n===Fg.SPACE||n===Fg.NEWLINE||n===Fg.CARRIAGE_RETURN||n===Fg.TAB)continue;if(n===Fg.LEFT_CURLY_BRACKET){this.onToken({token:Vg.LEFT_BRACE,value:"{",offset:this.offset});continue}if(n===Fg.RIGHT_CURLY_BRACKET){this.onToken({token:Vg.RIGHT_BRACE,value:"}",offset:this.offset});continue}if(n===Fg.LEFT_SQUARE_BRACKET){this.onToken({token:Vg.LEFT_BRACKET,value:"[",offset:this.offset});continue}if(n===Fg.RIGHT_SQUARE_BRACKET){this.onToken({token:Vg.RIGHT_BRACKET,value:"]",offset:this.offset});continue}if(n===Fg.COLON){this.onToken({token:Vg.COLON,value:":",offset:this.offset});continue}if(n===Fg.COMMA){this.onToken({token:Vg.COMMA,value:",",offset:this.offset});continue}if(n===Fg.LATIN_SMALL_LETTER_T){this.state=Hg.TRUE1;continue}if(n===Fg.LATIN_SMALL_LETTER_F){this.state=Hg.FALSE1;continue}if(n===Fg.LATIN_SMALL_LETTER_N){this.state=Hg.NULL1;continue}if(n===Fg.QUOTATION_MARK){this.bufferedString.reset(),this.escapedCharsByteLength=0,this.state=Hg.STRING_DEFAULT;continue}if(n>=Fg.DIGIT_ONE&&n<=Fg.DIGIT_NINE){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_NON_ZERO;continue}if(n===Fg.DIGIT_ZERO){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_ZERO;continue}if(n===Fg.HYPHEN_MINUS){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_MINUS;continue}break;case Hg.STRING_DEFAULT:if(n===Fg.QUOTATION_MARK){const t=this.bufferedString.toString();this.state=Hg.START,this.onToken({token:Vg.STRING,value:t,offset:this.offset}),this.offset+=this.escapedCharsByteLength+this.bufferedString.byteLength+1;continue}if(n===Fg.REVERSE_SOLIDUS){this.state=Hg.STRING_AFTER_BACKSLASH;continue}if(n>=128){if(this.bytes_in_sequence=n>=194&&n<=223?2:n<=239?3:4,this.bytes_in_sequence<=e.length-i){this.bufferedString.appendBuf(e,i,i+this.bytes_in_sequence),i+=this.bytes_in_sequence-1;continue}this.bytes_remaining=i+this.bytes_in_sequence-e.length,this.char_split_buffer.set(e.subarray(i)),i=e.length-1,this.state=Hg.STRING_INCOMPLETE_CHAR;continue}if(n>=Fg.SPACE){this.bufferedString.appendChar(n);continue}break;case Hg.STRING_INCOMPLETE_CHAR:this.char_split_buffer.set(e.subarray(i,i+this.bytes_remaining),this.bytes_in_sequence-this.bytes_remaining),this.bufferedString.appendBuf(this.char_split_buffer,0,this.bytes_in_sequence),i=this.bytes_remaining-1,this.state=Hg.STRING_DEFAULT;continue;case Hg.STRING_AFTER_BACKSLASH:const s=Bg[n];if(s){this.bufferedString.appendChar(s),this.escapedCharsByteLength+=1,this.state=Hg.STRING_DEFAULT;continue}if(n===Fg.LATIN_SMALL_LETTER_U){this.unicode="",this.state=Hg.STRING_UNICODE_DIGIT_1;continue}break;case Hg.STRING_UNICODE_DIGIT_1:case Hg.STRING_UNICODE_DIGIT_2:case Hg.STRING_UNICODE_DIGIT_3:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE||n>=Fg.LATIN_CAPITAL_LETTER_A&&n<=Fg.LATIN_CAPITAL_LETTER_F||n>=Fg.LATIN_SMALL_LETTER_A&&n<=Fg.LATIN_SMALL_LETTER_F){this.unicode+=String.fromCharCode(n),this.state+=1;continue}break;case Hg.STRING_UNICODE_DIGIT_4:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE||n>=Fg.LATIN_CAPITAL_LETTER_A&&n<=Fg.LATIN_CAPITAL_LETTER_F||n>=Fg.LATIN_SMALL_LETTER_A&&n<=Fg.LATIN_SMALL_LETTER_F){const t=parseInt(this.unicode+String.fromCharCode(n),16);let e;if(void 0===this.highSurrogate){if(t>=55296&&t<=56319){this.highSurrogate=t,this.state=Hg.STRING_DEFAULT;continue}e=String.fromCharCode(t)}else e=t>=56320&&t<=57343?String.fromCharCode(this.highSurrogate,t):String.fromCharCode(this.highSurrogate),this.highSurrogate=void 0;const i=this.encoder.encode(e);this.bufferedString.appendBuf(i),this.escapedCharsByteLength+=6-i.byteLength,this.state=Hg.STRING_DEFAULT;continue}break;case Hg.NUMBER_AFTER_INITIAL_MINUS:if(n===Fg.DIGIT_ZERO){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_ZERO;continue}if(n>=Fg.DIGIT_ONE&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_NON_ZERO;continue}break;case Hg.NUMBER_AFTER_INITIAL_ZERO:if(n===Fg.FULL_STOP){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_FULL_STOP;continue}if(n===Fg.LATIN_SMALL_LETTER_E||n===Fg.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E;continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.NUMBER_AFTER_INITIAL_NON_ZERO:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n);continue}if(n===Fg.FULL_STOP){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_FULL_STOP;continue}if(n===Fg.LATIN_SMALL_LETTER_E||n===Fg.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E;continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.NUMBER_AFTER_FULL_STOP:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_DECIMAL;continue}break;case Hg.NUMBER_AFTER_DECIMAL:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n);continue}if(n===Fg.LATIN_SMALL_LETTER_E||n===Fg.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E;continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.NUMBER_AFTER_E:if(n===Fg.PLUS_SIGN||n===Fg.HYPHEN_MINUS){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E_AND_SIGN;continue}case Hg.NUMBER_AFTER_E_AND_SIGN:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E_AND_DIGIT;continue}break;case Hg.NUMBER_AFTER_E_AND_DIGIT:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n);continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.TRUE1:if(n===Fg.LATIN_SMALL_LETTER_R){this.state=Hg.TRUE2;continue}break;case Hg.TRUE2:if(n===Fg.LATIN_SMALL_LETTER_U){this.state=Hg.TRUE3;continue}break;case Hg.TRUE3:if(n===Fg.LATIN_SMALL_LETTER_E){this.state=Hg.START,this.onToken({token:Vg.TRUE,value:!0,offset:this.offset}),this.offset+=3;continue}break;case Hg.FALSE1:if(n===Fg.LATIN_SMALL_LETTER_A){this.state=Hg.FALSE2;continue}break;case Hg.FALSE2:if(n===Fg.LATIN_SMALL_LETTER_L){this.state=Hg.FALSE3;continue}break;case Hg.FALSE3:if(n===Fg.LATIN_SMALL_LETTER_S){this.state=Hg.FALSE4;continue}break;case Hg.FALSE4:if(n===Fg.LATIN_SMALL_LETTER_E){this.state=Hg.START,this.onToken({token:Vg.FALSE,value:!1,offset:this.offset}),this.offset+=4;continue}break;case Hg.NULL1:if(n===Fg.LATIN_SMALL_LETTER_U){this.state=Hg.NULL2;continue}break;case Hg.NULL2:if(n===Fg.LATIN_SMALL_LETTER_L){this.state=Hg.NULL3;continue}break;case Hg.NULL3:if(n===Fg.LATIN_SMALL_LETTER_L){this.state=Hg.START,this.onToken({token:Vg.NULL,value:null,offset:this.offset}),this.offset+=3;continue}break;case Hg.SEPARATOR:if(this.separatorIndex+=1,!this.separatorBytes||n!==this.separatorBytes[this.separatorIndex])break;this.separatorIndex===this.separatorBytes.length-1&&(this.state=Hg.START,this.onToken({token:Vg.SEPARATOR,value:this.separator,offset:this.offset+this.separatorIndex}),this.separatorIndex=0);continue;case Hg.BOM:if(n===this.bom[this.bomIndex]){if(this.bomIndex===this.bom.length-1){this.state=Hg.START,this.bom=void 0,this.bomIndex=0;continue}this.bomIndex+=1;continue}break;case Hg.ENDED:if(n===Fg.SPACE||n===Fg.NEWLINE||n===Fg.CARRIAGE_RETURN||n===Fg.TAB)continue}throw new Xg(`Unexpected "${String.fromCharCode(n)}" at position "${i}" in state ${Wg(this.state)}`)}if(this.emitPartialTokens)switch(this.state){case Hg.TRUE1:case Hg.TRUE2:case Hg.TRUE3:this.onToken({token:Vg.TRUE,value:!0,offset:this.offset,partial:!0});break;case Hg.FALSE1:case Hg.FALSE2:case Hg.FALSE3:case Hg.FALSE4:this.onToken({token:Vg.FALSE,value:!1,offset:this.offset,partial:!0});break;case Hg.NULL1:case Hg.NULL2:case Hg.NULL3:this.onToken({token:Vg.NULL,value:null,offset:this.offset,partial:!0});break;case Hg.STRING_DEFAULT:{const t=this.bufferedString.toString();this.onToken({token:Vg.STRING,value:t,offset:this.offset,partial:!0});break}case Hg.NUMBER_AFTER_INITIAL_ZERO:case Hg.NUMBER_AFTER_INITIAL_NON_ZERO:case Hg.NUMBER_AFTER_DECIMAL:case Hg.NUMBER_AFTER_E_AND_DIGIT:try{this.onToken({token:Vg.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset,partial:!0})}catch(t){}}}catch(t){this.error(t)}}emitNumber(){this.onToken({token:Vg.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset}),this.offset+=this.bufferedNumber.byteLength-1}parseNumber(t){return Number(t)}error(t){this.state!==Hg.ENDED&&(this.state=Hg.ERROR),this.onError(t)}end(){switch(this.state){case Hg.NUMBER_AFTER_INITIAL_ZERO:case Hg.NUMBER_AFTER_INITIAL_NON_ZERO:case Hg.NUMBER_AFTER_DECIMAL:case Hg.NUMBER_AFTER_E_AND_DIGIT:this.state=Hg.ENDED,this.emitNumber(),this.onEnd();break;case Hg.BOM_OR_START:case Hg.START:case Hg.ERROR:case Hg.SEPARATOR:this.state=Hg.ENDED,this.onEnd();break;default:this.error(new Xg(`Tokenizer ended in the middle of a token (state: ${Wg(this.state)}). Either not all the data was received or the data was invalid.`))}}onToken(t){throw new Xg('Can\'t emit tokens before the "onToken" callback has been set up.')}onError(t){throw t}onEnd(){}}var qg,Zg;function Kg(t){return["VALUE","KEY","COLON","COMMA","ENDED","ERROR","SEPARATOR"][t]}!function(t){t[t.OBJECT=0]="OBJECT",t[t.ARRAY=1]="ARRAY"}(qg||(qg={})),function(t){t[t.VALUE=0]="VALUE",t[t.KEY=1]="KEY",t[t.COLON=2]="COLON",t[t.COMMA=3]="COMMA",t[t.ENDED=4]="ENDED",t[t.ERROR=5]="ERROR",t[t.SEPARATOR=6]="SEPARATOR"}(Zg||(Zg={}));const Jg={paths:void 0,keepStack:!0,separator:void 0,emitPartialValues:!1};class Qg extends Error{constructor(t){super(t),Object.setPrototypeOf(this,Qg.prototype)}}class $g{constructor(t){this.state=Zg.VALUE,this.mode=void 0,this.key=void 0,this.value=void 0,this.stack=[],(t=Object.assign(Object.assign({},Jg),t)).paths&&(this.paths=t.paths.map(t=>{if(void 0===t||"$*"===t)return;if(!t.startsWith("$"))throw new Qg(`Invalid selector "${t}". Should start with "$".`);const e=t.split(".").slice(1);if(e.includes(""))throw new Qg(`Invalid selector "${t}". ".." syntax not supported.`);return e})),this.keepStack=t.keepStack||!1,this.separator=t.separator,t.emitPartialValues||(this.emitPartial=()=>{})}shouldEmit(){return!this.paths||this.paths.some(t=>{var e;if(void 0===t)return!0;if(t.length!==this.stack.length)return!1;for(let e=0;e<t.length-1;e++){const i=t[e],n=this.stack[e+1].key;if("*"!==i&&i!==(null==n?void 0:n.toString()))return!1}const i=t[t.length-1];return"*"===i||i===(null===(e=this.key)||void 0===e?void 0:e.toString())})}push(){this.stack.push({key:this.key,value:this.value,mode:this.mode,emit:this.shouldEmit()})}pop(){const t=this.value;let e;({key:this.key,value:this.value,mode:this.mode,emit:e}=this.stack.pop()),this.state=void 0!==this.mode?Zg.COMMA:Zg.VALUE,this.emit(t,e)}emit(t,e){!this.keepStack&&this.value&&this.stack.every(t=>!t.emit)&&delete this.value[this.key],e&&this.onValue({value:t,key:this.key,parent:this.value,stack:this.stack}),0===this.stack.length&&(this.separator?this.state=Zg.SEPARATOR:void 0===this.separator&&this.end())}emitPartial(t){this.shouldEmit()&&(this.state!==Zg.KEY?this.onValue({value:t,key:this.key,parent:this.value,stack:this.stack,partial:!0}):this.onValue({value:void 0,key:t,parent:this.value,stack:this.stack,partial:!0}))}get isEnded(){return this.state===Zg.ENDED}write({token:t,value:e,partial:i}){try{if(i)return void this.emitPartial(e);if(this.state===Zg.VALUE){if(t===Vg.STRING||t===Vg.NUMBER||t===Vg.TRUE||t===Vg.FALSE||t===Vg.NULL)return this.mode===qg.OBJECT?(this.value[this.key]=e,this.state=Zg.COMMA):this.mode===qg.ARRAY&&(this.value.push(e),this.state=Zg.COMMA),void this.emit(e,this.shouldEmit());if(t===Vg.LEFT_BRACE){if(this.push(),this.mode===qg.OBJECT)this.value=this.value[this.key]={};else if(this.mode===qg.ARRAY){const t={};this.value.push(t),this.value=t}else this.value={};return this.mode=qg.OBJECT,this.state=Zg.KEY,this.key=void 0,void this.emitPartial()}if(t===Vg.LEFT_BRACKET){if(this.push(),this.mode===qg.OBJECT)this.value=this.value[this.key]=[];else if(this.mode===qg.ARRAY){const t=[];this.value.push(t),this.value=t}else this.value=[];return this.mode=qg.ARRAY,this.state=Zg.VALUE,this.key=0,void this.emitPartial()}if(this.mode===qg.ARRAY&&t===Vg.RIGHT_BRACKET&&0===this.value.length)return void this.pop()}if(this.state===Zg.KEY){if(t===Vg.STRING)return this.key=e,this.state=Zg.COLON,void this.emitPartial();if(t===Vg.RIGHT_BRACE&&0===Object.keys(this.value).length)return void this.pop()}if(this.state===Zg.COLON&&t===Vg.COLON)return void(this.state=Zg.VALUE);if(this.state===Zg.COMMA){if(t===Vg.COMMA){if(this.mode===qg.ARRAY)return this.state=Zg.VALUE,void(this.key+=1);if(this.mode===qg.OBJECT)return void(this.state=Zg.KEY)}if(t===Vg.RIGHT_BRACE&&this.mode===qg.OBJECT||t===Vg.RIGHT_BRACKET&&this.mode===qg.ARRAY)return void this.pop()}if(this.state===Zg.SEPARATOR&&t===Vg.SEPARATOR&&e===this.separator)return void(this.state=Zg.VALUE);if(t===Vg.SEPARATOR&&this.state!==Zg.SEPARATOR&&Array.from(e).map(t=>t.charCodeAt(0)).every(t=>t===Fg.SPACE||t===Fg.NEWLINE||t===Fg.CARRIAGE_RETURN||t===Fg.TAB))return;throw new Qg(`Unexpected ${Vg[t]} (${JSON.stringify(e)}) in state ${Kg(this.state)}`)}catch(t){this.error(t)}}error(t){this.state!==Zg.ENDED&&(this.state=Zg.ERROR),this.onError(t)}end(){this.state!==Zg.VALUE&&this.state!==Zg.SEPARATOR||this.stack.length>0?this.error(new Error(`Parser ended in mid-parsing (state: ${Kg(this.state)}). Either not all the data was received or the data was invalid.`)):(this.state=Zg.ENDED,this.onEnd())}onValue(t){throw new Qg('Can\'t emit data before the "onValue" callback has been set up.')}onError(t){throw t}onEnd(){}}class tv{constructor(t={}){this.tokenizer=new Yg(t),this.tokenParser=new $g(t),this.tokenizer.onToken=this.tokenParser.write.bind(this.tokenParser),this.tokenizer.onEnd=()=>{this.tokenParser.isEnded||this.tokenParser.end()},this.tokenParser.onError=this.tokenizer.error.bind(this.tokenizer),this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end()}}get isEnded(){return this.tokenizer.isEnded&&this.tokenParser.isEnded}write(t){this.tokenizer.write(t)}end(){this.tokenizer.end()}set onToken(t){this.tokenizer.onToken=e=>{t(e),this.tokenParser.write(e)}}set onValue(t){this.tokenParser.onValue=t}set onError(t){this.tokenizer.onError=t}set onEnd(t){this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end(),t.call(this.tokenParser)}}}class ev extends tv{constructor(t){super(),this.onValue=({value:t,stack:e})=>{0===e.length&&(this.json=t)},t&&this.write(t)}}class iv extends Error{constructor(t,e){super(e),this.name="FetchError",this.status=t}}class nv{constructor(){this.requestHeader={},this.withCredentials=!1,this.abortSignal=void 0}setRequestHeader(t){this.requestHeader=t}setWithCredentials(t){this.withCredentials=t}setAbortSignal(t){this.abortSignal=t}async load(t,e){const i={headers:{...this.requestHeader,Range:"bytes="+e.map(t=>`${t.offset}-${t.offset+t.length-1}`).join(",")},credentials:this.withCredentials?"include":"same-origin",signal:this.abortSignal},n=await fetch(t,i);if(!n.ok)throw new iv(n.status,`Failed to fetch "${t}", status ${n.status}`);if(206!==n.status){const t=await n.arrayBuffer();return this.extractRanges(t,e)}return n.arrayBuffer()}extractRanges(t,e){const i=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(i);let s=0;for(const i of e){const e=new Uint8Array(t,i.offset,i.length);n.set(e,s),s+=i.length}return n.buffer}}class sv extends c{constructor(t){super(),this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear(),this.manager&&this.manager.dispose()}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/(gltf|glb)$/i.test(e)}async load(t,e,i){this.manager=new Dg(t,i);const n=new fr;this.gltfLoader=new Pg(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.visibleEdges=this.viewer.options.edgeModel;const s=new yg(n);s.id=i.modelId||this.extractFileName(t),s.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",()=>{this.viewer.scene.add(n),this.viewer.models.push(s),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t}),this.viewer.update(!0)}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t})}),this.gltfLoader.addEventListener("update",()=>{this.viewer.update()});const r={loadJson:async()=>{const e=new Ml(this.manager);e.setPath(this.manager.path),e.setRequestHeader(i.requestHeader||{}),e.setWithCredentials(i.withCredentials||e.withCredentials),e.setResponseType("arraybuffer");const n=await e.loadAsync(this.manager.fileURL,e=>{const{lengthComputable:i,loaded:n,total:s}=e,r=i?n/s:1;this.viewer.emitEvent({type:"geometryprogress",data:r,file:t})}),s=new Ug(n),r=new ev(s.content);if(!r.json)throw new Error("GLTFFileDynamicLoader: JSON content not found or invalid.");return this.glb=s.body,r.json},loadBinaryData:(t,e="")=>{const n=new nv;if(n.setRequestHeader(i.requestHeader||{}),n.setWithCredentials(i.withCredentials||!1),n.setAbortSignal(this.gltfLoader.abortController.signal),this.glb)return n.extractRanges(this.glb,t);const s=this.manager.path||this.manager.resourcePath,r=Xl.resolveURL(e,s);return n.load(this.manager.resolveURL(r),t)},resolveURL:t=>{const e=this.manager.path||this.manager.resourcePath,i=Xl.resolveURL(t,e);return Promise.resolve(this.manager.resolveURL(i))}},a=new Lg(s.id,r);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}class rv extends c{constructor(t){super(),this.requestId=0,this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear()}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.gltf$/i.test(t.database)}async load(t,e,i={}){const n=new fr;this.gltfLoader=new Pg(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);const s=new yg(n);s.id=t.file.id,s.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",e=>{this.viewer.scene.add(n),this.viewer.models.push(s),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t.file,model:t}),this.viewer.update(!0)}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})}),this.gltfLoader.addEventListener("update",()=>{this.viewer.update()});const r={loadJson:async()=>{const e=new ev;if(await t.downloadResource(t.database,(i,n)=>{e.write(n),this.viewer.emitEvent({type:"geometryprogress",data:i,file:t.file,model:t})},this.gltfLoader.getAbortController().signal),!e.json)throw new Error("GLTFCloudDynamicLoader: JSON content not found or invalid.");return e.json},loadBinaryData:e=>{const i=e.map(t=>({begin:t.offset,end:t.offset+t.length-1,requestId:this.requestId++}));return t.downloadResourceRange(t.geometry[0],void 0,i,void 0,this.gltfLoader.getAbortController().signal)},resolveURL:e=>{const i=`${t.httpClient.serverUrl}${t.path}/`,n=Xl.resolveURL(e,i);return Promise.resolve(n)}},a=new Lg(s.id,r);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}const av=p("threejs");av.registerLoader("gltf-file",t=>new sv(t)),av.registerLoader("gltf-cloud",t=>new rv(t));const ov={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"};class hv{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const lv=new Bl(-1,1,1,-1,0,1);const cv=new class extends zs{constructor(){super(),this.setAttribute("position",new Ps([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ps([0,2,0,0,2,0],2))}};class dv{constructor(t){this._mesh=new Qs(cv,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,lv)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class uv extends hv{constructor(t,e="tDiffuse"){super(),this.textureID=e,this.uniforms=null,this.material=null,t instanceof rr?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=sr.clone(t.uniforms),this.material=new rr({name:void 0!==t.name?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this._fsQuad=new dv(this.material)}render(t,e,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this._fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class pv extends hv{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,i){const n=t.getContext(),s=t.state;let r,a;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0),this.inverse?(r=0,a=1):(r=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),s.buffers.stencil.setFunc(n.ALWAYS,r,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),t.setRenderTarget(i),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(n.EQUAL,1,4294967295),s.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),s.buffers.stencil.setLocked(!0)}}class mv extends hv{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class fv{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),void 0===e){const i=t.getSize(new Ai);this._width=i.width,this._height=i.height,(e=new Zi(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Dt})).texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new uv(ov),this.copyPass.material.blending=0,this.clock=new rc}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){void 0===t&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let i=!1;for(let e=0,n=this.passes.length;e<n;e++){const n=this.passes[e];if(!1!==n.enabled){if(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(e),n.render(this.renderer,this.writeBuffer,this.readBuffer,t,i),n.needsSwap){if(i){const e=this.renderer.getContext(),i=this.renderer.state.buffers.stencil;i.setFunc(e.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),i.setFunc(e.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==pv&&(n instanceof pv?i=!0:n instanceof mv&&(i=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new Ai);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(let t=0;t<this.passes.length;t++)this.passes[t].setSize(i,n)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class gv extends hv{constructor(t,e,i=null,n=null,s=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new _s}render(t,e,i){const n=t.autoClear;let s,r;t.autoClear=!1,null!==this.overrideMaterial&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),null!==this.clearColor&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),null!==this.clearAlpha&&(s=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),1==this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:i),!0===this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),null!==this.clearColor&&t.setClearColor(this._oldClearColor),null!==this.clearAlpha&&t.setClearAlpha(s),null!==this.overrideMaterial&&(this.scene.overrideMaterial=r),t.autoClear=n}}const vv={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\t#define EDGE_STEP_COUNT 6\n\t\t#define EDGE_GUESS 8.0\n\t\t#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n\t\tconst float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n\t\tfloat _ContrastThreshold = 0.0312;\n\t\tfloat _RelativeThreshold = 0.063;\n\t\tfloat _SubpixelBlending = 1.0;\n\n\t\tvec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn texture( tex2D, uv );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n\t\t\tuv += texSize * vec2(uOffset, vOffset);\n\t\t\treturn SampleLuminance(tex2D, uv);\n\n\t\t}\n\n\t\tstruct LuminanceData {\n\n\t\t\tfloat m, n, e, s, w;\n\t\t\tfloat ne, nw, se, sw;\n\t\t\tfloat highest, lowest, contrast;\n\n\t\t};\n\n\t\tLuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData l;\n\t\t\tl.m = SampleLuminance( tex2D, uv );\n\t\t\tl.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n\t\t\tl.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n\t\t\tl.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n\t\t\tl.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n\t\t\tl.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n\t\t\tl.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n\t\t\tl.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n\t\t\tl.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n\t\t\tl.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.contrast = l.highest - l.lowest;\n\t\t\treturn l;\n\n\t\t}\n\n\t\tbool ShouldSkipPixel( LuminanceData l ) {\n\n\t\t\tfloat threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n\t\t\treturn l.contrast < threshold;\n\n\t\t}\n\n\t\tfloat DeterminePixelBlendFactor( LuminanceData l ) {\n\n\t\t\tfloat f = 2.0 * ( l.n + l.e + l.s + l.w );\n\t\t\tf += l.ne + l.nw + l.se + l.sw;\n\t\t\tf *= 1.0 / 12.0;\n\t\t\tf = abs( f - l.m );\n\t\t\tf = clamp( f / l.contrast, 0.0, 1.0 );\n\n\t\t\tfloat blendFactor = smoothstep( 0.0, 1.0, f );\n\t\t\treturn blendFactor * blendFactor * _SubpixelBlending;\n\n\t\t}\n\n\t\tstruct EdgeData {\n\n\t\t\tbool isHorizontal;\n\t\t\tfloat pixelStep;\n\t\t\tfloat oppositeLuminance, gradient;\n\n\t\t};\n\n\t\tEdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n\t\t\tEdgeData e;\n\t\t\tfloat horizontal =\n\t\t\t\tabs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.se - 2.0 * l.e ) +\n\t\t\t\tabs( l.nw + l.sw - 2.0 * l.w );\n\t\t\tfloat vertical =\n\t\t\t\tabs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.nw - 2.0 * l.n ) +\n\t\t\t\tabs( l.se + l.sw - 2.0 * l.s );\n\t\t\te.isHorizontal = horizontal >= vertical;\n\n\t\t\tfloat pLuminance = e.isHorizontal ? l.n : l.e;\n\t\t\tfloat nLuminance = e.isHorizontal ? l.s : l.w;\n\t\t\tfloat pGradient = abs( pLuminance - l.m );\n\t\t\tfloat nGradient = abs( nLuminance - l.m );\n\n\t\t\te.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\n\t\t\tif (pGradient < nGradient) {\n\n\t\t\t\te.pixelStep = -e.pixelStep;\n\t\t\t\te.oppositeLuminance = nLuminance;\n\t\t\t\te.gradient = nGradient;\n\n\t\t\t} else {\n\n\t\t\t\te.oppositeLuminance = pLuminance;\n\t\t\t\te.gradient = pGradient;\n\n\t\t\t}\n\n\t\t\treturn e;\n\n\t\t}\n\n\t\tfloat DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n\t\t\tvec2 uvEdge = uv;\n\t\t\tvec2 edgeStep;\n\t\t\tif (e.isHorizontal) {\n\n\t\t\t\tuvEdge.y += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( texSize.x, 0.0 );\n\n\t\t\t} else {\n\n\t\t\t\tuvEdge.x += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( 0.0, texSize.y );\n\n\t\t\t}\n\n\t\t\tfloat edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n\t\t\tfloat gradientThreshold = e.gradient * 0.25;\n\n\t\t\tvec2 puv = uvEdge + edgeStep * edgeSteps[0];\n\t\t\tfloat pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\tbool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n\t\t\t\tpuv += edgeStep * edgeSteps[i];\n\t\t\t\tpLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\t\tpAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !pAtEnd ) {\n\n\t\t\t\tpuv += edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tvec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n\t\t\tfloat nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\tbool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n\t\t\t\tnuv -= edgeStep * edgeSteps[i];\n\t\t\t\tnLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\t\tnAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !nAtEnd ) {\n\n\t\t\t\tnuv -= edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tfloat pDistance, nDistance;\n\t\t\tif ( e.isHorizontal ) {\n\n\t\t\t\tpDistance = puv.x - uv.x;\n\t\t\t\tnDistance = uv.x - nuv.x;\n\n\t\t\t} else {\n\n\t\t\t\tpDistance = puv.y - uv.y;\n\t\t\t\tnDistance = uv.y - nuv.y;\n\n\t\t\t}\n\n\t\t\tfloat shortestDistance;\n\t\t\tbool deltaSign;\n\t\t\tif ( pDistance <= nDistance ) {\n\n\t\t\t\tshortestDistance = pDistance;\n\t\t\t\tdeltaSign = pLuminanceDelta >= 0.0;\n\n\t\t\t} else {\n\n\t\t\t\tshortestDistance = nDistance;\n\t\t\t\tdeltaSign = nLuminanceDelta >= 0.0;\n\n\t\t\t}\n\n\t\t\tif ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n\t\t\t\treturn 0.0;\n\n\t\t\t}\n\n\t\t\treturn 0.5 - shortestDistance / ( pDistance + nDistance );\n\n\t\t}\n\n\t\tvec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n\t\t\tif ( ShouldSkipPixel( luminance ) ) {\n\n\t\t\t\treturn Sample( tex2D, uv );\n\n\t\t\t}\n\n\t\t\tfloat pixelBlend = DeterminePixelBlendFactor( luminance );\n\t\t\tEdgeData edge = DetermineEdge( texSize, luminance );\n\t\t\tfloat edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n\t\t\tfloat finalBlend = max( pixelBlend, edgeBlend );\n\n\t\t\tif (edge.isHorizontal) {\n\n\t\t\t\tuv.y += edge.pixelStep * finalBlend;\n\n\t\t\t} else {\n\n\t\t\t\tuv.x += edge.pixelStep * finalBlend;\n\n\t\t\t}\n\n\t\t\treturn Sample( tex2D, uv );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\n\t\t}"};class _v extends uv{constructor(){super(vv)}setSize(t,e){this.material.uniforms.resolution.value.set(1/t,1/e)}}const yv={defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvoid SMAAEdgeDetectionVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAAEdgeDetectionVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {\n\t\t\tvec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );\n\n\t\t\t// Calculate color deltas:\n\t\t\tvec4 delta;\n\t\t\tvec3 C = texture2D( colorTex, texcoord ).rgb;\n\n\t\t\tvec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;\n\t\t\tvec3 t = abs( C - Cleft );\n\t\t\tdelta.x = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;\n\t\t\tt = abs( C - Ctop );\n\t\t\tdelta.y = max( max( t.r, t.g ), t.b );\n\n\t\t\t// We do the usual threshold:\n\t\t\tvec2 edges = step( threshold, delta.xy );\n\n\t\t\t// Then discard if there is no edge:\n\t\t\tif ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )\n\t\t\t\tdiscard;\n\n\t\t\t// Calculate right and bottom deltas:\n\t\t\tvec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;\n\t\t\tt = abs( C - Cright );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;\n\t\t\tt = abs( C - Cbottom );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the maximum delta in the direct neighborhood:\n\t\t\tfloat maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );\n\n\t\t\t// Calculate left-left and top-top deltas:\n\t\t\tvec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;\n\t\t\tt = abs( C - Cleftleft );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;\n\t\t\tt = abs( C - Ctoptop );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the final maximum delta:\n\t\t\tmaxDelta = max( max( maxDelta, delta.z ), delta.w );\n\n\t\t\t// Local contrast adaptation in action:\n\t\t\tedges.xy *= step( 0.5 * maxDelta, delta.xy );\n\n\t\t\treturn vec4( edges, 0.0, 0.0 );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );\n\n\t\t}"},xv={defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\t\tvarying vec2 vPixcoord;\n\n\t\tvoid SMAABlendingWeightCalculationVS( vec2 texcoord ) {\n\t\t\tvPixcoord = texcoord / resolution;\n\n\t\t\t// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components\n\n\t\t\t// And these for the searches, they indicate the ends of the loops:\n\t\t\tvOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAABlendingWeightCalculationVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tArea;\n\t\tuniform sampler2D tSearch;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[3];\n\t\tvarying vec2 vPixcoord;\n\n\t\t#if __VERSION__ == 100\n\t\tvec2 round( vec2 x ) {\n\t\t\treturn sign( x ) * floor( abs( x ) + 0.5 );\n\t\t}\n\t\t#endif\n\n\t\tfloat SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {\n\t\t\t// Not required if searchTex accesses are set to point:\n\t\t\t// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n\t\t\t// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n\t\t\t// e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n\t\t\te.r = bias + e.r * scale;\n\t\t\treturn 255.0 * texture2D( searchTex, e, 0.0 ).r;\n\t\t}\n\n\t\tfloat SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\t/**\n\t\t\t\t* @PSEUDO_GATHER4\n\t\t\t\t* This texcoord has been offset by (-0.25, -0.125) in the vertex shader to\n\t\t\t\t* sample between edge, thus fetching four edges in a row.\n\t\t\t\t* Sampling with different offsets in each direction allows to disambiguate\n\t\t\t\t* which edges are active from the four fetched ones.\n\t\t\t\t*/\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\t// We correct the previous (-0.25, -0.125) offset we applied:\n\t\t\ttexcoord.x += 0.25 * resolution.x;\n\n\t\t\t// The searches are bias by 1, so adjust the coords accordingly:\n\t\t\ttexcoord.x += resolution.x;\n\n\t\t\t// Disambiguate the length added by the last step:\n\t\t\ttexcoord.x += 2.0 * resolution.x; // Undo last step\n\t\t\ttexcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.x -= 0.25 * resolution.x;\n\t\t\ttexcoord.x -= resolution.x;\n\t\t\ttexcoord.x -= 2.0 * resolution.x;\n\t\t\ttexcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tfloat SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tvec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {\n\t\t\t// Rounding prevents precision errors of bilinear filtering:\n\t\t\tvec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;\n\n\t\t\t// We do a scale and bias for mapping to texel space:\n\t\t\ttexcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );\n\n\t\t\t// Move to proper place, according to the subpixel offset:\n\t\t\ttexcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n\t\t\treturn texture2D( areaTex, texcoord, 0.0 ).rg;\n\t\t}\n\n\t\tvec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {\n\t\t\tvec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n\t\t\tvec2 e = texture2D( edgesTex, texcoord ).rg;\n\n\t\t\tif ( e.g > 0.0 ) { // Edge at north\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the left:\n\t\t\t\tvec2 coords;\n\t\t\t\tcoords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );\n\t\t\t\tcoords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)\n\t\t\t\td.x = coords.x;\n\n\t\t\t\t// Now fetch the left crossing edges, two at a time using bilinear\n\t\t\t\t// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n\t\t\t\t// discern what value each edge has:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).r;\n\n\t\t\t\t// Find the distance to the right:\n\t\t\t\tcoords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );\n\t\t\t\td.y = coords.x;\n\n\t\t\t\t// We want the distances to be in pixel units (doing this here allow to\n\t\t\t\t// better interleave arithmetic and memory accesses):\n\t\t\t\td = d / resolution.x - pixcoord.x;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the right crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;\n\n\t\t\t\t// Ok, we know how this pattern looks like, now it is time for getting\n\t\t\t\t// the actual area:\n\t\t\t\tweights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );\n\t\t\t}\n\n\t\t\tif ( e.r > 0.0 ) { // Edge at west\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the top:\n\t\t\t\tvec2 coords;\n\n\t\t\t\tcoords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );\n\t\t\t\tcoords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;\n\t\t\t\td.x = coords.y;\n\n\t\t\t\t// Fetch the top crossing edges:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).g;\n\n\t\t\t\t// Find the distance to the bottom:\n\t\t\t\tcoords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );\n\t\t\t\td.y = coords.y;\n\n\t\t\t\t// We want the distances to be in pixel units:\n\t\t\t\td = d / resolution.y - pixcoord.y;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the bottom crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;\n\n\t\t\t\t// Get the area for this direction:\n\t\t\t\tweights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );\n\t\t\t}\n\n\t\t\treturn weights;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );\n\n\t\t}"},bv={uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvoid SMAANeighborhoodBlendingVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAANeighborhoodBlendingVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tColor;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {\n\t\t\t// Fetch the blending weights for current pixel:\n\t\t\tvec4 a;\n\t\t\ta.xz = texture2D( blendTex, texcoord ).xz;\n\t\t\ta.y = texture2D( blendTex, offset[ 1 ].zw ).g;\n\t\t\ta.w = texture2D( blendTex, offset[ 1 ].xy ).a;\n\n\t\t\t// Is there any blending weight with a value greater than 0.0?\n\t\t\tif ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {\n\t\t\t\treturn texture2D( colorTex, texcoord, 0.0 );\n\t\t\t} else {\n\t\t\t\t// Up to 4 lines can be crossing a pixel (one through each edge). We\n\t\t\t\t// favor blending by choosing the line with the maximum weight for each\n\t\t\t\t// direction:\n\t\t\t\tvec2 offset;\n\t\t\t\toffset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n\t\t\t\toffset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n\t\t\t\t// Then we go in the direction that has the maximum weight:\n\t\t\t\tif ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical\n\t\t\t\t\toffset.y = 0.0;\n\t\t\t\t} else {\n\t\t\t\t\toffset.x = 0.0;\n\t\t\t\t}\n\n\t\t\t\t// Fetch the opposite color and lerp by hand:\n\t\t\t\tvec4 C = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\ttexcoord += sign( offset ) * resolution;\n\t\t\t\tvec4 Cop = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\tfloat s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );\n\n\t\t\t\t// WebGL port note: Added gamma correction\n\t\t\t\tC.xyz = pow(C.xyz, vec3(2.2));\n\t\t\t\tCop.xyz = pow(Cop.xyz, vec3(2.2));\n\t\t\t\tvec4 mixed = mix(C, Cop, s);\n\t\t\t\tmixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n\t\t\t\treturn mixed;\n\t\t\t}\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );\n\n\t\t}"};class Sv extends hv{constructor(){super(),this._edgesRT=new Zi(1,1,{depthBuffer:!1,type:Dt}),this._edgesRT.texture.name="SMAAPass.edges",this._weightsRT=new Zi(1,1,{depthBuffer:!1,type:Dt}),this._weightsRT.texture.name="SMAAPass.weights";const t=this,e=new Image;e.src=this._getAreaTexture(),e.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new Xi,this._areaTexture.name="SMAAPass.area",this._areaTexture.image=e,this._areaTexture.minFilter=wt,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;const i=new Image;i.src=this._getSearchTexture(),i.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new Xi,this._searchTexture.name="SMAAPass.search",this._searchTexture.image=i,this._searchTexture.magFilter=xt,this._searchTexture.minFilter=xt,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=sr.clone(yv.uniforms),this._materialEdges=new rr({defines:Object.assign({},yv.defines),uniforms:this._uniformsEdges,vertexShader:yv.vertexShader,fragmentShader:yv.fragmentShader}),this._uniformsWeights=sr.clone(xv.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new rr({defines:Object.assign({},xv.defines),uniforms:this._uniformsWeights,vertexShader:xv.vertexShader,fragmentShader:xv.fragmentShader}),this._uniformsBlend=sr.clone(bv.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new rr({uniforms:this._uniformsBlend,vertexShader:bv.vertexShader,fragmentShader:bv.fragmentShader}),this._fsQuad=new dv(null)}render(t,e,i){this._uniformsEdges.tDiffuse.value=i.texture,this._fsQuad.material=this._materialEdges,t.setRenderTarget(this._edgesRT),this.clear&&t.clear(),this._fsQuad.render(t),this._fsQuad.material=this._materialWeights,t.setRenderTarget(this._weightsRT),this.clear&&t.clear(),this._fsQuad.render(t),this._uniformsBlend.tColor.value=i.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(),this._fsQuad.render(t))}setSize(t,e){this._edgesRT.setSize(t,e),this._weightsRT.setSize(t,e),this._materialEdges.uniforms.resolution.value.set(1/t,1/e),this._materialWeights.uniforms.resolution.value.set(1/t,1/e),this._materialBlend.uniforms.resolution.value.set(1/t,1/e)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture(){return"data:image/png;base64,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"}_getSearchTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}}class wv extends hv{constructor(t,e,i=0,n=0){super(),this.scenes=Array.isArray(t)?t:[t],this.camera=e,this.sampleLevel=2,this.unbiased=!0,this.stencilBuffer=!1,this.clearColor=i,this.clearAlpha=n,this._sampleRenderTarget=null,this._oldClearColor=new _s,this._copyUniforms=sr.clone(ov.uniforms),this._copyMaterial=new rr({uniforms:this._copyUniforms,vertexShader:ov.vertexShader,fragmentShader:ov.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:2}),this._fsQuad=new dv(this._copyMaterial)}dispose(){this._sampleRenderTarget&&(this._sampleRenderTarget.dispose(),this._sampleRenderTarget=null),this._copyMaterial.dispose(),this._fsQuad.dispose()}setSize(t,e){this._sampleRenderTarget&&this._sampleRenderTarget.setSize(t,e)}render(t,e,i,n,s){this._sampleRenderTarget||(this._sampleRenderTarget=new Zi(i.width,i.height,{type:Dt,stencilBuffer:this.stencilBuffer}),this._sampleRenderTarget.texture.name="SSAAMultiRenderPass.sample");const r=Mv[Math.max(0,Math.min(this.sampleLevel,5))],a=t.autoClear;t.autoClear=!1,t.getClearColor(this._oldClearColor);const o=t.getClearAlpha(),h=1/r.length;this._copyUniforms.tDiffuse.value=this._sampleRenderTarget.texture;const l={fullWidth:i.width,fullHeight:i.height,offsetX:0,offsetY:0,width:i.width,height:i.height},c=Object.assign({},this.camera.view);c.enabled&&Object.assign(l,c);for(let i=0;i<r.length;i++){const n=r[i];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*n[0],l.offsetY+.0625*n[1],l.width,l.height);let s=h;if(this.unbiased){s+=.03125*((i+.5)/r.length-.5)}this._copyUniforms.opacity.value=s,t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this._sampleRenderTarget),t.clear(),this.scenes.forEach(e=>t.render(e,this.camera)),t.setRenderTarget(this.renderToScreen?null:e),0===i&&(t.setClearColor(0,0),t.clear()),this._fsQuad.render(t)}this.camera.setViewOffset&&c.enabled?this.camera.setViewOffset(c.fullWidth,c.fullHeight,c.offsetX,c.offsetY,c.width,c.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),t.autoClear=a,t.setClearColor(this._oldClearColor,o)}}const Mv=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],Tv={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:"\n\t\tprecision highp float;\n\n\t\tuniform mat4 modelViewMatrix;\n\t\tuniform mat4 projectionMatrix;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\t#include <tonemapping_pars_fragment>\n\t\t#include <colorspace_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t// tone mapping\n\n\t\t\t#ifdef LINEAR_TONE_MAPPING\n\n\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( AGX_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\n\t\t\t#endif\n\n\t\t\t// color space\n\n\t\t\t#ifdef SRGB_TRANSFER\n\n\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\n\t\t\t#endif\n\n\t\t}"};class Ev extends hv{constructor(){super(),this.isOutputPass=!0,this.uniforms=sr.clone(Tv.uniforms),this.material=new Vh({name:Tv.name,uniforms:this.uniforms,vertexShader:Tv.vertexShader,fragmentShader:Tv.fragmentShader}),this._fsQuad=new dv(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,i){this.uniforms.tDiffuse.value=i.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,this._outputColorSpace===t.outputColorSpace&&this._toneMapping===t.toneMapping||(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},Ui.getTransfer(this._outputColorSpace)===Ve&&(this.material.defines.SRGB_TRANSFER=""),1===this._toneMapping?this.material.defines.LINEAR_TONE_MAPPING="":2===this._toneMapping?this.material.defines.REINHARD_TONE_MAPPING="":3===this._toneMapping?this.material.defines.CINEON_TONE_MAPPING="":4===this._toneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":6===this._toneMapping?this.material.defines.AGX_TONE_MAPPING="":7===this._toneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":5===this._toneMapping&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),!0===this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Av{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter(t=>t!==e);return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach(e=>e.call(this,t)),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}const Cv=Math.PI/180;const Lv="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Rv={_global:Lv,version:"10.2.0",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>Rv.angleDeg?t*Cv:t,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Rv.DD.isDragging,isTransforming(){var t,e;return null!==(e=null===(t=Rv.Transformer)||void 0===t?void 0:t.isTransforming())&&void 0!==e&&e},isDragReady:()=>!!Rv.DD.node,releaseCanvasOnDestroy:!0,document:Lv.document,_injectGlobal(t){void 0!==Lv.Konva&&console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment."),Lv.Konva=t}},Iv=t=>{Rv[t.prototype.getClassName()]=t};Rv._injectGlobal(Rv);const Pv=()=>{if("undefined"==typeof document)throw new Error('Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.\n\nbash: npm install canvas\njs: import "konva/canvas-backend";\n\nor\n\nbash: npm install skia-canvas\njs: import "konva/skia-backend";\n')};class Dv{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Dv(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,r=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=s,this.m[2]=r,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,r=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=s,this.m[3]=r,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],r=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,s=this.m[0]*t,r=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],s=t*n-e*i,r={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const a=Math.sqrt(t*t+e*e);r.rotation=e>0?Math.acos(t/a):-Math.acos(t/a),r.scaleX=a,r.scaleY=s/a,r.skewX=(t*i+e*n)/s,r.skewY=0}else if(0!=i||0!=n){const a=Math.sqrt(i*i+n*n);r.rotation=Math.PI/2-(n>0?Math.acos(-i/a):-Math.acos(i/a)),r.scaleX=s/a,r.scaleY=a,r.skewX=0,r.skewY=(t*i+e*n)/s}return r.rotation=Vv._getRotation(r.rotation),r}}const Ov=Math.PI/180,Nv=180/Math.PI,Uv="#",Fv="Konva error: ",Bv={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},kv=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let zv=[],Gv=null;const Hv="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,16)},Vv={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){zv.push(t),1===zv.length&&Hv(function(){const t=zv;zv=[],t.forEach(function(t){t()})})},createCanvasElement(){Pv();const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>(Pv(),document.createElement("img")),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,e){const i=Vv.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace(Uv,"");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return Uv+t},isCanvasFarblingActive(){if(null!==Gv)return Gv;if("undefined"==typeof document)return Gv=!1,!1;const t=this.createCanvasElement();t.width=10,t.height=10;const e=t.getContext("2d",{willReadFrequently:!0});e.clearRect(0,0,10,10),e.fillStyle="#282828",e.fillRect(0,0,10,10);const i=e.getImageData(0,0,10,10).data;let n=!1;for(let t=0;t<100;t++)if(40!==i[4*t]||40!==i[4*t+1]||40!==i[4*t+2]||255!==i[4*t+3]){n=!0;break}return Gv=n,this.releaseCanvas(t),Gv},getHitColor(){const t=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(t):t},getHitColorKey(t,e,i){return this.isCanvasFarblingActive()&&(t=5*Math.round(t/5),e=5*Math.round(e/5),i=5*Math.round(i/5)),Uv+this._rgbToHex(t,e,i)},getSnappedHexColor(t){const e=this._hexToRgb(t);return Uv+this._rgbToHex(5*Math.round(e.r/5),5*Math.round(e.g/5),5*Math.round(e.b/5))},getRGB(t){let e;return t in Bv?(e=Bv[t],{r:e[0],g:e[1],b:e[2]}):t[0]===Uv?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=kv.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",Vv._namedColorToRBA(t)||Vv._hex3ColorToRGBA(t)||Vv._hex4ColorToRGBA(t)||Vv._hex6ColorToRGBA(t)||Vv._hex8ColorToRGBA(t)||Vv._rgbColorToRGBA(t)||Vv._rgbaColorToRGBA(t)||Vv._hslColorToRGBA(t)),_namedColorToRBA(t){const e=Bv[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,s=Number(i[1])/100,r=Number(i[2])/100;let a,o,h;if(0===s)return h=255*r,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=r<.5?r*(1+s):r+s-r*s;const l=2*r-a,c=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*Ov,radToDeg:t=>t*Nv,_degToRad:t=>(Vv.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Vv.degToRad(t)),_radToDeg:t=>(Vv.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Vv.radToDeg(t)),_getRotation:t=>Rv.angleDeg?Vv.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(Fv+t)},error(t){console.error(Fv+t)},warn(t){Rv.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,s,r){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(s-i)*(s-i)+(r-n)*(r-n);else{const c=((s-t)*(i-t)+(r-e)*(n-e))/l;c<0?(a=t,o=e,h=(t-s)*(t-s)+(e-r)*(e-r)):c>1?(a=i,o=n,h=(i-s)*(i-s)+(n-r)*(n-r)):(a=t+c*(i-t),o=e+c*(n-e),h=(a-s)*(a-s)+(o-r)*(o-r))}return[a,o,h]},_getProjectionToLine(t,e,i){const n=Vv.cloneObject(t);let s=Number.MAX_VALUE;return e.forEach(function(r,a){if(!i&&a===e.length-1)return;const o=e[(a+1)%e.length],h=Vv._getProjectionToSegment(r.x,r.y,o.x,o.y,t.x,t.y),l=h[0],c=h[1],d=h[2];d<s&&(n.x=l,n.y=c,s=d)}),n},_prepareArrayForTween(t,e,i){const n=[],s=[];if(t.length>e.length){const i=e;e=t,t=i}for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});for(let t=0;t<e.length;t+=2)s.push({x:e[t],y:e[t+1]});const r=[];return s.forEach(function(t){const e=Vv._getProjectionToLine(t,n,i);r.push(e.x),r.push(e.y)}),r},_prepareToStringify(t){let e;t.visitedByCircularReferenceRemoval=!0;for(const i in t)if(t.hasOwnProperty(i)&&t[i]&&"object"==typeof t[i])if(e=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||Vv._isElement(t[i])){if(!e.configurable)return null;delete t[i]}else if(null===Vv._prepareToStringify(t[i])){if(!e.configurable)return null;delete t[i]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){Rv.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,n){let s=e<0?e:0,r=i<0?i:0;e=Math.abs(e),i=Math.abs(i);let a=0,o=0,h=0,l=0;"number"==typeof n?a=o=h=l=Math.min(n,e/2,i/2):(a=Math.min(n[0]||0,e/2,i/2),o=Math.min(n[1]||0,e/2,i/2),l=Math.min(n[2]||0,e/2,i/2),h=Math.min(n[3]||0,e/2,i/2)),t.moveTo(s+a,r),t.lineTo(s+e-o,r),t.arc(s+e-o,r+o,o,3*Math.PI/2,0,!1),t.lineTo(s+e,r+i-l),t.arc(s+e-l,r+i-l,l,0,Math.PI/2,!1),t.lineTo(s+h,r+i),t.arc(s+h,r+i-h,h,Math.PI/2,Math.PI,!1),t.lineTo(s,r+a),t.arc(s+a,r+a,a,Math.PI,3*Math.PI/2,!1)},drawRoundedPolygonPath(t,e,i,n,s){n=Math.abs(n);for(let r=0;r<i;r++){const a=e[(r-1+i)%i],o=e[r],h=e[(r+1)%i],l={x:o.x-a.x,y:o.y-a.y},c={x:h.x-o.x,y:h.y-o.y},d=Math.hypot(l.x,l.y),u=Math.hypot(c.x,c.y);let p;p="number"==typeof s?s:r<s.length?s[r]:0;p=n*Math.cos(Math.PI/i)*Math.min(1,p/n*2);const m={x:l.x/d,y:l.y/d},f={x:c.x/u,y:c.y/u},g={x:o.x-m.x*p,y:o.y-m.y*p},v={x:o.x+f.x*p,y:o.y+f.y*p};0===r?t.moveTo(g.x,g.y):t.lineTo(g.x,g.y),t.arcTo(o.x,o.y,v.x,v.y,p)}}};const Wv=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let jv,Xv=null;function Yv(){if(null!==Xv)return Xv;try{const t=Vv.createCanvasElement().getContext("2d");return t?!!t&&"filter"in t:(Xv=!1,!1)}catch(t){return Xv=!1,!1}}class qv{constructor(t){this.canvas=t,Rv.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,s,r,a=this.traceArr,o=a.length,h="";for(i=0;i<o;i++)n=a[i],s=n.method,s?(r=n.args,h+=s,t?h+="()":Vv._isArray(r[0])?h+="(["+r.join(",")+"])":(e&&(r=r.map(t=>"number"==typeof t?Math.floor(t):t)),h+="("+r.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}_applyMiterLimit(t){const e=t.attrs.miterLimit;null!=e&&this.setAttr("miterLimit",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,s,r){this._context.arc(t,e,i,n,s,r)}arcTo(t,e,i,n,s){this._context.arcTo(t,e,i,n,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,s,r){this._context.bezierCurveTo(t,e,i,n,s,r)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,s,r){return this._context.createRadialGradient(t,e,i,n,s,r)}drawImage(t,e,i,n,s,r,a,o,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,s):9===l.length&&c.drawImage(t,e,i,n,s,r,a,o,h)}ellipse(t,e,i,n,s,r,a,o){this._context.ellipse(t,e,i,n,s,r,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,s){this._context.roundRect(t,e,i,n,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,s,r){this._context.setTransform(t,e,i,n,s,r)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,s,r){this._context.transform(t,e,i,n,s,r)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=Wv.length,s=this.setAttr;const r=function(t){let n,s=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=Vv;for(let s=0;s<i;s++){let i=t[s];n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),e.push(i)}return e}(Array.prototype.slice.call(arguments,0)),n=s.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)r(Wv[t]);i.setAttr=function(){s.apply(i,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"].forEach(function(t){Object.defineProperty(qv.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});class Zv extends qv{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const r=t.getFillRadialGradientColorStops();r&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):s?this._fillLinearGradient(t):r&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)s.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",s)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",r=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,c=o.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",r*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*c)}}class Kv extends qv{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}class Jv{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||Rv.pixelRatio||function(){if(jv)return jv;const t=Vv.createCanvasElement(),e=t.getContext("2d");return jv=(Rv._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),Vv.releaseCanvas(t),jv}();this.pixelRatio=e,this._canvas=Vv.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return Vv.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class Qv extends Jv{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new Zv(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}class $v extends Jv{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new Kv(this),this.setSize(t.width,t.height)}}const t_={get isDragging(){let t=!1;return t_._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return t_._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_drag(t){const e=[];t_._dragElements.forEach((i,n)=>{const{node:s}=i,r=s.getStage();r.setPointersPositions(t),void 0===i.pointerId&&(i.pointerId=Vv._getFirstPointerId(t));const a=r._changedPointerPositions.find(t=>t.id===i.pointerId);if(a){if("dragging"!==i.dragStatus){const e=s.dragDistance();if(Math.max(Math.abs(a.x-i.startPointerPos.x),Math.abs(a.y-i.startPointerPos.y))<e)return;if(s.startDrag({evt:t}),!s.isDragging())return}s._setDragPosition(t,i),e.push(s)}}),e.forEach(e=>{e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t){const e=[];t_._dragElements.forEach(i=>{const{node:n}=i,s=n.getStage();t&&s.setPointersPositions(t);if(!s._changedPointerPositions.find(t=>t.id===i.pointerId))return;"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(t_.justDragged=!0,Rv._mouseListenClick=!1,Rv._touchListenClick=!1,Rv._pointerListenClick=!1,i.dragStatus="stopped");const r=i.node.getLayer()||i.node instanceof Rv.Stage&&i.node;r&&-1===e.indexOf(r)&&e.push(r)}),e.forEach(t=>{t.draw()})},_endDragAfter(t){t_._dragElements.forEach((e,i)=>{"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&t_._dragElements.delete(i)})}};function e_(t){return Vv._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||Vv._isBoolean(t)?t:Object.prototype.toString.call(t)}function i_(t){return t>255?255:t<0?0:Math.round(t)}function n_(){if(Rv.isUnminified)return function(t,e){return Vv._isNumber(t)||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function s_(t){if(Rv.isUnminified)return function(e,i){let n=Vv._isNumber(e),s=Vv._isArray(e)&&e.length==t;return n||s||Vv.warn(e_(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function r_(){if(Rv.isUnminified)return function(t,e){return Vv._isNumber(t)||"auto"===t||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function a_(){if(Rv.isUnminified)return function(t,e){return Vv._isString(t)||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function o_(){if(Rv.isUnminified)return function(t,e){const i=Vv._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function h_(){if(Rv.isUnminified)return function(t,e){return!0===t||!1===t||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}Rv.isBrowser&&(window.addEventListener("mouseup",t_._endDragBefore,!0),window.addEventListener("touchend",t_._endDragBefore,!0),window.addEventListener("touchcancel",t_._endDragBefore,!0),window.addEventListener("mousemove",t_._drag),window.addEventListener("touchmove",t_._drag),window.addEventListener("mouseup",t_._endDragAfter,!1),window.addEventListener("touchend",t_._endDragAfter,!1),window.addEventListener("touchcancel",t_._endDragAfter,!1));const l_="get",c_="set",d_={addGetterSetter(t,e,i,n,s){d_.addGetter(t,e,i),d_.addSetter(t,e,n,s),d_.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=l_+Vv._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const s=c_+Vv._capitalize(e);t.prototype[s]||d_.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const s=c_+Vv._capitalize(e);t.prototype[s]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,i,n,s){const r=i.length,a=Vv._capitalize,o=l_+a(e),h=c_+a(e);t.prototype[o]=function(){const t={};for(let n=0;n<r;n++){const s=i[n];t[s]=this.getAttr(e+a(s))}return t};const l=function(t){if(Rv.isUnminified)return function(e,i){return null==e||Vv.isObject(e)||Vv.warn(e_(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(i);t.prototype[h]=function(t){const r=this.attrs[e];n&&(t=n.call(this,t,e)),l&&l.call(this,t,e);for(const i in t)t.hasOwnProperty(i)&&this._setAttr(e+a(i),t[i]);return t||i.forEach(t=>{this._setAttr(e+a(t),void 0)}),this._fireChangeEvent(e,r,t),s&&s.call(this),this},d_.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=Vv._capitalize(e),n=c_+i,s=l_+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,e,i,n){Vv.error("Adding deprecated "+e);const s=l_+Vv._capitalize(e),r=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[s]=function(){Vv.error(r);const t=this.attrs[e];return void 0===t?i:t},d_.addSetter(t,e,n,function(){Vv.error(r)}),d_.addOverloadedGetterSetter(t,e)},backCompat(t,e){Vv.each(e,function(e,i){const n=t.prototype[i],s=l_+Vv._capitalize(e),r=c_+Vv._capitalize(e);function a(){n.apply(this,arguments),Vv.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=a,t.prototype[s]=a,t.prototype[r]=a})},afterSetFilter(){this._filterUpToDate=!1}};function u_(t){const e=/(\w+)\(([^)]+)\)/g;let i;for(;null!==(i=e.exec(t));){const[,t,e]=i;switch(t){case"blur":{const t=parseFloat(e.replace("px",""));return function(e){this.blurRadius(.5*t);const i=Rv.Filters;i&&i.Blur&&i.Blur.call(this,e)}}case"brightness":{const t=e.includes("%")?parseFloat(e)/100:parseFloat(e);return function(e){this.brightness(t);const i=Rv.Filters;i&&i.Brightness&&i.Brightness.call(this,e)}}case"contrast":{const t=parseFloat(e);return function(e){const i=100*(Math.sqrt(t)-1);this.contrast(i);const n=Rv.Filters;n&&n.Contrast&&n.Contrast.call(this,e)}}case"grayscale":return function(t){const e=Rv.Filters;e&&e.Grayscale&&e.Grayscale.call(this,t)};case"sepia":return function(t){const e=Rv.Filters;e&&e.Sepia&&e.Sepia.call(this,t)};case"invert":return function(t){const e=Rv.Filters;e&&e.Invert&&e.Invert.call(this,t)};default:Vv.warn(`CSS filter "${t}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}const p_="absoluteOpacity",m_="allEventListeners",f_="absoluteTransform",g_="absoluteScale",v_="canvas",__="listening",y_="Shape",x_=" ",b_="stage",S_="transform",w_="visible",M_=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(x_);let T_=1;class E_{constructor(t){this._id=T_++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==S_&&t!==f_||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===S_||t===f_)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map(t=>t+"Change.konva").join(x_);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(v_)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===f_&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(v_)){const{scene:t,filter:e,hit:i}=this._cache.get(v_);Vv.releaseCanvas(t._canvas,e._canvas,i._canvas),this._cache.delete(v_)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),r=e.pixelRatio,a=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,c=e.hitCanvasPixelRatio||1;if(!n||!s)return void Vv.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-a)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),a-=h,o-=h;const d=new Qv({pixelRatio:r,width:n,height:s}),u=new Qv({pixelRatio:r,width:0,height:0,willReadFrequently:!0}),p=new $v({pixelRatio:c,width:n,height:s}),m=d.getContext(),f=p.getContext(),g=new Qv({width:d.width/d.pixelRatio+Math.abs(a),height:d.height/d.pixelRatio+Math.abs(o),pixelRatio:d.pixelRatio}),v=g.getContext();return p.isCache=!0,d.isCache=!0,this._cache.delete(v_),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),m.save(),f.save(),v.save(),m.translate(-a,-o),f.translate(-a,-o),v.translate(-a,-o),g.x=a,g.y=o,this._isUnderCache=!0,this._clearSelfAndDescendantCache(p_),this._clearSelfAndDescendantCache(g_),this.drawScene(d,this,g),this.drawHit(p,this),this._isUnderCache=!1,m.restore(),f.restore(),l&&(m.save(),m.beginPath(),m.rect(0,0,n,s),m.closePath(),m.setAttr("strokeStyle","red"),m.setAttr("lineWidth",5),m.stroke(),m.restore()),Vv.releaseCanvas(g._canvas),this._cache.set(v_,{scene:d,filter:u,hit:p,x:a,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(v_)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,s=1/0,r=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=o.point(t);void 0===n&&(n=r=e.x,s=a=e.y),n=Math.min(n,e.x),s=Math.min(s,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)}),{x:n,y:s,width:r-n,height:a-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,s=this.filters(),r=this._getCanvasCache(),a=r.scene,o=r.filter,h=o.getContext();if(!s||0===s.length)return a;if(this._filterUpToDate)return o;let l=!0;for(let t=0;t<s.length;t++)if("string"==typeof s[t]&&Yv(),"string"!=typeof s[t]||!Yv()){l=!1;break}const c=a.pixelRatio;if(o.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio),l){const t=s.join(" ");return h.save(),h.setAttr("filter",t),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),h.restore(),this._filterUpToDate=!0,o}try{for(t=s.length,h.clear(),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)n=s[i],"string"==typeof n&&(n=u_(n)),n.call(this,e),h.putImageData(e,0,0)}catch(t){Vv.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(t,e){if(this._cache&&this._cache.delete(m_),3===arguments.length)return this._delegate.apply(this,arguments);const i=t.split(x_);for(let t=0;t<i.length;t++){const n=i[t].split("."),s=n[0],r=n[1]||"";this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:r,handler:e})}return this}off(t,e){let i,n,s,r,a,o,h=(t||"").split(x_),l=h.length;if(this._cache&&this._cache.delete(m_),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<l;i++)if(s=h[i],r=s.split("."),a=r[0],o=r[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){const n=this;this.on(t,function(t){const s=t.target.findAncestors(e,!0,n);for(let e=0;e<s.length;e++)(t=Vv.cloneObject(t)).currentTarget=s[e],i.call(s[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),t_._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(f_),this._clearSelfAndDescendantCache(p_),this._clearSelfAndDescendantCache(g_),this._clearSelfAndDescendantCache(b_),this._clearSelfAndDescendantCache(w_),this._clearSelfAndDescendantCache(__)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+Vv._capitalize(t);return Vv._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+Vv._capitalize(e),Vv._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(__,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(w_,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;t_._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)});const s=!e&&!Rv.hitOnDragEnabled&&(n||Rv.isTransforming());return this.isListening()&&this.isVisible()&&!s}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,s=this.getDepth(),r=this,a=0;const o=this.getStage();return"Stage"!==r.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==y_&&(t=t.concat(n.getChildren().slice())),n._id===r._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(S_),this._clearSelfAndDescendantCache(f_)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);const n=this.getAbsoluteTransform(t).getMatrix(),s=new Dv,r=this.offset();return s.m=n.slice(),s.translate(r.x,r.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(S_);const s=this._getAbsoluteTransform().copy();return s.invert(),s.translate(t.x,t.y),t={x:this.attrs.x+s.getTranslation().x,y:this.attrs.y+s.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(S_),this._clearSelfAndDescendantCache(f_),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),s=this.y();return void 0!==e&&(n+=e),void 0!==i&&(s+=i),this.setPosition({x:n,y:s}),this}_eachAncestorReverse(t,e){let i,n,s=[],r=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);r&&(!e||r._id!==e._id);)s.unshift(r),r=r.parent;for(i=s.length,n=0;n<i;n++)t(s[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Vv.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return Vv.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return Vv.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return Vv.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return Vv.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Vv.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(p_,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,i,n,s,r=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in r)e=r[t],s=Vv.isObject(e)&&!Vv._isPlainObject(e)&&!Vv._isArray(e),s||(i="function"==typeof this[t]&&this[t],delete r[t],n=i?i.call(this):null,r[t]=e,n!==e&&(a.attrs[t]=e));return Vv._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let s=this.parent;for(;s;){if(s===i)return n;s._isMatch(t)&&n.push(s),s=s.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),s=n.length;for(e=0;e<s;e++)if(i=n[e],Vv.isValidSelector(i)||(Vv.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Vv.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Vv.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(b_,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(f_,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new Dv,this._eachAncestorReverse(function(t){const i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(f_)||new Dv,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-n,i-s)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(S_,this._getTransform)}_getTransform(){var t,e;const i=this._cache.get(S_)||new Dv;i.reset();const n=this.x(),s=this.y(),r=Rv.getAngle(this.rotation()),a=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,c=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===s||i.translate(n,s),0!==r&&i.rotate(r),0===h&&0===l||i.skew(h,l),1===a&&1===o||i.scale(a,o),0===c&&0===d||i.translate(-1*c,-1*d),i.dirty=!1,i}clone(t){let e,i,n,s,r,a=Vv.cloneObject(this.attrs);for(e in t)a[e]=t[e];const o=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],n=i.length,s=0;s<n;s++)r=i[s],r.name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(r));return o}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),r=t.pixelRatio||1,a=new Qv({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:r}),o=a.getContext(),h=new Qv({width:a.width/a.pixelRatio+Math.abs(n),height:a.height/a.pixelRatio+Math.abs(s),pixelRatio:a.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(n||s)&&o.translate(-1*n,-1*s),this.drawScene(a,void 0,h),o.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,Vv._urlToImage(this.toDataURL(t),function(t){e(t),null==i||i(t)})}catch(t){i(t)}})}toBlob(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==i||i(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Rv.dragDistance}_off(t,e,i){let n,s,r,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(s=a[n].name,r=a[n].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==r)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){const i=this["set"+Vv._capitalize(t)];return Vv._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(Rv.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||Vv.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===y_&&(e.target=this);const n=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==n.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=-1!==n.indexOf(t)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!s&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i;const{nodeType:n}=this,s=E_.protoListenerMap.get(n)||{};let r=null==s?void 0:s[t];if(void 0===r){r=[];let a=Object.getPrototypeOf(this);for(;a;){const n=null!==(i=null===(e=a.eventListeners)||void 0===e?void 0:e[t])&&void 0!==i?i:[];r.push(...n),a=Object.getPrototypeOf(a)}s[t]=r,E_.protoListenerMap.set(n,s)}return r}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const n=this.eventListeners[t];if(n)for(let t=0;t<n.length;t++)n[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||n;t_._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){t_._dragElements.has(this._id)||this._createDragElement(t);t_._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let n={x:i.x-e.offset.x,y:i.y-e.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const e=s.call(this,n,t);e?n=e:Vv.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}stopDrag(t){const e=t_._dragElements.get(this._id);e&&(e.dragStatus="stopped"),t_._endDragBefore(t),t_._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=t_._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(!(void 0!==t.evt.button)||Rv.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;t_._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=t_._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&t_._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return Vv.haveIntersection(i,this.getClientRect())}static create(t,e){return Vv._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let i,n,s,r=E_.prototype.getClassName.call(t),a=t.children;e&&(t.attrs.container=e),Rv[r]||(Vv.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");if(i=new(0,Rv[r])(t.attrs),a)for(n=a.length,s=0;s<n;s++)i.add(E_._createNode(a[s]));return i}}E_.protoListenerMap=new Map,E_.prototype.nodeType="Node",E_.prototype._attrsAffectingSize=[],E_.prototype.eventListeners={},E_.prototype.on.call(E_.prototype,M_,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(S_),this._clearSelfAndDescendantCache(f_))}),E_.prototype.on.call(E_.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(w_)}),E_.prototype.on.call(E_.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(__)}),E_.prototype.on.call(E_.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(p_)});const A_=d_.addGetterSetter;A_(E_,"zIndex"),A_(E_,"absolutePosition"),A_(E_,"position"),A_(E_,"x",0,n_()),A_(E_,"y",0,n_()),A_(E_,"globalCompositeOperation","source-over",a_()),A_(E_,"opacity",1,n_()),A_(E_,"name","",a_()),A_(E_,"id","",a_()),A_(E_,"rotation",0,n_()),d_.addComponentsGetterSetter(E_,"scale",["x","y"]),A_(E_,"scaleX",1,n_()),A_(E_,"scaleY",1,n_()),d_.addComponentsGetterSetter(E_,"skew",["x","y"]),A_(E_,"skewX",0,n_()),A_(E_,"skewY",0,n_()),d_.addComponentsGetterSetter(E_,"offset",["x","y"]),A_(E_,"offsetX",0,n_()),A_(E_,"offsetY",0,n_()),A_(E_,"dragDistance",void 0,n_()),A_(E_,"width",0,n_()),A_(E_,"height",0,n_()),A_(E_,"listening",!0,h_()),A_(E_,"preventDefault",!0,h_()),A_(E_,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),A_(E_,"visible",!0,h_()),A_(E_,"transformsEnabled","all",a_()),A_(E_,"size"),A_(E_,"dragBoundFunc"),A_(E_,"draggable",!1,h_()),d_.backCompat(E_,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class C_ extends E_{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants(n=>{const s=n._isMatch(t);return s&&i.push(n),!(!s||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=E_.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=E_.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas(),r=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,s=n&&n.getContext(),r=this._getCanvasCache();if(r&&r.hit){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s),s.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var s;const r=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,c=i===this;if(l){r.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),r.beginPath(),h)e=h.call(this,r,this);else{const t=this.clipX(),e=this.clipY();r.rect(t||0,e||0,a,o)}r.clip.apply(r,e),n=t.copy().invert().getMatrix(),r.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach(function(s){s[t](e,i,n)}),d&&r.restore(),l&&r.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let s,r,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===s?(s=i.x,r=i.y,a=i.x+i.width,o=i.y+i.height):(s=Math.min(s,i.x),r=Math.min(r,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))});const c=this.find("Shape");let d=!1;for(let t=0;t<c.length;t++){if(c[t]._isVisible(this)){d=!0;break}}return h=d&&void 0!==s?{x:s,y:r,width:a-s,height:o-r}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}}d_.addComponentsGetterSetter(C_,"clip",["x","y","width","height"]),d_.addGetterSetter(C_,"clipX",void 0,n_()),d_.addGetterSetter(C_,"clipY",void 0,n_()),d_.addGetterSetter(C_,"clipWidth",void 0,n_()),d_.addGetterSetter(C_,"clipHeight",void 0,n_()),d_.addGetterSetter(C_,"clipFunc");const L_=new Map,R_=void 0!==Rv._global.PointerEvent;function I_(t){return L_.get(t)}function P_(t){return{evt:t,pointerId:t.pointerId}}function D_(t,e){return L_.get(t)===e}function O_(t,e){N_(t);e.getStage()&&(L_.set(t,e),R_&&e._fire("gotpointercapture",P_(new PointerEvent("gotpointercapture"))))}function N_(t,e){const i=L_.get(t);if(!i)return;const n=i.getStage();n&&n.content,L_.delete(t),R_&&i._fire("lostpointercapture",P_(new PointerEvent("lostpointercapture")))}const U_="mouseleave",F_="mouseover",B_="mouseenter",k_="mousemove",z_="mousedown",G_="mouseup",H_="pointermove",V_="pointerdown",W_="pointerup",j_="pointercancel",X_="pointerout",Y_="pointerleave",q_="pointerover",Z_="pointerenter",K_="contextmenu",J_="touchstart",Q_="touchend",$_="touchmove",ty="touchcancel",ey="wheel",iy=[[B_,"_pointerenter"],[z_,"_pointerdown"],[k_,"_pointermove"],[G_,"_pointerup"],[U_,"_pointerleave"],[J_,"_pointerdown"],[$_,"_pointermove"],[Q_,"_pointerup"],[ty,"_pointercancel"],[F_,"_pointerover"],[ey,"_wheel"],[K_,"_contextmenu"],[V_,"_pointerdown"],[H_,"_pointermove"],[W_,"_pointerup"],[j_,"_pointercancel"],[Y_,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],ny={mouse:{[X_]:"mouseout",[Y_]:U_,[q_]:F_,[Z_]:B_,[H_]:k_,[V_]:z_,[W_]:G_,[j_]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[X_]:"touchout",[Y_]:"touchleave",[q_]:"touchover",[Z_]:"touchenter",[H_]:$_,[V_]:J_,[W_]:Q_,[j_]:ty,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[X_]:X_,[Y_]:Y_,[q_]:q_,[Z_]:Z_,[H_]:H_,[V_]:V_,[W_]:W_,[j_]:j_,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},sy=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",ry=t=>{const e=sy(t);return"pointer"===e?Rv.pointerEventsEnabled&&ny.pointer:"touch"===e?ny.touch:"mouse"===e?ny.mouse:void 0};function ay(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&Vv.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const oy=[];class hy extends C_{constructor(t){super(ay(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),oy.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{ay(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||Vv.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),C_.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&Vv._isInDocument(t)&&this.container().removeChild(t);const e=oy.indexOf(this);return e>-1&&oy.splice(e,1),Vv.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(Vv.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t={...t}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new Qv({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach(function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const i=this.children.length;return i>5&&Vv.warn("The stage has "+i+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),Rv.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return D_(t,this)}setPointerCapture(t){O_(t,this)}releaseCapture(t){N_(t)}getLayers(){return this.children}_bindContentEvents(){Rv.isBrowser&&iy.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=ry(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=ry(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=ry(t.type),i=sy(t.type);if(!e)return;this.setPointersPositions(t);const n=this._getTargetShape(i),s=!(Rv.isDragging()||Rv.isTransforming())||Rv.hitOnDragEnabled;n&&s?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):s&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=ry(t.type),i=sy(t.type);if(!e)return;this.setPointersPositions(t);let n=!1;this._changedPointerPositions.forEach(s=>{const r=this.getIntersection(s);if(t_.justDragged=!1,Rv["_"+i+"ListenClick"]=!0,!r||!r.isListening())return void(this[i+"ClickStartShape"]=void 0);Rv.capturePointerEventsEnabled&&r.setPointerCapture(s.id),this[i+"ClickStartShape"]=r,r._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),n=!0;const a=t.type.indexOf("touch")>=0;r.preventDefault()&&t.cancelable&&a&&t.preventDefault()}),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=ry(t.type),i=sy(t.type);if(!e)return;const n=t.type.indexOf("touch")>=0||"touch"===t.pointerType;Rv.isDragging()&&t_.node.preventDefault()&&t.cancelable&&n&&t.preventDefault(),this.setPointersPositions(t);if(!(!(Rv.isDragging()||Rv.isTransforming())||Rv.hitOnDragEnabled))return;const s={};let r=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach(n=>{const o=I_(n.id)||this.getIntersection(n),h=n.id,l={evt:t,pointerId:h},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...l},o),a._fireAndBubble(e.pointerleave,{...l},o)),o){if(s[o._id])return;s[o._id]=!0}o&&o.isListening()?(r=!0,c&&(o._fireAndBubble(e.pointerover,{...l},a),o._fireAndBubble(e.pointerenter,{...l},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...l})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)}),r||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=ry(t.type),i=sy(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],s=this[i+"ClickEndShape"],r={};let a=!1;this._changedPointerPositions.forEach(o=>{const h=I_(o.id)||this.getIntersection(o);if(h){if(h.releaseCapture(o.id),r[h._id])return;r[h._id]=!0}const l=o.id,c={evt:t,pointerId:l};let d=!1;Rv["_"+i+"InDblClickWindow"]?(d=!0,clearTimeout(this[i+"DblTimeout"])):t_.justDragged||(Rv["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){Rv["_"+i+"InDblClickWindow"]=!1},Rv.dblClickWindow),h&&h.isListening()?(a=!0,this[i+"ClickEndShape"]=h,h._fireAndBubble(e.pointerup,{...c}),Rv["_"+i+"ListenClick"]&&n&&n===h&&(h._fireAndBubble(e.pointerclick,{...c}),d&&s&&s===h&&h._fireAndBubble(e.pointerdblclick,{...c}))):(this[i+"ClickEndShape"]=null,a||(this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a=!0),Rv["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:l}),d&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:l}))}),a||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Rv["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(K_,{evt:t}):this._fire(K_,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(ey,{evt:t}):this._fire(ey,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=I_(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(W_,P_(t)),N_(t.pointerId)}_lostpointercapture(t){N_(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:Vv._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:Vv._getFirstPointerId(t)}])}_setPointerPosition(t){Vv.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new Qv({width:this.width(),height:this.height()}),this.bufferHitCanvas=new $v({pixelRatio:1,width:this.width(),height:this.height()}),!Rv.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return Vv.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}hy.prototype.nodeType="Stage",Iv(hy),d_.addGetterSetter(hy,"container"),Rv.isBrowser&&document.addEventListener("visibilitychange",()=>{oy.forEach(t=>{t.batchDraw()})});const ly="hasShadow",cy="shadowRGBA",dy="patternImage",uy="linearGradient",py="radialGradient";let my;function fy(){return my||(my=Vv.createCanvasElement().getContext("2d"),my)}const gy={};class vy extends E_{constructor(t){let e;super(t);let i=0;for(;e=Vv.getHitColor(),!e||e in gy;)if(i++,i>=1e4){Vv.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),e=Vv.getRandomColor();break}this.colorKey=e,gy[e]=this}getContext(){return Vv.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Vv.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(ly,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(dy,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=fy().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new Dv;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(Rv.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const i=e.getMatrix(),n="undefined"==typeof DOMMatrix?{a:i[0],b:i[1],c:i[2],d:i[3],e:i[4],f:i[5]}:new DOMMatrix(i);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(uy,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=fy(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}_getRadialGradient(){return this._getCache(py,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=fy(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}getShadowRGBA(){return this._getCache(cy,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=Vv.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return E_.prototype.destroy.call(this),delete gy[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&n&&s)return!0;const r=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&r&&a)}setStrokeHitEnabled(t){Vv.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,r=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=r.width+a,h=r.height+a,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=o+Math.abs(c),p=h+Math.abs(d),m=l&&this.shadowBlur()||0,f={width:u+2*m,height:p+2*m,x:-(a/2+m)+Math.min(c,0)+r.x,y:-(a/2+m)+Math.min(d,0)+r.y};return n?f:this._transformedRect(f,s)}drawScene(t,e,i){const n=this.getLayer(),s=(t||n.getCanvas()).getContext(),r=this._getCanvasCache(),a=this.getSceneFunc(),o=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(r){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore(),this}if(!a)return this;if(s.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,n=t.getContext();i?(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()):n.clear(),n.save(),n._applyLineJoin(this),n._applyMiterLimit(this);const r=this.getAbsoluteTransform(e).getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),a.call(this,n,this),n.restore();const c=t.pixelRatio;o&&s._applyShadow(this),l||(s._applyOpacity(this),s._applyGlobalCompositeOperation(this)),s.drawImage(t._canvas,t.x||0,t.y||0,t.width/c,t.height/c)}else{if(s._applyLineJoin(this),s._applyMiterLimit(this),!l){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),s._applyOpacity(this),s._applyGlobalCompositeOperation(this)}o&&s._applyShadow(this),a.call(this,s,this)}return s.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const n=this.getLayer(),s=t||n.hitCanvas,r=s&&s.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCanvasCache(),h=o&&o.hit;if(this.colorKey||Vv.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore(),this}if(!a)return this;r.save(),r._applyLineJoin(this),r._applyMiterLimit(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,r,this),r.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),i=this._getCachedSceneCanvas(),n=e.hit,s=n.getContext(),r=n.getWidth(),a=n.getHeight();s.clear(),s.drawImage(i._canvas,0,0,r,a);try{const e=s.getImageData(0,0,r,a),i=e.data,n=i.length,o=Vv._hexToRgb(this.colorKey);for(let e=0;e<n;e+=4){i[e+3]>t?(i[e]=o.r,i[e+1]=o.g,i[e+2]=o.b,i[e+3]=255):i[e+3]=0}s.putImageData(e,0,0)}catch(t){Vv.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return D_(t,this)}setPointerCapture(t){O_(t,this)}releaseCapture(t){N_(t)}}vy.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},vy.prototype._strokeFunc=function(t){t.stroke()},vy.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},vy.prototype._strokeFuncHit=function(t){t.stroke()},vy.prototype._centroid=!1,vy.prototype.nodeType="Shape",Iv(vy),vy.prototype.eventListeners={},vy.prototype.on.call(vy.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(ly)}),vy.prototype.on.call(vy.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(cy)}),vy.prototype.on.call(vy.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(dy)}),vy.prototype.on.call(vy.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(uy)}),vy.prototype.on.call(vy.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(py)}),d_.addGetterSetter(vy,"stroke",void 0,o_()),d_.addGetterSetter(vy,"strokeWidth",2,n_()),d_.addGetterSetter(vy,"fillAfterStrokeEnabled",!1),d_.addGetterSetter(vy,"hitStrokeWidth","auto",r_()),d_.addGetterSetter(vy,"strokeHitEnabled",!0,h_()),d_.addGetterSetter(vy,"perfectDrawEnabled",!0,h_()),d_.addGetterSetter(vy,"shadowForStrokeEnabled",!0,h_()),d_.addGetterSetter(vy,"lineJoin"),d_.addGetterSetter(vy,"lineCap"),d_.addGetterSetter(vy,"miterLimit"),d_.addGetterSetter(vy,"sceneFunc"),d_.addGetterSetter(vy,"hitFunc"),d_.addGetterSetter(vy,"dash"),d_.addGetterSetter(vy,"dashOffset",0,n_()),d_.addGetterSetter(vy,"shadowColor",void 0,a_()),d_.addGetterSetter(vy,"shadowBlur",0,n_()),d_.addGetterSetter(vy,"shadowOpacity",1,n_()),d_.addComponentsGetterSetter(vy,"shadowOffset",["x","y"]),d_.addGetterSetter(vy,"shadowOffsetX",0,n_()),d_.addGetterSetter(vy,"shadowOffsetY",0,n_()),d_.addGetterSetter(vy,"fillPatternImage"),d_.addGetterSetter(vy,"fill",void 0,o_()),d_.addGetterSetter(vy,"fillPatternX",0,n_()),d_.addGetterSetter(vy,"fillPatternY",0,n_()),d_.addGetterSetter(vy,"fillLinearGradientColorStops"),d_.addGetterSetter(vy,"strokeLinearGradientColorStops"),d_.addGetterSetter(vy,"fillRadialGradientStartRadius",0),d_.addGetterSetter(vy,"fillRadialGradientEndRadius",0),d_.addGetterSetter(vy,"fillRadialGradientColorStops"),d_.addGetterSetter(vy,"fillPatternRepeat","repeat"),d_.addGetterSetter(vy,"fillEnabled",!0),d_.addGetterSetter(vy,"strokeEnabled",!0),d_.addGetterSetter(vy,"shadowEnabled",!0),d_.addGetterSetter(vy,"dashEnabled",!0),d_.addGetterSetter(vy,"strokeScaleEnabled",!0),d_.addGetterSetter(vy,"fillPriority","color"),d_.addComponentsGetterSetter(vy,"fillPatternOffset",["x","y"]),d_.addGetterSetter(vy,"fillPatternOffsetX",0,n_()),d_.addGetterSetter(vy,"fillPatternOffsetY",0,n_()),d_.addComponentsGetterSetter(vy,"fillPatternScale",["x","y"]),d_.addGetterSetter(vy,"fillPatternScaleX",1,n_()),d_.addGetterSetter(vy,"fillPatternScaleY",1,n_()),d_.addComponentsGetterSetter(vy,"fillLinearGradientStartPoint",["x","y"]),d_.addComponentsGetterSetter(vy,"strokeLinearGradientStartPoint",["x","y"]),d_.addGetterSetter(vy,"fillLinearGradientStartPointX",0),d_.addGetterSetter(vy,"strokeLinearGradientStartPointX",0),d_.addGetterSetter(vy,"fillLinearGradientStartPointY",0),d_.addGetterSetter(vy,"strokeLinearGradientStartPointY",0),d_.addComponentsGetterSetter(vy,"fillLinearGradientEndPoint",["x","y"]),d_.addComponentsGetterSetter(vy,"strokeLinearGradientEndPoint",["x","y"]),d_.addGetterSetter(vy,"fillLinearGradientEndPointX",0),d_.addGetterSetter(vy,"strokeLinearGradientEndPointX",0),d_.addGetterSetter(vy,"fillLinearGradientEndPointY",0),d_.addGetterSetter(vy,"strokeLinearGradientEndPointY",0),d_.addComponentsGetterSetter(vy,"fillRadialGradientStartPoint",["x","y"]),d_.addGetterSetter(vy,"fillRadialGradientStartPointX",0),d_.addGetterSetter(vy,"fillRadialGradientStartPointY",0),d_.addComponentsGetterSetter(vy,"fillRadialGradientEndPoint",["x","y"]),d_.addGetterSetter(vy,"fillRadialGradientEndPointX",0),d_.addGetterSetter(vy,"fillRadialGradientEndPointY",0),d_.addGetterSetter(vy,"fillPatternRotation",0),d_.addGetterSetter(vy,"fillRule",void 0,a_()),d_.backCompat(vy,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});const _y=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],yy=_y.length;class xy extends C_{constructor(t){super(t),this.canvas=new Qv,this.hitCanvas=new $v({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){E_.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!E_.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(E_.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(E_.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return E_.prototype.remove.call(this),t&&t.parentNode&&Vv._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Vv.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t={...t}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),E_.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Vv.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Vv.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Vv.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<yy;n++){const s=_y[n],r=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),a=r.shape;if(a)return a;if(i=!!r.antialiased,!r.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){const t=Vv.getHitColorKey(i[0],i[1],i[2]),e=gy[t];return e?{shape:e}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),C_.prototype.drawScene.call(this,s,e,i),this._fire("draw",{node:this}),this}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),C_.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){Vv.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return Vv.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return Vv.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}xy.prototype.nodeType="Layer",Iv(xy),d_.addGetterSetter(xy,"imageSmoothingEnabled",!0),d_.addGetterSetter(xy,"clearBeforeDraw",!0),d_.addGetterSetter(xy,"hitGraphEnabled",!0,h_());class by extends xy{constructor(t){super(t),this.listening(!1),Vv.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}by.prototype.nodeType="FastLayer",Iv(by);class Sy extends C_{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Vv.throw("You may only add groups and shapes to groups.")}}Sy.prototype.nodeType="Group",Iv(Sy);const wy=Lv.performance&&Lv.performance.now?function(){return Lv.performance.now()}:function(){return(new Date).getTime()};class My{constructor(t,e){this.id=My.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:wy(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=My.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=wy(),My._addAnimation(this),this}stop(){return My._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const n=e[i],s=n.layers,r=n.func;n._updateFrameObject(wy());const a=s.length;let o;if(o=!r||!1!==r.call(n,n.frame),o)for(let e=0;e<a;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=My;t.animations.length?(t._runFrames(),Vv.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Vv.requestAnimFrame(this._animationLoop))}}My.animations=[],My.animIdCounter=0,My.animRunning=!1;const Ty={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Ey=["fill","stroke","shadowColor"];let Ay=0;class Cy{constructor(t,e,i,n,s,r,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=r,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=s-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class Ly{constructor(t){const e=this,i=t.node,n=i._id,s=t.easing||Ry.Linear,r=!!t.yoyo;let a,o;a=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=i,this._id=Ay++;const h=i.getLayer()||(i instanceof Rv.Stage?i.getLayers():null);for(o in h||Vv.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new My(function(){e.tween.onEnterFrame()},h),this.tween=new Cy(o,function(t){e._tweenFunc(t)},s,0,1,1e3*a,r),this._addListeners(),Ly.attrs[n]||(Ly.attrs[n]={}),Ly.attrs[n][this._id]||(Ly.attrs[n][this._id]={}),Ly.tweens[n]||(Ly.tweens[n]={}),t)void 0===Ty[o]&&this._addAttr(o,t[o]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const i=this.node,n=i._id;let s,r,a,o,h;const l=Ly.tweens[n][t];l&&delete Ly.attrs[n][l][t];let c=i.getAttr(t);if(Vv._isArray(e))if(s=[],r=Math.max(e.length,c.length),"points"===t&&e.length!==c.length&&(e.length>c.length?(o=c,c=Vv._prepareArrayForTween(c,e,i.closed())):(a=e,e=Vv._prepareArrayForTween(e,c,i.closed()))),0===t.indexOf("fill"))for(let t=0;t<r;t++)if(t%2==0)s.push(e[t]-c[t]);else{const i=Vv.colorToRGBA(c[t]);h=Vv.colorToRGBA(e[t]),c[t]=i,s.push({r:h.r-i.r,g:h.g-i.g,b:h.b-i.b,a:h.a-i.a})}else for(let t=0;t<r;t++)s.push(e[t]-c[t]);else-1!==Ey.indexOf(t)?(c=Vv.colorToRGBA(c),h=Vv.colorToRGBA(e),s={r:h.r-c.r,g:h.g-c.g,b:h.b-c.b,a:h.a-c.a}):s=e-c;Ly.attrs[n][this._id][t]={start:c,diff:s,end:e,trueEnd:a,trueStart:o},Ly.tweens[n][t]=this._id}_tweenFunc(t){const e=this.node,i=Ly.attrs[e._id][this._id];let n,s,r,a,o,h,l,c;for(n in i){if(s=i[n],r=s.start,a=s.diff,c=s.end,Vv._isArray(r))if(o=[],l=Math.max(r.length,c.length),0===n.indexOf("fill"))for(h=0;h<l;h++)h%2==0?o.push((r[h]||0)+a[h]*t):o.push("rgba("+Math.round(r[h].r+a[h].r*t)+","+Math.round(r[h].g+a[h].g*t)+","+Math.round(r[h].b+a[h].b*t)+","+(r[h].a+a[h].a*t)+")");else for(h=0;h<l;h++)o.push((r[h]||0)+a[h]*t);else o=-1!==Ey.indexOf(n)?"rgba("+Math.round(r.r+a.r*t)+","+Math.round(r.g+a.g*t)+","+Math.round(r.b+a.b*t)+","+(r.a+a.a*t)+")":r+a*t;e.setAttr(n,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=Ly.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=Ly.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=Ly.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete Ly.tweens[t][e];delete Ly.attrs[t][e],Ly.tweens[t]&&(0===Object.keys(Ly.tweens[t]).length&&delete Ly.tweens[t],0===Object.keys(Ly.attrs[t]).length&&delete Ly.attrs[t])}}Ly.attrs={},Ly.tweens={},E_.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()};new Ly(t).play()};const Ry={BackEaseIn(t,e,i,n){const s=1.70158;return i*(t/=n)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,n){const s=1.70158;return i*((t=t/n-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,n){let s=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},ElasticEaseIn(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)+e)},ElasticEaseOut(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/r)+i+e)},ElasticEaseInOut(t,e,i,n,s,r){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(r||(r=n*(.3*1.5)),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,e,i,n)=>i-Ry.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>t<n/2?.5*Ry.BounceEaseIn(2*t,0,i,n)+e:.5*Ry.BounceEaseOut(2*t-n,0,i,n)+.5*i+e,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},Iy=Vv._assign(Rv,{Util:Vv,Transform:Dv,Node:E_,Container:C_,Stage:hy,stages:oy,Layer:xy,FastLayer:by,Group:Sy,DD:t_,Shape:vy,shapes:gy,Animation:My,Tween:Ly,Easings:Ry,Context:qv,Canvas:Jv});class Py extends vy{_sceneFunc(t){const e=Rv.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),n=Rv.getAngle(i?360-this.angle():this.angle()),s=Math.cos(Math.min(n,Math.PI)),r=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),a=Math.sin(Math.min(n,Math.PI/2)),o=s*(s>0?t:e),h=r*(r>0?t:e),l=a*(a>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}function Dy(t,e,i,n,s,r,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(r-n,2)),l=a*o/(o+h),c=a*h/(o+h);return[i-l*(s-t),n-l*(r-e),i+c*(s-t),n+c*(r-e)]}function Oy(t,e){const i=t.length,n=[];for(let s=2;s<i-2;s+=2){const i=Dy(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[s]),n.push(t[s+1]),n.push(i[2]),n.push(i[3]))}return n}function Ny(t){const e=[[t[0],t[2],t[4],t[6]],[t[1],t[3],t[5],t[7]]],i=[];for(const t of e){const e=-3*t[0]+9*t[1]-9*t[2]+3*t[3];if(0!==e){const n=6*t[0]-12*t[1]+6*t[2],s=n*n-4*e*(-3*t[0]+3*t[1]);if(s>=0){const t=Math.sqrt(s);i.push((-n+t)/(2*e)),i.push((-n-t)/(2*e))}}}return i.filter(t=>t>0&&t<1).flatMap(t=>e.map(e=>{const i=1-t;return i*i*i*e[0]+3*i*i*t*e[1]+3*i*t*t*e[2]+t*t*t*e[3]}))}Py.prototype._centroid=!0,Py.prototype.className="Arc",Py.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],Iv(Py),d_.addGetterSetter(Py,"innerRadius",0,n_()),d_.addGetterSetter(Py,"outerRadius",0,n_()),d_.addGetterSetter(Py,"angle",0,n_()),d_.addGetterSetter(Py,"clockwise",!1,h_());class Uy extends vy{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),i=e.length,n=this.tension(),s=this.closed(),r=this.bezier();if(!i)return;let a=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==n&&i>4){const n=this.getTensionPoints(),r=n.length;for(a=s?0:4,s||t.quadraticCurveTo(n[0],n[1],n[2],n[3]);a<r-2;)t.bezierCurveTo(n[a++],n[a++],n[a++],n[a++],n[a++],n[a++]);s||t.quadraticCurveTo(n[r-2],n[r-1],e[i-2],e[i-1])}else if(r)for(a=2;a<i;)t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);else for(a=2;a<i;a+=2)t.lineTo(e[a],e[a+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Oy(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=Dy(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=Dy(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),r=Oy(t,i);return[n[2],n[3]].concat(r).concat([s[0],s[1],t[e-2],t[e-1],s[2],s[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.bezier()?[t[0],t[1],...Ny(this.points()),t[t.length-2],t[t.length-1]]:this.points();let e,i,n=t[0],s=t[0],r=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),a=Math.max(a,i);return{x:n,y:r,width:s-n,height:a-r}}}Uy.prototype.className="Line",Uy.prototype._attrsAffectingSize=["points","bezier","tension"],Iv(Uy),d_.addGetterSetter(Uy,"closed",!1),d_.addGetterSetter(Uy,"bezier",!1),d_.addGetterSetter(Uy,"tension",0,n_()),d_.addGetterSetter(Uy,"points",[],function(){if(Rv.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(Vv._isArray(t)?t.forEach(function(t){Vv._isNumber(t)||Vv.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());const Fy=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],By=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],ky=[[1],[1,1],[1,2,1],[1,3,3,1]],zy=(t,e,i)=>{let n,s;const r=i/2;n=0;for(let i=0;i<20;i++)s=r*Fy[20][i]+r,n+=By[20][i]*Hy(t,e,s);return r*n},Gy=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],r=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+s*s),h=4*(n*r+s*a),l=r*r+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,u=l/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,m=c*c+u>0?Math.sqrt(c*c+u):0,f=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+m))):0;return Math.sqrt(o)/2*(d*p-c*m+f)};function Hy(t,e,i){const n=Vy(1,i,t),s=Vy(1,i,e),r=n*n+s*s;return Math.sqrt(r)}const Vy=(t,e,i)=>{const n=i.length-1;let s,r;if(0===n)return 0;if(0===t){r=0;for(let t=0;t<=n;t++)r+=ky[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return r}s=new Array(n);for(let t=0;t<n;t++)s[t]=n*(i[t+1]-i[t]);return Vy(t-1,e,s)},Wy=(t,e,i)=>{let n=1,s=t/e,r=(t-i(s))/e,a=0;for(;n>.001;){const o=i(s+r),h=Math.abs(t-o)/e;if(h<n)n=h,s+=r;else{const a=i(s-r),o=Math.abs(t-a)/e;o<n?(n=o,s-=r):r/=2}if(a++,a>500)break}return s};class jy extends vy{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=jy.parsePathData(this.data()),this.pathLength=jy.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;n<e.length;n++){const s=e[n].command,r=e[n].points;switch(s){case"L":t.lineTo(r[0],r[1]);break;case"M":t.moveTo(r[0],r[1]);break;case"C":t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"Q":t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case"A":const e=r[0],n=r[1],s=r[2],a=r[3],o=r[4],h=r[5],l=r[6],c=r[7],d=s>a?s:a,u=s>a?1:s/a,p=s>a?a/s:1;t.translate(e,n),t.rotate(l),t.scale(u,p),t.arc(0,0,d,o,o+h,1-c),t.scale(1/u,1/p),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],s=e.points[4]+n;let r=Math.PI/180;if(Math.abs(i-s)<r&&(r=Math.abs(i-s)),n<0)for(let n=i-r;n>s;n-=r){const i=jy.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}else for(let n=i+r;n<s;n+=r){const i=jy.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const n=jy.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(n.x,n.y)}else t=t.concat(e.points)});let e,i,n=t[0],s=t[0],r=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(n=Math.min(n,e),s=Math.max(s,e)),isNaN(i)||(r=Math.min(r,i),a=Math.max(a,i));return{x:n,y:r,width:s-n,height:a-r}}getLength(){return this.pathLength}getPointAtLength(t){return jy.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let i,n=0,s=e.length;if(!s)return null;for(;n<s&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===s)return i=e[n-1].points.slice(-2),{x:i[0],y:i[1]};if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const r=e[n],a=r.points;switch(r.command){case"L":return jy.getPointOnLine(t,r.start.x,r.start.y,a[0],a[1]);case"C":return jy.getPointOnCubicBezier(Wy(t,jy.getPathLength(e),t=>zy([r.start.x,a[0],a[2],a[4]],[r.start.y,a[1],a[3],a[5]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return jy.getPointOnQuadraticBezier(Wy(t,jy.getPathLength(e),t=>Gy([r.start.x,a[0],a[2]],[r.start.y,a[1],a[3]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3]);case"A":const i=a[0],n=a[1],s=a[2],o=a[3],h=a[5],l=a[6];let c=a[4];return c+=h*t/r.pathLength,jy.getPointOnEllipticalArc(i,n,s,o,c,l)}return null}static getPointOnLine(t,e,i,n,s,r,a){r=null!=r?r:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,s);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:r,y:a+(s>i?t:-t)};const h=(s-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(a-i-h*(r-e))<1e-10)return{x:r+l,y:a+c};const d=((r-e)*(n-e)+(a-i)*(s-i))/(o*o),u=e+d*(n-e),p=i+d*(s-i),m=this.getLineLength(r,a,u,p),f=Math.sqrt(t*t-m*m),g=Math.sqrt(f*f/(1+h*h))*(n<e?-1:1);return{x:u+g,y:p+h*g}}static getPointOnCubicBezier(t,e,i,n,s,r,a,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+r*c(t)+n*d(t)+e*u(t),y:h*l(t)+a*c(t)+s*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,s,r,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:r*o(t)+n*h(t)+e*l(t),y:a*o(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,s,r){const a=Math.cos(r),o=Math.sin(r),h=i*Math.cos(s),l=n*Math.sin(s);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<i.length;t++)e=e.replace(new RegExp(i[t],"g"),"|"+i[t]);const n=e.split("|"),s=[],r=[];let a=0,o=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<n.length;t++){let e=n[t],i=e.charAt(0);for(e=e.slice(1),r.length=0;l=h.exec(e);)r.push(l[0]);let c=[],d="A"===i||"a"===i?0:-1;for(let t=0,e=r.length;t<e;t++){const e=r[t];if("00"!==e)if(d>=0){if(3===d){if(/^[01]{2}\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),c.push(parseFloat(e.slice(2))),d+=3,d>=7&&(d-=7);continue}if("11"===e||"10"===e||"01"===e){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}else if(4===d){if(/^[01]\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseFloat(e.slice(1))),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t),d+=1,d>=7&&(d-=7)}else{const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t)}else c.push(0,0),d>=0&&(d+=2,d>=7&&(d-=7))}for(;c.length>0&&!isNaN(c[0]);){let t="",e=[];const n=a,r=o;let h,l,d,u,p,m,f,g,v,_;switch(i){case"l":a+=c.shift(),o+=c.shift(),t="L",e.push(a,o);break;case"L":a=c.shift(),o=c.shift(),e.push(a,o);break;case"m":const n=c.shift(),r=c.shift();if(a+=n,o+=r,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){a=s[t].points[0]+n,o=s[t].points[1]+r;break}e.push(a,o),i="l";break;case"M":a=c.shift(),o=c.shift(),t="M",e.push(a,o),i="L";break;case"h":a+=c.shift(),t="L",e.push(a,o);break;case"H":a=c.shift(),t="L",e.push(a,o);break;case"v":o+=c.shift(),t="L",e.push(a,o);break;case"V":o=c.shift(),t="L",e.push(a,o);break;case"C":e.push(c.shift(),c.shift(),c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"c":e.push(a+c.shift(),o+c.shift(),a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"S":l=a,d=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,c.shift(),c.shift()),a=c.shift(),o=c.shift(),t="C",e.push(a,o);break;case"s":l=a,d=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"Q":e.push(c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"q":e.push(a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="Q",e.push(a,o);break;case"T":l=a,d=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a=c.shift(),o=c.shift(),t="Q",e.push(l,d,a,o);break;case"t":l=a,d=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a+=c.shift(),o+=c.shift(),t="Q",e.push(l,d,a,o);break;case"A":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,_=o,a=c.shift(),o=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,_,a,o,f,g,u,p,m);break;case"a":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,_=o,a+=c.shift(),o+=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,_,a,o,f,g,u,p,m)}s.push({command:t||i,points:e,start:{x:n,y:r},pathLength:this.calcLength(n,r,t||i,e)})}"z"!==i&&"Z"!==i||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,n){let s,r,a,o;const h=jy;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return zy([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return Gy([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":s=0;const i=n[4],l=n[5],c=n[4]+l;let d=Math.PI/180;if(Math.abs(i-c)<d&&(d=Math.abs(i-c)),r=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),l<0)for(o=i-d;o>c;o-=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;else for(o=i+d;o<c;o+=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;return a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),s}return 0}static convertEndpointToCenterParameterization(t,e,i,n,s,r,a,o,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(a*a)+d*d/(o*o);u>1&&(a*=Math.sqrt(u),o*=Math.sqrt(u));let p=Math.sqrt((a*a*(o*o)-a*a*(d*d)-o*o*(c*c))/(a*a*(d*d)+o*o*(c*c)));s===r&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*d/o,f=p*-o*c/a,g=(t+i)/2+Math.cos(l)*m-Math.sin(l)*f,v=(e+n)/2+Math.sin(l)*m+Math.cos(l)*f,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},b=x([1,0],[(c-m)/a,(d-f)/o]),S=[(c-m)/a,(d-f)/o],w=[(-1*c-m)/a,(-1*d-f)/o];let M=x(S,w);return y(S,w)<=-1&&(M=Math.PI),y(S,w)>=1&&(M=0),0===r&&M>0&&(M-=2*Math.PI),1===r&&M<0&&(M+=2*Math.PI),[g,v,a,o,b,M,l,r]}}jy.prototype.className="Path",jy.prototype._attrsAffectingSize=["data"],Iv(jy),d_.addGetterSetter(jy,"data");class Xy extends Uy{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const r=this.pointerLength(),a=i.length;let o,h;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[a-2],i[a-1]],e=jy.calcLength(n[n.length-4],n[n.length-3],"C",t),s=jy.getPointOnQuadraticBezier(Math.min(1,1-r/e),t[0],t[1],t[2],t[3],t[4],t[5]);o=i[a-2]-s.x,h=i[a-1]-s.y}else o=i[a-2]-i[a-4],h=i[a-1]-i[a-3];const l=(Math.atan2(h,o)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(o=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(o=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}Xy.prototype.className="Arrow",Iv(Xy),d_.addGetterSetter(Xy,"pointerLength",10,n_()),d_.addGetterSetter(Xy,"pointerWidth",10,n_()),d_.addGetterSetter(Xy,"pointerAtBeginning",!1),d_.addGetterSetter(Xy,"pointerAtEnding",!0);class Yy extends vy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}Yy.prototype._centroid=!0,Yy.prototype.className="Circle",Yy.prototype._attrsAffectingSize=["radius"],Iv(Yy),d_.addGetterSetter(Yy,"radius",0,n_());class qy extends vy{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}qy.prototype.className="Ellipse",qy.prototype._centroid=!0,qy.prototype._attrsAffectingSize=["radiusX","radiusY"],Iv(qy),d_.addComponentsGetterSetter(qy,"radius",["x","y"]),d_.addGetterSetter(qy,"radiusX",0,n_()),d_.addGetterSetter(qy,"radiusY",0,n_());let Zy=class t extends vy{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image;let r;if(s){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;r=t&&n?[s,this.cropX(),this.cropY(),t,n,0,0,e,i]:[s,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?Vv.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s&&(n&&t.clip(),t.drawImage.apply(t,r))}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?Vv.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e,i;return null!==(i=null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width)&&void 0!==i?i:0}getHeight(){var t,e,i;return null!==(i=null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height)&&void 0!==i?i:0}static fromURL(e,i,n=null){const s=Vv.createImageElement();s.onload=function(){const e=new t({image:s});i(e)},s.onerror=n,s.crossOrigin="Anonymous",s.src=e}};Zy.prototype.className="Image",Zy.prototype._attrsAffectingSize=["image"],Iv(Zy),d_.addGetterSetter(Zy,"cornerRadius",0,s_(4)),d_.addGetterSetter(Zy,"image"),d_.addComponentsGetterSetter(Zy,"crop",["x","y","width","height"]),d_.addGetterSetter(Zy,"cropX",0,n_()),d_.addGetterSetter(Zy,"cropY",0,n_()),d_.addGetterSetter(Zy,"cropWidth",0,n_()),d_.addGetterSetter(Zy,"cropHeight",0,n_());const Ky=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Jy="up",Qy="right",$y="down",tx="left",ex=Ky.length;class ix extends Sy{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<ex;e++)t.on(Ky[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,s,r,a,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),n=h.pointerWidth(),a=h.pointerHeight(),s=0,r=0,i){case Jy:s=t/2,r=-1*a;break;case Qy:s=t+n,r=e/2;break;case $y:s=t/2,r=e+a;break;case tx:s=-1*n,r=e/2}h.setAttrs({x:-1*s,y:-1*r,width:t,height:e}),o.setAttrs({x:-1*s,y:-1*r})}}}ix.prototype.className="Label",Iv(ix);class nx extends vy{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),s=this.pointerWidth(),r=this.pointerHeight(),a=this.cornerRadius();let o=0,h=0,l=0,c=0;"number"==typeof a?o=h=l=c=Math.min(a,e/2,i/2):(o=Math.min(a[0]||0,e/2,i/2),h=Math.min(a[1]||0,e/2,i/2),c=Math.min(a[2]||0,e/2,i/2),l=Math.min(a[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),n===Jy&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*r),t.lineTo((e+s)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===Qy&&(t.lineTo(e,(i-r)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+r)/2)),t.lineTo(e,i-c),t.arc(e-c,i-c,c,0,Math.PI/2,!1),n===$y&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+r),t.lineTo((e-s)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===tx&&(t.lineTo(0,(i+r)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-r)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),s=this.pointerDirection(),r=this.width(),a=this.height();return s===Jy?(e-=n,a+=n):s===$y?a+=n:s===tx?(t-=1.5*i,r+=i):s===Qy&&(r+=1.5*i),{x:t,y:e,width:r,height:a}}}nx.prototype.className="Tag",Iv(nx),d_.addGetterSetter(nx,"pointerDirection","none"),d_.addGetterSetter(nx,"pointerWidth",0,n_()),d_.addGetterSetter(nx,"pointerHeight",0,n_()),d_.addGetterSetter(nx,"cornerRadius",0,s_(4));class sx extends vy{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?Vv.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}sx.prototype.className="Rect",Iv(sx),d_.addGetterSetter(sx,"cornerRadius",0,s_(4));class rx extends vy{_sceneFunc(t){const e=this._getPoints(),i=this.radius(),n=this.sides(),s=this.cornerRadius();if(t.beginPath(),s)Vv.drawRoundedPolygonPath(t,e,n,i,s);else{t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].x,n=t[0].y,s=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),s=Math.max(s,t.y)}),{x:e,y:n,width:i-e,height:s-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}rx.prototype.className="RegularPolygon",rx.prototype._centroid=!0,rx.prototype._attrsAffectingSize=["radius"],Iv(rx),d_.addGetterSetter(rx,"radius",0,n_()),d_.addGetterSetter(rx,"sides",0,n_()),d_.addGetterSetter(rx,"cornerRadius",0,s_(4));const ax=2*Math.PI;class ox extends vy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,ax,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),ax,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}ox.prototype.className="Ring",ox.prototype._centroid=!0,ox.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Iv(ox),d_.addGetterSetter(ox,"innerRadius",0,n_()),d_.addGetterSetter(ox,"outerRadius",0,n_());class hx extends vy{constructor(t){super(t),this._updated=!0,this.anim=new My(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+0],o=s[n+1],h=s[n+2],l=s[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(r){const n=r[e],s=2*i;t.drawImage(c,a,o,h,l,n[s+0],n[s+1],h,l)}else t.drawImage(c,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+2],o=s[n+3];if(t.beginPath(),r){const n=r[e],s=2*i;t.rect(n[s+0],n[s+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}hx.prototype.className="Sprite",Iv(hx),d_.addGetterSetter(hx,"animation"),d_.addGetterSetter(hx,"animations"),d_.addGetterSetter(hx,"frameOffsets"),d_.addGetterSetter(hx,"image"),d_.addGetterSetter(hx,"frameIndex",0,n_()),d_.addGetterSetter(hx,"frameRate",17,n_()),d_.backCompat(hx,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class lx extends vy{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let s=1;s<2*n;s++){const r=s%2==0?i:e,a=r*Math.sin(s*Math.PI/n),o=-1*r*Math.cos(s*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}function cx(t){return[...t].reduce((t,e,i,n)=>{if(/\p{Emoji}/u.test(e)){const s=n[i+1];s&&/\p{Emoji_Modifier}|\u200D/u.test(s)?(t.push(e+s),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}lx.prototype.className="Star",lx.prototype._centroid=!0,lx.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Iv(lx),d_.addGetterSetter(lx,"numPoints",5,n_()),d_.addGetterSetter(lx,"innerRadius",0,n_()),d_.addGetterSetter(lx,"outerRadius",0,n_());const dx="auto",ux="inherit",px="justify",mx="left",fx="middle",gx="normal",vx=" ",_x="none",yx=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],xx=yx.length;let bx;function Sx(){return bx||(bx=Vv.createCanvasElement().getContext("2d"),bx)}class wx extends vy{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<xx;t++)this.on(yx[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e,i;const n=this.textArr,s=n.length;if(!this.text())return;let r,a=this.padding(),o=this.fontSize(),h=this.lineHeight()*o,l=this.verticalAlign(),c=this.direction(),d=0,u=this.align(),p=this.getWidth(),m=this.letterSpacing(),f=this.charRenderFunc(),g=this.fill(),v=this.textDecoration(),_=this.underlineOffset(),y=-1!==v.indexOf("underline"),x=-1!==v.indexOf("line-through");c=c===ux?t.direction:c;let b=h/2,S=fx;if(!Rv.legacyTextRendering){const t=this.measureSize("M");S="alphabetic";b=((null!==(e=t.fontBoundingBoxAscent)&&void 0!==e?e:t.actualBoundingBoxAscent)-(null!==(i=t.fontBoundingBoxDescent)&&void 0!==i?i:t.actualBoundingBoxDescent))/2+h/2}for("rtl"===c&&t.setAttr("direction",c),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",S),t.setAttr("textAlign",mx),l===fx?d=(this.getHeight()-s*h-2*a)/2:"bottom"===l&&(d=this.getHeight()-s*h-2*a),t.translate(a,d+a),r=0;r<s;r++){let e=0,i=0;const l=n[r],d=l.text,v=l.width,S=l.lastInParagraph;if(t.save(),"right"===u?e+=p-v-2*a:"center"===u&&(e+=(p-v-2*a)/2),y){t.save(),t.beginPath();const n=e,s=b+i+(null!=_?_:Rv.legacyTextRendering?Math.round(o/2):Math.round(o/4));t.moveTo(n,s);const r=u!==px||S?v:p-2*a;t.lineTo(n+Math.round(r),s),t.lineWidth=o/15;const h=this._getLinearGradient();t.strokeStyle=h||g,t.stroke(),t.restore()}const w=e;if("rtl"===c||0===m&&u!==px&&!f)0!==m&&t.setAttr("letterSpacing",`${m}px`),this._partialTextX=e,this._partialTextY=b+i,this._partialText=d,t.fillStrokeShape(this);else{const s=d.split(" ").length-1,o=cx(d);for(let h=0;h<o.length;h++){const l=o[h];if(" "!==l||S||u!==px||(e+=(p-2*a-v)/s),this._partialTextX=e,this._partialTextY=b+i,this._partialText=l,f){t.save();f({char:l,index:h+n.slice(0,r).reduce((t,e)=>t+cx(e.text).length,0),x:e,y:b+i,lineIndex:r,column:h,isLastInLine:S,width:this.measureSize(l).width,context:t})}t.fillStrokeShape(this),f&&t.restore(),e+=this.measureSize(l).width+m}}if(x){t.save(),t.beginPath();const e=Rv.legacyTextRendering?0:-Math.round(o/4),n=w;t.moveTo(n,b+i+e);const s=u!==px||S?v:p-2*a;t.lineTo(n+Math.round(s),b+i+e),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||g,t.stroke(),t.restore()}t.restore(),s>1&&(b+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=Vv._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===dx||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===dx||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Vv.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,s,r,a,o,h,l,c,d;let u,p=Sx(),m=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const f=m/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*f,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*f,actualBoundingBoxRight:null!==(s=u.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*f,alphabeticBaseline:null!==(r=u.alphabeticBaseline)&&void 0!==r?r:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*f,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*f,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*f,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*f,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*f,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*f,width:u.width,height:m}}_getContextFont(){return this.fontStyle()+vx+this.fontVariant()+vx+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===px&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return Sx().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,s=this.attrs.width,r=this.attrs.height,a=s!==dx&&void 0!==s,o=r!==dx&&void 0!==r,h=this.padding(),l=s-2*h,c=r-2*h,d=0,u=this.wrap(),p="char"!==u&&u!==_x,m=this.ellipsis();this.textArr=[],Sx().font=this._getContextFont();const f=m?this._getTextWidth("…"):0;for(let e=0,s=t.length;e<s;++e){let r=t[e],h=this._getTextWidth(r);if(a&&h>l)for(;r.length>0;){let t=0,e=cx(r).length,s="",a=0;for(;t<e;){const i=t+e>>>1,h=cx(r).slice(0,i+1).join(""),u=this._getTextWidth(h);(m&&o&&d+n>c?u+f:u)<=l?(t=i+1,s=h,a=u):e=i}if(!s)break;if(p){const e=cx(r),i=cx(s),n=e[i.length];let o;if((n===vx||"-"===n)&&a<=l)o=i.length;else{const t=i.lastIndexOf(vx),e=i.lastIndexOf("-");o=Math.max(t,e)+1}o>0&&(t=o,s=e.slice(0,t).join(""),a=this._getTextWidth(s))}s=s.trimRight(),this._addTextLine(s),i=Math.max(i,a),d+=n;if(this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(r=cx(r).slice(t).join("").trimLeft(),r.length>0&&(h=this._getTextWidth(r),h<=l)){this._addTextLine(r),d+=n,i=Math.max(i,h);break}}else this._addTextLine(r),d+=n,i=Math.max(i,h),this._shouldHandleEllipsis(d)&&e<s-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&d+n>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,s=n!==dx&&void 0!==n,r=n-2*this.padding();return!(this.wrap()!==_x)||s&&t+i>r}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==dx&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&n){if(e){this._getTextWidth(s.text+"…")<i||(s.text=s.text.slice(0,s.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}wx.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},wx.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},wx.prototype.className="Text",wx.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Iv(wx),d_.overWriteSetter(wx,"width",r_()),d_.overWriteSetter(wx,"height",r_()),d_.addGetterSetter(wx,"direction",ux),d_.addGetterSetter(wx,"fontFamily","Arial"),d_.addGetterSetter(wx,"fontSize",12,n_()),d_.addGetterSetter(wx,"fontStyle",gx),d_.addGetterSetter(wx,"fontVariant",gx),d_.addGetterSetter(wx,"padding",0,n_()),d_.addGetterSetter(wx,"align",mx),d_.addGetterSetter(wx,"verticalAlign","top"),d_.addGetterSetter(wx,"lineHeight",1,n_()),d_.addGetterSetter(wx,"wrap","word"),d_.addGetterSetter(wx,"ellipsis",!1,h_()),d_.addGetterSetter(wx,"letterSpacing",0,n_()),d_.addGetterSetter(wx,"text","",a_()),d_.addGetterSetter(wx,"textDecoration",""),d_.addGetterSetter(wx,"underlineOffset",void 0,n_()),d_.addGetterSetter(wx,"charRenderFunc",void 0);const Mx="normal";function Tx(t){t.fillText(this.partialText,0,0)}function Ex(t){t.strokeText(this.partialText,0,0)}class Ax extends vy{constructor(t){super(t),this.dummyCanvas=Vv.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return jy.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t>this.pathLength?null:jy.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=jy.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),s=this.glyphInfo,r=-1!==e.indexOf("underline"),a=-1!==e.indexOf("line-through");r&&t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),this.partialText=s[e].text,t.fillStrokeShape(this),r&&(0===e&&t.moveTo(0,n/2+1),t.lineTo(s[e].width,n/2+1)),t.restore()}if(r&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),a){t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),0===e&&t.moveTo(0,0),t.lineTo(s[e].width,0),t.restore()}t.strokeStyle=i,t.lineWidth=n/20,t.stroke()}t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Vv.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return wx.prototype.setText.call(this,t)}_getContextFont(){return wx.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const t=cx(this.text()),e=[];let i=0;for(let n=0;n<t.length;n++)e.push({char:t[n],width:this._getTextSize(t[n]).width}),i+=e[n].width;const{height:n}=this._getTextSize(this.attrs.text);if(this.textWidth=i,this.textHeight=n,this.glyphInfo=[],!this.attrs.data)return null;const s=this.letterSpacing(),r=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*s,0);let h=0;"center"===r&&(h=Math.max(0,this.pathLength/2-o/2)),"right"===r&&(h=Math.max(0,this.pathLength-o));let l=h;for(let i=0;i<e.length;i++){const n=this._getPointAtLength(l);if(!n)return;const h=e[i].char;let c=e[i].width+s;if(" "===h&&"justify"===r){const t=this.text().split(" ").length-1;c+=(this.pathLength-o)/t}const d=this._getPointAtLength(l+c);if(!d)return;const u=jy.getLineLength(n.x,n.y,d.x,d.y);let p=0;if(a)try{p=a(e[i-1].char,h)*this.fontSize()}catch(t){p=0}n.x+=p,d.x+=p,this.textWidth+=p;const m=jy.getPointOnLine(p+u/2,n.x,n.y,d.x,d.y),f=Math.atan2(d.y-n.y,d.x-n.x);this.glyphInfo.push({transposeX:m.x,transposeY:m.y,text:t[i],rotation:f,p0:n,p1:d,width:u}),l+=c}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,i,n=t[0]||0,s=t[0]||0,r=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),a=Math.max(a,i);const o=this.fontSize();return{x:n-o/2,y:r-o/2,width:s-n+o,height:a-r+o}}destroy(){return Vv.releaseCanvas(this.dummyCanvas),super.destroy()}}Ax.prototype._fillFunc=Tx,Ax.prototype._strokeFunc=Ex,Ax.prototype._fillFuncHit=Tx,Ax.prototype._strokeFuncHit=Ex,Ax.prototype.className="TextPath",Ax.prototype._attrsAffectingSize=["text","fontSize","data"],Iv(Ax),d_.addGetterSetter(Ax,"data"),d_.addGetterSetter(Ax,"fontFamily","Arial"),d_.addGetterSetter(Ax,"fontSize",12,n_()),d_.addGetterSetter(Ax,"fontStyle",Mx),d_.addGetterSetter(Ax,"align","left"),d_.addGetterSetter(Ax,"letterSpacing",0,n_()),d_.addGetterSetter(Ax,"textBaseline","middle"),d_.addGetterSetter(Ax,"fontVariant",Mx),d_.addGetterSetter(Ax,"text",""),d_.addGetterSetter(Ax,"textDecoration",""),d_.addGetterSetter(Ax,"kerningFunc",void 0);const Cx="tr-konva",Lx=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${Cx}`).join(" "),Rx="nodesRect",Ix=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],Px={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Dx="ontouchstart"in Rv._global;const Ox=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Nx(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:s}}function Ux(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return Nx(t,e,i)}let Fx=0;class Bx extends Sy{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(Lx,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return Vv.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Cx+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(Vv.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(Ix.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,i=>{if(!e)return;const n=t.getAbsolutePosition(),s=n.x-e.x,r=n.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+s,y:n.y+r}),e.startDrag(i)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Rx),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(Rx,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=t.getAbsoluteScale(i),r=t.getAbsolutePosition(i),a=n.x*s.x-t.offsetX()*s.x,o=n.y*s.y-t.offsetY()*s.y,h=(Rv.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Nx({x:r.x+a*Math.cos(h)+o*Math.sin(-h),y:r.y+o*Math.cos(h)+a*Math.sin(h),width:n.width*s.x,height:n.height*s.y,rotation:h},-Rv.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],s=e.getAbsoluteTransform();n.forEach(function(e){const i=s.point(e);t.push(i)})});const e=new Dv;e.rotate(-Rv.getAngle(this.rotation()));let i=1/0,n=1/0,s=-1/0,r=-1/0;t.forEach(function(t){const a=e.point(t);void 0===i&&(i=s=a.x,n=r=a.y),i=Math.min(i,a.x),n=Math.min(n,a.y),s=Math.max(s,a.x),r=Math.max(r,a.y)}),e.invert();const a=e.point({x:i,y:n});return{x:a.x,y:a.y,width:s-i,height:r-n,rotation:Rv.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Ox.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(t){const e=new sx({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Dx?10:"auto"}),i=this;e.on("mousedown touchstart",function(t){i._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const i=Rv.getAngle(this.rotation()),n=this.rotateAnchorCursor(),s=function(t,e,i){if("rotater"===t)return i;e+=Vv.degToRad(Px[t]||0);const n=(Vv.radToDeg(e)%360+360)%360;return Vv._inRange(n,337.5,360)||Vv._inRange(n,0,22.5)?"ns-resize":Vv._inRange(n,22.5,67.5)?"nesw-resize":Vv._inRange(n,67.5,112.5)?"ew-resize":Vv._inRange(n,112.5,157.5)?"nwse-resize":Vv._inRange(n,157.5,202.5)?"ns-resize":Vv._inRange(n,202.5,247.5)?"nesw-resize":Vv._inRange(n,247.5,292.5)?"ew-resize":Vv._inRange(n,292.5,337.5)?"nwse-resize":(Vv.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,i,n);e.getStage().content&&(e.getStage().content.style.cursor=s),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new vy({name:"back",width:0,height:0,sceneFunc(t,e){const i=e.getParent(),n=i.padding(),s=e.width(),r=e.height();if(t.beginPath(),t.rect(-n,-n,s+2*n,r+2*n),i.rotateEnabled()&&i.rotateLineVisible()){const e=i.rotateAnchorAngle(),n=i.rotateAnchorOffset(),a=Vv.degToRad(e),o=Math.sin(a),h=-Math.cos(a),l=s/2,c=r/2;let d=1/0;h<0?d=Math.min(d,-c/h):h>0&&(d=Math.min(d,(r-c)/h)),o<0?d=Math.min(d,-l/o):o>0&&(d=Math.min(d,(s-l)/o));const u=l+o*d,p=c+h*d,m=Vv._sign(r),f=u+o*n*m,g=p+h*n*m;t.moveTo(u,p),t.lineTo(f,g)}t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const r=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-r.x,y:a.y-r.y},Fx++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,i,n;const s=this.findOne("."+this._movingAnchorName),r=s.getStage();r.setPointersPositions(t);const a=r.getPointerPosition();let o={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const h=s.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),s.setAbsolutePosition(o);const l=s.getAbsolutePosition();if(h.x===l.x&&h.y===l.y)return;if("rotater"===this._movingAnchorName){const n=this._getNodeRect();e=s.x()-n.width/2,i=-s.y()+n.height/2;const r=Rv.getAngle(this.rotateAnchorAngle());let a=Math.atan2(-i,e)+Math.PI/2-r;n.height<0&&(a-=Math.PI);const o=Rv.getAngle(this.rotation())+a,h=Rv.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let n=e;for(let s=0;s<t.length;s++){const r=Rv.getAngle(t[s]),a=Math.abs(r-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(n=r)}return n}(this.rotationSnaps(),o,h),c=Ux(n,l-n.rotation);return void this._fitNodesInto(c,t)}const c=this.shiftBehavior();let d;d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(t.y-s.y(),2));const r=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(s.y());else if("top-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(t.y-s.y(),2));const r=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-i)}var p=s.position();this.findOne(".top-left").y(p.y),this.findOne(".bottom-right").x(p.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(s.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(s.x());else if("bottom-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(s.y()-t.y,2));const r=t.x<s.x()?-1:1,a=s.y()<t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,s.x(t.x-e),s.y(t.y+i)}p=s.position(),this.findOne(".top-left").x(p.x),this.findOne(".bottom-right").y(p.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(s.y());else if("bottom-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(s.y()-t.y,2));const r=this.findOne(".bottom-right").x()<t.x?-1:1,a=this.findOne(".bottom-right").y()<t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey,u){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),s=this.getWidth()-e.x(),r=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:s,y:r})}const m=this.findOne(".top-left").getAbsolutePosition();e=m.x,i=m.y;const f=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:f,height:g,rotation:Rv.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();Fx--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach(e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e){const i=this._getNodeRect();if(Vv._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(Vv._inRange(t.height,2*-this.padding()-1,1))return void this.update();const n=new Dv;if(n.rotate(Rv.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=n.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=n.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:Vv.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,r=new Dv;r.translate(i.x,i.y),r.rotate(i.rotation),r.scale(i.width/s,i.height/s);const a=new Dv,o=t.width/s,h=t.height/s;!1===this.flipEnabled()?(a.translate(t.x,t.y),a.rotate(t.rotation),a.translate(t.width<0?t.width:0,t.height<0?t.height:0),a.scale(Math.abs(o),Math.abs(h))):(a.translate(t.x,t.y),a.rotate(t.rotation),a.scale(o,h));const l=a.multiply(r.invert());this._nodes.forEach(t=>{var e;if(!t.getStage())return;const i=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());const s=new Dv;s.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(n);const r=s.decompose();t.setAttrs(r),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(Vv._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(Vv._getRotation(e.rotation));const i=e.width,n=e.height,s=this.enabledAnchors(),r=this.resizeEnabled(),a=this.padding(),o=this.anchorSize(),h=this.find("._anchor");h.forEach(t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+a,offsetY:o/2+a,visible:r&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+a,visible:r&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-a,offsetY:o/2+a,visible:r&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:o/2+a,visible:r&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:o/2-a,visible:r&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:o/2+a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:o/2-a,visible:r&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:o/2-a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-right")>=0});const l=this.rotateAnchorAngle(),c=this.rotateAnchorOffset(),d=Vv.degToRad(l),u=Math.sin(d),p=-Math.cos(d),m=i/2,f=n/2;let g=1/0;p<0?g=Math.min(g,-f/p):p>0&&(g=Math.min(g,(n-f)/p)),u<0?g=Math.min(g,-m/u):u>0&&(g=Math.min(g,(i-m)/u));const v=m+u*g,_=f+p*g,y=Vv._sign(n);this._batchChangeChild(".rotater",{x:v+u*c*y,y:_+p*c*y-a*p,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(t=>t.draggable()),x:0,y:0});const x=this.anchorStyleFunc();x&&h.forEach(t=>{x(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Sy.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return E_.prototype.toObject.call(this)}clone(t){return E_.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Bx.isTransforming=()=>Fx>0,Bx.prototype.className="Transformer",Iv(Bx),d_.addGetterSetter(Bx,"enabledAnchors",Ox,function(t){return t instanceof Array||Vv.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===Ox.indexOf(t)&&Vv.warn("Unknown anchor name: "+t+". Available names are: "+Ox.join(", "))}),t||[]}),d_.addGetterSetter(Bx,"flipEnabled",!0,h_()),d_.addGetterSetter(Bx,"resizeEnabled",!0),d_.addGetterSetter(Bx,"anchorSize",10,n_()),d_.addGetterSetter(Bx,"rotateEnabled",!0),d_.addGetterSetter(Bx,"rotateLineVisible",!0),d_.addGetterSetter(Bx,"rotationSnaps",[]),d_.addGetterSetter(Bx,"rotateAnchorOffset",50,n_()),d_.addGetterSetter(Bx,"rotateAnchorAngle",0,n_()),d_.addGetterSetter(Bx,"rotateAnchorCursor","crosshair"),d_.addGetterSetter(Bx,"rotationSnapTolerance",5,n_()),d_.addGetterSetter(Bx,"borderEnabled",!0),d_.addGetterSetter(Bx,"anchorStroke","rgb(0, 161, 255)"),d_.addGetterSetter(Bx,"anchorStrokeWidth",1,n_()),d_.addGetterSetter(Bx,"anchorFill","white"),d_.addGetterSetter(Bx,"anchorCornerRadius",0,n_()),d_.addGetterSetter(Bx,"borderStroke","rgb(0, 161, 255)"),d_.addGetterSetter(Bx,"borderStrokeWidth",1,n_()),d_.addGetterSetter(Bx,"borderDash"),d_.addGetterSetter(Bx,"keepRatio",!0),d_.addGetterSetter(Bx,"shiftBehavior","default"),d_.addGetterSetter(Bx,"centeredScaling",!1),d_.addGetterSetter(Bx,"ignoreStroke",!1),d_.addGetterSetter(Bx,"padding",0,n_()),d_.addGetterSetter(Bx,"nodes"),d_.addGetterSetter(Bx,"node"),d_.addGetterSetter(Bx,"boundBoxFunc"),d_.addGetterSetter(Bx,"anchorDragBoundFunc"),d_.addGetterSetter(Bx,"anchorStyleFunc"),d_.addGetterSetter(Bx,"shouldOverdrawWholeArea",!1),d_.addGetterSetter(Bx,"useSingleNodeRotation",!0),d_.backCompat(Bx,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class kx extends vy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Rv.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}function zx(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}kx.prototype.className="Wedge",kx.prototype._centroid=!0,kx.prototype._attrsAffectingSize=["radius"],Iv(kx),d_.addGetterSetter(kx,"radius",0,n_()),d_.addGetterSetter(kx,"angle",0,n_()),d_.addGetterSetter(kx,"clockwise",!1),d_.backCompat(kx,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const Gx=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Hx=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];d_.addGetterSetter(E_,"blurRadius",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"brightness",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"contrast",0,n_(),d_.afterSetFilter);function Vx(t,e,i,n,s){const r=i-e,a=s-n;if(0===r)return n+a/2;if(0===a)return n;let o=(t-e)/r;return o=a*o+n,o}d_.addGetterSetter(E_,"embossStrength",.5,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"embossWhiteLevel",.5,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"embossDirection","top-left",void 0,d_.afterSetFilter),d_.addGetterSetter(E_,"embossBlend",!1,void 0,d_.afterSetFilter);d_.addGetterSetter(E_,"enhance",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"hue",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"saturation",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"luminance",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"hue",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"saturation",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"value",0,n_(),d_.afterSetFilter);function Wx(t,e,i){let n=4*(i*t.width+e);const s=[];return s.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),s}function jx(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}d_.addGetterSetter(E_,"kaleidoscopePower",2,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"kaleidoscopeAngle",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"threshold",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"noise",.2,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"pixelSize",8,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"levels",.5,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"blue",0,i_,d_.afterSetFilter);d_.addGetterSetter(E_,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"blue",0,i_,d_.afterSetFilter),d_.addGetterSetter(E_,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t});d_.addGetterSetter(E_,"threshold",.5,n_(),d_.afterSetFilter);const Xx=Iy.Util._assign(Iy,{Arc:Py,Arrow:Xy,Circle:Yy,Ellipse:qy,Image:Zy,Label:ix,Tag:nx,Line:Uy,Path:jy,Rect:sx,RegularPolygon:rx,Ring:ox,Sprite:hx,Star:lx,Text:wx,TextPath:Ax,Transformer:Bx,Wedge:kx,Filters:{Blur:function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,n=t.width,s=t.height;let r,a,o,h,l,c,d,u,p,m,f,g,v,_,y,x,b,S,w,M;const T=e+e+1,E=n-1,A=s-1,C=e+1,L=C*(C+1)/2,R=new zx,I=Gx[e],P=Hx[e];let D=null,O=R,N=null,U=null;for(let t=1;t<T;t++)O=O.next=new zx,t===C&&(D=O);O.next=R,o=a=0;for(let t=0;t<s;t++){g=v=_=y=h=l=c=d=0,u=C*(x=i[a]),p=C*(b=i[a+1]),m=C*(S=i[a+2]),f=C*(w=i[a+3]),h+=L*x,l+=L*b,c+=L*S,d+=L*w,O=R;for(let t=0;t<C;t++)O.r=x,O.g=b,O.b=S,O.a=w,O=O.next;for(let t=1;t<C;t++)r=a+((E<t?E:t)<<2),h+=(O.r=x=i[r])*(M=C-t),l+=(O.g=b=i[r+1])*M,c+=(O.b=S=i[r+2])*M,d+=(O.a=w=i[r+3])*M,g+=x,v+=b,_+=S,y+=w,O=O.next;N=R,U=D;for(let t=0;t<n;t++)i[a+3]=w=d*I>>P,0!==w?(w=255/w,i[a]=(h*I>>P)*w,i[a+1]=(l*I>>P)*w,i[a+2]=(c*I>>P)*w):i[a]=i[a+1]=i[a+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,r=o+((r=t+e+1)<E?r:E)<<2,g+=N.r=i[r],v+=N.g=i[r+1],_+=N.b=i[r+2],y+=N.a=i[r+3],h+=g,l+=v,c+=_,d+=y,N=N.next,u+=x=U.r,p+=b=U.g,m+=S=U.b,f+=w=U.a,g-=x,v-=b,_-=S,y-=w,U=U.next,a+=4;o+=n}for(let t=0;t<n;t++){v=_=y=g=l=c=d=h=0,a=t<<2,u=C*(x=i[a]),p=C*(b=i[a+1]),m=C*(S=i[a+2]),f=C*(w=i[a+3]),h+=L*x,l+=L*b,c+=L*S,d+=L*w,O=R;for(let t=0;t<C;t++)O.r=x,O.g=b,O.b=S,O.a=w,O=O.next;let o=n;for(let s=1;s<=e;s++)a=o+t<<2,h+=(O.r=x=i[a])*(M=C-s),l+=(O.g=b=i[a+1])*M,c+=(O.b=S=i[a+2])*M,d+=(O.a=w=i[a+3])*M,g+=x,v+=b,_+=S,y+=w,O=O.next,s<A&&(o+=n);a=t,N=R,U=D;for(let e=0;e<s;e++)r=a<<2,i[r+3]=w=d*I>>P,w>0?(w=255/w,i[r]=(h*I>>P)*w,i[r+1]=(l*I>>P)*w,i[r+2]=(c*I>>P)*w):i[r]=i[r+1]=i[r+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,r=t+((r=e+C)<A?r:A)*n<<2,h+=g+=N.r=i[r],l+=v+=N.g=i[r+1],c+=_+=N.b=i[r+2],d+=y+=N.a=i[r+3],N=N.next,u+=x=U.r,p+=b=U.g,m+=S=U.b,f+=w=U.a,g-=x,v-=b,_-=S,y-=w,U=U.next,a+=n}}(t,e)},Brightness:function(t){const e=this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]=Math.min(255,i[t]*e),i[t+1]=Math.min(255,i[t+1]*e),i[t+2]=Math.min(255,i[t+2]*e)},Brighten:function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},Contrast:function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let s=150,r=150,a=150;for(let t=0;t<n;t+=4)s=i[t],r=i[t+1],a=i[t+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,r/=255,r-=.5,r*=e,r+=.5,r*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,s=s<0?0:s>255?255:s,r=r<0?0:r>255?255:r,a=a<0?0:a>255?255:a,i[t]=s,i[t+1]=r,i[t+2]=a},Emboss:function(t){var e,i,n,s,r,a,o,h,l;const c=t.data,d=t.width,u=t.height,p=Math.min(1,Math.max(0,null!==(i=null===(e=this.embossStrength)||void 0===e?void 0:e.call(this))&&void 0!==i?i:.5)),m=Math.min(1,Math.max(0,null!==(s=null===(n=this.embossWhiteLevel)||void 0===n?void 0:n.call(this))&&void 0!==s?s:.5)),f=null!==(o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[null!==(a=null===(r=this.embossDirection)||void 0===r?void 0:r.call(this))&&void 0!==a?a:"top-left"])&&void 0!==o?o:315,g=!(null===(l=null===(h=this.embossBlend)||void 0===h?void 0:h.call(this))||void 0===l||!l),v=10*p,_=255*m,y=f*Math.PI/180,x=Math.cos(y),b=Math.sin(y),S=128/1020*v,w=new Uint8ClampedArray(c),M=new Float32Array(d*u);for(let t=0,e=0;e<c.length;e+=4,t++)M[t]=.2126*w[e]+.7152*w[e+1]+.0722*w[e+2];const T=[-1,0,1,-2,0,2,-1,0,1],E=[-1,-2,-1,0,0,0,1,2,1],A=[-d-1,-d,1-d,-1,0,1,d-1,d,d+1],C=t=>t<0?0:t>255?255:t;for(let t=1;t<u-1;t++)for(let e=1;e<d-1;e++){const i=t*d+e;let n=0,s=0;n+=M[i+A[0]]*T[0],s+=M[i+A[0]]*E[0],n+=M[i+A[1]]*T[1],s+=M[i+A[1]]*E[1],n+=M[i+A[2]]*T[2],s+=M[i+A[2]]*E[2],n+=M[i+A[3]]*T[3],s+=M[i+A[3]]*E[3],n+=M[i+A[5]]*T[5],s+=M[i+A[5]]*E[5],n+=M[i+A[6]]*T[6],s+=M[i+A[6]]*E[6],n+=M[i+A[7]]*T[7],s+=M[i+A[7]]*E[7],n+=M[i+A[8]]*T[8],s+=M[i+A[8]]*E[8];const r=C(_+(x*n+b*s)*S),a=4*i;if(g){const t=r-_;c[a]=C(w[a]+t),c[a+1]=C(w[a+1]+t),c[a+2]=C(w[a+2]+t),c[a+3]=w[a+3]}else c[a]=c[a+1]=c[a+2]=r,c[a+3]=w[a+3]}for(let t=0;t<d;t++){let e=4*t,i=4*((u-1)*d+t);c[e]=w[e],c[e+1]=w[e+1],c[e+2]=w[e+2],c[e+3]=w[e+3],c[i]=w[i],c[i+1]=w[i+1],c[i+2]=w[i+2],c[i+3]=w[i+3]}for(let t=1;t<u-1;t++){let e=t*d*4,i=4*(t*d+(d-1));c[e]=w[e],c[e+1]=w[e+1],c[e+2]=w[e+2],c[e+3]=w[e+3],c[i]=w[i],c[i+1]=w[i+1],c[i+2]=w[i+2],c[i+3]=w[i+3]}return t},Enhance:function(t){const e=t.data,i=e.length;let n,s,r,a=e[0],o=a,h=e[1],l=h,c=e[2],d=c;const u=this.enhance();if(0===u)return;for(let t=0;t<i;t+=4)n=e[t+0],n<a?a=n:n>o&&(o=n),s=e[t+1],s<h?h=s:s>l&&(l=s),r=e[t+2],r<c?c=r:r>d&&(d=r);let p,m,f,g,v,_;if(o===a&&(o=255,a=0),l===h&&(l=255,h=0),d===c&&(d=255,c=0),u>0)p=o+u*(255-o),m=a-u*(a-0),f=l+u*(255-l),g=h-u*(h-0),v=d+u*(255-d),_=c-u*(c-0);else{const t=.5*(o+a);p=o+u*(o-t),m=a+u*(a-t);const e=.5*(l+h);f=l+u*(l-e),g=h+u*(h-e);const i=.5*(d+c);v=d+u*(d-i),_=c+u*(c-i)}for(let t=0;t<i;t+=4)e[t+0]=Vx(e[t+0],a,o,m,p),e[t+1]=Vx(e[t+1],h,l,g,f),e[t+2]=Vx(e[t+2],c,d,_,v)},Grayscale:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}},HSL:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,r=127*this.luminance(),a=1*n*Math.cos(s*Math.PI/180),o=1*n*Math.sin(s*Math.PI/180),h=.299+.701*a+.167*o,l=.587-.587*a+.33*o,c=.114-.114*a-.497*o,d=.299-.299*a-.328*o,u=.587+.413*a+.035*o,p=.114-.114*a+.293*o,m=.299-.3*a+1.25*o,f=.587-.586*a-1.05*o,g=.114+.886*a-.2*o;let v,_,y,x;for(let t=0;t<i;t+=4)v=e[t+0],_=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=h*v+l*_+c*y+r,e[t+1]=d*v+u*_+p*y+r,e[t+2]=m*v+f*_+g*y+r,e[t+3]=x},HSV:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,a=n*s*Math.cos(r*Math.PI/180),o=n*s*Math.sin(r*Math.PI/180),h=.299*n+.701*a+.167*o,l=.587*n-.587*a+.33*o,c=.114*n-.114*a-.497*o,d=.299*n-.299*a-.328*o,u=.587*n+.413*a+.035*o,p=.114*n-.114*a+.293*o,m=.299*n-.3*a+1.25*o,f=.587*n-.586*a-1.05*o,g=.114*n+.886*a-.2*o;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2],r=e[t+3];e[t+0]=h*i+l*n+c*s,e[t+1]=d*i+u*n+p*s,e[t+2]=m*i+f*n+g*s,e[t+3]=r}},Invert:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},Kaleidoscope:function(t){const e=t.width,i=t.height;let n,s,r,a,o,h,l,c,d,u,p=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),f=Math.floor(e*(m%360)/360);if(p<1)return;const g=Vv.createCanvasElement();g.width=e,g.height=i;const v=g.getContext("2d").getImageData(0,0,e,i);Vv.releaseCanvas(g),function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=r-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=r,f=360/m*Math.PI/180;for(let t=0;t<m;t+=1){const e=Math.sin(t*f),i=Math.cos(t*f);for(let a=0;a<p;a+=1){c=Math.floor(o+l*a/p*i),d=Math.floor(h+l*a/p*e);let u=4*(d*r+c);const m=n[u+0],f=n[u+1],g=n[u+2],v=n[u+3];u=4*(t+a*r),s[u+0]=m,s[u+1]=f,s[u+2]=g,s[u+3]=v}}}(t,v,{polarCenterX:e/2,polarCenterY:i/2});let _=e/Math.pow(2,p);for(;_<=8;)_*=2,p-=1;_=Math.ceil(_);let y=_,x=0,b=y,S=1;for(f+_>e&&(x=y,b=0,S=-1),s=0;s<i;s+=1)for(n=x;n!==b;n+=S)r=Math.round(n+f)%e,d=4*(e*s+r),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*s+n),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;for(s=0;s<i;s+=1)for(y=Math.floor(_),a=0;a<p;a+=1){for(n=0;n<y+1;n+=1)d=4*(e*s+n),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*s+2*y-n-1),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;y*=2}!function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=r-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=r;let f,g;for(c=0;c<r;c+=1)for(d=0;d<a;d+=1){const t=c-o,e=d-h,i=Math.sqrt(t*t+e*e)*p/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*m/360,f=Math.floor(a),g=Math.floor(i);let u=4*(g*r+f);const v=n[u+0],_=n[u+1],y=n[u+2],x=n[u+3];u=4*(d*r+c),s[u+0]=v,s[u+1]=_,s[u+2]=y,s[u+3]=x}}(v,t,{})},Mask:function(t){let e=function(t,e){const i=Wx(t,0,0),n=Wx(t,t.width-1,0),s=Wx(t,0,t.height-1),r=Wx(t,t.width-1,t.height-1),a=e||10;if(jx(i,n)<a&&jx(n,r)<a&&jx(r,s)<a&&jx(s,i)<a){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,r,s]),o=[];for(let i=0;i<t.width*t.height;i++){const n=jx(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);o[i]=n<a?0:255}return o}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*s+l];c+=t[d*e+u]*i}}a[l]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*s+l];c+=t[d*e+u]*i}}a[l]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*s+l];c+=t[d*e+u]*i}}a[l]=c}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},Noise:function(t){const e=255*this.noise(),i=t.data,n=i.length,s=e/2;for(let t=0;t<n;t+=4)i[t+0]+=s-2*s*Math.random(),i[t+1]+=s-2*s*Math.random(),i[t+2]+=s-2*s*Math.random()},Pixelate:function(t){let e=Math.ceil(this.pixelSize()),i=t.width,n=t.height,s=Math.ceil(i/e),r=Math.ceil(n/e),a=t.data;if(e<=0)Vv.error("pixelSize value can not be <= 0");else for(let t=0;t<s;t+=1)for(let s=0;s<r;s+=1){let r=0,o=0,h=0,l=0;const c=t*e,d=c+e,u=s*e,p=u+e;let m=0;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const s=4*(i*e+t);r+=a[s+0],o+=a[s+1],h+=a[s+2],l+=a[s+3],m+=1}r/=m,o/=m,h/=m,l/=m;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const s=4*(i*e+t);a[s+0]=r,a[s+1]=o,a[s+2]=h,a[s+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,s=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/s)*s},RGB:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*s,e[t+2]=i*r,e[t+3]=e[t+3]}},RGBA:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=s*a+e[t+1]*i,e[t+2]=r*a+e[t+2]*i}},Sepia:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*s),e[t+1]=Math.min(255,.349*i+.686*n+.168*s),e[t+2]=Math.min(255,.272*i+.534*n+.131*s)}},Solarize:function(t){const e=t.data;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],s=e[t+2];.2126*i+.7152*n+.0722*s>=128&&(e[t]=255-i,e[t+1]=255-n,e[t+2]=255-s)}return t},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255}}});class Yx{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class qx{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const n=t=>{const e=t.toString(16);return"0"===e?"00":e};return n(t)+n(e)+n(i)}}const Zx=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Kx{constructor(t,e=null,i=new Yx){var n,s;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let n=0;n<e.length;n+=2)i=this._worldTransformer.screenToWorld({x:e[n],y:e[n+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const r=[],a=[];t.points.forEach(t=>{r.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});a.push({x:e.x,y:e.y,z:e.z})}),this._ref=new Xx.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(s=t.width)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:r,draggable:!0,strokeScaleEnabled:!1,dash:Zx.get(t.type)||[]}),this._ref.setAttr("wcsPoints",a),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)}),this._ref.on("transformend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let s=0;s<i.length;s+=2){const r=t.point({x:i[s],y:i[s+1]});n=this._worldTransformer.screenToWorld({x:r.x,y:r.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.on("dragend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let s=0;s<i.length;s+=2){const r=t.point({x:i[s],y:i[s+1]});n=this._worldTransformer.screenToWorld({x:r.x,y:r.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Zx.get("dot"):t="dot";break;case Zx.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Zx.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach(t=>{e=e.concat([t.x,t.y]);const n=this._worldTransformer.screenToWorld(t);i.push(n)}),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach(t=>{let n=this._worldTransformer.worldToScreen(t);n=i.point({x:n.x,y:n.y}),e.push(n.x),e.push(n.y)}),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class Jx{constructor(t,e=null,i=new Yx){var n,s,r;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;return void(this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new Xx.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(n=t.fontSize)&&void 0!==n?n:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",align:"left",draggable:!0,rotation:null!==(r=t.rotation)&&void 0!==r?r:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY);s<50&&(s=50),r<Math.round(this.getFontSize())&&(r=Math.round(this.getFontSize())),i&&this._ref.width(s),n&&this._ref.height(r),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class Qx{constructor(t,e=null,i=new Yx){var n,s,r,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new Xx.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(r=t.width)&&void 0!==r?r:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY);s<50&&(s=50),r<50&&(r=50),i&&this._ref.width(s),n&&this._ref.height(r),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),s=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(s.x-n.x)),this._ref.height(Math.abs(s.y-n.y))}}function $x(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class tb{constructor(t,e=null,i=new Yx){var n,s,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),n=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(n||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(n=t.radius)&&void 0!==n||(t.radius={x:0,y:0}),t.radius.x=$x(t.position,t.position2),t.position3?t.radius.y=$x(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new Xx.Ellipse({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.radiusX();i&&(s*=e.scaleX);let r=this._ref.radiusY();n&&(r*=e.scaleY);s<25&&(s=25),r<25&&(r=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:r}),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let n=this._ref.getStage().getAbsoluteTransform().copy();n=n.invert();const s=n.point({x:t.x,y:t.y});this._ref.position({x:s.x,y:s.y}),this._ref.radius({x:Math.abs(n.point(e).x-s.x),y:Math.abs(n.point(i).y-s.y)})}}class eb{constructor(t,e=null,i=new Yx){var n,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new Xx.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),n=this._ref.getAbsoluteTransform(),s=n.point({x:i[0],y:i[1]}),r=n.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(s)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))}),this._ref.on("dragend",t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),n=i.point({x:e[0],y:e[1]}),s=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(n)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const n=i.point({x:t.x,y:t.y}),s=i.point({x:e.x,y:e.y});this._ref.points([n.x,n.y,s.x,s.y])}}class ib{constructor(t,e=null,i=new Yx){var n,s;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Xx.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(s=t.height)&&void 0!==s?s:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),t.position2&&this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(s),this._ref.height(s*this._ratio)):(this._ref.width(r/this._ratio),this._ref.height(r)):(i&&this._ref.width(s),n&&this._ref.height(r)),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),s=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(s.x-n.x)),this._ref.height(Math.abs(s.y-n.y))}}class nb{constructor(t,e=null,i=new Yx){var n,s,r,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new Xx.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(s=t.height)&&void 0!==s?s:200,stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),n=this._ref.height(),s=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+n},{x:0,y:0+n},{x:0,y:0}];function r(r,a){const o={x:(h={x:0,y:0}).x+i/2,y:h.y+n/2};var h;t.beginPath();for(let e=0;e<s.length-1;e++){let i=a;const n=s[e+1].x-s[e].x,h=s[e+1].y-s[e].y,l=Math.sqrt(n*n+h*h),c=Math.floor(l/i);i=a+c/(l%i);let d=s[e].x+n/c/2,u=s[e].y+h/c/2;const p=s[e+1].x,m=s[e+1].y,f=Math.atan((m-u)/(p-d)),g=f+Math.PI,v=d>o.x&&u>o.y;for(let e=0;e<c;e++)v?t.arc(d,u,r,f,g):t.arc(d,u,r,g,f),d+=n/c,u+=h/c}t.closePath(),t.fillStrokeShape(e)}i>=49||n>=49?r(8,15):i>=25||n>=25?r(4,7.5):(t.beginPath(),t.lineTo(s[1].x,s[1].y),t.lineTo(s[2].x,s[2].y),t.lineTo(s[3].x,s[3].y),t.lineTo(s[4].x,s[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY),s<50&&(s=50),r<50&&(r=50),i&&this._ref.width(s),n&&this._ref.height(r),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),s=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(s.x-n.x)),this._ref.height(Math.abs(s.y-n.y))}}const sb={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new Kx(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new Jx(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new Qx(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new tb(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new eb(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new ib(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new nb(e,t,...i)}};class rb{constructor(){this._markupIsActive=!1,this._markupColor=new qx(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter(t=>!t.startsWith("oda-cursor-")).filter(t=>t).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this._container;i&&n&&(this._markupContainer.style.left=`${t}px`,this._markupContainer.style.top=`${e}px`,this._konvaStage.width(i),this._konvaStage.height(n),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.pan=()=>{this.updateScreenCoordinatesForAll()},this.zoomAt=()=>{this.updateScreenCoordinatesForAll()},this.changeCameraMode=()=>{this.clearOverlay()},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,n){this._viewer=i,this._worldTransformer=null!=n?n:new Yx,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(t),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt),this._viewer.addEventListener("changecameramode",this.changeCameraMode))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("changecameramode",this.changeCameraMode),this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,this.destroyKonva(),null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach(t=>t.delete())}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const n=new qx(t,e,i).asHex();this.getObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}colorizeSelectedMarkups(t,e,i){const n=new qx(t,e,i).asHex();this.getSelectedObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}setViewpoint(t){var e,i,n,s,r,a,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach(t=>{const e=[];t.points.forEach(t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)}),this.addLine(e,t.color,t.type,t.width,t.id)}),null===(n=t.texts)||void 0===n||n.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)}),null===(s=t.rectangles)||void 0===s||s.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(r=t.ellipses)||void 0===r||r.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,n=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,n,t.radius,t.line_width,t.color,t.id)}),null===(a=t.arrows)||void 0===a||a.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)}),null===(o=t.clouds)||void 0===o||o.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(h=t.images)||void 0===h||h.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)})}getViewpoint(t){return t||(t={custom_fields:{}}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields.markup_color=this.getMarkupColor(),t}getSnapshot(t="image/jpeg",e=.25){this.clearSelected();const i=document.createElement("canvas");if(this._konvaStage){i.width=this._konvaStage.width(),i.height=this._konvaStage.height();const t=i.getContext("2d");this._container instanceof HTMLCanvasElement&&t.drawImage(this._container,0,0),t.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return i.toDataURL(t,e)}enableEditMode(t){return t&&sb[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=sb[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const n=i.initializer(null,e,this._worldTransformer);return this.addObject(n),n}getObjects(){const t=[];return Object.keys(sb).forEach(e=>{const i=sb[e];this.konvaLayerFind(e).forEach(e=>t.push(i.initializer(e,null,this._worldTransformer)))}),t}getSelectedObjects(){if(!this._konvaTransformer)return[];const t=this._konvaTransformer.nodes().filter(t=>{try{return null!==t.getLayer()&&null!==t.getParent()}catch{return!1}});return t.length!==this._konvaTransformer.nodes().length&&this._konvaTransformer.nodes(t),t.map(t=>{const e=t.className,i=Object.values(sb).find(t=>t.name===e);return i?i.initializer(t,null,this._worldTransformer):null}).filter(t=>t)}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map(t=>t.ref()));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=sb[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter(t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts):[]}updateScreenCoordinatesForAll(){this.getObjects().forEach(t=>{t.updateScreenCoordinates()})}initializeKonva(){const t=new Xx.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Xx.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Xx.Group,e.add(this._groupImages),this._groupGeometry=new Xx.Group,e.add(this._groupGeometry),this._groupTexts=new Xx.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Xx.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let n,s,r,a=!1;t.on("mousedown touchstart",e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const r=this.getRelativePointerPosition(t);s=r,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some(t=>t===this._markupMode),"Line"===this._markupMode&&(n=this.addLine([r.x,r.y,r.x,r.y]))}),t.on("mouseup touchend",()=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,n=i?s.x:Math.min(s.x,e.x),r=i?s.y:Math.min(s.y,e.y),a=i?200:Math.abs(s.x-e.x),o=i?200:Math.abs(s.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:n,y:r},null,a,o):"Ellipse"===this._markupMode?this.addEllipse({x:n,y:r},null,null,{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:s.x,y:s.y},{x:i?s.x+200:e.x,y:i?r:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:n,y:r},null,Math.max(100,a),Math.max(100,o)))}r=void 0,a=!1}}),t.on("mousemove touchmove",()=>{if(!this._markupIsActive)return;if(!a)return;const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,o=i?s.x:Math.min(s.x,e.x),h=i?s.y:Math.min(s.y,e.y),l=i?200:Math.abs(s.x-e.x),c=i?200:Math.abs(s.y-e.y);"Line"===this._markupMode?n.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?r?r.setEndPoint(e.x,e.y):r=this.addArrow({x:s.x,y:s.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?r?(r.setPosition(o,h),r.setWidth(l),r.setHeight(c)):r=this.addRectangle({x:o,y:h},null,l,c):"Ellipse"===this._markupMode?r?(r.setPosition(o,h),r.setRadiusX(l),r.setRadiusY(c)):r=this.addEllipse({x:o,y:h},null,null,{x:l,y:c}):"Cloud"===this._markupMode&&(r?(r.setPosition(o,h),r.setWidth(Math.max(100,l)),r.setHeight(Math.max(100,c))):r=this.addCloud({x:o,y:h},null,l,c))}),t.on("click tap",e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter(t=>"Cloud"===t.className||"Image"===t.className).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const n=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(n||s){if(n&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(n&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])});const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach(t=>t.delete()),void this.clearSelected()):void t.preventDefault()})}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach(e=>{const i=e.getAttr("wcsPoints");if(!i)return;const n=new Kx(null,e,this._worldTransformer),s={id:n.id(),points:i,color:n.getColor()||"#ff0000",type:n.getLineType()||this.lineType,width:n.getLineWidth()||this.lineWidth};t.push(s)}),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach(e=>{const i=this._worldTransformer.getScale(),n=e.getAttr("wcsStart"),s=this._konvaStage.getAbsoluteTransform(),r=new Jx(null,e,this._worldTransformer),a={id:r.id(),position:n,text:r.getText(),text_size:.02*i.y,angle:r.getRotation(),color:r.getColor(),font_size:r.getFontSize()*s.getMatrix()[0]};t.push(a)}),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),r=this._worldTransformer.worldToScreen(n),a=new Qx(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(s.x-r.x),height:Math.abs(s.y-r.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach(e=>{const i=e.getAttr("wcsPosition"),n=e.getAttr("wcsRadiusX"),s=e.getAttr("wcsRadiusY"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],a=new tb(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,position3:s,radius:{x:e.getRadiusX()*r,y:e.getRadiusY()*r},line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=new eb(null,e,this._worldTransformer),r={id:s.id(),start:i,end:n,color:s.getColor()};t.push(r)}),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],r=new ib(null,e,this._worldTransformer),a={id:r.id(),position:i,position2:n,src:r.getSrc(),width:r.getWidth()*s,height:r.getHeight()*s};t.push(a)}),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),r=this._worldTransformer.worldToScreen(n),a=new nb(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(s.x-r.x),height:Math.abs(s.y-r.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}addLine(t,e,i,n,s){if(!t||0===t.length)return;const r=[];for(let e=0;e<t.length;e+=2)r.push({x:t[e],y:t[e+1]});const a=new Kx({points:r,type:i||this.lineType,width:n||this.lineWidth,color:e||this._markupColor.asHex(),id:s},null,this._worldTransformer);return this.addObject(a),a}createTextInput(t,e,i,n,s){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=n,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout(()=>{this._textInputRef.focus()},50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise((e,i)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{e(n.result)},n.onerror=t=>{i(t)}});this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],n=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,n.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout(()=>{this._imageInputRef.click()},50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,n,s,r,a){var o;if(!t)return;null===(o=this.getSelectedObjects().shift())||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(s&&s>h&&(!r||r<h)){const t=.02;r=s/(this._worldTransformer.getScale().y/t)/34}const l=new Jx({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:r||this.fontSize,color:n||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,n,s,r,a){if(!t)return;const o=new Qx({position:t,position2:e,width:i,height:n,lineWidth:s||this.lineWidth,color:r||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addEllipse(t,e,i,n,s,r,a){if(!t)return;const o=new tb({position:t,position2:e,position3:i,radius:n,lineWidth:s,color:r||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addArrow(t,e,i,n){if(!t||!e)return;const s=new eb({start:t,end:e,color:i||this._markupColor.asHex(),id:n},null,this._worldTransformer);return this.addObject(s),s}addCloud(t,e,i,n,s,r,a){if(!t||!i||!n)return;const o=new nb({position:t,position2:e,width:i,height:n,color:r||this._markupColor.asHex(),lineWidth:s||this.lineWidth,id:a},null,this._worldTransformer);return this.addObject(o),o}addImage(t,e,i,n,s,r){var a;if(!t||!i)return;null===(a=this.getSelectedObjects().shift())||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const o=new ib({position:t,position2:e,src:i,width:n,height:s,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:r},null,this._worldTransformer);return this.addObject(o),o}}class ab extends xr{constructor(){super(...arguments),this.oldAutoClear=!1,this.oldClippingPlanes=[]}onBeforeRender(t){this.oldAutoClear=t.autoClear,this.oldClippingPlanes=t.clippingPlanes,t.autoClear=!1,t.clippingPlanes=[]}onAfterRender(t){t.clippingPlanes=this.oldClippingPlanes,t.autoClear=this.oldAutoClear}}"undefined"!=typeof window&&(window.THREE=lm),t.CANVAS_EVENTS=v,t.CanvasEvents=g,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.GLTFLoadingManager=Dg,t.Info=_,t.Loader=c,t.Markup=rb,t.ModelImpl=_g,t.Options=f,t.Viewer=class extends Av{constructor(t){super(),this.client=t,this.options=new f(this),this.loaders=[],this.models=[],this.info=new _,this.canvasEvents=v.slice(),this.canvaseventlistener=t=>this.emit(t),this.selected=[],this.extents=new Qi,this.target=new Li(0,0,0),this._activeDragger=null,this._components=[],this._updateDelay=1e3,this._renderNeeded=!1,this._renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new rb}get markup(){return this._markup}get draggers(){return[...Vf.getDraggers().keys()]}get components(){return[...vg.getComponents().keys()]}initialize(t,e){this.addEventListener("optionschange",t=>this.syncOptions(t.data)),this.scene=new xr,this.helpers=new ab;const i=window.devicePixelRatio,n=t.parentElement.getBoundingClientRect(),s=n.width||1,r=n.height||1,a=s/r;this.camera=new cr(45,a,.001,1e3),this.camera.up.set(0,1,0),this.camera.position.set(0,0,1),this.camera.lookAt(this.target),this.camera.updateProjectionMatrix(),this.renderer=new hm({canvas:t,antialias:!0,alpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!0}),this.renderer.setPixelRatio(i),this.renderer.setSize(s,r),this.renderer.outputColorSpace=Ge,this.renderPass=new gv(this.scene,this.camera),this.helpersPass=new gv(this.helpers,this.camera),this.helpersPass.clear=!1,this.fxaaPass=new _v,this.smaaPass=new Sv,this.ssaaRenderPass=new wv([this.scene,this.helpers],this.camera),this.ssaaRenderPass.unbiased=!0,this.outputPass=new Ev,this.composer=new fv(this.renderer),this.composer.addPass(this.renderPass),this.composer.addPass(this.helpersPass),this.composer.addPass(this.smaaPass),this.composer.addPass(this.fxaaPass),this.composer.addPass(this.ssaaRenderPass),this.composer.addPass(this.outputPass),this.composer.setSize(s,r),this.canvas=t,this.canvasEvents.forEach(e=>t.addEventListener(e,this.canvaseventlistener)),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of vg.getComponents().keys())this._components.push(vg.createComponent(t,this));if(this.syncOptions(),this.syncOverlay(),this._renderTime=performance.now(),"function"==typeof e){e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1}))}return this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),this.update(!0),Promise.resolve(this)}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach(t=>t.dispose()),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach(t=>this.canvas.removeEventListener(t,this.canvaseventlistener)),this.canvas=void 0),this.composer&&this.composer.dispose(),this.renderPass&&this.renderPass.dispose(),this.helpersPass&&this.helpersPass.dispose(),this.fxaaPass&&this.fxaaPass.dispose(),this.smaaPass&&this.smaaPass.dispose(),this.ssaaRenderPass&&this.ssaaRenderPass.dispose(),this.outputPass&&this.outputPass.dispose(),this.renderer&&this.renderer.dispose(),this.scene=void 0,this.helpers=void 0,this.camera=void 0,this.renderer=void 0,this.renderPass=void 0,this.helpersPass=void 0,this.fxaaPass=void 0,this.smaaPass=void 0,this.ssaaRenderPass=void 0,this.outputPass=void 0,this.composer=void 0,this}isInitialized(){return!!this.renderer}setSize(t,e,i=!0){if(!this.renderer)return;const n=this.camera,s=t/e;n.isPerspectiveCamera&&(n.aspect=s,n.updateProjectionMatrix()),n.isOrthographicCamera&&(n.left=n.bottom*s,n.right=n.top*s,n.updateProjectionMatrix()),this.renderer.setSize(t,e,i),this.composer.setSize(t,e),this.emitEvent({type:"resize",width:t,height:e}),this.update(!0)}update(t=!1){const e=performance.now();t=t||e-this._renderTime>=this._updateDelay,this._renderNeeded=!0,t&&this.render(e),this.emitEvent({type:"update",force:t})}render(t,e=!1){if(!this.renderer)return;if(!this._renderNeeded&&!e)return;t||(t=performance.now());const i=(t-this._renderTime)/1e3;this._renderTime=t,this._renderNeeded=!1,this.renderer.info.autoReset=!1,this.renderer.info.reset(),!0===this.options.antialiasing||"msaa"===this.options.antialiasing?(this.renderer.render(this.scene,this.camera),this.renderer.render(this.helpers,this.camera)):this.composer.render(i),this.emitEvent({type:"render",time:t,deltaTime:i})}loadReferences(t){return Promise.resolve(this)}async open(t,e={}){if(!this.renderer)return this;const i=e.mode||"file";"assembly"!==i&&"a"!==i&&"append"!==i&&(this.cancel(),this.clear()),this.emitEvent({type:"open",mode:i,file:t});let n=t;if(n&&"function"==typeof n.getModels){const e=await n.getModels();n=e.find(t=>t.default)||e[0]||t}n&&"string"==typeof n.database&&(t=n.file);let s=e.format;!s&&t&&"string"==typeof t.type&&(s=t.type.split(".").pop()),s||"string"!=typeof t||(s=t.split(".").pop()),!s&&t instanceof globalThis.File&&(s=t.name.split(".").pop());const r=av.createLoader(this,n,s);if(!r)throw new Error(`Format not supported (${s})`);this.loaders.push(r),this.emitEvent({type:"geometrystart",file:t,model:n});try{await this.loadReferences(n),await r.load(n,s,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:n}),e}return this.emitEvent({type:"geometryend",file:t,model:n}),this.update(!0),this}cancel(){return this.loaders.forEach(t=>t.cancel()),this.emitEvent({type:"cancel"}),this}clear(){return this.renderer?(this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.loaders.forEach(t=>t.dispose()),this.loaders=[],this.models.forEach(t=>t.dispose()),this.models=[],this.scene.clear(),this.helpers.clear(),this.extents.makeEmpty(),this.syncOptions(),this.syncOverlay(),this.emitEvent({type:"clear"}),this.update(!0),this):this}is3D(){return!0}syncOptions(t=this.options){this.renderer&&(this.fxaaPass.enabled="fxaa"===t.antialiasing,this.smaaPass.enabled="smaa"===t.antialiasing,this.ssaaRenderPass.enabled="ssaa"===t.antialiasing,this.renderPass.enabled=!this.ssaaRenderPass.enabled,this.helpersPass.enabled=!this.ssaaRenderPass.enabled,this.update())}syncOverlay(){this.renderer&&(this._markup.syncOverlay(),this.update())}clearOverlay(){this.renderer&&(this._markup.clearOverlay(),this.update())}clearSlices(){this.renderer&&(this.renderer.clippingPlanes=[],this.update())}getSelected(){return this.executeCommand("getSelected")}getSelected2(){return this.executeCommand("getSelected2")}setSelected(t){this.executeCommand("setSelected",t)}setSelected2(t){this.executeCommand("setSelected2",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(t=""){if(!this._activeDragger||this._activeDragger.name!==t){const e=this._activeDragger;let i=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()&&(i=Vf.createDragger(t,this),this._activeDragger=i);const n=this.canvas;n&&(e&&n.classList.remove(`oda-cursor-${e.name.toLowerCase()}`),i&&n.classList.add(`oda-cursor-${i.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find(e=>e.name===t)}drawViewpoint(t){var e,i,n,s;if(!this.renderer)return;const r=({x:t,y:e,z:i})=>new Li(t,e,i),a=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{if(t){const e=this.extents.getSize(new Li).length()||1,i=this.renderer.getSize(new Ai),n=i.x/i.y,s=new Bl;s.top=t.field_height/2,s.bottom=-t.field_height/2,s.left=s.bottom*n,s.right=s.top*n,s.near=1e3*-e,s.far=1e3*e,s.zoom=t.view_to_world_scale,s.updateProjectionMatrix(),s.up.copy(r(t.up_vector)),s.position.copy(r(t.view_point)),s.lookAt(r(t.direction).add(s.position)),s.updateMatrixWorld(),this.camera=s,this.renderPass.camera=s,this.helpersPass.camera=s,this.ssaaRenderPass.camera=s,this.options.cameraMode="orthographic",this.emitEvent({type:"changecameramode",mode:"orthographic"})}})(t.orthogonal_camera),(t=>{if(t){const e=this.extents.getSize(new Li).length()||1,i=this.renderer.getSize(new Ai),n=i.x/i.y,s=new cr;s.fov=t.field_of_view,s.aspect=n,s.near=e/1e3,s.far=1e3*e,s.updateProjectionMatrix(),s.up.copy(r(t.up_vector)),s.position.copy(r(t.view_point)),s.lookAt(r(t.direction).add(s.position)),s.updateMatrixWorld(),this.camera=s,this.renderPass.camera=s,this.helpersPass.camera=s,this.ssaaRenderPass.camera=s,this.options.cameraMode="perspective",this.emitEvent({type:"changecameramode",mode:"perspective"})}})(t.perspective_camera),(t=>{t&&t.forEach(t=>{const e=new ga;e.setFromNormalAndCoplanarPoint(r(t.direction),r(t.location)),this.renderer.clippingPlanes.push(e)})})(t.clipping_planes),(t=>{t&&this.setSelected(t.map(t=>t.handle))})((null===(i=t.custom_fields)||void 0===i?void 0:i.selection2)||t.selection),this._markup.setViewpoint(t),this.target.copy(r(null!==(s=null===(n=t.custom_fields)||void 0===n?void 0:n.camera_target)&&void 0!==s?s:this.target)),this.syncOverlay(),this.setActiveDragger(a),this.emitEvent({type:"drawviewpoint",data:t}),this.update(!0)}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:i})=>({x:t,y:e,z:i}),e={custom_fields:{}};return e.orthogonal_camera=(()=>this.camera.isOrthographicCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Li)),up_vector:t(this.camera.up),field_width:this.camera.right-this.camera.left,field_height:this.camera.top-this.camera.bottom,view_to_world_scale:this.camera.zoom}:void 0)(),e.perspective_camera=(()=>this.camera.isPerspectiveCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Li)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}:void 0)(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach(i=>{const n={location:t(i.coplanarPoint(new Li)),direction:t(i.normal)};e.push(n)}),e})(),e.selection=(()=>this.getSelected().map(t=>({handle:t})))(),e.description=(new Date).toDateString(),e.snapshot={data:this.getSnapshot()},this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),e.custom_fields.selection2=(()=>this.getSelected2().map(t=>({handle:t})))(),this.emitEvent({type:"createviewpoint",data:e}),e}getSnapshot(t,e){return this.executeCommand("getSnapshot",t,e)}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),i=t.x/(e.width/2)-1,n=-t.y/(e.height/2)+1;if(this.camera.isPerspectiveCamera){const t=new Oc,e=new Ai(i,n);t.setFromCamera(e,this.camera);const s=new Li;this.camera.getWorldDirection(s);const r=(new ga).setFromNormalAndCoplanarPoint(s,this.target),a=new Li;if(t.ray.intersectPlane(r,a),!a){const t=new Li(i,n,-1);return t.unproject(this.camera),{x:t.x,y:t.y,z:t.z}}return{x:a.x,y:a.y,z:a.z}}const s=new Li(i,n,-1);return s.unproject(this.camera),{x:s.x,y:s.y,z:s.z}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new Li(t.x,t.y,t.z);e.project(this.camera);const i=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(i.width/2),y:(1-e.y)*(i.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return qf.executeCommand(t,this,...e)}},t.commands=qf,t.commandsRegistry=n,t.components=vg,t.componentsRegistry=l,t.defaultOptions=m,t.draggers=Vf,t.draggersRegistry=a,t.loaders=av,t.loadersRegistry=p});
|
|
37
|
+
this.useVAO=!1,this.visibleEdges=!0,this.handleToOptimizedObjects=new Map,this.hiddenHandles=new Set,this.newOptimizedObjects=new Set,this.oldOptimizeObjects=new Set,this.objectTransforms=new Map,this.transformedGeometries=new Map,this.activeChunkLoads=0,this.chunkQueue=[],this.objectIdToIndex=new Map,this.maxObjectId=0,this.objectVisibility=new Float32Array,this.maxConcurrentChunks=6,this.mergedObjectMap=new Map,this.mergedGeometryVisibility=new Map,this._webglInfoCache=null}setVisibleEdges(t){this.visibleEdges=t}getAvailableMemory(){let t=6442450944;try{if(navigator.deviceMemory)t=1024*navigator.deviceMemory*1024*1024;else if(performance.memory){const e=performance.memory.jsHeapSizeLimit;e&&(t=Math.min(t,e))}t=Math.min(t,17179869184),t=Math.max(t,2147483648),console.log(`Available memory set to ${Math.round(t/1073741824)}GB`)}catch(t){console.warn("Error detecting available memory:",t)}return t}getAbortController(){return this.abortController}abortLoading(){this.abortController.abort()}getOptimizedGeometrySize(){let t=0;const e=e=>{e&&e.geometry&&(t+=this.estimateGeometrySize(e))};return this.mergedMesh?.forEach(e),this.mergedLines?.forEach(e),this.mergedLineSegments?.forEach(e),this.mergedPoints?.forEach(e),t}updateMemoryIndicator(){const t=this.getOptimizedGeometrySize(),e=this.currentMemoryUsage+t,i=Math.round(e*this.memoryEstimationFactor);this.dispatchEvent("geometrymemory",{currentUsage:this.currentMemoryUsage,optimizedUsage:t,totalUsage:e,totalUsageEstimate:i,limit:this.memoryLimit})}setMemoryLimit(t){}estimateGeometrySize(t){let e=0;return t.traverse(t=>{if(t.geometry){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const i=t.geometry;i.attributes&&Object.values(i.attributes).forEach(t=>{t&&t.array&&(e+=t.array.byteLength)}),i.index&&i.index.array&&(e+=i.index.array.byteLength)}}),e}recalculateScene(){const t=[];if(this.scene.traverse(e=>{if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");if(e.geometry&&!this.geometryCache.has(e.geometry.uuid)){const i=this.estimateGeometrySize(e);this.geometryCache.set(e.geometry.uuid,i),t.push({object:e,size:i,distance:e.position.distanceTo(this.camera.position)})}}),this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");t.sort((t,e)=>e.distance-t.distance);let e=0;for(const i of t)e+=i.size;const i=this.memoryLimit/this.memoryEstimationFactor;if(e>i){console.log(`Memory usage (${Math.round(e*this.memoryEstimationFactor/1048576)}MB est.) exceeds limit`);for(const n of t){if(e<=i)break;if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=n.object;t.geometry&&(e-=n.size,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose(),t.visible=!1)}}this.currentMemoryUsage=e,this.updateMemoryIndicator(),console.log(`Final memory usage: ${Math.round(e/1048576)}MB`)}getStats(){let t=0,e=0,i=0,n=0,s=0,r=0,a=0,o=0;this.scene.traverse(h=>{t++;const l=h.geometry;if(!l)return;let c=0;l.index?c=Math.floor(l.index.count/3):l.attributes&&l.attributes.position&&(c=Math.floor(l.attributes.position.count/3)),i+=c;let d=0;l.index?d=Math.floor(l.index.count/2):l.attributes&&l.attributes.position&&(d=Math.floor(l.attributes.position.count/2)),"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?a+=d:s+=d),!1!==h.visible&&(h.isMesh||h.isLine||h.isPoints)&&(e++,h.isMesh?n+=c:"Line"!==h.type&&"LineSegments"!==h.type&&"LineLoop"!==h.type||(h.userData.isEdge?o+=d:r+=d))});const h=this.geometryCache?this.geometryCache.size:0,l=Array.from(this.geometryCache?.values?.()||[]).reduce((t,e)=>t+e,0),c=new Set,d=new Set;if(Array.isArray(this.structures))for(const t of this.structures)try{for(const e of t.materialCache.values())e?.mesh?.uuid&&c.add(e.mesh.uuid),e?.points?.uuid&&c.add(e.points.uuid),e?.lines?.uuid&&c.add(e.lines.uuid)}catch(t){console.error("Error adding material to uniqueMaterialIds",t)}const u=c.size,p=d.size,m=this.getOptimizedGeometrySize(),f=l+m,g=Math.round(f*this.memoryEstimationFactor);if(!this._webglInfoCache)try{const t=this.renderer.getContext(),e=t.getExtension("WEBGL_debug_renderer_info");if(e){const i=t.getParameter(e.UNMASKED_RENDERER_WEBGL),n=t.getParameter(e.UNMASKED_VENDOR_WEBGL);this._webglInfoCache={renderer:i,vendor:n}}else this._webglInfoCache={renderer:null,vendor:null}}catch(t){console.error("Error getting webgl info",t),this._webglInfoCache={renderer:null,vendor:null}}const v=new Ai;return this.renderer&&this.renderer.getSize&&this.renderer.getSize(v),{scene:{beforeOptimization:{objects:t-e,triangles:i-n,lines:s-r,edges:a-o},afterOptimization:{objects:e,triangles:n,lines:r,edges:o}},memory:{geometries:{count:h,bytes:l,optimizedBytes:m,totalRawBytes:f},textures:{count:p},materials:{count:u},totalEstimatedGpuBytes:g},system:{webglRenderer:this._webglInfoCache?.renderer||"",webglVendor:this._webglInfoCache?.vendor||"",viewport:{width:v.x||0,height:v.y||0}}}}async loadNode(t,e,i=0){const n=this.nodes.get(t);if(!n||n.loaded||n.loading)return void(this.pendingMemoryUsage=Math.max(0,this.pendingMemoryUsage-i));n.loading=!0;const s=n.structure.getJson().meshes[n.meshIndex];try{const t=[],r=new Map;for(let e=0;e<s.primitives.length;e++){const i=s.primitives[e],a=[];if(void 0!==i.attributes.POSITION){const t=i.attributes.POSITION,s=n.structure.json.accessors[t],r=(n.structure.json.bufferViews[s.bufferView].byteOffset||0)+(s.byteOffset||0),o=n.structure.getNumComponents(s.type),h=s.count*o*n.structure.getComponentSize(s.componentType);a.push({offset:r,length:h,componentType:s.componentType,accessorIndex:t,type:"position",primIdx:e})}if(void 0!==i.attributes.NORMAL){const t=i.attributes.NORMAL,s=n.structure.json.accessors[t],r=(n.structure.json.bufferViews[s.bufferView].byteOffset||0)+(s.byteOffset||0),o=n.structure.getNumComponents(s.type),h=s.count*o*n.structure.getComponentSize(s.componentType);a.push({offset:r,length:h,componentType:s.componentType,accessorIndex:t,type:"normal",primIdx:e})}if(void 0!==i.attributes.TEXCOORD_0){const t=i.attributes.TEXCOORD_0,s=n.structure.json.accessors[t],r=(n.structure.json.bufferViews[s.bufferView].byteOffset||0)+(s.byteOffset||0),o=n.structure.getNumComponents(s.type),h=s.count*o*n.structure.getComponentSize(s.componentType);a.push({offset:r,length:h,componentType:s.componentType,accessorIndex:t,type:"uv",primIdx:e})}if(void 0!==i.indices){const t=i.indices,s=n.structure.json.accessors[t],r=(n.structure.json.bufferViews[s.bufferView].byteOffset||0)+(s.byteOffset||0),o=n.structure.getNumComponents(s.type),h=s.count*o*n.structure.getComponentSize(s.componentType);a.push({offset:r,length:h,componentType:s.componentType,accessorIndex:t,type:"index",primIdx:e})}r.set(e,a),t.push(...a)}if(0===t.length)return n.loaded=!0,n.loading=!1,void(this.pendingMemoryUsage=Math.max(0,this.pendingMemoryUsage-i));t.sort((t,e)=>t.offset-e.offset);const a=t[0].offset,o=Math.max(...t.map(t=>t.offset+t.length))-a,{buffer:h,relOffset:l}=await n.structure.scheduleRequest({offset:a,length:o,componentType:null});for(const e of t){const t=e.offset-a;e.data=n.structure.createTypedArray(h,l+t,e.length,e.componentType)}for(let t=0;t<s.primitives.length;t++){const e=s.primitives[t],i=new zs,a=r.get(t);if(void 0!==e.attributes.POSITION){const t=a.find(t=>"position"===t.type&&t.accessorIndex===e.attributes.POSITION),s=n.structure.json.accessors[e.attributes.POSITION],r=n.structure.getNumComponents(s.type);i.setAttribute("position",new Ls(t.data,r))}if(void 0!==e.attributes.NORMAL){const t=a.find(t=>"normal"===t.type&&t.accessorIndex===e.attributes.NORMAL),s=n.structure.json.accessors[e.attributes.NORMAL],r=n.structure.getNumComponents(s.type);i.setAttribute("normal",new Ls(t.data,r))}if(void 0!==e.attributes.TEXCOORD_0){const t=a.find(t=>"uv"===t.type&&t.accessorIndex===e.attributes.TEXCOORD_0),s=n.structure.json.accessors[e.attributes.TEXCOORD_0],r=n.structure.getNumComponents(s.type);i.setAttribute("uv",new Ls(t.data,r))}if(void 0!==e.indices){const t=a.find(t=>"index"===t.type&&t.accessorIndex===e.indices);i.setIndex(new Ls(t.data,1))}let o,h;if(void 0!==e.material){if(o=n.structure.getCachedMaterial(e.material,e.mode),!o){const t=n.structure.json.materials[e.material];o=n.structure.createMaterial(t,e.mode)}}else o=this.createDefaultMaterial(e.mode);e.mode===bg?h=new oo(i,o):e.mode===Tg||e.mode===Eg||e.mode===Ag||void 0===e.mode?(h=new Qs(i,o),e.mode===Eg?h.drawMode=1:e.mode===Ag&&(h.drawMode=2)):e.mode===Sg?h=new to(i,o):e.mode===Mg?h=new Ka(i,o):e.mode===wg&&(h=new eo(i,o)),n.extras&&(h.userData={...h.userData,...n.extras}),s.extras&&(h.userData={...h.userData,...s.extras}),e.extras&&(h.userData={...h.userData,...e.extras}),n.handle?h.userData.handle=n.handle:h.userData.handle=this.getFullHandle(n.structure.id,h.userData.handle),"edges"===h.material.name?h.userData.isEdge=!0:h.userData.isEdge=!1,this.registerObjectWithHandle(h,h.userData.handle),h.position.copy(n.position),i.attributes.normal||i.computeVertexNormals(),o.aoMap&&i.attributes.uv&&i.setAttribute("uv2",i.attributes.uv),n.group?n.group.add(h):this.scene.add(h),n.object=h,this.totalLoadedObjects++,h.visible=this.totalLoadedObjects<this.graphicsObjectLimit}n.loaded=!0,n.loading=!1,this.pendingMemoryUsage=Math.max(0,this.pendingMemoryUsage-i);const c=this.estimateGeometrySize(n.object);this.geometryCache.set(n.object.uuid,c),this.currentMemoryUsage+=c,e&&e()}catch(e){if(n.loading=!1,this.pendingMemoryUsage=Math.max(0,this.pendingMemoryUsage-i),"AbortError"===e.name)return;if(n.structure&&n.structure.loadingAborted)return;console.error(`Error loading node ${t}:`,e)}}unloadNode(t){const e=this.nodes.get(t);e&&e.loaded&&e.object&&(e.object.parent?e.object.parent.remove(e.object):this.scene.remove(e.object),e.object.traverse(t=>{if(t.geometry){const e=this.geometryCache.get(t.geometry.uuid)||0;this.currentMemoryUsage-=e,this.geometryCache.delete(t.geometry.uuid),t.geometry.dispose()}}),e.object=null,e.loaded=!1,this.updateMemoryIndicator(),console.log(`Unloaded node: ${t}`))}checkDistances(){const t=this.camera.position;this.nodes.forEach((e,i)=>{const n=t.distanceTo(e.position);e.loaded?n>this.unloadDistance&&this.unloadNode(i):e.loading||n<this.loadDistance&&this.loadNode(i)})}async loadStructure(t){this.clear();const e=Array.isArray(t)?t:[t];for(const t of e)await t.initialize(this),this.structures.push(t);for(const t of this.structures)try{await t.loadTextures(),await t.loadMaterials()}catch(t){throw console.error("Error loading materials:",t),t}await this.processSceneHierarchy()}async processSceneHierarchy(){if(0===this.structures.length)throw new Error("No GLTF structures loaded");this.nodesToLoad=[];let t=0;for(const e of this.structures){const i=e.getJson();if(!i.scenes||!i.scenes.length){console.warn("No scenes found in GLTF structure");continue}t+=i.buffers[0].byteLength;const n=new fr;n.name=`structure_${e.id}_root`,this.scene.add(n),this.structureRoots.set(e.id,n);const s=i.scenes[i.scene||0];for(const t of s.nodes)await this.processNodeHierarchy(e,t,n)}const e=2*t>this.memoryLimit;this.nodesToLoad.sort((t,e)=>{const i=this.nodes.get(t),n=this.nodes.get(e);if(!i?.geometryExtents||!n?.geometryExtents)return 0;const s=i.geometryExtents.getSize(new Li),r=n.geometryExtents.getSize(new Li),a=s.x*s.y*s.z;return r.x*r.y*r.z-a}),!e&&this.visibleEdges&&this.nodesToLoad.push(...this.edgeNodes),this.dispatchEvent("databasechunk",{totalNodes:this.nodesToLoad.length,structures:this.structures.map(t=>({id:t.id,nodeCount:this.nodesToLoad.filter(e=>e.startsWith(t.id)).length}))})}getFullHandle(t,e){return`${t}:${e}`}async processNodeHierarchy(t,e,i){const n=t.json.nodes[e];let s=null,r=null;if(n.extras?.handle&&(r=this.getFullHandle(t.id,n.extras.handle)),void 0!==n.camera){const e=this.loadCamera(t,n.camera,n);return n.extras&&(e.userData={...e.userData,...n.extras}),void this.scene.add(e)}if(this.needsGroupForNode(t,n)){if(s=new fr,s.name=n.name||`node_${e}`,n.extras&&(s.userData={...n.extras},s.userData.handle&&(s.userData.handle=this.getFullHandle(t.id,s.userData.handle))),n.matrix)s.matrix.fromArray(n.matrix),s.matrixAutoUpdate=!1;else if(n.translation||n.rotation||n.scale){const t=n.translation?(new Li).fromArray(n.translation):new Li,e=n.rotation?(new Ci).fromArray(n.rotation):new Ci,i=n.scale?(new Li).fromArray(n.scale):new Li(1,1,1);s.matrix.compose(t,e,i),s.matrixAutoUpdate=!1}i&&i.add(s)}if(void 0!==n.mesh){const a=new En,o=`${t.id}_${e}`,h=t.json.meshes[n.mesh],l=new Qi;for(const e of h.primitives){const i=t.json.accessors[e.attributes.POSITION];if(i&&i.min&&i.max){const t=new Qi((new Li).fromArray(i.min),(new Li).fromArray(i.max));l.union(t)}}let c=!1;if(void 0!==h.primitives[0].material){const e=t.json.materials[h.primitives[0].material];"edges"===e?.name&&(c=!0)}c?this.edgeNodes.push(o):this.nodesToLoad.push(o),h.extras&&h.extras.handle&&(r=this.getFullHandle(t.id,h.extras.handle)),this.nodes.set(o,{position:s?s.position.clone():(new Li).setFromMatrixPosition(a),nodeIndex:e,meshIndex:n.mesh,loaded:!1,loading:!1,object:null,group:s||i,structure:t,extras:n.extras,geometryExtents:l,handle:r||this.getFullHandle(t.id,t._nextObjectId++)})}if(n.children)for(const e of n.children)await this.processNodeHierarchy(t,e,s||i);return s}needsGroupForNode(t,e){const i=e.matrix||e.translation||e.rotation||e.scale,n=void 0!==e.mesh&&t.json.meshes[e.mesh].primitives.length>1;return void 0!==i||n}async processNodes(){const t=this.nodesToLoad;let e=0,i=0;const n={value:t.length},s=async()=>{e++;const t=n.value,s=t>0?Math.min(100,Math.round(e/t*100)):0;e-i>1e3&&(i=e,this.updateMemoryIndicator(),this.dispatchEvent("geometryprogress",{percentage:s,loaded:e,total:t}),this.dispatchEvent("update"),await new Promise(t=>{setTimeout(t,0)}))};try{const i=[];let r=!1;for(const e of t){if(this.abortController.signal.aborted)throw new DOMException("Loading aborted","AbortError");const t=await this.estimateNodeSize(e),a=Number(t)||0,o=this.memoryLimit/this.optimizationMemoryMultiplier/this.memoryEstimationFactor;if(this.currentMemoryUsage+this.pendingMemoryUsage+a>o){r=!0,n.value=i.length,console.log(`Memory limit reached after scheduling ${i.length} nodes`);break}this.pendingMemoryUsage+=a,i.push(this.loadNode(e,s,a))}for(const t of this.structures)i.push(t.flushBufferRequests());return await Promise.all(i),this.dispatchEvent("geometryend",{totalLoaded:e,totalNodes:n.value,memoryLimitReached:r}),e}catch(t){throw this.dispatchEvent("geometryerror",{error:t}),t}}async loadNodes(){console.time("Process nodes"),await this.processNodes(),console.timeEnd("Process nodes"),console.time("Optimize scene"),await this.optimizeScene(),console.timeEnd("Optimize scene")}cleanupPartialLoad(){this.nodesToLoad.forEach(t=>{const e=this.nodes.get(t);e&&e.loading&&this.unloadNode(t)})}createDefaultMaterial(t=void 0){return t===bg?new io({color:new _s(8421504),size:.05,sizeAttenuation:!1,alphaTest:.5,transparent:!0,vertexColors:!1,blending:1,depthWrite:!1,depthTest:!0}):t===Sg||t===Mg||t===wg?new Ha({color:8421504,linewidth:1,alphaTest:.1,depthTest:!0,depthWrite:!0,transparent:!0,opacity:1}):new Xh({color:8421504,specular:2236962,shininess:10,side:2})}async estimateNodeSize(t){const e=this.nodes.get(t);return e?await e.structure.estimateNodeSize(e.meshIndex):0}getTotalGeometryExtent(){const t=new Qi;for(const e of this.nodes.values()){if(!e.geometryExtents)continue;if(e.object&&this.hiddenHandles.has(e.object.userData.handle))continue;const i=e.geometryExtents.clone(),n=e.structure?this.structureRoots.get(e.structure.id):null;if(e.group){const t=new En;let s=e.group;for(;s&&s!==n;)t.premultiply(s.matrix),s=s.parent;t.equals(new En)||i.applyMatrix4(t)}n&&n.matrix&&i.applyMatrix4(n.matrix);const s=this.objectTransforms.get(e.object);s&&i.applyMatrix4(s),t.union(i)}return this.scene&&this.scene.matrix&&!t.isEmpty()&&t.applyMatrix4(this.scene.matrix),t}loadCamera(t,e,i){const n=t.getJson().cameras[e],s=n[n.type];let r;return"perspective"===n.type?r=new cr(Ei.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===n.type&&(r=new Bl(s.xmag/-2,s.xmag/2,s.ymag/2,s.ymag/-2,s.znear,s.zfar)),i.matrix?(r.matrix.fromArray(i.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)):(i.translation&&r.position.fromArray(i.translation),i.rotation&&r.quaternion.fromArray(i.rotation),i.scale&&r.scale.fromArray(i.scale)),r}clearNodesToLoad(){this.nodesToLoad=[]}removeOptimization(){this.originalObjects.forEach(t=>t.visible=!0);const t=t=>{t.parent&&t.parent.remove(t),t.geometry&&t.geometry.dispose()};if(this.structureGroups)for(const e of this.structureGroups.values())e.meshes.forEach(t),e.lines.forEach(t),e.lineSegments.forEach(t),e.meshes.clear(),e.lines.clear(),e.lineSegments.clear();this.optimizedOriginalMap.clear(),this.mergedMesh.clear(),this.mergedLines.clear(),this.mergedLineSegments.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear()}initializeObjectVisibility(){if(this.maxObjectId>0){this.objectVisibility=new Float32Array(this.maxObjectId);for(let t=0;t<this.maxObjectId;t++)this.objectVisibility[t]=1}}createVisibilityMaterial(t){return t.onBeforeCompile=t=>{t.vertexShader=t.vertexShader.replace("#include <common>","\n #include <common>\n attribute float visibility;\n varying float vVisibility;\n "),t.fragmentShader=t.fragmentShader.replace("#include <common>","\n #include <common>\n varying float vVisibility;\n "),t.vertexShader=t.vertexShader.replace("void main() {","\n void main() {\n vVisibility = visibility;\n "),t.fragmentShader=t.fragmentShader.replace("void main() {","\n void main() {\n if (vVisibility < 0.5) discard;\n ")},t.needsUpdate=!0,t}clear(){this.chunkQueue=[],this.structures.forEach(t=>{t&&t.clear()}),this.structures=[],this.nodes.forEach(t=>{t.object&&(t.object.parent&&t.object.parent.remove(t.object),t.object.geometry&&t.object.geometry.dispose(),t.object.material&&(Array.isArray(t.object.material)?t.object.material.forEach(t=>t.dispose()):t.object.material.dispose()))}),this.nodes.clear(),this.loadedMeshes.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),this.loadedMeshes.clear(),this.structureRoots.forEach(t=>{t&&(t.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose())}),t.parent&&t.parent.remove(t))}),this.structureRoots.clear(),this.mergedMesh.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.dispose()):t.material.dispose()),t.parent&&t.parent.remove(t)}),this.mergedMesh.clear(),this.mergedLines.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLines.clear(),this.mergedLineSegments.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedLineSegments.clear(),this.mergedPoints.forEach(t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.parent&&t.parent.remove(t)}),this.mergedPoints.clear(),this.geometryCache.clear(),this.materialCache.clear(),this.textureCache.clear(),this.loadedMaterials.clear(),this.nodesToLoad=[],this.handleToObjects.clear(),this.originalObjects.clear(),this.originalObjectsToSelection.clear(),this.optimizedOriginalMap.clear(),this.handleToOptimizedObjects.clear(),this.hiddenHandles.clear(),this.newOptimizedObjects.clear(),this.oldOptimizeObjects.clear(),this.isolatedObjects=[],this.objectTransforms.clear(),this.transformedGeometries.clear(),this.totalLoadedObjects=0,this.currentMemoryUsage=0,this.pendingMemoryUsage=0,this.loadedGeometrySize=0,this.abortController=new AbortController,this.updateMemoryIndicator(),this.objectIdToIndex.clear(),this.maxObjectId=0,this.objectVisibility=new Float32Array}setStructureTransform(t,e){const i=this.structureRoots.get(t);return!!i&&(i.matrix.copy(e),i.matrix.decompose(i.position,i.quaternion,i.scale),!0)}getStructureRootGroup(t){return this.structureRoots.get(t)}addEventListener(t,e){this.eventHandlers[t]&&this.eventHandlers[t].push(e)}removeEventListener(t,e){this.eventHandlers[t]&&(this.eventHandlers[t]=this.eventHandlers[t].filter(t=>t!==e))}dispatchEvent(t,e){this.eventHandlers[t]&&this.eventHandlers[t].forEach(t=>t(e))}registerObjectWithHandle(t,e){if(!e)return;const i=t.userData.handle;this.handleToObjects.has(i)||this.handleToObjects.set(i,new Set),this.handleToObjects.get(i).add(t),t.userData.structureId=t.userData.handle.split(":")[0]}getObjectsByHandle(t){return t?Array.from(this.handleToObjects.get(t)||[]):[]}getHandlesByObjects(t){if(!t.length)return[];const e=new Set;return t.forEach(t=>{this.originalObjects.has(t)&&e.add(t.userData.handle)}),Array.from(e)}getMaterialId(t,e){const i={type:t.type,color:t.color?.getHex(),map:t.map?.uuid,transparent:t.transparent,opacity:t.opacity,side:t.side,index:e?1:0};return JSON.stringify(i)}addToMaterialGroup(t,e,i){const n=t.geometry.attributes.position.count,s=t.geometry.index?t.geometry.index.count:0,r=t.material;let a,o=this.getMaterialId(r,null!==t.geometry.index);if(e.has(o))if(a=e.get(o),a.totalVertices+n>1e5||a.totalIndices+s>1e5){const a={material:r,objects:[t],totalVertices:n,totalIndices:s};o=this.getMaterialId(r,null!==t.geometry.index),e.set(o,a),i.push(a)}else a.objects.push(t),a.totalVertices+=n,a.totalIndices+=s;else a={material:r,objects:[t],totalVertices:n,totalIndices:s},e.set(o,a),i.push(a);this.originalObjects.add(t)}yieldToUI(){return new Promise(t=>{setTimeout(t,0)})}async optimizeScene(){console.log("Starting scene optimization..."),this.dispatchEvent("optimizationprogress",{phase:"start",progress:0,message:"Starting optimization..."}),this.originalObjects.clear(),this.originalObjectsToSelection.clear();const t=new Map;this.dispatchEvent("optimizationprogress",{phase:"collecting",progress:5,message:"Collecting scene objects..."}),this.scene.traverse(e=>{if(e.userData.structureId){const i=e.userData.structureId;t.has(i)||t.set(i,{mapMeshes:new Map,mapLines:new Map,mapLineSegments:new Map,mapPoints:new Map,meshes:[],lines:[],lineSegments:[],points:[],rootGroup:this.structureRoots.get(i)});const n=t.get(i);e instanceof Qs?this.addToMaterialGroup(e,n.mapMeshes,n.meshes):e instanceof to?this.addToMaterialGroup(e,n.mapLineSegments,n.lineSegments):e instanceof Ka?this.addToMaterialGroup(e,n.mapLines,n.lines):e instanceof oo&&this.addToMaterialGroup(e,n.mapPoints,n.points)}});let e=0;const i=t.size;this.dispatchEvent("optimizationprogress",{phase:"merging",progress:10,message:`Merging ${i} structure groups...`,current:0,total:i});for(const n of t.values()){n.mapMeshes.clear(),n.mapLines.clear(),n.mapLineSegments.clear(),n.mapPoints.clear(),await this.mergeMeshGroups(n.meshes,n.rootGroup),await this.yieldToUI(),await this.mergeLineGroups(n.lines,n.rootGroup),await this.yieldToUI(),await this.mergeLineSegmentGroups(n.lineSegments,n.rootGroup),await this.yieldToUI(),await this.mergePointsGroups(n.points,n.rootGroup),e++;const t=10+Math.round(e/i*80);this.dispatchEvent("optimizationprogress",{phase:"merging",progress:t,message:`Processing structure ${e}/${i}...`,current:e,total:i}),console.log(`Optimization progress: ${e}/${i} structure groups processed (${t}%)`),await this.yieldToUI()}this.dispatchEvent("optimizationprogress",{phase:"finalizing",progress:95,message:"Finalizing optimization..."}),this.originalObjects.forEach(t=>{t.visible=!1,t instanceof oo||t.userData.isEdge||this.originalObjectsToSelection.add(t)}),this.initializeObjectVisibility(),console.log(`Optimization complete. Total objects: ${this.maxObjectId}`),this.dispatchEvent("optimizationprogress",{phase:"complete",progress:100,message:`Optimization complete! ${this.maxObjectId} objects processed.`}),this.updateMemoryIndicator(),this.dispatchEvent("update")}async mergeMeshGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],s=new Set,r=[],a=new Map;let o=0;for(const i of n.objects){const n=i.geometry.clone(),h=new En;let l=i;for(;l&&l!==e;)h.premultiply(l.matrix),l=l.parent;h.equals(new En)||n.applyMatrix4(h);const c=i.userData.handle;this.objectIdToIndex.has(c)||this.objectIdToIndex.set(c,this.maxObjectId++);const d=this.objectIdToIndex.get(c),u=n.attributes.position.count,p=new Float32Array(u);for(let t=0;t<u;t++)p[t]=d;n.setAttribute("objectId",new Ls(p,1)),a.set(i,{geometry:n,startVertexIndex:o,vertexCount:n.attributes.position.count}),o+=n.attributes.position.count,t.push(n),r.push(i),s.add(i.userData.handle)}const h=[];if(t.length>0){const i=Rg(t),s=i.attributes.position.count,o=new Float32Array(s);for(let t=0;t<s;t++)o[t]=1;i.setAttribute("visibility",new Ls(o,1)),this.useVAO&&this.createVAO(i);const l=this.createVisibilityMaterial(n.material),c=new Qs(i,l);c.userData.isOptimized=!0,e.add(c),this.mergedMesh.add(c),this.optimizedOriginalMap.set(c,r),this.mergedObjectMap.set(c.uuid,{objectMapping:a,visibilityArray:o,totalVertices:s}),this.mergedGeometryVisibility.set(c,o),h.push(c),t.forEach(t=>{t.dispose()})}s.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...h),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,h)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.error("Failed to merge meshes for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping mesh group with null material")}async mergeLineGroups(t,e){let i=0;for(const n of t){if(0===n.objects.length)continue;if(!n.material){console.warn("Skipping line group with null material");continue}const t=new Set;let s=0;const r=new Map;let a=0;n.objects.map(e=>{t.add(e.userData.handle),s+=e.geometry.attributes.position.count});const o=new Float32Array(3*s);let h=0;const l=[];let c=0,d=!1;n.objects.forEach(t=>{d=t.userData.isEdge;const i=t.geometry.clone(),n=new En;let s=t;for(;s&&s!==e;)n.premultiply(s.matrix),s=s.parent;n.equals(new En)||i.applyMatrix4(n);const u=i.attributes.position,p=u.count,m=t.userData.handle;this.objectIdToIndex.has(m)||this.objectIdToIndex.set(m,this.maxObjectId++),r.set(t,{startVertexIndex:a,vertexCount:p}),a+=p;const f=new Li;for(let t=0;t<p;t++)f.fromBufferAttribute(u,t),o[h++]=f.x,o[h++]=f.y,o[h++]=f.z;for(let t=0;t<p-1;t++)l.push(c+t,c+t+1);c+=p,i.dispose()});const u=new zs;u.setAttribute("position",new Ls(o,3)),u.setIndex(l),u.computeBoundingSphere(),u.computeBoundingBox();const p=new Float32Array(s);let m=0;n.objects.forEach(t=>{const e=t.geometry.attributes.position.count,i=t.userData.handle,n=this.objectIdToIndex.get(i);for(let t=0;t<e;t++)p[m++]=n}),u.setAttribute("objectId",new Ls(p,1));const f=new Float32Array(s);for(let t=0;t<s;t++)f[t]=1;u.setAttribute("visibility",new Ls(f,1));const g=this.createVisibilityMaterial(n.material),v=new to(u,g);v.userData.isEdge=d,v.userData.isOptimized=!0;const _=[v];this.useVAO&&this.createVAO(v),e.add(v),this.mergedLines.add(v),this.optimizedOriginalMap.set(v,n.objects),this.mergedObjectMap.set(v.uuid,{objectMapping:r,visibilityArray:f,totalVertices:s}),this.mergedGeometryVisibility.set(v,f),t.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(..._),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,_)}),i++,i%5==0&&await this.yieldToUI()}}async mergeLineSegmentGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],s=[],r=new Set,a=new Map;let o=0,h=!1;for(const i of n.objects){h=i.userData.isEdge;const n=i.geometry.clone(),l=new En;let c=i;for(;c&&c!==e;)l.premultiply(c.matrix),c=c.parent;l.equals(new En)||n.applyMatrix4(l);const d=i.userData.handle;this.objectIdToIndex.has(d)||this.objectIdToIndex.set(d,this.maxObjectId++);const u=this.objectIdToIndex.get(d),p=n.attributes.position.count,m=new Float32Array(p);for(let t=0;t<p;t++)m[t]=u;n.setAttribute("objectId",new Ls(m,1)),a.set(i,{geometry:n,startVertexIndex:o,vertexCount:n.attributes.position.count}),o+=n.attributes.position.count,t.push(n),s.push(i),r.add(i.userData.handle)}const l=[];if(t.length>0){const i=Rg(t,!1),r=i.attributes.position.count,o=new Float32Array(r);for(let t=0;t<r;t++)o[t]=1;i.setAttribute("visibility",new Ls(o,1));const c=this.createVisibilityMaterial(n.material),d=new to(i,c);d.userData.isEdge=h,d.userData.isOptimized=!0,this.useVAO&&this.createVAO(d),e.add(d),this.mergedLineSegments.add(d),this.optimizedOriginalMap.set(d,s),this.mergedObjectMap.set(d.uuid,{objectMapping:a,visibilityArray:o,totalVertices:r}),this.mergedGeometryVisibility.set(d,o),l.push(d),t.forEach(t=>{t.dispose()})}r.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...l),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,l)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge line segments for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping line segment group with null material")}async mergePointsGroups(t,e){let i=0;for(const n of t)if(n.material)try{const t=[],s=[],r=new Set;for(const i of n.objects){const n=i.geometry.clone(),a=new En;let o=i;for(;o&&o!==e;)a.premultiply(o.matrix),o=o.parent;a.equals(new En)||n.applyMatrix4(a),t.push(n),s.push(i),r.add(i.userData.handle)}const a=[];if(t.length>0){const i=Rg(t,!1),r=new oo(i,n.material);r.userData.isOptimized=!0,this.useVAO&&this.createVAO(r),e.add(r),this.mergedPoints.add(r),this.optimizedOriginalMap.set(r,s),a.push(r),t.forEach(t=>{t.dispose()})}r.forEach(t=>{if(this.handleToOptimizedObjects.has(t)){const e=this.handleToOptimizedObjects.get(t);e.push(...a),this.handleToOptimizedObjects.set(t,e)}else this.handleToOptimizedObjects.set(t,a)}),i++,i%5==0&&await this.yieldToUI()}catch(t){console.warn("Failed to merge points for material:",t),n.objects.forEach(t=>{t.visible=!0})}else console.warn("Skipping points group with null material")}mergeInSingleSegment(t,e){const i=[...this.mergedLineSegments,...this.mergedLines].filter(e=>e.userData.structureId===t);if(0!==i.length)try{const n=[],s=i.some(t=>void 0!==t.geometry.attributes.normal);i.forEach(t=>{const e=t.geometry.clone();e.applyMatrix4(t.matrixWorld),s&&!e.attributes.normal&&e.computeVertexNormals(),!s&&e.attributes.normal&&e.deleteAttribute("normal");const i=new Float32Array(3*e.attributes.position.count);for(let e=0;e<i.length;e+=3)i[e]=t.material.color.r,i[e+1]=t.material.color.g,i[e+2]=t.material.color.b;if(e.setAttribute("color",new Ls(i,3)),!e.index){const t=[],i=e.attributes.position.count;for(let e=0;e<i-1;e+=2)t.push(e,e+1);e.setIndex(t)}n.push(e)});const r=Rg(n,!1),a=new Ha({vertexColors:!0});this.useVAO&&this.createVAO(r);const o=new to(r,a);o.userData.structureId=t,o.userData.isOptimized=!0,e.add(o),this.mergedLineSegments.add(o),i.forEach(t=>{t.parent&&t.parent.remove(t),t.geometry.dispose()})}catch(t){console.error("Failed to merge geometries:",t),i.forEach(t=>{t.visible=!0,e.add(t)})}}showOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!0)})}hideOriginalObjects(t){t.forEach(t=>{this.originalObjects.has(t)&&(t.visible=!1)})}createVAO(t){if(!this.useVAO)return;if(t.attributes?.position?.count<1e3)return;const e=this.renderer.getContext(),i=e.createVertexArray();e.bindVertexArray(i);for(const i in t.attributes){const n=t.attributes[i],s=this.renderer.properties.get(n).buffer;e.bindBuffer(e.ARRAY_BUFFER,s),e.enableVertexAttribArray(n.itemSize),e.vertexAttribPointer(n.itemSize,n.itemSize,e.FLOAT,!1,0,0)}if(t.index){const i=this.renderer.properties.get(t.index).buffer;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i)}e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),t.vao=i}getOriginalObjectForSelect(){const t=[];for(const e of this.originalObjectsToSelection)this.hiddenHandles.has(e.userData.handle)||t.push(e);return t}isolateObjects(t){0!==this.hiddenHandles.size&&(this.hiddenHandles.clear(),this.syncHiddenObjects());for(const e of this.handleToOptimizedObjects.keys())t.has(e)||this.hiddenHandles.add(e);this.syncHiddenObjects()}showAllHiddenObjects(){this.hiddenHandles.clear(),this.syncHiddenObjects()}hideObjects(t){t.forEach(t=>{this.hiddenHandles.add(t)}),this.syncHiddenObjects()}showObjects(t){t.forEach(t=>{this.hiddenHandles.delete(t)}),this.syncHiddenObjects()}_updateVisibilityAttribute(t){if(t.geometry&&t.geometry.attributes.visibility&&t.geometry.attributes.objectId){const e=t.geometry.attributes.visibility.array,i=t.geometry.attributes.objectId.array;for(let t=0;t<e.length;t++){const n=i[t];n<this.objectVisibility.length&&(e[t]=this.objectVisibility[n])}t.geometry.attributes.visibility.needsUpdate=!0}}applyObjectTransforms(t){if(0!==this.mergedObjectMap.size){this.objectTransforms=new Map(t);for(const t of this.mergedMesh)this._applyTransformToMergedObject(t);for(const t of this.mergedLines)this._applyTransformToMergedObject(t);for(const t of this.mergedLineSegments)this._applyTransformToMergedObject(t);for(const t of this.mergedPoints)this._applyTransformToMergedObject(t)}else console.warn("No merged objects to transform")}createExplodeTransforms(t=null,e=null,i=1.5){const n=new Map;if(!e){e=new Li;const t=this.getTotalGeometryExtent();t.isEmpty()||t.getCenter(e)}const s=t?Array.isArray(t)?t:Array.from(t):Array.from(this.originalObjects);for(const t of s){if(!t.geometry||!t.geometry.attributes.position)continue;const s=(new Qi).setFromBufferAttribute(t.geometry.attributes.position);if(t.matrixWorld&&s.applyMatrix4(t.matrixWorld),s.isEmpty())continue;const r=new Li;s.getCenter(r);const a=r.clone().sub(e),o=a.length();if(o>0){a.normalize();const e=a.multiplyScalar(o*(i-1)),s=(new En).makeTranslation(e.x,e.y,e.z);n.set(t,s)}}return n}clearTransforms(){this.objectTransforms.clear();for(const t of this.mergedMesh)this._restoreOriginalGeometry(t);for(const t of this.mergedLines)this._restoreOriginalGeometry(t);for(const t of this.mergedLineSegments)this._restoreOriginalGeometry(t);for(const t of this.mergedPoints)this._restoreOriginalGeometry(t)}clearHandleTransforms(){this.clearTransforms()}_applyTransformToMergedObject(t){const e=this.mergedObjectMap.get(t.uuid);if(!e||!e.objectMapping)return;const i=t.geometry;if(!i||!i.attributes.position)return;const n=i.attributes.position,s=n.array;this.transformedGeometries.has(t.uuid)||this.transformedGeometries.set(t.uuid,new Float32Array(s));const r=this.transformedGeometries.get(t.uuid),a=new Li;for(const[t,i]of e.objectMapping){const e=this.objectTransforms.get(t);if(!e){const t=3*i.startVertexIndex,e=3*(i.startVertexIndex+i.vertexCount);for(let i=t;i<e;i++)s[i]=r[i];continue}const n=i.startVertexIndex,o=i.vertexCount;for(let t=0;t<o;t++){const i=3*(n+t);a.set(r[i],r[i+1],r[i+2]),a.applyMatrix4(e),s[i]=a.x,s[i+1]=a.y,s[i+2]=a.z}}i.attributes.normal&&this._updateNormalsForTransform(i,e,r),n.needsUpdate=!0,i.computeBoundingSphere(),i.computeBoundingBox()}_updateNormalsForTransform(t,e,i){const n=t.attributes.normal;if(!n)return;const s=n.array,r=new Li,a=new En,o=`${t.uuid}_normals`;this.transformedGeometries.has(o)||this.transformedGeometries.set(o,new Float32Array(s));const h=this.transformedGeometries.get(o);for(const[t,i]of e.objectMapping){const e=this.objectTransforms.get(t);if(!e){const t=3*i.startVertexIndex,e=3*(i.startVertexIndex+i.vertexCount);for(let i=t;i<e;i++)s[i]=h[i];continue}a.copy(e).invert().transpose();const n=i.startVertexIndex,o=i.vertexCount;for(let t=0;t<o;t++){const e=3*(n+t);r.set(h[e],h[e+1],h[e+2]),r.applyMatrix4(a).normalize(),s[e]=r.x,s[e+1]=r.y,s[e+2]=r.z}}n.needsUpdate=!0}_restoreOriginalGeometry(t){const e=t.geometry;if(!e||!e.attributes.position)return;const i=this.transformedGeometries.get(t.uuid);if(i){e.attributes.position.array.set(i),e.attributes.position.needsUpdate=!0}const n=`${e.uuid}_normals`,s=this.transformedGeometries.get(n);if(s&&e.attributes.normal){e.attributes.normal.array.set(s),e.attributes.normal.needsUpdate=!0}e.computeBoundingSphere(),e.computeBoundingBox()}syncHiddenObjects(){if(0!==this.mergedObjectMap.size){if(this.objectVisibility.length>0){for(let t=0;t<this.objectVisibility.length;t++)this.objectVisibility[t]=1;this.hiddenHandles.forEach(t=>{const e=this.objectIdToIndex.get(t);void 0!==e&&e<this.objectVisibility.length&&(this.objectVisibility[e]=0)})}for(const t of this.mergedMesh)this._updateVisibilityAttribute(t);for(const t of this.mergedLines)this._updateVisibilityAttribute(t);for(const t of this.mergedLineSegments)this._updateVisibilityAttribute(t);for(const t of this.mergedPoints)this._updateVisibilityAttribute(t)}else console.log("No merged objects to sync")}getStructureGeometryExtent(t){const e=new Qi,i=this.structureRoots.get(t);for(const[n,s]of this.nodes.entries()){if(!s.geometryExtents)continue;if(!n.startsWith(t+"_"))continue;if(s.object&&this.hiddenHandles&&this.hiddenHandles.has(s.object.userData.handle))continue;const r=s.geometryExtents.clone();if(s.group){const t=[];let e=s.group;for(;e&&e!==i;)e.matrix&&!1===e.matrixAutoUpdate&&t.unshift(e.matrix),e=e.parent;for(const e of t)r.applyMatrix4(e)}i&&i.matrix&&r.applyMatrix4(i.matrix),e.union(r)}return this.scene&&this.scene.matrix&&!e.isEmpty()&&e.applyMatrix4(this.scene.matrix),e}setMaxConcurrentChunks(t){t<1?console.warn("Max concurrent chunks must be at least 1"):this.maxConcurrentChunks=t}waitForChunkSlot(){return this.activeChunkLoads<this.maxConcurrentChunks?(this.activeChunkLoads++,Promise.resolve()):new Promise(t=>{this.chunkQueue.push(t)})}releaseChunkSlot(){if(this.activeChunkLoads--,this.chunkQueue.length>0){const t=this.chunkQueue.shift();this.activeChunkLoads++,t()}}}class Dg extends yl{constructor(t,e={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=e.path||"";const i=e.externalFiles||new Map;"string"==typeof t?(this.fileURL=t,this.resourcePath=Xl.extractUrlBase(t)):(i.forEach((e,i)=>this.fileURL=e===t?i:this.fileURL),i.set(this.fileURL,t)),i.forEach((t,e)=>{let i;i="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,i)}),this.setURLModifier(t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),i=this.dataURLs.get(e);return null!=i?i:t})}dispose(){this.dataURLs.forEach(t=>URL.revokeObjectURL(t))}}const Og=1313821514,Ng=5130562;class Ug{constructor(t){const e=new DataView(t,0),i=(new TextDecoder).decode(new Uint8Array(t,0,Math.min(4,t.byteLength)));if("glTF"!==i)return void(this.content=new Uint8Array(t));if(this.header={magic:i,version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.length!==t.byteLength)throw new Error("GLTFBinaryParser: Invalid binary file header.");if(this.header.version<2)throw new Error("GLTFBinaryParser: Legacy binary file detected.");let n=12;for(;n<this.header.length;){const i=e.getUint32(n,!0);n+=4;const s=e.getUint32(n,!0);n+=4,s===Og?this.content=new Uint8Array(t,n,i):s===Ng&&(this.body=t.slice(n,n+i)),n+=i}if(void 0===this.content)throw new Error("GLTFBinaryParser: JSON content not found.");if(void 0===this.body)throw new Error("GLTFBinaryParser: Binary buffer chunk not found or type not supported.")}}var Fg;!function(t){t[t.BACKSPACE=8]="BACKSPACE",t[t.FORM_FEED=12]="FORM_FEED",t[t.NEWLINE=10]="NEWLINE",t[t.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",t[t.TAB=9]="TAB",t[t.SPACE=32]="SPACE",t[t.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",t[t.QUOTATION_MARK=34]="QUOTATION_MARK",t[t.NUMBER_SIGN=35]="NUMBER_SIGN",t[t.DOLLAR_SIGN=36]="DOLLAR_SIGN",t[t.PERCENT_SIGN=37]="PERCENT_SIGN",t[t.AMPERSAND=38]="AMPERSAND",t[t.APOSTROPHE=39]="APOSTROPHE",t[t.LEFT_PARENTHESIS=40]="LEFT_PARENTHESIS",t[t.RIGHT_PARENTHESIS=41]="RIGHT_PARENTHESIS",t[t.ASTERISK=42]="ASTERISK",t[t.PLUS_SIGN=43]="PLUS_SIGN",t[t.COMMA=44]="COMMA",t[t.HYPHEN_MINUS=45]="HYPHEN_MINUS",t[t.FULL_STOP=46]="FULL_STOP",t[t.SOLIDUS=47]="SOLIDUS",t[t.DIGIT_ZERO=48]="DIGIT_ZERO",t[t.DIGIT_ONE=49]="DIGIT_ONE",t[t.DIGIT_TWO=50]="DIGIT_TWO",t[t.DIGIT_THREE=51]="DIGIT_THREE",t[t.DIGIT_FOUR=52]="DIGIT_FOUR",t[t.DIGIT_FIVE=53]="DIGIT_FIVE",t[t.DIGIT_SIX=54]="DIGIT_SIX",t[t.DIGIT_SEVEN=55]="DIGIT_SEVEN",t[t.DIGIT_EIGHT=56]="DIGIT_EIGHT",t[t.DIGIT_NINE=57]="DIGIT_NINE",t[t.COLON=58]="COLON",t[t.SEMICOLON=59]="SEMICOLON",t[t.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",t[t.EQUALS_SIGN=61]="EQUALS_SIGN",t[t.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",t[t.QUESTION_MARK=63]="QUESTION_MARK",t[t.COMMERCIAL_AT=64]="COMMERCIAL_AT",t[t.LATIN_CAPITAL_LETTER_A=65]="LATIN_CAPITAL_LETTER_A",t[t.LATIN_CAPITAL_LETTER_B=66]="LATIN_CAPITAL_LETTER_B",t[t.LATIN_CAPITAL_LETTER_C=67]="LATIN_CAPITAL_LETTER_C",t[t.LATIN_CAPITAL_LETTER_D=68]="LATIN_CAPITAL_LETTER_D",t[t.LATIN_CAPITAL_LETTER_E=69]="LATIN_CAPITAL_LETTER_E",t[t.LATIN_CAPITAL_LETTER_F=70]="LATIN_CAPITAL_LETTER_F",t[t.LATIN_CAPITAL_LETTER_G=71]="LATIN_CAPITAL_LETTER_G",t[t.LATIN_CAPITAL_LETTER_H=72]="LATIN_CAPITAL_LETTER_H",t[t.LATIN_CAPITAL_LETTER_I=73]="LATIN_CAPITAL_LETTER_I",t[t.LATIN_CAPITAL_LETTER_J=74]="LATIN_CAPITAL_LETTER_J",t[t.LATIN_CAPITAL_LETTER_K=75]="LATIN_CAPITAL_LETTER_K",t[t.LATIN_CAPITAL_LETTER_L=76]="LATIN_CAPITAL_LETTER_L",t[t.LATIN_CAPITAL_LETTER_M=77]="LATIN_CAPITAL_LETTER_M",t[t.LATIN_CAPITAL_LETTER_N=78]="LATIN_CAPITAL_LETTER_N",t[t.LATIN_CAPITAL_LETTER_O=79]="LATIN_CAPITAL_LETTER_O",t[t.LATIN_CAPITAL_LETTER_P=80]="LATIN_CAPITAL_LETTER_P",t[t.LATIN_CAPITAL_LETTER_Q=81]="LATIN_CAPITAL_LETTER_Q",t[t.LATIN_CAPITAL_LETTER_R=82]="LATIN_CAPITAL_LETTER_R",t[t.LATIN_CAPITAL_LETTER_S=83]="LATIN_CAPITAL_LETTER_S",t[t.LATIN_CAPITAL_LETTER_T=84]="LATIN_CAPITAL_LETTER_T",t[t.LATIN_CAPITAL_LETTER_U=85]="LATIN_CAPITAL_LETTER_U",t[t.LATIN_CAPITAL_LETTER_V=86]="LATIN_CAPITAL_LETTER_V",t[t.LATIN_CAPITAL_LETTER_W=87]="LATIN_CAPITAL_LETTER_W",t[t.LATIN_CAPITAL_LETTER_X=88]="LATIN_CAPITAL_LETTER_X",t[t.LATIN_CAPITAL_LETTER_Y=89]="LATIN_CAPITAL_LETTER_Y",t[t.LATIN_CAPITAL_LETTER_Z=90]="LATIN_CAPITAL_LETTER_Z",t[t.LEFT_SQUARE_BRACKET=91]="LEFT_SQUARE_BRACKET",t[t.REVERSE_SOLIDUS=92]="REVERSE_SOLIDUS",t[t.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",t[t.CIRCUMFLEX_ACCENT=94]="CIRCUMFLEX_ACCENT",t[t.LOW_LINE=95]="LOW_LINE",t[t.GRAVE_ACCENT=96]="GRAVE_ACCENT",t[t.LATIN_SMALL_LETTER_A=97]="LATIN_SMALL_LETTER_A",t[t.LATIN_SMALL_LETTER_B=98]="LATIN_SMALL_LETTER_B",t[t.LATIN_SMALL_LETTER_C=99]="LATIN_SMALL_LETTER_C",t[t.LATIN_SMALL_LETTER_D=100]="LATIN_SMALL_LETTER_D",t[t.LATIN_SMALL_LETTER_E=101]="LATIN_SMALL_LETTER_E",t[t.LATIN_SMALL_LETTER_F=102]="LATIN_SMALL_LETTER_F",t[t.LATIN_SMALL_LETTER_G=103]="LATIN_SMALL_LETTER_G",t[t.LATIN_SMALL_LETTER_H=104]="LATIN_SMALL_LETTER_H",t[t.LATIN_SMALL_LETTER_I=105]="LATIN_SMALL_LETTER_I",t[t.LATIN_SMALL_LETTER_J=106]="LATIN_SMALL_LETTER_J",t[t.LATIN_SMALL_LETTER_K=107]="LATIN_SMALL_LETTER_K",t[t.LATIN_SMALL_LETTER_L=108]="LATIN_SMALL_LETTER_L",t[t.LATIN_SMALL_LETTER_M=109]="LATIN_SMALL_LETTER_M",t[t.LATIN_SMALL_LETTER_N=110]="LATIN_SMALL_LETTER_N",t[t.LATIN_SMALL_LETTER_O=111]="LATIN_SMALL_LETTER_O",t[t.LATIN_SMALL_LETTER_P=112]="LATIN_SMALL_LETTER_P",t[t.LATIN_SMALL_LETTER_Q=113]="LATIN_SMALL_LETTER_Q",t[t.LATIN_SMALL_LETTER_R=114]="LATIN_SMALL_LETTER_R",t[t.LATIN_SMALL_LETTER_S=115]="LATIN_SMALL_LETTER_S",t[t.LATIN_SMALL_LETTER_T=116]="LATIN_SMALL_LETTER_T",t[t.LATIN_SMALL_LETTER_U=117]="LATIN_SMALL_LETTER_U",t[t.LATIN_SMALL_LETTER_V=118]="LATIN_SMALL_LETTER_V",t[t.LATIN_SMALL_LETTER_W=119]="LATIN_SMALL_LETTER_W",t[t.LATIN_SMALL_LETTER_X=120]="LATIN_SMALL_LETTER_X",t[t.LATIN_SMALL_LETTER_Y=121]="LATIN_SMALL_LETTER_Y",t[t.LATIN_SMALL_LETTER_Z=122]="LATIN_SMALL_LETTER_Z",t[t.LEFT_CURLY_BRACKET=123]="LEFT_CURLY_BRACKET",t[t.VERTICAL_LINE=124]="VERTICAL_LINE",t[t.RIGHT_CURLY_BRACKET=125]="RIGHT_CURLY_BRACKET",t[t.TILDE=126]="TILDE"}(Fg||(Fg={}));const Bg={[Fg.QUOTATION_MARK]:Fg.QUOTATION_MARK,[Fg.REVERSE_SOLIDUS]:Fg.REVERSE_SOLIDUS,[Fg.SOLIDUS]:Fg.SOLIDUS,[Fg.LATIN_SMALL_LETTER_B]:Fg.BACKSPACE,[Fg.LATIN_SMALL_LETTER_F]:Fg.FORM_FEED,[Fg.LATIN_SMALL_LETTER_N]:Fg.NEWLINE,[Fg.LATIN_SMALL_LETTER_R]:Fg.CARRIAGE_RETURN,[Fg.LATIN_SMALL_LETTER_T]:Fg.TAB};class kg{constructor(){this.decoder=new TextDecoder("utf-8"),this.strings=[],this.byteLength=0}appendChar(t){this.strings.push(String.fromCharCode(t)),this.byteLength+=1}appendBuf(t,e=0,i=t.length){this.strings.push(this.decoder.decode(t.subarray(e,i))),this.byteLength+=i-e}reset(){this.strings=[],this.byteLength=0}toString(){return this.strings.join("")}}class zg{constructor(t){this.decoder=new TextDecoder("utf-8"),this.bufferOffset=0,this.string="",this.byteLength=0,this.buffer=new Uint8Array(t)}appendChar(t){this.bufferOffset>=this.buffer.length&&this.flushStringBuffer(),this.buffer[this.bufferOffset++]=t,this.byteLength+=1}appendBuf(t,e=0,i=t.length){const n=i-e;this.bufferOffset+n>this.buffer.length&&this.flushStringBuffer(),this.buffer.set(t.subarray(e,i),this.bufferOffset),this.bufferOffset+=n,this.byteLength+=n}flushStringBuffer(){this.string+=this.decoder.decode(this.buffer.subarray(0,this.bufferOffset)),this.bufferOffset=0}reset(){this.string="",this.bufferOffset=0,this.byteLength=0}toString(){return this.flushStringBuffer(),this.string}}var Gg;!function(t){t[t.LEFT_BRACE=0]="LEFT_BRACE",t[t.RIGHT_BRACE=1]="RIGHT_BRACE",t[t.LEFT_BRACKET=2]="LEFT_BRACKET",t[t.RIGHT_BRACKET=3]="RIGHT_BRACKET",t[t.COLON=4]="COLON",t[t.COMMA=5]="COMMA",t[t.TRUE=6]="TRUE",t[t.FALSE=7]="FALSE",t[t.NULL=8]="NULL",t[t.STRING=9]="STRING",t[t.NUMBER=10]="NUMBER",t[t.SEPARATOR=11]="SEPARATOR"}(Gg||(Gg={}));var Hg,Vg=Gg;function Wg(t){return["START","ENDED","ERROR","TRUE1","TRUE2","TRUE3","FALSE1","FALSE2","FALSE3","FALSE4","NULL1","NULL2","NULL3","STRING_DEFAULT","STRING_AFTER_BACKSLASH","STRING_UNICODE_DIGIT_1","STRING_UNICODE_DIGIT_2","STRING_UNICODE_DIGIT_3","STRING_UNICODE_DIGIT_4","STRING_INCOMPLETE_CHAR","NUMBER_AFTER_INITIAL_MINUS","NUMBER_AFTER_INITIAL_ZERO","NUMBER_AFTER_INITIAL_NON_ZERO","NUMBER_AFTER_FULL_STOP","NUMBER_AFTER_DECIMAL","NUMBER_AFTER_E","NUMBER_AFTER_E_AND_SIGN","NUMBER_AFTER_E_AND_DIGIT","SEPARATOR","BOM_OR_START","BOM"][t]}!function(t){t[t.START=0]="START",t[t.ENDED=1]="ENDED",t[t.ERROR=2]="ERROR",t[t.TRUE1=3]="TRUE1",t[t.TRUE2=4]="TRUE2",t[t.TRUE3=5]="TRUE3",t[t.FALSE1=6]="FALSE1",t[t.FALSE2=7]="FALSE2",t[t.FALSE3=8]="FALSE3",t[t.FALSE4=9]="FALSE4",t[t.NULL1=10]="NULL1",t[t.NULL2=11]="NULL2",t[t.NULL3=12]="NULL3",t[t.STRING_DEFAULT=13]="STRING_DEFAULT",t[t.STRING_AFTER_BACKSLASH=14]="STRING_AFTER_BACKSLASH",t[t.STRING_UNICODE_DIGIT_1=15]="STRING_UNICODE_DIGIT_1",t[t.STRING_UNICODE_DIGIT_2=16]="STRING_UNICODE_DIGIT_2",t[t.STRING_UNICODE_DIGIT_3=17]="STRING_UNICODE_DIGIT_3",t[t.STRING_UNICODE_DIGIT_4=18]="STRING_UNICODE_DIGIT_4",t[t.STRING_INCOMPLETE_CHAR=19]="STRING_INCOMPLETE_CHAR",t[t.NUMBER_AFTER_INITIAL_MINUS=20]="NUMBER_AFTER_INITIAL_MINUS",t[t.NUMBER_AFTER_INITIAL_ZERO=21]="NUMBER_AFTER_INITIAL_ZERO",t[t.NUMBER_AFTER_INITIAL_NON_ZERO=22]="NUMBER_AFTER_INITIAL_NON_ZERO",t[t.NUMBER_AFTER_FULL_STOP=23]="NUMBER_AFTER_FULL_STOP",t[t.NUMBER_AFTER_DECIMAL=24]="NUMBER_AFTER_DECIMAL",t[t.NUMBER_AFTER_E=25]="NUMBER_AFTER_E",t[t.NUMBER_AFTER_E_AND_SIGN=26]="NUMBER_AFTER_E_AND_SIGN",t[t.NUMBER_AFTER_E_AND_DIGIT=27]="NUMBER_AFTER_E_AND_DIGIT",t[t.SEPARATOR=28]="SEPARATOR",t[t.BOM_OR_START=29]="BOM_OR_START",t[t.BOM=30]="BOM"}(Hg||(Hg={}));const jg={stringBufferSize:0,numberBufferSize:0,separator:void 0,emitPartialTokens:!1};class Xg extends Error{constructor(t){super(t),Object.setPrototypeOf(this,Xg.prototype)}}class Yg{constructor(t){this.state=Hg.BOM_OR_START,this.bomIndex=0,this.separatorIndex=0,this.escapedCharsByteLength=0,this.bytes_remaining=0,this.bytes_in_sequence=0,this.char_split_buffer=new Uint8Array(4),this.encoder=new TextEncoder,this.offset=-1,t=Object.assign(Object.assign({},jg),t),this.emitPartialTokens=!0===t.emitPartialTokens,this.bufferedString=t.stringBufferSize&&t.stringBufferSize>4?new zg(t.stringBufferSize):new kg,this.bufferedNumber=t.numberBufferSize&&t.numberBufferSize>0?new zg(t.numberBufferSize):new kg,this.separator=t.separator,this.separatorBytes=t.separator?this.encoder.encode(t.separator):void 0}get isEnded(){return this.state===Hg.ENDED}write(t){try{let e;if(t instanceof Uint8Array)e=t;else if("string"==typeof t)e=this.encoder.encode(t);else if(Array.isArray(t))e=Uint8Array.from(t);else{if(!ArrayBuffer.isView(t))throw new TypeError("Unexpected type. The `write` function only accepts Arrays, TypedArrays and Strings.");e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}for(let i=0;i<e.length;i+=1){const n=e[i];switch(this.state){case Hg.BOM_OR_START:if(t instanceof Uint8Array&&239===n){this.bom=[239,187,191],this.bomIndex+=1,this.state=Hg.BOM;continue}if(t instanceof Uint16Array){if(254===n){this.bom=[254,255],this.bomIndex+=1,this.state=Hg.BOM;continue}if(255===n){this.bom=[255,254],this.bomIndex+=1,this.state=Hg.BOM;continue}}if(t instanceof Uint32Array){if(0===n){this.bom=[0,0,254,255],this.bomIndex+=1,this.state=Hg.BOM;continue}if(255===n){this.bom=[255,254,0,0],this.bomIndex+=1,this.state=Hg.BOM;continue}}case Hg.START:if(this.offset+=1,this.separatorBytes&&n===this.separatorBytes[0]){if(1===this.separatorBytes.length){this.state=Hg.START,this.onToken({token:Vg.SEPARATOR,value:this.separator,offset:this.offset+this.separatorBytes.length-1});continue}this.state=Hg.SEPARATOR;continue}if(n===Fg.SPACE||n===Fg.NEWLINE||n===Fg.CARRIAGE_RETURN||n===Fg.TAB)continue;if(n===Fg.LEFT_CURLY_BRACKET){this.onToken({token:Vg.LEFT_BRACE,value:"{",offset:this.offset});continue}if(n===Fg.RIGHT_CURLY_BRACKET){this.onToken({token:Vg.RIGHT_BRACE,value:"}",offset:this.offset});continue}if(n===Fg.LEFT_SQUARE_BRACKET){this.onToken({token:Vg.LEFT_BRACKET,value:"[",offset:this.offset});continue}if(n===Fg.RIGHT_SQUARE_BRACKET){this.onToken({token:Vg.RIGHT_BRACKET,value:"]",offset:this.offset});continue}if(n===Fg.COLON){this.onToken({token:Vg.COLON,value:":",offset:this.offset});continue}if(n===Fg.COMMA){this.onToken({token:Vg.COMMA,value:",",offset:this.offset});continue}if(n===Fg.LATIN_SMALL_LETTER_T){this.state=Hg.TRUE1;continue}if(n===Fg.LATIN_SMALL_LETTER_F){this.state=Hg.FALSE1;continue}if(n===Fg.LATIN_SMALL_LETTER_N){this.state=Hg.NULL1;continue}if(n===Fg.QUOTATION_MARK){this.bufferedString.reset(),this.escapedCharsByteLength=0,this.state=Hg.STRING_DEFAULT;continue}if(n>=Fg.DIGIT_ONE&&n<=Fg.DIGIT_NINE){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_NON_ZERO;continue}if(n===Fg.DIGIT_ZERO){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_ZERO;continue}if(n===Fg.HYPHEN_MINUS){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_MINUS;continue}break;case Hg.STRING_DEFAULT:if(n===Fg.QUOTATION_MARK){const t=this.bufferedString.toString();this.state=Hg.START,this.onToken({token:Vg.STRING,value:t,offset:this.offset}),this.offset+=this.escapedCharsByteLength+this.bufferedString.byteLength+1;continue}if(n===Fg.REVERSE_SOLIDUS){this.state=Hg.STRING_AFTER_BACKSLASH;continue}if(n>=128){if(this.bytes_in_sequence=n>=194&&n<=223?2:n<=239?3:4,this.bytes_in_sequence<=e.length-i){this.bufferedString.appendBuf(e,i,i+this.bytes_in_sequence),i+=this.bytes_in_sequence-1;continue}this.bytes_remaining=i+this.bytes_in_sequence-e.length,this.char_split_buffer.set(e.subarray(i)),i=e.length-1,this.state=Hg.STRING_INCOMPLETE_CHAR;continue}if(n>=Fg.SPACE){this.bufferedString.appendChar(n);continue}break;case Hg.STRING_INCOMPLETE_CHAR:this.char_split_buffer.set(e.subarray(i,i+this.bytes_remaining),this.bytes_in_sequence-this.bytes_remaining),this.bufferedString.appendBuf(this.char_split_buffer,0,this.bytes_in_sequence),i=this.bytes_remaining-1,this.state=Hg.STRING_DEFAULT;continue;case Hg.STRING_AFTER_BACKSLASH:const s=Bg[n];if(s){this.bufferedString.appendChar(s),this.escapedCharsByteLength+=1,this.state=Hg.STRING_DEFAULT;continue}if(n===Fg.LATIN_SMALL_LETTER_U){this.unicode="",this.state=Hg.STRING_UNICODE_DIGIT_1;continue}break;case Hg.STRING_UNICODE_DIGIT_1:case Hg.STRING_UNICODE_DIGIT_2:case Hg.STRING_UNICODE_DIGIT_3:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE||n>=Fg.LATIN_CAPITAL_LETTER_A&&n<=Fg.LATIN_CAPITAL_LETTER_F||n>=Fg.LATIN_SMALL_LETTER_A&&n<=Fg.LATIN_SMALL_LETTER_F){this.unicode+=String.fromCharCode(n),this.state+=1;continue}break;case Hg.STRING_UNICODE_DIGIT_4:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE||n>=Fg.LATIN_CAPITAL_LETTER_A&&n<=Fg.LATIN_CAPITAL_LETTER_F||n>=Fg.LATIN_SMALL_LETTER_A&&n<=Fg.LATIN_SMALL_LETTER_F){const t=parseInt(this.unicode+String.fromCharCode(n),16);let e;if(void 0===this.highSurrogate){if(t>=55296&&t<=56319){this.highSurrogate=t,this.state=Hg.STRING_DEFAULT;continue}e=String.fromCharCode(t)}else e=t>=56320&&t<=57343?String.fromCharCode(this.highSurrogate,t):String.fromCharCode(this.highSurrogate),this.highSurrogate=void 0;const i=this.encoder.encode(e);this.bufferedString.appendBuf(i),this.escapedCharsByteLength+=6-i.byteLength,this.state=Hg.STRING_DEFAULT;continue}break;case Hg.NUMBER_AFTER_INITIAL_MINUS:if(n===Fg.DIGIT_ZERO){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_ZERO;continue}if(n>=Fg.DIGIT_ONE&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_INITIAL_NON_ZERO;continue}break;case Hg.NUMBER_AFTER_INITIAL_ZERO:if(n===Fg.FULL_STOP){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_FULL_STOP;continue}if(n===Fg.LATIN_SMALL_LETTER_E||n===Fg.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E;continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.NUMBER_AFTER_INITIAL_NON_ZERO:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n);continue}if(n===Fg.FULL_STOP){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_FULL_STOP;continue}if(n===Fg.LATIN_SMALL_LETTER_E||n===Fg.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E;continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.NUMBER_AFTER_FULL_STOP:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_DECIMAL;continue}break;case Hg.NUMBER_AFTER_DECIMAL:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n);continue}if(n===Fg.LATIN_SMALL_LETTER_E||n===Fg.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E;continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.NUMBER_AFTER_E:if(n===Fg.PLUS_SIGN||n===Fg.HYPHEN_MINUS){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E_AND_SIGN;continue}case Hg.NUMBER_AFTER_E_AND_SIGN:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n),this.state=Hg.NUMBER_AFTER_E_AND_DIGIT;continue}break;case Hg.NUMBER_AFTER_E_AND_DIGIT:if(n>=Fg.DIGIT_ZERO&&n<=Fg.DIGIT_NINE){this.bufferedNumber.appendChar(n);continue}i-=1,this.state=Hg.START,this.emitNumber();continue;case Hg.TRUE1:if(n===Fg.LATIN_SMALL_LETTER_R){this.state=Hg.TRUE2;continue}break;case Hg.TRUE2:if(n===Fg.LATIN_SMALL_LETTER_U){this.state=Hg.TRUE3;continue}break;case Hg.TRUE3:if(n===Fg.LATIN_SMALL_LETTER_E){this.state=Hg.START,this.onToken({token:Vg.TRUE,value:!0,offset:this.offset}),this.offset+=3;continue}break;case Hg.FALSE1:if(n===Fg.LATIN_SMALL_LETTER_A){this.state=Hg.FALSE2;continue}break;case Hg.FALSE2:if(n===Fg.LATIN_SMALL_LETTER_L){this.state=Hg.FALSE3;continue}break;case Hg.FALSE3:if(n===Fg.LATIN_SMALL_LETTER_S){this.state=Hg.FALSE4;continue}break;case Hg.FALSE4:if(n===Fg.LATIN_SMALL_LETTER_E){this.state=Hg.START,this.onToken({token:Vg.FALSE,value:!1,offset:this.offset}),this.offset+=4;continue}break;case Hg.NULL1:if(n===Fg.LATIN_SMALL_LETTER_U){this.state=Hg.NULL2;continue}break;case Hg.NULL2:if(n===Fg.LATIN_SMALL_LETTER_L){this.state=Hg.NULL3;continue}break;case Hg.NULL3:if(n===Fg.LATIN_SMALL_LETTER_L){this.state=Hg.START,this.onToken({token:Vg.NULL,value:null,offset:this.offset}),this.offset+=3;continue}break;case Hg.SEPARATOR:if(this.separatorIndex+=1,!this.separatorBytes||n!==this.separatorBytes[this.separatorIndex])break;this.separatorIndex===this.separatorBytes.length-1&&(this.state=Hg.START,this.onToken({token:Vg.SEPARATOR,value:this.separator,offset:this.offset+this.separatorIndex}),this.separatorIndex=0);continue;case Hg.BOM:if(n===this.bom[this.bomIndex]){if(this.bomIndex===this.bom.length-1){this.state=Hg.START,this.bom=void 0,this.bomIndex=0;continue}this.bomIndex+=1;continue}break;case Hg.ENDED:if(n===Fg.SPACE||n===Fg.NEWLINE||n===Fg.CARRIAGE_RETURN||n===Fg.TAB)continue}throw new Xg(`Unexpected "${String.fromCharCode(n)}" at position "${i}" in state ${Wg(this.state)}`)}if(this.emitPartialTokens)switch(this.state){case Hg.TRUE1:case Hg.TRUE2:case Hg.TRUE3:this.onToken({token:Vg.TRUE,value:!0,offset:this.offset,partial:!0});break;case Hg.FALSE1:case Hg.FALSE2:case Hg.FALSE3:case Hg.FALSE4:this.onToken({token:Vg.FALSE,value:!1,offset:this.offset,partial:!0});break;case Hg.NULL1:case Hg.NULL2:case Hg.NULL3:this.onToken({token:Vg.NULL,value:null,offset:this.offset,partial:!0});break;case Hg.STRING_DEFAULT:{const t=this.bufferedString.toString();this.onToken({token:Vg.STRING,value:t,offset:this.offset,partial:!0});break}case Hg.NUMBER_AFTER_INITIAL_ZERO:case Hg.NUMBER_AFTER_INITIAL_NON_ZERO:case Hg.NUMBER_AFTER_DECIMAL:case Hg.NUMBER_AFTER_E_AND_DIGIT:try{this.onToken({token:Vg.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset,partial:!0})}catch(t){}}}catch(t){this.error(t)}}emitNumber(){this.onToken({token:Vg.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset}),this.offset+=this.bufferedNumber.byteLength-1}parseNumber(t){return Number(t)}error(t){this.state!==Hg.ENDED&&(this.state=Hg.ERROR),this.onError(t)}end(){switch(this.state){case Hg.NUMBER_AFTER_INITIAL_ZERO:case Hg.NUMBER_AFTER_INITIAL_NON_ZERO:case Hg.NUMBER_AFTER_DECIMAL:case Hg.NUMBER_AFTER_E_AND_DIGIT:this.state=Hg.ENDED,this.emitNumber(),this.onEnd();break;case Hg.BOM_OR_START:case Hg.START:case Hg.ERROR:case Hg.SEPARATOR:this.state=Hg.ENDED,this.onEnd();break;default:this.error(new Xg(`Tokenizer ended in the middle of a token (state: ${Wg(this.state)}). Either not all the data was received or the data was invalid.`))}}onToken(t){throw new Xg('Can\'t emit tokens before the "onToken" callback has been set up.')}onError(t){throw t}onEnd(){}}var qg,Zg;function Kg(t){return["VALUE","KEY","COLON","COMMA","ENDED","ERROR","SEPARATOR"][t]}!function(t){t[t.OBJECT=0]="OBJECT",t[t.ARRAY=1]="ARRAY"}(qg||(qg={})),function(t){t[t.VALUE=0]="VALUE",t[t.KEY=1]="KEY",t[t.COLON=2]="COLON",t[t.COMMA=3]="COMMA",t[t.ENDED=4]="ENDED",t[t.ERROR=5]="ERROR",t[t.SEPARATOR=6]="SEPARATOR"}(Zg||(Zg={}));const Jg={paths:void 0,keepStack:!0,separator:void 0,emitPartialValues:!1};class Qg extends Error{constructor(t){super(t),Object.setPrototypeOf(this,Qg.prototype)}}class $g{constructor(t){this.state=Zg.VALUE,this.mode=void 0,this.key=void 0,this.value=void 0,this.stack=[],(t=Object.assign(Object.assign({},Jg),t)).paths&&(this.paths=t.paths.map(t=>{if(void 0===t||"$*"===t)return;if(!t.startsWith("$"))throw new Qg(`Invalid selector "${t}". Should start with "$".`);const e=t.split(".").slice(1);if(e.includes(""))throw new Qg(`Invalid selector "${t}". ".." syntax not supported.`);return e})),this.keepStack=t.keepStack||!1,this.separator=t.separator,t.emitPartialValues||(this.emitPartial=()=>{})}shouldEmit(){return!this.paths||this.paths.some(t=>{var e;if(void 0===t)return!0;if(t.length!==this.stack.length)return!1;for(let e=0;e<t.length-1;e++){const i=t[e],n=this.stack[e+1].key;if("*"!==i&&i!==(null==n?void 0:n.toString()))return!1}const i=t[t.length-1];return"*"===i||i===(null===(e=this.key)||void 0===e?void 0:e.toString())})}push(){this.stack.push({key:this.key,value:this.value,mode:this.mode,emit:this.shouldEmit()})}pop(){const t=this.value;let e;({key:this.key,value:this.value,mode:this.mode,emit:e}=this.stack.pop()),this.state=void 0!==this.mode?Zg.COMMA:Zg.VALUE,this.emit(t,e)}emit(t,e){!this.keepStack&&this.value&&this.stack.every(t=>!t.emit)&&delete this.value[this.key],e&&this.onValue({value:t,key:this.key,parent:this.value,stack:this.stack}),0===this.stack.length&&(this.separator?this.state=Zg.SEPARATOR:void 0===this.separator&&this.end())}emitPartial(t){this.shouldEmit()&&(this.state!==Zg.KEY?this.onValue({value:t,key:this.key,parent:this.value,stack:this.stack,partial:!0}):this.onValue({value:void 0,key:t,parent:this.value,stack:this.stack,partial:!0}))}get isEnded(){return this.state===Zg.ENDED}write({token:t,value:e,partial:i}){try{if(i)return void this.emitPartial(e);if(this.state===Zg.VALUE){if(t===Vg.STRING||t===Vg.NUMBER||t===Vg.TRUE||t===Vg.FALSE||t===Vg.NULL)return this.mode===qg.OBJECT?(this.value[this.key]=e,this.state=Zg.COMMA):this.mode===qg.ARRAY&&(this.value.push(e),this.state=Zg.COMMA),void this.emit(e,this.shouldEmit());if(t===Vg.LEFT_BRACE){if(this.push(),this.mode===qg.OBJECT)this.value=this.value[this.key]={};else if(this.mode===qg.ARRAY){const t={};this.value.push(t),this.value=t}else this.value={};return this.mode=qg.OBJECT,this.state=Zg.KEY,this.key=void 0,void this.emitPartial()}if(t===Vg.LEFT_BRACKET){if(this.push(),this.mode===qg.OBJECT)this.value=this.value[this.key]=[];else if(this.mode===qg.ARRAY){const t=[];this.value.push(t),this.value=t}else this.value=[];return this.mode=qg.ARRAY,this.state=Zg.VALUE,this.key=0,void this.emitPartial()}if(this.mode===qg.ARRAY&&t===Vg.RIGHT_BRACKET&&0===this.value.length)return void this.pop()}if(this.state===Zg.KEY){if(t===Vg.STRING)return this.key=e,this.state=Zg.COLON,void this.emitPartial();if(t===Vg.RIGHT_BRACE&&0===Object.keys(this.value).length)return void this.pop()}if(this.state===Zg.COLON&&t===Vg.COLON)return void(this.state=Zg.VALUE);if(this.state===Zg.COMMA){if(t===Vg.COMMA){if(this.mode===qg.ARRAY)return this.state=Zg.VALUE,void(this.key+=1);if(this.mode===qg.OBJECT)return void(this.state=Zg.KEY)}if(t===Vg.RIGHT_BRACE&&this.mode===qg.OBJECT||t===Vg.RIGHT_BRACKET&&this.mode===qg.ARRAY)return void this.pop()}if(this.state===Zg.SEPARATOR&&t===Vg.SEPARATOR&&e===this.separator)return void(this.state=Zg.VALUE);if(t===Vg.SEPARATOR&&this.state!==Zg.SEPARATOR&&Array.from(e).map(t=>t.charCodeAt(0)).every(t=>t===Fg.SPACE||t===Fg.NEWLINE||t===Fg.CARRIAGE_RETURN||t===Fg.TAB))return;throw new Qg(`Unexpected ${Vg[t]} (${JSON.stringify(e)}) in state ${Kg(this.state)}`)}catch(t){this.error(t)}}error(t){this.state!==Zg.ENDED&&(this.state=Zg.ERROR),this.onError(t)}end(){this.state!==Zg.VALUE&&this.state!==Zg.SEPARATOR||this.stack.length>0?this.error(new Error(`Parser ended in mid-parsing (state: ${Kg(this.state)}). Either not all the data was received or the data was invalid.`)):(this.state=Zg.ENDED,this.onEnd())}onValue(t){throw new Qg('Can\'t emit data before the "onValue" callback has been set up.')}onError(t){throw t}onEnd(){}}class tv{constructor(t={}){this.tokenizer=new Yg(t),this.tokenParser=new $g(t),this.tokenizer.onToken=this.tokenParser.write.bind(this.tokenParser),this.tokenizer.onEnd=()=>{this.tokenParser.isEnded||this.tokenParser.end()},this.tokenParser.onError=this.tokenizer.error.bind(this.tokenizer),this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end()}}get isEnded(){return this.tokenizer.isEnded&&this.tokenParser.isEnded}write(t){this.tokenizer.write(t)}end(){this.tokenizer.end()}set onToken(t){this.tokenizer.onToken=e=>{t(e),this.tokenParser.write(e)}}set onValue(t){this.tokenParser.onValue=t}set onError(t){this.tokenizer.onError=t}set onEnd(t){this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end(),t.call(this.tokenParser)}}}class ev extends tv{constructor(t){super(),this.onValue=({value:t,stack:e})=>{0===e.length&&(this.json=t)},t&&this.write(t)}}class iv extends Error{constructor(t,e){super(e),this.name="FetchError",this.status=t}}class nv{constructor(){this.requestHeader={},this.withCredentials=!1,this.abortSignal=void 0}setRequestHeader(t){this.requestHeader=t}setWithCredentials(t){this.withCredentials=t}setAbortSignal(t){this.abortSignal=t}async load(t,e){const i={headers:{...this.requestHeader,Range:"bytes="+e.map(t=>`${t.offset}-${t.offset+t.length-1}`).join(",")},credentials:this.withCredentials?"include":"same-origin",signal:this.abortSignal},n=await fetch(t,i);if(!n.ok)throw new iv(n.status,`Failed to fetch "${t}", status ${n.status}`);if(206!==n.status){const t=await n.arrayBuffer();return this.extractRanges(t,e)}return n.arrayBuffer()}extractRanges(t,e){const i=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(i);let s=0;for(const i of e){const e=new Uint8Array(t,i.offset,i.length);n.set(e,s),s+=i.length}return n.buffer}}class sv extends c{constructor(t){super(),this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear(),this.manager&&this.manager.dispose()}isSupport(t,e){return("string"==typeof t||t instanceof globalThis.File||t instanceof ArrayBuffer)&&/(gltf|glb)$/i.test(e)}async load(t,e,i){this.manager=new Dg(t,i);const n=new fr;this.gltfLoader=new Pg(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.visibleEdges=this.viewer.options.edgeModel;const s=new yg(n);s.id=i.modelId||this.extractFileName(t),s.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",()=>{this.viewer.scene.add(n),this.viewer.models.push(s),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t}),this.viewer.update(!0)}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t})}),this.gltfLoader.addEventListener("update",()=>{this.viewer.update()});const r={loadJson:async()=>{const e=new Ml(this.manager);e.setPath(this.manager.path),e.setRequestHeader(i.requestHeader||{}),e.setWithCredentials(i.withCredentials||e.withCredentials),e.setResponseType("arraybuffer");const n=await e.loadAsync(this.manager.fileURL,e=>{const{lengthComputable:i,loaded:n,total:s}=e,r=i?n/s:1;this.viewer.emitEvent({type:"geometryprogress",data:r,file:t})}),s=new Ug(n),r=new ev(s.content);if(!r.json)throw new Error("GLTFFileDynamicLoader: JSON content not found or invalid.");return this.glb=s.body,r.json},loadBinaryData:(t,e="")=>{const n=new nv;if(n.setRequestHeader(i.requestHeader||{}),n.setWithCredentials(i.withCredentials||!1),n.setAbortSignal(this.gltfLoader.abortController.signal),this.glb)return n.extractRanges(this.glb,t);const s=this.manager.path||this.manager.resourcePath,r=Xl.resolveURL(e,s);return n.load(this.manager.resolveURL(r),t)},resolveURL:t=>{const e=this.manager.path||this.manager.resourcePath,i=Xl.resolveURL(t,e);return Promise.resolve(this.manager.resolveURL(i))}},a=new Lg(s.id,r);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}class rv extends c{constructor(t){super(),this.requestId=0,this.viewer=t}dispose(){this.gltfLoader&&this.gltfLoader.clear()}isSupport(t){return"object"==typeof t&&"string"==typeof t.database&&"function"==typeof t.downloadResource&&"function"==typeof t.downloadResourceRange&&/.gltf$/i.test(t.database)}async load(t,e,i={}){const n=new fr;this.gltfLoader=new Pg(this.viewer.camera,n,this.viewer.renderer),this.gltfLoader.memoryLimit=this.viewer.options.memoryLimit,this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);const s=new yg(n);s.id=t.file.id,s.gltfLoader=this.gltfLoader,this.gltfLoader.addEventListener("databasechunk",e=>{this.viewer.scene.add(n),this.viewer.models.push(s),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.emitEvent({type:"databasechunk",data:n,file:t.file,model:t}),this.viewer.update(!0)}),this.gltfLoader.addEventListener("geometryerror",e=>{this.viewer.emitEvent({type:"geometryerror",data:e,file:t.file,model:t})}),this.gltfLoader.addEventListener("update",()=>{this.viewer.update()});const r={loadJson:async()=>{const e=new ev;if(await t.downloadResource(t.database,(i,n)=>{e.write(n),this.viewer.emitEvent({type:"geometryprogress",data:i,file:t.file,model:t})},this.gltfLoader.getAbortController().signal),!e.json)throw new Error("GLTFCloudDynamicLoader: JSON content not found or invalid.");return e.json},loadBinaryData:e=>{const i=e.map(t=>({begin:t.offset,end:t.offset+t.length-1,requestId:this.requestId++}));return t.downloadResourceRange(t.geometry[0],void 0,i,void 0,this.gltfLoader.getAbortController().signal)},resolveURL:e=>{const i=`${t.httpClient.serverUrl}${t.path}/`,n=Xl.resolveURL(e,i);return Promise.resolve(n)}},a=new Lg(s.id,r);return await this.gltfLoader.loadStructure(a),await this.gltfLoader.loadNodes(),this}cancel(){this.gltfLoader&&this.gltfLoader.abortLoading()}}const av=p("threejs");av.registerLoader("gltf-file",t=>new sv(t)),av.registerLoader("gltf-cloud",t=>new rv(t));const ov={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"};class hv{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const lv=new Bl(-1,1,1,-1,0,1);const cv=new class extends zs{constructor(){super(),this.setAttribute("position",new Ps([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ps([0,2,0,0,2,0],2))}};class dv{constructor(t){this._mesh=new Qs(cv,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,lv)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class uv extends hv{constructor(t,e="tDiffuse"){super(),this.textureID=e,this.uniforms=null,this.material=null,t instanceof rr?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=sr.clone(t.uniforms),this.material=new rr({name:void 0!==t.name?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this._fsQuad=new dv(this.material)}render(t,e,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this._fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class pv extends hv{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,i){const n=t.getContext(),s=t.state;let r,a;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0),this.inverse?(r=0,a=1):(r=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),s.buffers.stencil.setFunc(n.ALWAYS,r,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),t.setRenderTarget(i),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(n.EQUAL,1,4294967295),s.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),s.buffers.stencil.setLocked(!0)}}class mv extends hv{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class fv{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),void 0===e){const i=t.getSize(new Ai);this._width=i.width,this._height=i.height,(e=new Zi(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Dt})).texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new uv(ov),this.copyPass.material.blending=0,this.clock=new rc}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){void 0===t&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let i=!1;for(let e=0,n=this.passes.length;e<n;e++){const n=this.passes[e];if(!1!==n.enabled){if(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(e),n.render(this.renderer,this.writeBuffer,this.readBuffer,t,i),n.needsSwap){if(i){const e=this.renderer.getContext(),i=this.renderer.state.buffers.stencil;i.setFunc(e.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),i.setFunc(e.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==pv&&(n instanceof pv?i=!0:n instanceof mv&&(i=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new Ai);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(let t=0;t<this.passes.length;t++)this.passes[t].setSize(i,n)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class gv extends hv{constructor(t,e,i=null,n=null,s=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new _s}render(t,e,i){const n=t.autoClear;let s,r;t.autoClear=!1,null!==this.overrideMaterial&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),null!==this.clearColor&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),null!==this.clearAlpha&&(s=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),1==this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:i),!0===this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),null!==this.clearColor&&t.setClearColor(this._oldClearColor),null!==this.clearAlpha&&t.setClearAlpha(s),null!==this.overrideMaterial&&(this.scene.overrideMaterial=r),t.autoClear=n}}const vv={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\t#define EDGE_STEP_COUNT 6\n\t\t#define EDGE_GUESS 8.0\n\t\t#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n\t\tconst float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n\t\tfloat _ContrastThreshold = 0.0312;\n\t\tfloat _RelativeThreshold = 0.063;\n\t\tfloat _SubpixelBlending = 1.0;\n\n\t\tvec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn texture( tex2D, uv );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n\t\t\tuv += texSize * vec2(uOffset, vOffset);\n\t\t\treturn SampleLuminance(tex2D, uv);\n\n\t\t}\n\n\t\tstruct LuminanceData {\n\n\t\t\tfloat m, n, e, s, w;\n\t\t\tfloat ne, nw, se, sw;\n\t\t\tfloat highest, lowest, contrast;\n\n\t\t};\n\n\t\tLuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData l;\n\t\t\tl.m = SampleLuminance( tex2D, uv );\n\t\t\tl.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n\t\t\tl.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n\t\t\tl.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n\t\t\tl.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n\t\t\tl.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n\t\t\tl.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n\t\t\tl.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n\t\t\tl.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n\t\t\tl.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.contrast = l.highest - l.lowest;\n\t\t\treturn l;\n\n\t\t}\n\n\t\tbool ShouldSkipPixel( LuminanceData l ) {\n\n\t\t\tfloat threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n\t\t\treturn l.contrast < threshold;\n\n\t\t}\n\n\t\tfloat DeterminePixelBlendFactor( LuminanceData l ) {\n\n\t\t\tfloat f = 2.0 * ( l.n + l.e + l.s + l.w );\n\t\t\tf += l.ne + l.nw + l.se + l.sw;\n\t\t\tf *= 1.0 / 12.0;\n\t\t\tf = abs( f - l.m );\n\t\t\tf = clamp( f / l.contrast, 0.0, 1.0 );\n\n\t\t\tfloat blendFactor = smoothstep( 0.0, 1.0, f );\n\t\t\treturn blendFactor * blendFactor * _SubpixelBlending;\n\n\t\t}\n\n\t\tstruct EdgeData {\n\n\t\t\tbool isHorizontal;\n\t\t\tfloat pixelStep;\n\t\t\tfloat oppositeLuminance, gradient;\n\n\t\t};\n\n\t\tEdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n\t\t\tEdgeData e;\n\t\t\tfloat horizontal =\n\t\t\t\tabs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.se - 2.0 * l.e ) +\n\t\t\t\tabs( l.nw + l.sw - 2.0 * l.w );\n\t\t\tfloat vertical =\n\t\t\t\tabs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.nw - 2.0 * l.n ) +\n\t\t\t\tabs( l.se + l.sw - 2.0 * l.s );\n\t\t\te.isHorizontal = horizontal >= vertical;\n\n\t\t\tfloat pLuminance = e.isHorizontal ? l.n : l.e;\n\t\t\tfloat nLuminance = e.isHorizontal ? l.s : l.w;\n\t\t\tfloat pGradient = abs( pLuminance - l.m );\n\t\t\tfloat nGradient = abs( nLuminance - l.m );\n\n\t\t\te.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\n\t\t\tif (pGradient < nGradient) {\n\n\t\t\t\te.pixelStep = -e.pixelStep;\n\t\t\t\te.oppositeLuminance = nLuminance;\n\t\t\t\te.gradient = nGradient;\n\n\t\t\t} else {\n\n\t\t\t\te.oppositeLuminance = pLuminance;\n\t\t\t\te.gradient = pGradient;\n\n\t\t\t}\n\n\t\t\treturn e;\n\n\t\t}\n\n\t\tfloat DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n\t\t\tvec2 uvEdge = uv;\n\t\t\tvec2 edgeStep;\n\t\t\tif (e.isHorizontal) {\n\n\t\t\t\tuvEdge.y += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( texSize.x, 0.0 );\n\n\t\t\t} else {\n\n\t\t\t\tuvEdge.x += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( 0.0, texSize.y );\n\n\t\t\t}\n\n\t\t\tfloat edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n\t\t\tfloat gradientThreshold = e.gradient * 0.25;\n\n\t\t\tvec2 puv = uvEdge + edgeStep * edgeSteps[0];\n\t\t\tfloat pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\tbool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n\t\t\t\tpuv += edgeStep * edgeSteps[i];\n\t\t\t\tpLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\t\tpAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !pAtEnd ) {\n\n\t\t\t\tpuv += edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tvec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n\t\t\tfloat nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\tbool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n\t\t\t\tnuv -= edgeStep * edgeSteps[i];\n\t\t\t\tnLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\t\tnAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !nAtEnd ) {\n\n\t\t\t\tnuv -= edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tfloat pDistance, nDistance;\n\t\t\tif ( e.isHorizontal ) {\n\n\t\t\t\tpDistance = puv.x - uv.x;\n\t\t\t\tnDistance = uv.x - nuv.x;\n\n\t\t\t} else {\n\n\t\t\t\tpDistance = puv.y - uv.y;\n\t\t\t\tnDistance = uv.y - nuv.y;\n\n\t\t\t}\n\n\t\t\tfloat shortestDistance;\n\t\t\tbool deltaSign;\n\t\t\tif ( pDistance <= nDistance ) {\n\n\t\t\t\tshortestDistance = pDistance;\n\t\t\t\tdeltaSign = pLuminanceDelta >= 0.0;\n\n\t\t\t} else {\n\n\t\t\t\tshortestDistance = nDistance;\n\t\t\t\tdeltaSign = nLuminanceDelta >= 0.0;\n\n\t\t\t}\n\n\t\t\tif ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n\t\t\t\treturn 0.0;\n\n\t\t\t}\n\n\t\t\treturn 0.5 - shortestDistance / ( pDistance + nDistance );\n\n\t\t}\n\n\t\tvec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n\t\t\tif ( ShouldSkipPixel( luminance ) ) {\n\n\t\t\t\treturn Sample( tex2D, uv );\n\n\t\t\t}\n\n\t\t\tfloat pixelBlend = DeterminePixelBlendFactor( luminance );\n\t\t\tEdgeData edge = DetermineEdge( texSize, luminance );\n\t\t\tfloat edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n\t\t\tfloat finalBlend = max( pixelBlend, edgeBlend );\n\n\t\t\tif (edge.isHorizontal) {\n\n\t\t\t\tuv.y += edge.pixelStep * finalBlend;\n\n\t\t\t} else {\n\n\t\t\t\tuv.x += edge.pixelStep * finalBlend;\n\n\t\t\t}\n\n\t\t\treturn Sample( tex2D, uv );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\n\t\t}"};class _v extends uv{constructor(){super(vv)}setSize(t,e){this.material.uniforms.resolution.value.set(1/t,1/e)}}const yv={defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvoid SMAAEdgeDetectionVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAAEdgeDetectionVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\n\t\tvec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {\n\t\t\tvec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );\n\n\t\t\t// Calculate color deltas:\n\t\t\tvec4 delta;\n\t\t\tvec3 C = texture2D( colorTex, texcoord ).rgb;\n\n\t\t\tvec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;\n\t\t\tvec3 t = abs( C - Cleft );\n\t\t\tdelta.x = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;\n\t\t\tt = abs( C - Ctop );\n\t\t\tdelta.y = max( max( t.r, t.g ), t.b );\n\n\t\t\t// We do the usual threshold:\n\t\t\tvec2 edges = step( threshold, delta.xy );\n\n\t\t\t// Then discard if there is no edge:\n\t\t\tif ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )\n\t\t\t\tdiscard;\n\n\t\t\t// Calculate right and bottom deltas:\n\t\t\tvec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;\n\t\t\tt = abs( C - Cright );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;\n\t\t\tt = abs( C - Cbottom );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the maximum delta in the direct neighborhood:\n\t\t\tfloat maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );\n\n\t\t\t// Calculate left-left and top-top deltas:\n\t\t\tvec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;\n\t\t\tt = abs( C - Cleftleft );\n\t\t\tdelta.z = max( max( t.r, t.g ), t.b );\n\n\t\t\tvec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;\n\t\t\tt = abs( C - Ctoptop );\n\t\t\tdelta.w = max( max( t.r, t.g ), t.b );\n\n\t\t\t// Calculate the final maximum delta:\n\t\t\tmaxDelta = max( max( maxDelta, delta.z ), delta.w );\n\n\t\t\t// Local contrast adaptation in action:\n\t\t\tedges.xy *= step( 0.5 * maxDelta, delta.xy );\n\n\t\t\treturn vec4( edges, 0.0, 0.0 );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );\n\n\t\t}"},xv={defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 3 ];\n\t\tvarying vec2 vPixcoord;\n\n\t\tvoid SMAABlendingWeightCalculationVS( vec2 texcoord ) {\n\t\t\tvPixcoord = texcoord / resolution;\n\n\t\t\t// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components\n\n\t\t\t// And these for the searches, they indicate the ends of the loops:\n\t\t\tvOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAABlendingWeightCalculationVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tArea;\n\t\tuniform sampler2D tSearch;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[3];\n\t\tvarying vec2 vPixcoord;\n\n\t\t#if __VERSION__ == 100\n\t\tvec2 round( vec2 x ) {\n\t\t\treturn sign( x ) * floor( abs( x ) + 0.5 );\n\t\t}\n\t\t#endif\n\n\t\tfloat SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {\n\t\t\t// Not required if searchTex accesses are set to point:\n\t\t\t// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);\n\t\t\t// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +\n\t\t\t// e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;\n\t\t\te.r = bias + e.r * scale;\n\t\t\treturn 255.0 * texture2D( searchTex, e, 0.0 ).r;\n\t\t}\n\n\t\tfloat SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\t/**\n\t\t\t\t* @PSEUDO_GATHER4\n\t\t\t\t* This texcoord has been offset by (-0.25, -0.125) in the vertex shader to\n\t\t\t\t* sample between edge, thus fetching four edges in a row.\n\t\t\t\t* Sampling with different offsets in each direction allows to disambiguate\n\t\t\t\t* which edges are active from the four fetched ones.\n\t\t\t\t*/\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\t// We correct the previous (-0.25, -0.125) offset we applied:\n\t\t\ttexcoord.x += 0.25 * resolution.x;\n\n\t\t\t// The searches are bias by 1, so adjust the coords accordingly:\n\t\t\ttexcoord.x += resolution.x;\n\n\t\t\t// Disambiguate the length added by the last step:\n\t\t\ttexcoord.x += 2.0 * resolution.x; // Undo last step\n\t\t\ttexcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 0.0, 1.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 2.0, 0.0 ) * resolution;\n\t\t\t\tif ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.x -= 0.25 * resolution.x;\n\t\t\ttexcoord.x -= resolution.x;\n\t\t\ttexcoord.x -= 2.0 * resolution.x;\n\t\t\ttexcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );\n\n\t\t\treturn texcoord.x;\n\t\t}\n\n\t\tfloat SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tfloat SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {\n\t\t\tvec2 e = vec2( 1.0, 0.0 );\n\n\t\t\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for\n\t\t\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;\n\t\t\t\ttexcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign\n\t\t\t\tif ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;\n\t\t\t}\n\n\t\t\ttexcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign\n\t\t\ttexcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign\n\n\t\t\treturn texcoord.y;\n\t\t}\n\n\t\tvec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {\n\t\t\t// Rounding prevents precision errors of bilinear filtering:\n\t\t\tvec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;\n\n\t\t\t// We do a scale and bias for mapping to texel space:\n\t\t\ttexcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );\n\n\t\t\t// Move to proper place, according to the subpixel offset:\n\t\t\ttexcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;\n\n\t\t\treturn texture2D( areaTex, texcoord, 0.0 ).rg;\n\t\t}\n\n\t\tvec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {\n\t\t\tvec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n\t\t\tvec2 e = texture2D( edgesTex, texcoord ).rg;\n\n\t\t\tif ( e.g > 0.0 ) { // Edge at north\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the left:\n\t\t\t\tvec2 coords;\n\t\t\t\tcoords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );\n\t\t\t\tcoords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)\n\t\t\t\td.x = coords.x;\n\n\t\t\t\t// Now fetch the left crossing edges, two at a time using bilinear\n\t\t\t\t// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to\n\t\t\t\t// discern what value each edge has:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).r;\n\n\t\t\t\t// Find the distance to the right:\n\t\t\t\tcoords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );\n\t\t\t\td.y = coords.x;\n\n\t\t\t\t// We want the distances to be in pixel units (doing this here allow to\n\t\t\t\t// better interleave arithmetic and memory accesses):\n\t\t\t\td = d / resolution.x - pixcoord.x;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the right crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;\n\n\t\t\t\t// Ok, we know how this pattern looks like, now it is time for getting\n\t\t\t\t// the actual area:\n\t\t\t\tweights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );\n\t\t\t}\n\n\t\t\tif ( e.r > 0.0 ) { // Edge at west\n\t\t\t\tvec2 d;\n\n\t\t\t\t// Find the distance to the top:\n\t\t\t\tvec2 coords;\n\n\t\t\t\tcoords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );\n\t\t\t\tcoords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;\n\t\t\t\td.x = coords.y;\n\n\t\t\t\t// Fetch the top crossing edges:\n\t\t\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).g;\n\n\t\t\t\t// Find the distance to the bottom:\n\t\t\t\tcoords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );\n\t\t\t\td.y = coords.y;\n\n\t\t\t\t// We want the distances to be in pixel units:\n\t\t\t\td = d / resolution.y - pixcoord.y;\n\n\t\t\t\t// SMAAArea below needs a sqrt, as the areas texture is compressed\n\t\t\t\t// quadratically:\n\t\t\t\tvec2 sqrt_d = sqrt( abs( d ) );\n\n\t\t\t\t// Fetch the bottom crossing edges:\n\t\t\t\tcoords.y -= 1.0 * resolution.y; // WebGL port note: Added\n\t\t\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;\n\n\t\t\t\t// Get the area for this direction:\n\t\t\t\tweights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );\n\t\t\t}\n\n\t\t\treturn weights;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );\n\n\t\t}"},bv={uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new Ai(1/1024,1/512)}},vertexShader:"\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvoid SMAANeighborhoodBlendingVS( vec2 texcoord ) {\n\t\t\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component\n\t\t\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tSMAANeighborhoodBlendingVS( vUv );\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tColor;\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 vOffset[ 2 ];\n\n\t\tvec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {\n\t\t\t// Fetch the blending weights for current pixel:\n\t\t\tvec4 a;\n\t\t\ta.xz = texture2D( blendTex, texcoord ).xz;\n\t\t\ta.y = texture2D( blendTex, offset[ 1 ].zw ).g;\n\t\t\ta.w = texture2D( blendTex, offset[ 1 ].xy ).a;\n\n\t\t\t// Is there any blending weight with a value greater than 0.0?\n\t\t\tif ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {\n\t\t\t\treturn texture2D( colorTex, texcoord, 0.0 );\n\t\t\t} else {\n\t\t\t\t// Up to 4 lines can be crossing a pixel (one through each edge). We\n\t\t\t\t// favor blending by choosing the line with the maximum weight for each\n\t\t\t\t// direction:\n\t\t\t\tvec2 offset;\n\t\t\t\toffset.x = a.a > a.b ? a.a : -a.b; // left vs. right\n\t\t\t\toffset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs\n\n\t\t\t\t// Then we go in the direction that has the maximum weight:\n\t\t\t\tif ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical\n\t\t\t\t\toffset.y = 0.0;\n\t\t\t\t} else {\n\t\t\t\t\toffset.x = 0.0;\n\t\t\t\t}\n\n\t\t\t\t// Fetch the opposite color and lerp by hand:\n\t\t\t\tvec4 C = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\ttexcoord += sign( offset ) * resolution;\n\t\t\t\tvec4 Cop = texture2D( colorTex, texcoord, 0.0 );\n\t\t\t\tfloat s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );\n\n\t\t\t\t// WebGL port note: Added gamma correction\n\t\t\t\tC.xyz = pow(C.xyz, vec3(2.2));\n\t\t\t\tCop.xyz = pow(Cop.xyz, vec3(2.2));\n\t\t\t\tvec4 mixed = mix(C, Cop, s);\n\t\t\t\tmixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));\n\n\t\t\t\treturn mixed;\n\t\t\t}\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );\n\n\t\t}"};class Sv extends hv{constructor(){super(),this._edgesRT=new Zi(1,1,{depthBuffer:!1,type:Dt}),this._edgesRT.texture.name="SMAAPass.edges",this._weightsRT=new Zi(1,1,{depthBuffer:!1,type:Dt}),this._weightsRT.texture.name="SMAAPass.weights";const t=this,e=new Image;e.src=this._getAreaTexture(),e.onload=function(){t._areaTexture.needsUpdate=!0},this._areaTexture=new Xi,this._areaTexture.name="SMAAPass.area",this._areaTexture.image=e,this._areaTexture.minFilter=wt,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;const i=new Image;i.src=this._getSearchTexture(),i.onload=function(){t._searchTexture.needsUpdate=!0},this._searchTexture=new Xi,this._searchTexture.name="SMAAPass.search",this._searchTexture.image=i,this._searchTexture.magFilter=xt,this._searchTexture.minFilter=xt,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=sr.clone(yv.uniforms),this._materialEdges=new rr({defines:Object.assign({},yv.defines),uniforms:this._uniformsEdges,vertexShader:yv.vertexShader,fragmentShader:yv.fragmentShader}),this._uniformsWeights=sr.clone(xv.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new rr({defines:Object.assign({},xv.defines),uniforms:this._uniformsWeights,vertexShader:xv.vertexShader,fragmentShader:xv.fragmentShader}),this._uniformsBlend=sr.clone(bv.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new rr({uniforms:this._uniformsBlend,vertexShader:bv.vertexShader,fragmentShader:bv.fragmentShader}),this._fsQuad=new dv(null)}render(t,e,i){this._uniformsEdges.tDiffuse.value=i.texture,this._fsQuad.material=this._materialEdges,t.setRenderTarget(this._edgesRT),this.clear&&t.clear(),this._fsQuad.render(t),this._fsQuad.material=this._materialWeights,t.setRenderTarget(this._weightsRT),this.clear&&t.clear(),this._fsQuad.render(t),this._uniformsBlend.tColor.value=i.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(),this._fsQuad.render(t))}setSize(t,e){this._edgesRT.setSize(t,e),this._weightsRT.setSize(t,e),this._materialEdges.uniforms.resolution.value.set(1/t,1/e),this._materialWeights.uniforms.resolution.value.set(1/t,1/e),this._materialBlend.uniforms.resolution.value.set(1/t,1/e)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture(){return"data:image/png;base64,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"}_getSearchTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}}class wv extends hv{constructor(t,e,i=0,n=0){super(),this.scenes=Array.isArray(t)?t:[t],this.camera=e,this.sampleLevel=2,this.unbiased=!0,this.stencilBuffer=!1,this.clearColor=i,this.clearAlpha=n,this._sampleRenderTarget=null,this._oldClearColor=new _s,this._copyUniforms=sr.clone(ov.uniforms),this._copyMaterial=new rr({uniforms:this._copyUniforms,vertexShader:ov.vertexShader,fragmentShader:ov.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:2}),this._fsQuad=new dv(this._copyMaterial)}dispose(){this._sampleRenderTarget&&(this._sampleRenderTarget.dispose(),this._sampleRenderTarget=null),this._copyMaterial.dispose(),this._fsQuad.dispose()}setSize(t,e){this._sampleRenderTarget&&this._sampleRenderTarget.setSize(t,e)}render(t,e,i,n,s){this._sampleRenderTarget||(this._sampleRenderTarget=new Zi(i.width,i.height,{type:Dt,stencilBuffer:this.stencilBuffer}),this._sampleRenderTarget.texture.name="SSAAMultiRenderPass.sample");const r=Mv[Math.max(0,Math.min(this.sampleLevel,5))],a=t.autoClear;t.autoClear=!1,t.getClearColor(this._oldClearColor);const o=t.getClearAlpha(),h=1/r.length;this._copyUniforms.tDiffuse.value=this._sampleRenderTarget.texture;const l={fullWidth:i.width,fullHeight:i.height,offsetX:0,offsetY:0,width:i.width,height:i.height},c=Object.assign({},this.camera.view);c.enabled&&Object.assign(l,c);for(let i=0;i<r.length;i++){const n=r[i];this.camera.setViewOffset&&this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX+.0625*n[0],l.offsetY+.0625*n[1],l.width,l.height);let s=h;if(this.unbiased){s+=.03125*((i+.5)/r.length-.5)}this._copyUniforms.opacity.value=s,t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this._sampleRenderTarget),t.clear(),this.scenes.forEach(e=>t.render(e,this.camera)),t.setRenderTarget(this.renderToScreen?null:e),0===i&&(t.setClearColor(0,0),t.clear()),this._fsQuad.render(t)}this.camera.setViewOffset&&c.enabled?this.camera.setViewOffset(c.fullWidth,c.fullHeight,c.offsetX,c.offsetY,c.width,c.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),t.autoClear=a,t.setClearColor(this._oldClearColor,o)}}const Mv=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],Tv={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:"\n\t\tprecision highp float;\n\n\t\tuniform mat4 modelViewMatrix;\n\t\tuniform mat4 projectionMatrix;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\t#include <tonemapping_pars_fragment>\n\t\t#include <colorspace_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t// tone mapping\n\n\t\t\t#ifdef LINEAR_TONE_MAPPING\n\n\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( AGX_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\n\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\n\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\n\t\t\t#endif\n\n\t\t\t// color space\n\n\t\t\t#ifdef SRGB_TRANSFER\n\n\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\n\t\t\t#endif\n\n\t\t}"};class Ev extends hv{constructor(){super(),this.isOutputPass=!0,this.uniforms=sr.clone(Tv.uniforms),this.material=new Vh({name:Tv.name,uniforms:this.uniforms,vertexShader:Tv.vertexShader,fragmentShader:Tv.fragmentShader}),this._fsQuad=new dv(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,i){this.uniforms.tDiffuse.value=i.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,this._outputColorSpace===t.outputColorSpace&&this._toneMapping===t.toneMapping||(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},Ui.getTransfer(this._outputColorSpace)===Ve&&(this.material.defines.SRGB_TRANSFER=""),1===this._toneMapping?this.material.defines.LINEAR_TONE_MAPPING="":2===this._toneMapping?this.material.defines.REINHARD_TONE_MAPPING="":3===this._toneMapping?this.material.defines.CINEON_TONE_MAPPING="":4===this._toneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":6===this._toneMapping?this.material.defines.AGX_TONE_MAPPING="":7===this._toneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":5===this._toneMapping&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),!0===this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Av{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const i=this._listeners[t].filter(t=>t!==e);return 0!==i.length?this._listeners[t]=i:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach(e=>e.call(this,t)),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}const Cv=Math.PI/180;const Lv="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Rv={_global:Lv,version:"10.2.0",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>Rv.angleDeg?t*Cv:t,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:"web",legacyTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Rv.DD.isDragging,isTransforming(){var t,e;return null!==(e=null===(t=Rv.Transformer)||void 0===t?void 0:t.isTransforming())&&void 0!==e&&e},isDragReady:()=>!!Rv.DD.node,releaseCanvasOnDestroy:!0,document:Lv.document,_injectGlobal(t){void 0!==Lv.Konva&&console.error("Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment."),Lv.Konva=t}},Iv=t=>{Rv[t.prototype.getClassName()]=t};Rv._injectGlobal(Rv);const Pv=()=>{if("undefined"==typeof document)throw new Error('Konva.js unsupported environment.\n\nLooks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.\n\nTo use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.\n\nbash: npm install canvas\njs: import "konva/canvas-backend";\n\nor\n\nbash: npm install skia-canvas\njs: import "konva/skia-backend";\n')};class Dv{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Dv(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,r=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=s,this.m[2]=r,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,r=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=s,this.m[3]=r,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],r=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,s=this.m[0]*t,r=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],s=t*n-e*i,r={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const a=Math.sqrt(t*t+e*e);r.rotation=e>0?Math.acos(t/a):-Math.acos(t/a),r.scaleX=a,r.scaleY=s/a,r.skewX=(t*i+e*n)/s,r.skewY=0}else if(0!=i||0!=n){const a=Math.sqrt(i*i+n*n);r.rotation=Math.PI/2-(n>0?Math.acos(-i/a):-Math.acos(i/a)),r.scaleX=s/a,r.scaleY=a,r.skewX=0,r.skewY=(t*i+e*n)/s}return r.rotation=Vv._getRotation(r.rotation),r}}const Ov=Math.PI/180,Nv=180/Math.PI,Uv="#",Fv="Konva error: ",Bv={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},kv=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let zv=[],Gv=null;const Hv="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,16)},Vv={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){zv.push(t),1===zv.length&&Hv(function(){const t=zv;zv=[],t.forEach(function(t){t()})})},createCanvasElement(){Pv();const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>(Pv(),document.createElement("img")),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,e){const i=Vv.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace(Uv,"");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return Uv+t},isCanvasFarblingActive(){if(null!==Gv)return Gv;if("undefined"==typeof document)return Gv=!1,!1;const t=this.createCanvasElement();t.width=10,t.height=10;const e=t.getContext("2d",{willReadFrequently:!0});e.clearRect(0,0,10,10),e.fillStyle="#282828",e.fillRect(0,0,10,10);const i=e.getImageData(0,0,10,10).data;let n=!1;for(let t=0;t<100;t++)if(40!==i[4*t]||40!==i[4*t+1]||40!==i[4*t+2]||255!==i[4*t+3]){n=!0;break}return Gv=n,this.releaseCanvas(t),Gv},getHitColor(){const t=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(t):t},getHitColorKey(t,e,i){return this.isCanvasFarblingActive()&&(t=5*Math.round(t/5),e=5*Math.round(e/5),i=5*Math.round(i/5)),Uv+this._rgbToHex(t,e,i)},getSnappedHexColor(t){const e=this._hexToRgb(t);return Uv+this._rgbToHex(5*Math.round(e.r/5),5*Math.round(e.g/5),5*Math.round(e.b/5))},getRGB(t){let e;return t in Bv?(e=Bv[t],{r:e[0],g:e[1],b:e[2]}):t[0]===Uv?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=kv.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",Vv._namedColorToRBA(t)||Vv._hex3ColorToRGBA(t)||Vv._hex4ColorToRGBA(t)||Vv._hex6ColorToRGBA(t)||Vv._hex8ColorToRGBA(t)||Vv._rgbColorToRGBA(t)||Vv._rgbaColorToRGBA(t)||Vv._hslColorToRGBA(t)),_namedColorToRBA(t){const e=Bv[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,s=Number(i[1])/100,r=Number(i[2])/100;let a,o,h;if(0===s)return h=255*r,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=r<.5?r*(1+s):r+s-r*s;const l=2*r-a,c=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,c[t]=255*h;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*Ov,radToDeg:t=>t*Nv,_degToRad:t=>(Vv.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Vv.degToRad(t)),_radToDeg:t=>(Vv.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Vv.radToDeg(t)),_getRotation:t=>Rv.angleDeg?Vv.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(Fv+t)},error(t){console.error(Fv+t)},warn(t){Rv.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t<i,_getProjectionToSegment(t,e,i,n,s,r){let a,o,h;const l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)a=t,o=e,h=(s-i)*(s-i)+(r-n)*(r-n);else{const c=((s-t)*(i-t)+(r-e)*(n-e))/l;c<0?(a=t,o=e,h=(t-s)*(t-s)+(e-r)*(e-r)):c>1?(a=i,o=n,h=(i-s)*(i-s)+(n-r)*(n-r)):(a=t+c*(i-t),o=e+c*(n-e),h=(a-s)*(a-s)+(o-r)*(o-r))}return[a,o,h]},_getProjectionToLine(t,e,i){const n=Vv.cloneObject(t);let s=Number.MAX_VALUE;return e.forEach(function(r,a){if(!i&&a===e.length-1)return;const o=e[(a+1)%e.length],h=Vv._getProjectionToSegment(r.x,r.y,o.x,o.y,t.x,t.y),l=h[0],c=h[1],d=h[2];d<s&&(n.x=l,n.y=c,s=d)}),n},_prepareArrayForTween(t,e,i){const n=[],s=[];if(t.length>e.length){const i=e;e=t,t=i}for(let e=0;e<t.length;e+=2)n.push({x:t[e],y:t[e+1]});for(let t=0;t<e.length;t+=2)s.push({x:e[t],y:e[t+1]});const r=[];return s.forEach(function(t){const e=Vv._getProjectionToLine(t,n,i);r.push(e.x),r.push(e.y)}),r},_prepareToStringify(t){let e;t.visitedByCircularReferenceRemoval=!0;for(const i in t)if(t.hasOwnProperty(i)&&t[i]&&"object"==typeof t[i])if(e=Object.getOwnPropertyDescriptor(t,i),t[i].visitedByCircularReferenceRemoval||Vv._isElement(t[i])){if(!e.configurable)return null;delete t[i]}else if(null===Vv._prepareToStringify(t[i])){if(!e.configurable)return null;delete t[i]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const i in e)t[i]=e[i];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){Rv.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,i,n){let s=e<0?e:0,r=i<0?i:0;e=Math.abs(e),i=Math.abs(i);let a=0,o=0,h=0,l=0;"number"==typeof n?a=o=h=l=Math.min(n,e/2,i/2):(a=Math.min(n[0]||0,e/2,i/2),o=Math.min(n[1]||0,e/2,i/2),l=Math.min(n[2]||0,e/2,i/2),h=Math.min(n[3]||0,e/2,i/2)),t.moveTo(s+a,r),t.lineTo(s+e-o,r),t.arc(s+e-o,r+o,o,3*Math.PI/2,0,!1),t.lineTo(s+e,r+i-l),t.arc(s+e-l,r+i-l,l,0,Math.PI/2,!1),t.lineTo(s+h,r+i),t.arc(s+h,r+i-h,h,Math.PI/2,Math.PI,!1),t.lineTo(s,r+a),t.arc(s+a,r+a,a,Math.PI,3*Math.PI/2,!1)},drawRoundedPolygonPath(t,e,i,n,s){n=Math.abs(n);for(let r=0;r<i;r++){const a=e[(r-1+i)%i],o=e[r],h=e[(r+1)%i],l={x:o.x-a.x,y:o.y-a.y},c={x:h.x-o.x,y:h.y-o.y},d=Math.hypot(l.x,l.y),u=Math.hypot(c.x,c.y);let p;p="number"==typeof s?s:r<s.length?s[r]:0;p=n*Math.cos(Math.PI/i)*Math.min(1,p/n*2);const m={x:l.x/d,y:l.y/d},f={x:c.x/u,y:c.y/u},g={x:o.x-m.x*p,y:o.y-m.y*p},v={x:o.x+f.x*p,y:o.y+f.y*p};0===r?t.moveTo(g.x,g.y):t.lineTo(g.x,g.y),t.arcTo(o.x,o.y,v.x,v.y,p)}}};const Wv=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];let jv,Xv=null;function Yv(){if(null!==Xv)return Xv;try{const t=Vv.createCanvasElement().getContext("2d");return t?!!t&&"filter"in t:(Xv=!1,!1)}catch(t){return Xv=!1,!1}}class qv{constructor(t){this.canvas=t,Rv.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,s,r,a=this.traceArr,o=a.length,h="";for(i=0;i<o;i++)n=a[i],s=n.method,s?(r=n.args,h+=s,t?h+="()":Vv._isArray(r[0])?h+="(["+r.join(",")+"])":(e&&(r=r.map(t=>"number"==typeof t?Math.floor(t):t)),h+="("+r.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}_applyMiterLimit(t){const e=t.attrs.miterLimit;null!=e&&this.setAttr("miterLimit",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,s,r){this._context.arc(t,e,i,n,s,r)}arcTo(t,e,i,n,s){this._context.arcTo(t,e,i,n,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,s,r){this._context.bezierCurveTo(t,e,i,n,s,r)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,s,r){return this._context.createRadialGradient(t,e,i,n,s,r)}drawImage(t,e,i,n,s,r,a,o,h){const l=arguments,c=this._context;3===l.length?c.drawImage(t,e,i):5===l.length?c.drawImage(t,e,i,n,s):9===l.length&&c.drawImage(t,e,i,n,s,r,a,o,h)}ellipse(t,e,i,n,s,r,a,o){this._context.ellipse(t,e,i,n,s,r,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,s){this._context.roundRect(t,e,i,n,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,s,r){this._context.setTransform(t,e,i,n,s,r)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,s,r){this._context.transform(t,e,i,n,s,r)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=Wv.length,s=this.setAttr;const r=function(t){let n,s=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=Vv;for(let s=0;s<i;s++){let i=t[s];n._isNumber(i)?i=Math.round(1e3*i)/1e3:n._isString(i)||(i+=""),e.push(i)}return e}(Array.prototype.slice.call(arguments,0)),n=s.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)r(Wv[t]);i.setAttr=function(){s.apply(i,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"].forEach(function(t){Object.defineProperty(qv.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})});class Zv extends qv{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)return void this._fillColor(t);const n=t.getFillPatternImage();if(n&&"pattern"===i)return void this._fillPattern(t);const s=t.getFillLinearGradientColorStops();if(s&&"linear-gradient"===i)return void this._fillLinearGradient(t);const r=t.getFillRadialGradientColorStops();r&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):s?this._fillLinearGradient(t):r&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),s=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(let t=0;t<n.length;t+=2)s.addColorStop(n[t],n[t+1]);this.setAttr("strokeStyle",s)}}_stroke(t){const e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}_applyShadow(t){var e,i,n;const s=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",r=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,a=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},o=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=o.x*h,c=o.y*h;this.setAttr("shadowColor",s),this.setAttr("shadowBlur",r*Math.min(Math.abs(l),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*l),this.setAttr("shadowOffsetY",a.y*c)}}class Kv extends qv{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const i=t.hitStrokeWidth(),n="auto"===i?t.strokeWidth():i;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}class Jv{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||Rv.pixelRatio||function(){if(jv)return jv;const t=Vv.createCanvasElement(),e=t.getContext("2d");return jv=(Rv._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),Vv.releaseCanvas(t),jv}();this.pixelRatio=e,this._canvas=Vv.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return Vv.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}class Qv extends Jv{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new Zv(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}}class $v extends Jv{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new Kv(this),this.setSize(t.width,t.height)}}const t_={get isDragging(){let t=!1;return t_._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return t_._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_drag(t){const e=[];t_._dragElements.forEach((i,n)=>{const{node:s}=i,r=s.getStage();r.setPointersPositions(t),void 0===i.pointerId&&(i.pointerId=Vv._getFirstPointerId(t));const a=r._changedPointerPositions.find(t=>t.id===i.pointerId);if(a){if("dragging"!==i.dragStatus){const e=s.dragDistance();if(Math.max(Math.abs(a.x-i.startPointerPos.x),Math.abs(a.y-i.startPointerPos.y))<e)return;if(s.startDrag({evt:t}),!s.isDragging())return}s._setDragPosition(t,i),e.push(s)}}),e.forEach(e=>{e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t){const e=[];t_._dragElements.forEach(i=>{const{node:n}=i,s=n.getStage();t&&s.setPointersPositions(t);if(!s._changedPointerPositions.find(t=>t.id===i.pointerId))return;"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(t_.justDragged=!0,Rv._mouseListenClick=!1,Rv._touchListenClick=!1,Rv._pointerListenClick=!1,i.dragStatus="stopped");const r=i.node.getLayer()||i.node instanceof Rv.Stage&&i.node;r&&-1===e.indexOf(r)&&e.push(r)}),e.forEach(t=>{t.draw()})},_endDragAfter(t){t_._dragElements.forEach((e,i)=>{"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&t_._dragElements.delete(i)})}};function e_(t){return Vv._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||Vv._isBoolean(t)?t:Object.prototype.toString.call(t)}function i_(t){return t>255?255:t<0?0:Math.round(t)}function n_(){if(Rv.isUnminified)return function(t,e){return Vv._isNumber(t)||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function s_(t){if(Rv.isUnminified)return function(e,i){let n=Vv._isNumber(e),s=Vv._isArray(e)&&e.length==t;return n||s||Vv.warn(e_(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}}function r_(){if(Rv.isUnminified)return function(t,e){return Vv._isNumber(t)||"auto"===t||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function a_(){if(Rv.isUnminified)return function(t,e){return Vv._isString(t)||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function o_(){if(Rv.isUnminified)return function(t,e){const i=Vv._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function h_(){if(Rv.isUnminified)return function(t,e){return!0===t||!1===t||Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}Rv.isBrowser&&(window.addEventListener("mouseup",t_._endDragBefore,!0),window.addEventListener("touchend",t_._endDragBefore,!0),window.addEventListener("touchcancel",t_._endDragBefore,!0),window.addEventListener("mousemove",t_._drag),window.addEventListener("touchmove",t_._drag),window.addEventListener("mouseup",t_._endDragAfter,!1),window.addEventListener("touchend",t_._endDragAfter,!1),window.addEventListener("touchcancel",t_._endDragAfter,!1));const l_="get",c_="set",d_={addGetterSetter(t,e,i,n,s){d_.addGetter(t,e,i),d_.addSetter(t,e,n,s),d_.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=l_+Vv._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const s=c_+Vv._capitalize(e);t.prototype[s]||d_.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const s=c_+Vv._capitalize(e);t.prototype[s]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,i,n,s){const r=i.length,a=Vv._capitalize,o=l_+a(e),h=c_+a(e);t.prototype[o]=function(){const t={};for(let n=0;n<r;n++){const s=i[n];t[s]=this.getAttr(e+a(s))}return t};const l=function(t){if(Rv.isUnminified)return function(e,i){return null==e||Vv.isObject(e)||Vv.warn(e_(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}}(i);t.prototype[h]=function(t){const r=this.attrs[e];n&&(t=n.call(this,t,e)),l&&l.call(this,t,e);for(const i in t)t.hasOwnProperty(i)&&this._setAttr(e+a(i),t[i]);return t||i.forEach(t=>{this._setAttr(e+a(t),void 0)}),this._fireChangeEvent(e,r,t),s&&s.call(this),this},d_.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=Vv._capitalize(e),n=c_+i,s=l_+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,e,i,n){Vv.error("Adding deprecated "+e);const s=l_+Vv._capitalize(e),r=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[s]=function(){Vv.error(r);const t=this.attrs[e];return void 0===t?i:t},d_.addSetter(t,e,n,function(){Vv.error(r)}),d_.addOverloadedGetterSetter(t,e)},backCompat(t,e){Vv.each(e,function(e,i){const n=t.prototype[i],s=l_+Vv._capitalize(e),r=c_+Vv._capitalize(e);function a(){n.apply(this,arguments),Vv.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=a,t.prototype[s]=a,t.prototype[r]=a})},afterSetFilter(){this._filterUpToDate=!1}};function u_(t){const e=/(\w+)\(([^)]+)\)/g;let i;for(;null!==(i=e.exec(t));){const[,t,e]=i;switch(t){case"blur":{const t=parseFloat(e.replace("px",""));return function(e){this.blurRadius(.5*t);const i=Rv.Filters;i&&i.Blur&&i.Blur.call(this,e)}}case"brightness":{const t=e.includes("%")?parseFloat(e)/100:parseFloat(e);return function(e){this.brightness(t);const i=Rv.Filters;i&&i.Brightness&&i.Brightness.call(this,e)}}case"contrast":{const t=parseFloat(e);return function(e){const i=100*(Math.sqrt(t)-1);this.contrast(i);const n=Rv.Filters;n&&n.Contrast&&n.Contrast.call(this,e)}}case"grayscale":return function(t){const e=Rv.Filters;e&&e.Grayscale&&e.Grayscale.call(this,t)};case"sepia":return function(t){const e=Rv.Filters;e&&e.Sepia&&e.Sepia.call(this,t)};case"invert":return function(t){const e=Rv.Filters;e&&e.Invert&&e.Invert.call(this,t)};default:Vv.warn(`CSS filter "${t}" is not supported in fallback mode. Consider using function filters for better compatibility.`)}}return()=>{}}const p_="absoluteOpacity",m_="allEventListeners",f_="absoluteTransform",g_="absoluteScale",v_="canvas",__="listening",y_="Shape",x_=" ",b_="stage",S_="transform",w_="visible",M_=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(x_);let T_=1;class E_{constructor(t){this._id=T_++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==S_&&t!==f_||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===S_||t===f_)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map(t=>t+"Change.konva").join(x_);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(v_)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===f_&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(v_)){const{scene:t,filter:e,hit:i}=this._cache.get(v_);Vv.releaseCanvas(t._canvas,e._canvas,i._canvas),this._cache.delete(v_)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),r=e.pixelRatio,a=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,c=e.hitCanvasPixelRatio||1;if(!n||!s)return void Vv.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-a)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),a-=h,o-=h;const d=new Qv({pixelRatio:r,width:n,height:s}),u=new Qv({pixelRatio:r,width:0,height:0,willReadFrequently:!0}),p=new $v({pixelRatio:c,width:n,height:s}),m=d.getContext(),f=p.getContext(),g=new Qv({width:d.width/d.pixelRatio+Math.abs(a),height:d.height/d.pixelRatio+Math.abs(o),pixelRatio:d.pixelRatio}),v=g.getContext();return p.isCache=!0,d.isCache=!0,this._cache.delete(v_),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),m.save(),f.save(),v.save(),m.translate(-a,-o),f.translate(-a,-o),v.translate(-a,-o),g.x=a,g.y=o,this._isUnderCache=!0,this._clearSelfAndDescendantCache(p_),this._clearSelfAndDescendantCache(g_),this.drawScene(d,this,g),this.drawHit(p,this),this._isUnderCache=!1,m.restore(),f.restore(),l&&(m.save(),m.beginPath(),m.rect(0,0,n,s),m.closePath(),m.setAttr("strokeStyle","red"),m.setAttr("lineWidth",5),m.stroke(),m.restore()),Vv.releaseCanvas(g._canvas),this._cache.set(v_,{scene:d,filter:u,hit:p,x:a,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(v_)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,s=1/0,r=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach(function(t){const e=o.point(t);void 0===n&&(n=r=e.x,s=a=e.y),n=Math.min(n,e.x),s=Math.min(s,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)}),{x:n,y:s,width:r-n,height:a-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,s=this.filters(),r=this._getCanvasCache(),a=r.scene,o=r.filter,h=o.getContext();if(!s||0===s.length)return a;if(this._filterUpToDate)return o;let l=!0;for(let t=0;t<s.length;t++)if("string"==typeof s[t]&&Yv(),"string"!=typeof s[t]||!Yv()){l=!1;break}const c=a.pixelRatio;if(o.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio),l){const t=s.join(" ");return h.save(),h.setAttr("filter",t),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),h.restore(),this._filterUpToDate=!0,o}try{for(t=s.length,h.clear(),h.drawImage(a._canvas,0,0,a.getWidth()/c,a.getHeight()/c),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i<t;i++)n=s[i],"string"==typeof n&&(n=u_(n)),n.call(this,e),h.putImageData(e,0,0)}catch(t){Vv.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(t,e){if(this._cache&&this._cache.delete(m_),3===arguments.length)return this._delegate.apply(this,arguments);const i=t.split(x_);for(let t=0;t<i.length;t++){const n=i[t].split("."),s=n[0],r=n[1]||"";this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:r,handler:e})}return this}off(t,e){let i,n,s,r,a,o,h=(t||"").split(x_),l=h.length;if(this._cache&&this._cache.delete(m_),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<l;i++)if(s=h[i],r=s.split("."),a=r[0],o=r[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,i){const n=this;this.on(t,function(t){const s=t.target.findAncestors(e,!0,n);for(let e=0;e<s.length;e++)(t=Vv.cloneObject(t)).currentTarget=s[e],i.call(s[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),t_._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(f_),this._clearSelfAndDescendantCache(p_),this._clearSelfAndDescendantCache(g_),this._clearSelfAndDescendantCache(b_),this._clearSelfAndDescendantCache(w_),this._clearSelfAndDescendantCache(__)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+Vv._capitalize(t);return Vv._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+Vv._capitalize(e),Vv._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(__,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(w_,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const i=this.getLayer();let n=!1;t_._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)});const s=!e&&!Rv.hitOnDragEnabled&&(n||Rv.isTransforming());return this.isListening()&&this.isVisible()&&!s}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,s=this.getDepth(),r=this,a=0;const o=this.getStage();return"Stage"!==r.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],a++,n.nodeType!==y_&&(t=t.concat(n.getChildren().slice())),n._id===r._id&&(i=e);t.length>0&&t[0].getDepth()<=s&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(S_),this._clearSelfAndDescendantCache(f_)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);const n=this.getAbsoluteTransform(t).getMatrix(),s=new Dv,r=this.offset();return s.m=n.slice(),s.translate(r.x,r.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(S_);const s=this._getAbsoluteTransform().copy();return s.invert(),s.translate(t.x,t.y),t={x:this.attrs.x+s.getTranslation().x,y:this.attrs.y+s.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(S_),this._clearSelfAndDescendantCache(f_),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),s=this.y();return void 0!==e&&(n+=e),void 0!==i&&(s+=i),this.setPosition({x:n,y:s}),this}_eachAncestorReverse(t,e){let i,n,s=[],r=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);r&&(!e||r._id!==e._id);)s.unshift(r),r=r.parent;for(i=s.length,n=0;n<i;n++)t(s[n])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Vv.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return Vv.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return Vv.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return Vv.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return Vv.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Vv.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(p_,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,i,n,s,r=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in r)e=r[t],s=Vv.isObject(e)&&!Vv._isPlainObject(e)&&!Vv._isArray(e),s||(i="function"==typeof this[t]&&this[t],delete r[t],n=i?i.call(this):null,r[t]=e,n!==e&&(a.attrs[t]=e));return Vv._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let s=this.parent;for(;s;){if(s===i)return n;s._isMatch(t)&&n.push(s),s=s.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),s=n.length;for(e=0;e<s;e++)if(i=n[e],Vv.isValidSelector(i)||(Vv.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Vv.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Vv.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(b_,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},i){return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(f_,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new Dv,this._eachAncestorReverse(function(t){const i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(f_)||new Dv,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,i=this.attrs.y||0,n=this.attrs.offsetX||0,s=this.attrs.offsetY||0;e.translate(t-n,i-s)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(S_,this._getTransform)}_getTransform(){var t,e;const i=this._cache.get(S_)||new Dv;i.reset();const n=this.x(),s=this.y(),r=Rv.getAngle(this.rotation()),a=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,o=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,c=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===s||i.translate(n,s),0!==r&&i.rotate(r),0===h&&0===l||i.skew(h,l),1===a&&1===o||i.scale(a,o),0===c&&0===d||i.translate(-1*c,-1*d),i.dirty=!1,i}clone(t){let e,i,n,s,r,a=Vv.cloneObject(this.attrs);for(e in t)a[e]=t[e];const o=new this.constructor(a);for(e in this.eventListeners)for(i=this.eventListeners[e],n=i.length,s=0;s<n;s++)r=i[s],r.name.indexOf("konva")<0&&(o.eventListeners[e]||(o.eventListeners[e]=[]),o.eventListeners[e].push(r));return o}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),r=t.pixelRatio||1,a=new Qv({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:r}),o=a.getContext(),h=new Qv({width:a.width/a.pixelRatio+Math.abs(n),height:a.height/a.pixelRatio+Math.abs(s),pixelRatio:a.pixelRatio});return!1===t.imageSmoothingEnabled&&(o._context.imageSmoothingEnabled=!1),o.save(),(n||s)&&o.translate(-1*n,-1*s),this.drawScene(a,void 0,h),o.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}toImage(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,Vv._urlToImage(this.toDataURL(t),function(t){e(t),null==i||i(t)})}catch(t){i(t)}})}toBlob(t){return new Promise((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==i||i(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Rv.dragDistance}_off(t,e,i){let n,s,r,a=this.eventListeners[t];for(n=0;n<a.length;n++)if(s=a[n].name,r=a[n].handler,!("konva"===s&&"konva"!==e||e&&s!==e||i&&i!==r)){if(a.splice(n,1),0===a.length){delete this.eventListeners[t];break}n--}}_fireChangeEvent(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}addName(t){if(!this.hasName(t)){const e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}hasName(t){if(!t)return!1;const e=this.name();if(!e)return!1;return-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}setAttr(t,e){const i=this["set"+Vv._capitalize(t)];return Vv._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(Rv.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const i=this.attrs[t];(i!==e||Vv.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}_setComponentAttr(t,e,i){let n;void 0!==i&&(n=this.attrs[t],n||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}_fireAndBubble(t,e,i){e&&this.nodeType===y_&&(e.target=this);const n=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(!(-1!==n.indexOf(t)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);const s=-1!==n.indexOf(t)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!s&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,i;const{nodeType:n}=this,s=E_.protoListenerMap.get(n)||{};let r=null==s?void 0:s[t];if(void 0===r){r=[];let a=Object.getPrototypeOf(this);for(;a;){const n=null!==(i=null===(e=a.eventListeners)||void 0===e?void 0:e[t])&&void 0!==i?i:[];r.push(...n),a=Object.getPrototypeOf(a)}s[t]=r,E_.protoListenerMap.set(n,s)}return r}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const i=this._getProtoListeners(t);if(i)for(let t=0;t<i.length;t++)i[t].handler.call(this,e);const n=this.eventListeners[t];if(n)for(let t=0;t<n.length;t++)n[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition();if(!i)return;const s=i._getPointerById(e)||i._changedPointerPositions[0]||n;t_._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-n.x,y:s.y-n.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){t_._dragElements.has(this._id)||this._createDragElement(t);t_._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const i=this.getStage()._getPointerById(e.pointerId);if(!i)return;let n={x:i.x-e.offset.x,y:i.y-e.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const e=s.call(this,n,t);e?n=e:Vv.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}stopDrag(t){const e=t_._dragElements.get(this._id);e&&(e.dragStatus="stopped"),t_._endDragBefore(t),t_._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=t_._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(!(void 0!==t.evt.button)||Rv.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;t_._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=t_._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&t_._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return Vv.haveIntersection(i,this.getClientRect())}static create(t,e){return Vv._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let i,n,s,r=E_.prototype.getClassName.call(t),a=t.children;e&&(t.attrs.container=e),Rv[r]||(Vv.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");if(i=new(0,Rv[r])(t.attrs),a)for(n=a.length,s=0;s<n;s++)i.add(E_._createNode(a[s]));return i}}E_.protoListenerMap=new Map,E_.prototype.nodeType="Node",E_.prototype._attrsAffectingSize=[],E_.prototype.eventListeners={},E_.prototype.on.call(E_.prototype,M_,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(S_),this._clearSelfAndDescendantCache(f_))}),E_.prototype.on.call(E_.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(w_)}),E_.prototype.on.call(E_.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(__)}),E_.prototype.on.call(E_.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(p_)});const A_=d_.addGetterSetter;A_(E_,"zIndex"),A_(E_,"absolutePosition"),A_(E_,"position"),A_(E_,"x",0,n_()),A_(E_,"y",0,n_()),A_(E_,"globalCompositeOperation","source-over",a_()),A_(E_,"opacity",1,n_()),A_(E_,"name","",a_()),A_(E_,"id","",a_()),A_(E_,"rotation",0,n_()),d_.addComponentsGetterSetter(E_,"scale",["x","y"]),A_(E_,"scaleX",1,n_()),A_(E_,"scaleY",1,n_()),d_.addComponentsGetterSetter(E_,"skew",["x","y"]),A_(E_,"skewX",0,n_()),A_(E_,"skewY",0,n_()),d_.addComponentsGetterSetter(E_,"offset",["x","y"]),A_(E_,"offsetX",0,n_()),A_(E_,"offsetY",0,n_()),A_(E_,"dragDistance",void 0,n_()),A_(E_,"width",0,n_()),A_(E_,"height",0,n_()),A_(E_,"listening",!0,h_()),A_(E_,"preventDefault",!0,h_()),A_(E_,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),A_(E_,"visible",!0,h_()),A_(E_,"transformsEnabled","all",a_()),A_(E_,"size"),A_(E_,"dragBoundFunc"),A_(E_,"draggable",!1,h_()),d_.backCompat(E_,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class C_ extends E_{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants(n=>{const s=n._isMatch(t);return s&&i.push(n),!(!s||!e)}),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=E_.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=E_.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(i=>{i.isVisible()&&i.intersects(t)&&e.push(i)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas(),r=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,s=n&&n.getContext(),r=this._getCanvasCache();if(r&&r.hit){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s),s.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var s;const r=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,c=i===this;if(l){r.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),r.beginPath(),h)e=h.call(this,r,this);else{const t=this.clipX(),e=this.clipY();r.rect(t||0,e||0,a,o)}r.clip.apply(r,e),n=t.copy().invert().getMatrix(),r.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach(function(s){s[t](e,i,n)}),d&&r.restore(),l&&r.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let s,r,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===s?(s=i.x,r=i.y,a=i.x+i.width,o=i.y+i.height):(s=Math.min(s,i.x),r=Math.min(r,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))});const c=this.find("Shape");let d=!1;for(let t=0;t<c.length;t++){if(c[t]._isVisible(this)){d=!0;break}}return h=d&&void 0!==s?{x:s,y:r,width:a-s,height:o-r}:{x:0,y:0,width:0,height:0},i?h:this._transformedRect(h,n)}}d_.addComponentsGetterSetter(C_,"clip",["x","y","width","height"]),d_.addGetterSetter(C_,"clipX",void 0,n_()),d_.addGetterSetter(C_,"clipY",void 0,n_()),d_.addGetterSetter(C_,"clipWidth",void 0,n_()),d_.addGetterSetter(C_,"clipHeight",void 0,n_()),d_.addGetterSetter(C_,"clipFunc");const L_=new Map,R_=void 0!==Rv._global.PointerEvent;function I_(t){return L_.get(t)}function P_(t){return{evt:t,pointerId:t.pointerId}}function D_(t,e){return L_.get(t)===e}function O_(t,e){N_(t);e.getStage()&&(L_.set(t,e),R_&&e._fire("gotpointercapture",P_(new PointerEvent("gotpointercapture"))))}function N_(t,e){const i=L_.get(t);if(!i)return;const n=i.getStage();n&&n.content,L_.delete(t),R_&&i._fire("lostpointercapture",P_(new PointerEvent("lostpointercapture")))}const U_="mouseleave",F_="mouseover",B_="mouseenter",k_="mousemove",z_="mousedown",G_="mouseup",H_="pointermove",V_="pointerdown",W_="pointerup",j_="pointercancel",X_="pointerout",Y_="pointerleave",q_="pointerover",Z_="pointerenter",K_="contextmenu",J_="touchstart",Q_="touchend",$_="touchmove",ty="touchcancel",ey="wheel",iy=[[B_,"_pointerenter"],[z_,"_pointerdown"],[k_,"_pointermove"],[G_,"_pointerup"],[U_,"_pointerleave"],[J_,"_pointerdown"],[$_,"_pointermove"],[Q_,"_pointerup"],[ty,"_pointercancel"],[F_,"_pointerover"],[ey,"_wheel"],[K_,"_contextmenu"],[V_,"_pointerdown"],[H_,"_pointermove"],[W_,"_pointerup"],[j_,"_pointercancel"],[Y_,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],ny={mouse:{[X_]:"mouseout",[Y_]:U_,[q_]:F_,[Z_]:B_,[H_]:k_,[V_]:z_,[W_]:G_,[j_]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[X_]:"touchout",[Y_]:"touchleave",[q_]:"touchover",[Z_]:"touchenter",[H_]:$_,[V_]:J_,[W_]:Q_,[j_]:ty,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[X_]:X_,[Y_]:Y_,[q_]:q_,[Z_]:Z_,[H_]:H_,[V_]:V_,[W_]:W_,[j_]:j_,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},sy=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",ry=t=>{const e=sy(t);return"pointer"===e?Rv.pointerEventsEnabled&&ny.pointer:"touch"===e?ny.touch:"mouse"===e?ny.mouse:void 0};function ay(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&Vv.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const oy=[];class hy extends C_{constructor(t){super(ay(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),oy.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{ay(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||Vv.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i<e;i++)t[i].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),C_.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&Vv._isInDocument(t)&&this.container().removeChild(t);const e=oy.indexOf(this);return e>-1&&oy.splice(e,1),Vv.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(Vv.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t={...t}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new Qv({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach(function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(i=>{i.setSize({width:t,height:e}),i.draw()})}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const i=this.children.length;return i>5&&Vv.warn("The stage has "+i+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),Rv.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return D_(t,this)}setPointerCapture(t){O_(t,this)}releaseCapture(t){N_(t)}getLayers(){return this.children}_bindContentEvents(){Rv.isBrowser&&iy.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=ry(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=ry(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=ry(t.type),i=sy(t.type);if(!e)return;this.setPointersPositions(t);const n=this._getTargetShape(i),s=!(Rv.isDragging()||Rv.isTransforming())||Rv.hitOnDragEnabled;n&&s?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):s&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=ry(t.type),i=sy(t.type);if(!e)return;this.setPointersPositions(t);let n=!1;this._changedPointerPositions.forEach(s=>{const r=this.getIntersection(s);if(t_.justDragged=!1,Rv["_"+i+"ListenClick"]=!0,!r||!r.isListening())return void(this[i+"ClickStartShape"]=void 0);Rv.capturePointerEventsEnabled&&r.setPointerCapture(s.id),this[i+"ClickStartShape"]=r,r._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),n=!0;const a=t.type.indexOf("touch")>=0;r.preventDefault()&&t.cancelable&&a&&t.preventDefault()}),n||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=ry(t.type),i=sy(t.type);if(!e)return;const n=t.type.indexOf("touch")>=0||"touch"===t.pointerType;Rv.isDragging()&&t_.node.preventDefault()&&t.cancelable&&n&&t.preventDefault(),this.setPointersPositions(t);if(!(!(Rv.isDragging()||Rv.isTransforming())||Rv.hitOnDragEnabled))return;const s={};let r=!1;const a=this._getTargetShape(i);this._changedPointerPositions.forEach(n=>{const o=I_(n.id)||this.getIntersection(n),h=n.id,l={evt:t,pointerId:h},c=a!==o;if(c&&a&&(a._fireAndBubble(e.pointerout,{...l},o),a._fireAndBubble(e.pointerleave,{...l},o)),o){if(s[o._id])return;s[o._id]=!0}o&&o.isListening()?(r=!0,c&&(o._fireAndBubble(e.pointerover,{...l},a),o._fireAndBubble(e.pointerenter,{...l},a),this[i+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...l})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[i+"targetShape"]=null)}),r||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=ry(t.type),i=sy(t.type);if(!e)return;this.setPointersPositions(t);const n=this[i+"ClickStartShape"],s=this[i+"ClickEndShape"],r={};let a=!1;this._changedPointerPositions.forEach(o=>{const h=I_(o.id)||this.getIntersection(o);if(h){if(h.releaseCapture(o.id),r[h._id])return;r[h._id]=!0}const l=o.id,c={evt:t,pointerId:l};let d=!1;Rv["_"+i+"InDblClickWindow"]?(d=!0,clearTimeout(this[i+"DblTimeout"])):t_.justDragged||(Rv["_"+i+"InDblClickWindow"]=!0,clearTimeout(this[i+"DblTimeout"])),this[i+"DblTimeout"]=setTimeout(function(){Rv["_"+i+"InDblClickWindow"]=!1},Rv.dblClickWindow),h&&h.isListening()?(a=!0,this[i+"ClickEndShape"]=h,h._fireAndBubble(e.pointerup,{...c}),Rv["_"+i+"ListenClick"]&&n&&n===h&&(h._fireAndBubble(e.pointerclick,{...c}),d&&s&&s===h&&h._fireAndBubble(e.pointerdblclick,{...c}))):(this[i+"ClickEndShape"]=null,a||(this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a=!0),Rv["_"+i+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:l}),d&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:l}))}),a||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Rv["_"+i+"ListenClick"]=!1,t.cancelable&&"touch"!==i&&"pointer"!==i&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(K_,{evt:t}):this._fire(K_,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(ey,{evt:t}):this._fire(ey,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=I_(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(W_,P_(t)),N_(t.pointerId)}_lostpointercapture(t){N_(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:Vv._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:Vv._getFirstPointerId(t)}])}_setPointerPosition(t){Vv.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new Qv({width:this.width(),height:this.height()}),this.bufferHitCanvas=new $v({pixelRatio:1,width:this.width(),height:this.height()}),!Rv.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return Vv.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}hy.prototype.nodeType="Stage",Iv(hy),d_.addGetterSetter(hy,"container"),Rv.isBrowser&&document.addEventListener("visibilitychange",()=>{oy.forEach(t=>{t.batchDraw()})});const ly="hasShadow",cy="shadowRGBA",dy="patternImage",uy="linearGradient",py="radialGradient";let my;function fy(){return my||(my=Vv.createCanvasElement().getContext("2d"),my)}const gy={};class vy extends E_{constructor(t){let e;super(t);let i=0;for(;e=Vv.getHitColor(),!e||e in gy;)if(i++,i>=1e4){Vv.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),e=Vv.getRandomColor();break}this.colorKey=e,gy[e]=this}getContext(){return Vv.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Vv.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(ly,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(dy,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=fy().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new Dv;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(Rv.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const i=e.getMatrix(),n="undefined"==typeof DOMMatrix?{a:i[0],b:i[1],c:i[2],d:i[3],e:i[4],f:i[5]}:new DOMMatrix(i);t.setTransform(n)}return t}}_getLinearGradient(){return this._getCache(uy,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=fy(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}_getRadialGradient(){return this._getCache(py,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=fy(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),s=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)s.addColorStop(t[e],t[e+1]);return s}}getShadowRGBA(){return this._getCache(cy,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=Vv.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return E_.prototype.destroy.call(this),delete gy[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&n&&s)return!0;const r=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&r&&a)}setStrokeHitEnabled(t){Vv.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,r=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=r.width+a,h=r.height+a,l=!t.skipShadow&&this.hasShadow(),c=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,u=o+Math.abs(c),p=h+Math.abs(d),m=l&&this.shadowBlur()||0,f={width:u+2*m,height:p+2*m,x:-(a/2+m)+Math.min(c,0)+r.x,y:-(a/2+m)+Math.min(d,0)+r.y};return n?f:this._transformedRect(f,s)}drawScene(t,e,i){const n=this.getLayer(),s=(t||n.getCanvas()).getContext(),r=this._getCanvasCache(),a=this.getSceneFunc(),o=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(r){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore(),this}if(!a)return this;if(s.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,n=t.getContext();i?(n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore()):n.clear(),n.save(),n._applyLineJoin(this),n._applyMiterLimit(this);const r=this.getAbsoluteTransform(e).getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),a.call(this,n,this),n.restore();const c=t.pixelRatio;o&&s._applyShadow(this),l||(s._applyOpacity(this),s._applyGlobalCompositeOperation(this)),s.drawImage(t._canvas,t.x||0,t.y||0,t.width/c,t.height/c)}else{if(s._applyLineJoin(this),s._applyMiterLimit(this),!l){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),s._applyOpacity(this),s._applyGlobalCompositeOperation(this)}o&&s._applyShadow(this),a.call(this,s,this)}return s.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const n=this.getLayer(),s=t||n.hitCanvas,r=s&&s.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCanvasCache(),h=o&&o.hit;if(this.colorKey||Vv.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore(),this}if(!a)return this;r.save(),r._applyLineJoin(this),r._applyMiterLimit(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,r,this),r.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),i=this._getCachedSceneCanvas(),n=e.hit,s=n.getContext(),r=n.getWidth(),a=n.getHeight();s.clear(),s.drawImage(i._canvas,0,0,r,a);try{const e=s.getImageData(0,0,r,a),i=e.data,n=i.length,o=Vv._hexToRgb(this.colorKey);for(let e=0;e<n;e+=4){i[e+3]>t?(i[e]=o.r,i[e+1]=o.g,i[e+2]=o.b,i[e+3]=255):i[e+3]=0}s.putImageData(e,0,0)}catch(t){Vv.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return D_(t,this)}setPointerCapture(t){O_(t,this)}releaseCapture(t){N_(t)}}vy.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},vy.prototype._strokeFunc=function(t){t.stroke()},vy.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},vy.prototype._strokeFuncHit=function(t){t.stroke()},vy.prototype._centroid=!1,vy.prototype.nodeType="Shape",Iv(vy),vy.prototype.eventListeners={},vy.prototype.on.call(vy.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(ly)}),vy.prototype.on.call(vy.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(cy)}),vy.prototype.on.call(vy.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(dy)}),vy.prototype.on.call(vy.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(uy)}),vy.prototype.on.call(vy.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(py)}),d_.addGetterSetter(vy,"stroke",void 0,o_()),d_.addGetterSetter(vy,"strokeWidth",2,n_()),d_.addGetterSetter(vy,"fillAfterStrokeEnabled",!1),d_.addGetterSetter(vy,"hitStrokeWidth","auto",r_()),d_.addGetterSetter(vy,"strokeHitEnabled",!0,h_()),d_.addGetterSetter(vy,"perfectDrawEnabled",!0,h_()),d_.addGetterSetter(vy,"shadowForStrokeEnabled",!0,h_()),d_.addGetterSetter(vy,"lineJoin"),d_.addGetterSetter(vy,"lineCap"),d_.addGetterSetter(vy,"miterLimit"),d_.addGetterSetter(vy,"sceneFunc"),d_.addGetterSetter(vy,"hitFunc"),d_.addGetterSetter(vy,"dash"),d_.addGetterSetter(vy,"dashOffset",0,n_()),d_.addGetterSetter(vy,"shadowColor",void 0,a_()),d_.addGetterSetter(vy,"shadowBlur",0,n_()),d_.addGetterSetter(vy,"shadowOpacity",1,n_()),d_.addComponentsGetterSetter(vy,"shadowOffset",["x","y"]),d_.addGetterSetter(vy,"shadowOffsetX",0,n_()),d_.addGetterSetter(vy,"shadowOffsetY",0,n_()),d_.addGetterSetter(vy,"fillPatternImage"),d_.addGetterSetter(vy,"fill",void 0,o_()),d_.addGetterSetter(vy,"fillPatternX",0,n_()),d_.addGetterSetter(vy,"fillPatternY",0,n_()),d_.addGetterSetter(vy,"fillLinearGradientColorStops"),d_.addGetterSetter(vy,"strokeLinearGradientColorStops"),d_.addGetterSetter(vy,"fillRadialGradientStartRadius",0),d_.addGetterSetter(vy,"fillRadialGradientEndRadius",0),d_.addGetterSetter(vy,"fillRadialGradientColorStops"),d_.addGetterSetter(vy,"fillPatternRepeat","repeat"),d_.addGetterSetter(vy,"fillEnabled",!0),d_.addGetterSetter(vy,"strokeEnabled",!0),d_.addGetterSetter(vy,"shadowEnabled",!0),d_.addGetterSetter(vy,"dashEnabled",!0),d_.addGetterSetter(vy,"strokeScaleEnabled",!0),d_.addGetterSetter(vy,"fillPriority","color"),d_.addComponentsGetterSetter(vy,"fillPatternOffset",["x","y"]),d_.addGetterSetter(vy,"fillPatternOffsetX",0,n_()),d_.addGetterSetter(vy,"fillPatternOffsetY",0,n_()),d_.addComponentsGetterSetter(vy,"fillPatternScale",["x","y"]),d_.addGetterSetter(vy,"fillPatternScaleX",1,n_()),d_.addGetterSetter(vy,"fillPatternScaleY",1,n_()),d_.addComponentsGetterSetter(vy,"fillLinearGradientStartPoint",["x","y"]),d_.addComponentsGetterSetter(vy,"strokeLinearGradientStartPoint",["x","y"]),d_.addGetterSetter(vy,"fillLinearGradientStartPointX",0),d_.addGetterSetter(vy,"strokeLinearGradientStartPointX",0),d_.addGetterSetter(vy,"fillLinearGradientStartPointY",0),d_.addGetterSetter(vy,"strokeLinearGradientStartPointY",0),d_.addComponentsGetterSetter(vy,"fillLinearGradientEndPoint",["x","y"]),d_.addComponentsGetterSetter(vy,"strokeLinearGradientEndPoint",["x","y"]),d_.addGetterSetter(vy,"fillLinearGradientEndPointX",0),d_.addGetterSetter(vy,"strokeLinearGradientEndPointX",0),d_.addGetterSetter(vy,"fillLinearGradientEndPointY",0),d_.addGetterSetter(vy,"strokeLinearGradientEndPointY",0),d_.addComponentsGetterSetter(vy,"fillRadialGradientStartPoint",["x","y"]),d_.addGetterSetter(vy,"fillRadialGradientStartPointX",0),d_.addGetterSetter(vy,"fillRadialGradientStartPointY",0),d_.addComponentsGetterSetter(vy,"fillRadialGradientEndPoint",["x","y"]),d_.addGetterSetter(vy,"fillRadialGradientEndPointX",0),d_.addGetterSetter(vy,"fillRadialGradientEndPointY",0),d_.addGetterSetter(vy,"fillPatternRotation",0),d_.addGetterSetter(vy,"fillRule",void 0,a_()),d_.backCompat(vy,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});const _y=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],yy=_y.length;class xy extends C_{constructor(t){super(t),this.canvas=new Qv,this.hitCanvas=new $v({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){E_.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!E_.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(E_.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(E_.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return E_.prototype.remove.call(this),t&&t.parentNode&&Vv._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Vv.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t={...t}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),E_.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Vv.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Vv.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Vv.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n<yy;n++){const s=_y[n],r=this._getIntersection({x:t.x+s.x*e,y:t.y+s.y*e}),a=r.shape;if(a)return a;if(i=!!r.antialiased,!r.antialiased)break}if(!i)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){const t=Vv.getHitColorKey(i[0],i[1],i[2]),e=gy[t];return e?{shape:e}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),C_.prototype.drawScene.call(this,s,e,i),this._fire("draw",{node:this}),this}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),C_.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){Vv.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return Vv.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return Vv.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}xy.prototype.nodeType="Layer",Iv(xy),d_.addGetterSetter(xy,"imageSmoothingEnabled",!0),d_.addGetterSetter(xy,"clearBeforeDraw",!0),d_.addGetterSetter(xy,"hitGraphEnabled",!0,h_());class by extends xy{constructor(t){super(t),this.listening(!1),Vv.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}by.prototype.nodeType="FastLayer",Iv(by);class Sy extends C_{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&Vv.throw("You may only add groups and shapes to groups.")}}Sy.prototype.nodeType="Group",Iv(Sy);const wy=Lv.performance&&Lv.performance.now?function(){return Lv.performance.now()}:function(){return(new Date).getTime()};class My{constructor(t,e){this.id=My.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:wy(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;n<i;n++)if(e[n]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=My.animations,e=t.length;for(let i=0;i<e;i++)if(t[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=wy(),My._addAnimation(this),this}stop(){return My._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,i=this.animations,n=i.length;for(let t=0;t<n;t++)if(i[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let i=0;i<e.length;i++){const n=e[i],s=n.layers,r=n.func;n._updateFrameObject(wy());const a=s.length;let o;if(o=!r||!1!==r.call(n,n.frame),o)for(let e=0;e<a;e++){const i=s[e];void 0!==i._id&&(t[i._id]=i)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=My;t.animations.length?(t._runFrames(),Vv.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Vv.requestAnimFrame(this._animationLoop))}}My.animations=[],My.animIdCounter=0,My.animRunning=!1;const Ty={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Ey=["fill","stroke","shadowColor"];let Ay=0;class Cy{constructor(t,e,i,n,s,r,a){this.prop=t,this.propFunc=e,this.begin=n,this._pos=n,this.duration=r,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=i,this._change=s-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class Ly{constructor(t){const e=this,i=t.node,n=i._id,s=t.easing||Ry.Linear,r=!!t.yoyo;let a,o;a=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=i,this._id=Ay++;const h=i.getLayer()||(i instanceof Rv.Stage?i.getLayers():null);for(o in h||Vv.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new My(function(){e.tween.onEnterFrame()},h),this.tween=new Cy(o,function(t){e._tweenFunc(t)},s,0,1,1e3*a,r),this._addListeners(),Ly.attrs[n]||(Ly.attrs[n]={}),Ly.attrs[n][this._id]||(Ly.attrs[n][this._id]={}),Ly.tweens[n]||(Ly.tweens[n]={}),t)void 0===Ty[o]&&this._addAttr(o,t[o]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const i=this.node,n=i._id;let s,r,a,o,h;const l=Ly.tweens[n][t];l&&delete Ly.attrs[n][l][t];let c=i.getAttr(t);if(Vv._isArray(e))if(s=[],r=Math.max(e.length,c.length),"points"===t&&e.length!==c.length&&(e.length>c.length?(o=c,c=Vv._prepareArrayForTween(c,e,i.closed())):(a=e,e=Vv._prepareArrayForTween(e,c,i.closed()))),0===t.indexOf("fill"))for(let t=0;t<r;t++)if(t%2==0)s.push(e[t]-c[t]);else{const i=Vv.colorToRGBA(c[t]);h=Vv.colorToRGBA(e[t]),c[t]=i,s.push({r:h.r-i.r,g:h.g-i.g,b:h.b-i.b,a:h.a-i.a})}else for(let t=0;t<r;t++)s.push(e[t]-c[t]);else-1!==Ey.indexOf(t)?(c=Vv.colorToRGBA(c),h=Vv.colorToRGBA(e),s={r:h.r-c.r,g:h.g-c.g,b:h.b-c.b,a:h.a-c.a}):s=e-c;Ly.attrs[n][this._id][t]={start:c,diff:s,end:e,trueEnd:a,trueStart:o},Ly.tweens[n][t]=this._id}_tweenFunc(t){const e=this.node,i=Ly.attrs[e._id][this._id];let n,s,r,a,o,h,l,c;for(n in i){if(s=i[n],r=s.start,a=s.diff,c=s.end,Vv._isArray(r))if(o=[],l=Math.max(r.length,c.length),0===n.indexOf("fill"))for(h=0;h<l;h++)h%2==0?o.push((r[h]||0)+a[h]*t):o.push("rgba("+Math.round(r[h].r+a[h].r*t)+","+Math.round(r[h].g+a[h].g*t)+","+Math.round(r[h].b+a[h].b*t)+","+(r[h].a+a[h].a*t)+")");else for(h=0;h<l;h++)o.push((r[h]||0)+a[h]*t);else o=-1!==Ey.indexOf(n)?"rgba("+Math.round(r.r+a.r*t)+","+Math.round(r.g+a.g*t)+","+Math.round(r.b+a.b*t)+","+(r.a+a.a*t)+")":r+a*t;e.setAttr(n,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=Ly.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=Ly.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=Ly.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete Ly.tweens[t][e];delete Ly.attrs[t][e],Ly.tweens[t]&&(0===Object.keys(Ly.tweens[t]).length&&delete Ly.tweens[t],0===Object.keys(Ly.attrs[t]).length&&delete Ly.attrs[t])}}Ly.attrs={},Ly.tweens={},E_.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()};new Ly(t).play()};const Ry={BackEaseIn(t,e,i,n){const s=1.70158;return i*(t/=n)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,n){const s=1.70158;return i*((t=t/n-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,n){let s=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},ElasticEaseIn(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),-s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)+e)},ElasticEaseOut(t,e,i,n,s,r){let a=0;return 0===t?e:1===(t/=n)?e+i:(r||(r=.3*n),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),s*Math.pow(2,-10*t)*Math.sin((t*n-a)*(2*Math.PI)/r)+i+e)},ElasticEaseInOut(t,e,i,n,s,r){let a=0;return 0===t?e:2==(t/=n/2)?e+i:(r||(r=n*(.3*1.5)),!s||s<Math.abs(i)?(s=i,a=r/4):a=r/(2*Math.PI)*Math.asin(i/s),t<1?s*Math.pow(2,10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*-.5+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*n-a)*(2*Math.PI)/r)*.5+i+e)},BounceEaseOut:(t,e,i,n)=>(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,e,i,n)=>i-Ry.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>t<n/2?.5*Ry.BounceEaseIn(2*t,0,i,n)+e:.5*Ry.BounceEaseOut(2*t-n,0,i,n)+.5*i+e,EaseIn:(t,e,i,n)=>i*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},Iy=Vv._assign(Rv,{Util:Vv,Transform:Dv,Node:E_,Container:C_,Stage:hy,stages:oy,Layer:xy,FastLayer:by,Group:Sy,DD:t_,Shape:vy,shapes:gy,Animation:My,Tween:Ly,Easings:Ry,Context:qv,Canvas:Jv});class Py extends vy{_sceneFunc(t){const e=Rv.getAngle(this.angle()),i=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,i),t.arc(0,0,this.innerRadius(),e,0,!i),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),i=this.clockwise(),n=Rv.getAngle(i?360-this.angle():this.angle()),s=Math.cos(Math.min(n,Math.PI)),r=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),a=Math.sin(Math.min(n,Math.PI/2)),o=s*(s>0?t:e),h=r*(r>0?t:e),l=a*(a>0?e:t);return{x:o,y:i?-1*l:h,width:1*e-o,height:l-h}}}function Dy(t,e,i,n,s,r,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(r-n,2)),l=a*o/(o+h),c=a*h/(o+h);return[i-l*(s-t),n-l*(r-e),i+c*(s-t),n+c*(r-e)]}function Oy(t,e){const i=t.length,n=[];for(let s=2;s<i-2;s+=2){const i=Dy(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(i[0])||(n.push(i[0]),n.push(i[1]),n.push(t[s]),n.push(t[s+1]),n.push(i[2]),n.push(i[3]))}return n}function Ny(t){const e=[[t[0],t[2],t[4],t[6]],[t[1],t[3],t[5],t[7]]],i=[];for(const t of e){const e=-3*t[0]+9*t[1]-9*t[2]+3*t[3];if(0!==e){const n=6*t[0]-12*t[1]+6*t[2],s=n*n-4*e*(-3*t[0]+3*t[1]);if(s>=0){const t=Math.sqrt(s);i.push((-n+t)/(2*e)),i.push((-n-t)/(2*e))}}}return i.filter(t=>t>0&&t<1).flatMap(t=>e.map(e=>{const i=1-t;return i*i*i*e[0]+3*i*i*t*e[1]+3*i*t*t*e[2]+t*t*t*e[3]}))}Py.prototype._centroid=!0,Py.prototype.className="Arc",Py.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],Iv(Py),d_.addGetterSetter(Py,"innerRadius",0,n_()),d_.addGetterSetter(Py,"outerRadius",0,n_()),d_.addGetterSetter(Py,"angle",0,n_()),d_.addGetterSetter(Py,"clockwise",!1,h_());class Uy extends vy{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),i=e.length,n=this.tension(),s=this.closed(),r=this.bezier();if(!i)return;let a=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==n&&i>4){const n=this.getTensionPoints(),r=n.length;for(a=s?0:4,s||t.quadraticCurveTo(n[0],n[1],n[2],n[3]);a<r-2;)t.bezierCurveTo(n[a++],n[a++],n[a++],n[a++],n[a++],n[a++]);s||t.quadraticCurveTo(n[r-2],n[r-1],e[i-2],e[i-1])}else if(r)for(a=2;a<i;)t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);else for(a=2;a<i;a+=2)t.lineTo(e[a],e[a+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Oy(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,i=this.tension(),n=Dy(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),s=Dy(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),r=Oy(t,i);return[n[2],n[3]].concat(r).concat([s[0],s[1],t[e-2],t[e-1],s[2],s[3],n[0],n[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.bezier()?[t[0],t[1],...Ny(this.points()),t[t.length-2],t[t.length-1]]:this.points();let e,i,n=t[0],s=t[0],r=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),a=Math.max(a,i);return{x:n,y:r,width:s-n,height:a-r}}}Uy.prototype.className="Line",Uy.prototype._attrsAffectingSize=["points","bezier","tension"],Iv(Uy),d_.addGetterSetter(Uy,"closed",!1),d_.addGetterSetter(Uy,"bezier",!1),d_.addGetterSetter(Uy,"tension",0,n_()),d_.addGetterSetter(Uy,"points",[],function(){if(Rv.isUnminified)return function(t,e){const i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(Vv._isArray(t)?t.forEach(function(t){Vv._isNumber(t)||Vv.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Vv.warn(e_(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}}());const Fy=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],By=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],ky=[[1],[1,1],[1,2,1],[1,3,3,1]],zy=(t,e,i)=>{let n,s;const r=i/2;n=0;for(let i=0;i<20;i++)s=r*Fy[20][i]+r,n+=By[20][i]*Hy(t,e,s);return r*n},Gy=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],r=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+s*s),h=4*(n*r+s*a),l=r*r+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=h/(2*o),d=i+c,u=l/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,m=c*c+u>0?Math.sqrt(c*c+u):0,f=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+m))):0;return Math.sqrt(o)/2*(d*p-c*m+f)};function Hy(t,e,i){const n=Vy(1,i,t),s=Vy(1,i,e),r=n*n+s*s;return Math.sqrt(r)}const Vy=(t,e,i)=>{const n=i.length-1;let s,r;if(0===n)return 0;if(0===t){r=0;for(let t=0;t<=n;t++)r+=ky[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return r}s=new Array(n);for(let t=0;t<n;t++)s[t]=n*(i[t+1]-i[t]);return Vy(t-1,e,s)},Wy=(t,e,i)=>{let n=1,s=t/e,r=(t-i(s))/e,a=0;for(;n>.001;){const o=i(s+r),h=Math.abs(t-o)/e;if(h<n)n=h,s+=r;else{const a=i(s-r),o=Math.abs(t-a)/e;o<n?(n=o,s-=r):r/=2}if(a++,a>500)break}return s};class jy extends vy{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=jy.parsePathData(this.data()),this.pathLength=jy.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;n<e.length;n++){const s=e[n].command,r=e[n].points;switch(s){case"L":t.lineTo(r[0],r[1]);break;case"M":t.moveTo(r[0],r[1]);break;case"C":t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"Q":t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case"A":const e=r[0],n=r[1],s=r[2],a=r[3],o=r[4],h=r[5],l=r[6],c=r[7],d=s>a?s:a,u=s>a?1:s/a,p=s>a?a/s:1;t.translate(e,n),t.rotate(l),t.scale(u,p),t.arc(0,0,d,o,o+h,1-c),t.scale(1/u,1/p),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],s=e.points[4]+n;let r=Math.PI/180;if(Math.abs(i-s)<r&&(r=Math.abs(i-s)),n<0)for(let n=i-r;n>s;n-=r){const i=jy.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}else for(let n=i+r;n<s;n+=r){const i=jy.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}}else if("C"===e.command)for(let i=0;i<=1;i+=.01){const n=jy.getPointOnCubicBezier(i,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(n.x,n.y)}else t=t.concat(e.points)});let e,i,n=t[0],s=t[0],r=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],isNaN(e)||(n=Math.min(n,e),s=Math.max(s,e)),isNaN(i)||(r=Math.min(r,i),a=Math.max(a,i));return{x:n,y:r,width:s-n,height:a-r}}getLength(){return this.pathLength}getPointAtLength(t){return jy.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}static getPathLength(t){let e=0;for(let i=0;i<t.length;++i)e+=t[i].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let i,n=0,s=e.length;if(!s)return null;for(;n<s&&t>e[n].pathLength;)t-=e[n].pathLength,++n;if(n===s)return i=e[n-1].points.slice(-2),{x:i[0],y:i[1]};if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const r=e[n],a=r.points;switch(r.command){case"L":return jy.getPointOnLine(t,r.start.x,r.start.y,a[0],a[1]);case"C":return jy.getPointOnCubicBezier(Wy(t,jy.getPathLength(e),t=>zy([r.start.x,a[0],a[2],a[4]],[r.start.y,a[1],a[3],a[5]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return jy.getPointOnQuadraticBezier(Wy(t,jy.getPathLength(e),t=>Gy([r.start.x,a[0],a[2]],[r.start.y,a[1],a[3]],t)),r.start.x,r.start.y,a[0],a[1],a[2],a[3]);case"A":const i=a[0],n=a[1],s=a[2],o=a[3],h=a[5],l=a[6];let c=a[4];return c+=h*t/r.pathLength,jy.getPointOnEllipticalArc(i,n,s,o,c,l)}return null}static getPointOnLine(t,e,i,n,s,r,a){r=null!=r?r:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,s);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:r,y:a+(s>i?t:-t)};const h=(s-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n<e?-1:1),c=h*l;if(Math.abs(a-i-h*(r-e))<1e-10)return{x:r+l,y:a+c};const d=((r-e)*(n-e)+(a-i)*(s-i))/(o*o),u=e+d*(n-e),p=i+d*(s-i),m=this.getLineLength(r,a,u,p),f=Math.sqrt(t*t-m*m),g=Math.sqrt(f*f/(1+h*h))*(n<e?-1:1);return{x:u+g,y:p+h*g}}static getPointOnCubicBezier(t,e,i,n,s,r,a,o,h){function l(t){return t*t*t}function c(t){return 3*t*t*(1-t)}function d(t){return 3*t*(1-t)*(1-t)}function u(t){return(1-t)*(1-t)*(1-t)}return{x:o*l(t)+r*c(t)+n*d(t)+e*u(t),y:h*l(t)+a*c(t)+s*d(t)+i*u(t)}}static getPointOnQuadraticBezier(t,e,i,n,s,r,a){function o(t){return t*t}function h(t){return 2*t*(1-t)}function l(t){return(1-t)*(1-t)}return{x:r*o(t)+n*h(t)+e*l(t),y:a*o(t)+s*h(t)+i*l(t)}}static getPointOnEllipticalArc(t,e,i,n,s,r){const a=Math.cos(r),o=Math.sin(r),h=i*Math.cos(s),l=n*Math.sin(s);return{x:t+(h*a-l*o),y:e+(h*o+l*a)}}static parsePathData(t){if(!t)return[];let e=t;const i=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<i.length;t++)e=e.replace(new RegExp(i[t],"g"),"|"+i[t]);const n=e.split("|"),s=[],r=[];let a=0,o=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let l;for(let t=1;t<n.length;t++){let e=n[t],i=e.charAt(0);for(e=e.slice(1),r.length=0;l=h.exec(e);)r.push(l[0]);let c=[],d="A"===i||"a"===i?0:-1;for(let t=0,e=r.length;t<e;t++){const e=r[t];if("00"!==e)if(d>=0){if(3===d){if(/^[01]{2}\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),c.push(parseFloat(e.slice(2))),d+=3,d>=7&&(d-=7);continue}if("11"===e||"10"===e||"01"===e){c.push(parseInt(e[0],10)),c.push(parseInt(e[1],10)),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}else if(4===d){if(/^[01]\d+(?:\.\d+)?$/.test(e)){c.push(parseInt(e[0],10)),c.push(parseFloat(e.slice(1))),d+=2,d>=7&&(d-=7);continue}if("0"===e||"1"===e){c.push(parseInt(e,10)),d+=1,d>=7&&(d-=7);continue}}const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t),d+=1,d>=7&&(d-=7)}else{const t=parseFloat(e);isNaN(t)?c.push(0):c.push(t)}else c.push(0,0),d>=0&&(d+=2,d>=7&&(d-=7))}for(;c.length>0&&!isNaN(c[0]);){let t="",e=[];const n=a,r=o;let h,l,d,u,p,m,f,g,v,_;switch(i){case"l":a+=c.shift(),o+=c.shift(),t="L",e.push(a,o);break;case"L":a=c.shift(),o=c.shift(),e.push(a,o);break;case"m":const n=c.shift(),r=c.shift();if(a+=n,o+=r,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){a=s[t].points[0]+n,o=s[t].points[1]+r;break}e.push(a,o),i="l";break;case"M":a=c.shift(),o=c.shift(),t="M",e.push(a,o),i="L";break;case"h":a+=c.shift(),t="L",e.push(a,o);break;case"H":a=c.shift(),t="L",e.push(a,o);break;case"v":o+=c.shift(),t="L",e.push(a,o);break;case"V":o=c.shift(),t="L",e.push(a,o);break;case"C":e.push(c.shift(),c.shift(),c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"c":e.push(a+c.shift(),o+c.shift(),a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"S":l=a,d=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,c.shift(),c.shift()),a=c.shift(),o=c.shift(),t="C",e.push(a,o);break;case"s":l=a,d=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),d=o+(o-h.points[3])),e.push(l,d,a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="C",e.push(a,o);break;case"Q":e.push(c.shift(),c.shift()),a=c.shift(),o=c.shift(),e.push(a,o);break;case"q":e.push(a+c.shift(),o+c.shift()),a+=c.shift(),o+=c.shift(),t="Q",e.push(a,o);break;case"T":l=a,d=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a=c.shift(),o=c.shift(),t="Q",e.push(l,d,a,o);break;case"t":l=a,d=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),d=o+(o-h.points[1])),a+=c.shift(),o+=c.shift(),t="Q",e.push(l,d,a,o);break;case"A":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,_=o,a=c.shift(),o=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,_,a,o,f,g,u,p,m);break;case"a":u=c.shift(),p=c.shift(),m=c.shift(),f=c.shift(),g=c.shift(),v=a,_=o,a+=c.shift(),o+=c.shift(),t="A",e=this.convertEndpointToCenterParameterization(v,_,a,o,f,g,u,p,m)}s.push({command:t||i,points:e,start:{x:n,y:r},pathLength:this.calcLength(n,r,t||i,e)})}"z"!==i&&"Z"!==i||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,n){let s,r,a,o;const h=jy;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return zy([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return Gy([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":s=0;const i=n[4],l=n[5],c=n[4]+l;let d=Math.PI/180;if(Math.abs(i-c)<d&&(d=Math.abs(i-c)),r=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),l<0)for(o=i-d;o>c;o-=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;else for(o=i+d;o<c;o+=d)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;return a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],c,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),s}return 0}static convertEndpointToCenterParameterization(t,e,i,n,s,r,a,o,h){const l=h*(Math.PI/180),c=Math.cos(l)*(t-i)/2+Math.sin(l)*(e-n)/2,d=-1*Math.sin(l)*(t-i)/2+Math.cos(l)*(e-n)/2,u=c*c/(a*a)+d*d/(o*o);u>1&&(a*=Math.sqrt(u),o*=Math.sqrt(u));let p=Math.sqrt((a*a*(o*o)-a*a*(d*d)-o*o*(c*c))/(a*a*(d*d)+o*o*(c*c)));s===r&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*d/o,f=p*-o*c/a,g=(t+i)/2+Math.cos(l)*m-Math.sin(l)*f,v=(e+n)/2+Math.sin(l)*m+Math.cos(l)*f,_=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(_(t)*_(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},b=x([1,0],[(c-m)/a,(d-f)/o]),S=[(c-m)/a,(d-f)/o],w=[(-1*c-m)/a,(-1*d-f)/o];let M=x(S,w);return y(S,w)<=-1&&(M=Math.PI),y(S,w)>=1&&(M=0),0===r&&M>0&&(M-=2*Math.PI),1===r&&M<0&&(M+=2*Math.PI),[g,v,a,o,b,M,l,r]}}jy.prototype.className="Path",jy.prototype._attrsAffectingSize=["data"],Iv(jy),d_.addGetterSetter(jy,"data");class Xy extends Uy{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const r=this.pointerLength(),a=i.length;let o,h;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[a-2],i[a-1]],e=jy.calcLength(n[n.length-4],n[n.length-3],"C",t),s=jy.getPointOnQuadraticBezier(Math.min(1,1-r/e),t[0],t[1],t[2],t[3],t[4],t[5]);o=i[a-2]-s.x,h=i[a-1]-s.y}else o=i[a-2]-i[a-4],h=i[a-1]-i[a-3];const l=(Math.atan2(h,o)+e)%e,c=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(o=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(o=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-r,c/2),t.lineTo(-r,-c/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}Xy.prototype.className="Arrow",Iv(Xy),d_.addGetterSetter(Xy,"pointerLength",10,n_()),d_.addGetterSetter(Xy,"pointerWidth",10,n_()),d_.addGetterSetter(Xy,"pointerAtBeginning",!1),d_.addGetterSetter(Xy,"pointerAtEnding",!0);class Yy extends vy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}Yy.prototype._centroid=!0,Yy.prototype.className="Circle",Yy.prototype._attrsAffectingSize=["radius"],Iv(Yy),d_.addGetterSetter(Yy,"radius",0,n_());class qy extends vy{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}qy.prototype.className="Ellipse",qy.prototype._centroid=!0,qy.prototype._attrsAffectingSize=["radiusX","radiusY"],Iv(qy),d_.addComponentsGetterSetter(qy,"radius",["x","y"]),d_.addGetterSetter(qy,"radiusX",0,n_()),d_.addGetterSetter(qy,"radiusY",0,n_());let Zy=class t extends vy{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image;let r;if(s){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;r=t&&n?[s,this.cropX(),this.cropY(),t,n,0,0,e,i]:[s,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?Vv.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s&&(n&&t.clip(),t.drawImage.apply(t,r))}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?Vv.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e,i;return null!==(i=null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width)&&void 0!==i?i:0}getHeight(){var t,e,i;return null!==(i=null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height)&&void 0!==i?i:0}static fromURL(e,i,n=null){const s=Vv.createImageElement();s.onload=function(){const e=new t({image:s});i(e)},s.onerror=n,s.crossOrigin="Anonymous",s.src=e}};Zy.prototype.className="Image",Zy.prototype._attrsAffectingSize=["image"],Iv(Zy),d_.addGetterSetter(Zy,"cornerRadius",0,s_(4)),d_.addGetterSetter(Zy,"image"),d_.addComponentsGetterSetter(Zy,"crop",["x","y","width","height"]),d_.addGetterSetter(Zy,"cropX",0,n_()),d_.addGetterSetter(Zy,"cropY",0,n_()),d_.addGetterSetter(Zy,"cropWidth",0,n_()),d_.addGetterSetter(Zy,"cropHeight",0,n_());const Ky=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Jy="up",Qy="right",$y="down",tx="left",ex=Ky.length;class ix extends Sy{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e<ex;e++)t.on(Ky[e]+"Change.konva",n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,i,n,s,r,a,o=this.getText(),h=this.getTag();if(o&&h){switch(t=o.width(),e=o.height(),i=h.pointerDirection(),n=h.pointerWidth(),a=h.pointerHeight(),s=0,r=0,i){case Jy:s=t/2,r=-1*a;break;case Qy:s=t+n,r=e/2;break;case $y:s=t/2,r=e+a;break;case tx:s=-1*n,r=e/2}h.setAttrs({x:-1*s,y:-1*r,width:t,height:e}),o.setAttrs({x:-1*s,y:-1*r})}}}ix.prototype.className="Label",Iv(ix);class nx extends vy{_sceneFunc(t){const e=this.width(),i=this.height(),n=this.pointerDirection(),s=this.pointerWidth(),r=this.pointerHeight(),a=this.cornerRadius();let o=0,h=0,l=0,c=0;"number"==typeof a?o=h=l=c=Math.min(a,e/2,i/2):(o=Math.min(a[0]||0,e/2,i/2),h=Math.min(a[1]||0,e/2,i/2),c=Math.min(a[2]||0,e/2,i/2),l=Math.min(a[3]||0,e/2,i/2)),t.beginPath(),t.moveTo(o,0),n===Jy&&(t.lineTo((e-s)/2,0),t.lineTo(e/2,-1*r),t.lineTo((e+s)/2,0)),t.lineTo(e-h,0),t.arc(e-h,h,h,3*Math.PI/2,0,!1),n===Qy&&(t.lineTo(e,(i-r)/2),t.lineTo(e+s,i/2),t.lineTo(e,(i+r)/2)),t.lineTo(e,i-c),t.arc(e-c,i-c,c,0,Math.PI/2,!1),n===$y&&(t.lineTo((e+s)/2,i),t.lineTo(e/2,i+r),t.lineTo((e-s)/2,i)),t.lineTo(l,i),t.arc(l,i-l,l,Math.PI/2,Math.PI,!1),n===tx&&(t.lineTo(0,(i+r)/2),t.lineTo(-1*s,i/2),t.lineTo(0,(i-r)/2)),t.lineTo(0,o),t.arc(o,o,o,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,i=this.pointerWidth(),n=this.pointerHeight(),s=this.pointerDirection(),r=this.width(),a=this.height();return s===Jy?(e-=n,a+=n):s===$y?a+=n:s===tx?(t-=1.5*i,r+=i):s===Qy&&(r+=1.5*i),{x:t,y:e,width:r,height:a}}}nx.prototype.className="Tag",Iv(nx),d_.addGetterSetter(nx,"pointerDirection","none"),d_.addGetterSetter(nx,"pointerWidth",0,n_()),d_.addGetterSetter(nx,"pointerHeight",0,n_()),d_.addGetterSetter(nx,"cornerRadius",0,s_(4));class sx extends vy{_sceneFunc(t){const e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?Vv.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}sx.prototype.className="Rect",Iv(sx),d_.addGetterSetter(sx,"cornerRadius",0,s_(4));class rx extends vy{_sceneFunc(t){const e=this._getPoints(),i=this.radius(),n=this.sides(),s=this.cornerRadius();if(t.beginPath(),s)Vv.drawRoundedPolygonPath(t,e,n,i,s);else{t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,i=[];for(let n=0;n<t;n++)i.push({x:e*Math.sin(2*n*Math.PI/t),y:-1*e*Math.cos(2*n*Math.PI/t)});return i}getSelfRect(){const t=this._getPoints();let e=t[0].x,i=t[0].x,n=t[0].y,s=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),s=Math.max(s,t.y)}),{x:e,y:n,width:i-e,height:s-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}rx.prototype.className="RegularPolygon",rx.prototype._centroid=!0,rx.prototype._attrsAffectingSize=["radius"],Iv(rx),d_.addGetterSetter(rx,"radius",0,n_()),d_.addGetterSetter(rx,"sides",0,n_()),d_.addGetterSetter(rx,"cornerRadius",0,s_(4));const ax=2*Math.PI;class ox extends vy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,ax,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),ax,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}ox.prototype.className="Ring",ox.prototype._centroid=!0,ox.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Iv(ox),d_.addGetterSetter(ox,"innerRadius",0,n_()),d_.addGetterSetter(ox,"outerRadius",0,n_());class hx extends vy{constructor(t){super(t),this._updated=!0,this.anim=new My(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+0],o=s[n+1],h=s[n+2],l=s[n+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),c)if(r){const n=r[e],s=2*i;t.drawImage(c,a,o,h,l,n[s+0],n[s+1],h,l)}else t.drawImage(c,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+2],o=s[n+3];if(t.beginPath(),r){const n=r[e],s=2*i;t.rect(n[s+0],n[s+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}hx.prototype.className="Sprite",Iv(hx),d_.addGetterSetter(hx,"animation"),d_.addGetterSetter(hx,"animations"),d_.addGetterSetter(hx,"frameOffsets"),d_.addGetterSetter(hx,"image"),d_.addGetterSetter(hx,"frameIndex",0,n_()),d_.addGetterSetter(hx,"frameRate",17,n_()),d_.backCompat(hx,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class lx extends vy{_sceneFunc(t){const e=this.innerRadius(),i=this.outerRadius(),n=this.numPoints();t.beginPath(),t.moveTo(0,0-i);for(let s=1;s<2*n;s++){const r=s%2==0?i:e,a=r*Math.sin(s*Math.PI/n),o=-1*r*Math.cos(s*Math.PI/n);t.lineTo(a,o)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}function cx(t){return[...t].reduce((t,e,i,n)=>{if(/\p{Emoji}/u.test(e)){const s=n[i+1];s&&/\p{Emoji_Modifier}|\u200D/u.test(s)?(t.push(e+s),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}lx.prototype.className="Star",lx.prototype._centroid=!0,lx.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Iv(lx),d_.addGetterSetter(lx,"numPoints",5,n_()),d_.addGetterSetter(lx,"innerRadius",0,n_()),d_.addGetterSetter(lx,"outerRadius",0,n_());const dx="auto",ux="inherit",px="justify",mx="left",fx="middle",gx="normal",vx=" ",_x="none",yx=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],xx=yx.length;let bx;function Sx(){return bx||(bx=Vv.createCanvasElement().getContext("2d"),bx)}class wx extends vy{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<xx;t++)this.on(yx[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){var e,i;const n=this.textArr,s=n.length;if(!this.text())return;let r,a=this.padding(),o=this.fontSize(),h=this.lineHeight()*o,l=this.verticalAlign(),c=this.direction(),d=0,u=this.align(),p=this.getWidth(),m=this.letterSpacing(),f=this.charRenderFunc(),g=this.fill(),v=this.textDecoration(),_=this.underlineOffset(),y=-1!==v.indexOf("underline"),x=-1!==v.indexOf("line-through");c=c===ux?t.direction:c;let b=h/2,S=fx;if(!Rv.legacyTextRendering){const t=this.measureSize("M");S="alphabetic";b=((null!==(e=t.fontBoundingBoxAscent)&&void 0!==e?e:t.actualBoundingBoxAscent)-(null!==(i=t.fontBoundingBoxDescent)&&void 0!==i?i:t.actualBoundingBoxDescent))/2+h/2}for("rtl"===c&&t.setAttr("direction",c),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",S),t.setAttr("textAlign",mx),l===fx?d=(this.getHeight()-s*h-2*a)/2:"bottom"===l&&(d=this.getHeight()-s*h-2*a),t.translate(a,d+a),r=0;r<s;r++){let e=0,i=0;const l=n[r],d=l.text,v=l.width,S=l.lastInParagraph;if(t.save(),"right"===u?e+=p-v-2*a:"center"===u&&(e+=(p-v-2*a)/2),y){t.save(),t.beginPath();const n=e,s=b+i+(null!=_?_:Rv.legacyTextRendering?Math.round(o/2):Math.round(o/4));t.moveTo(n,s);const r=u!==px||S?v:p-2*a;t.lineTo(n+Math.round(r),s),t.lineWidth=o/15;const h=this._getLinearGradient();t.strokeStyle=h||g,t.stroke(),t.restore()}const w=e;if("rtl"===c||0===m&&u!==px&&!f)0!==m&&t.setAttr("letterSpacing",`${m}px`),this._partialTextX=e,this._partialTextY=b+i,this._partialText=d,t.fillStrokeShape(this);else{const s=d.split(" ").length-1,o=cx(d);for(let h=0;h<o.length;h++){const l=o[h];if(" "!==l||S||u!==px||(e+=(p-2*a-v)/s),this._partialTextX=e,this._partialTextY=b+i,this._partialText=l,f){t.save();f({char:l,index:h+n.slice(0,r).reduce((t,e)=>t+cx(e.text).length,0),x:e,y:b+i,lineIndex:r,column:h,isLastInLine:S,width:this.measureSize(l).width,context:t})}t.fillStrokeShape(this),f&&t.restore(),e+=this.measureSize(l).width+m}}if(x){t.save(),t.beginPath();const e=Rv.legacyTextRendering?0:-Math.round(o/4),n=w;t.moveTo(n,b+i+e);const s=u!==px||S?v:p-2*a;t.lineTo(n+Math.round(s),b+i+e),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||g,t.stroke(),t.restore()}t.restore(),s>1&&(b+=h)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=Vv._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===dx||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===dx||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Vv.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,s,r,a,o,h,l,c,d;let u,p=Sx(),m=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const f=m/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*f,actualBoundingBoxDescent:null!==(i=u.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=u.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*f,actualBoundingBoxRight:null!==(s=u.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*f,alphabeticBaseline:null!==(r=u.alphabeticBaseline)&&void 0!==r?r:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*f,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*f,fontBoundingBoxAscent:null!==(h=u.fontBoundingBoxAscent)&&void 0!==h?h:91*f,fontBoundingBoxDescent:null!==(l=u.fontBoundingBoxDescent)&&void 0!==l?l:21*f,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*f,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*f,width:u.width,height:m}}_getContextFont(){return this.fontStyle()+vx+this.fontVariant()+vx+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===px&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return Sx().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,s=this.attrs.width,r=this.attrs.height,a=s!==dx&&void 0!==s,o=r!==dx&&void 0!==r,h=this.padding(),l=s-2*h,c=r-2*h,d=0,u=this.wrap(),p="char"!==u&&u!==_x,m=this.ellipsis();this.textArr=[],Sx().font=this._getContextFont();const f=m?this._getTextWidth("…"):0;for(let e=0,s=t.length;e<s;++e){let r=t[e],h=this._getTextWidth(r);if(a&&h>l)for(;r.length>0;){let t=0,e=cx(r).length,s="",a=0;for(;t<e;){const i=t+e>>>1,h=cx(r).slice(0,i+1).join(""),u=this._getTextWidth(h);(m&&o&&d+n>c?u+f:u)<=l?(t=i+1,s=h,a=u):e=i}if(!s)break;if(p){const e=cx(r),i=cx(s),n=e[i.length];let o;if((n===vx||"-"===n)&&a<=l)o=i.length;else{const t=i.lastIndexOf(vx),e=i.lastIndexOf("-");o=Math.max(t,e)+1}o>0&&(t=o,s=e.slice(0,t).join(""),a=this._getTextWidth(s))}s=s.trimRight(),this._addTextLine(s),i=Math.max(i,a),d+=n;if(this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(r=cx(r).slice(t).join("").trimLeft(),r.length>0&&(h=this._getTextWidth(r),h<=l)){this._addTextLine(r),d+=n,i=Math.max(i,h);break}}else this._addTextLine(r),d+=n,i=Math.max(i,h),this._shouldHandleEllipsis(d)&&e<s-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&d+n>c)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,s=n!==dx&&void 0!==n,r=n-2*this.padding();return!(this.wrap()!==_x)||s&&t+i>r}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==dx&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&n){if(e){this._getTextWidth(s.text+"…")<i||(s.text=s.text.slice(0,s.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+"…")}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}wx.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},wx.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},wx.prototype.className="Text",wx.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Iv(wx),d_.overWriteSetter(wx,"width",r_()),d_.overWriteSetter(wx,"height",r_()),d_.addGetterSetter(wx,"direction",ux),d_.addGetterSetter(wx,"fontFamily","Arial"),d_.addGetterSetter(wx,"fontSize",12,n_()),d_.addGetterSetter(wx,"fontStyle",gx),d_.addGetterSetter(wx,"fontVariant",gx),d_.addGetterSetter(wx,"padding",0,n_()),d_.addGetterSetter(wx,"align",mx),d_.addGetterSetter(wx,"verticalAlign","top"),d_.addGetterSetter(wx,"lineHeight",1,n_()),d_.addGetterSetter(wx,"wrap","word"),d_.addGetterSetter(wx,"ellipsis",!1,h_()),d_.addGetterSetter(wx,"letterSpacing",0,n_()),d_.addGetterSetter(wx,"text","",a_()),d_.addGetterSetter(wx,"textDecoration",""),d_.addGetterSetter(wx,"underlineOffset",void 0,n_()),d_.addGetterSetter(wx,"charRenderFunc",void 0);const Mx="normal";function Tx(t){t.fillText(this.partialText,0,0)}function Ex(t){t.strokeText(this.partialText,0,0)}class Ax extends vy{constructor(t){super(t),this.dummyCanvas=Vv.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return jy.getPathLength(this.dataArray)}_getPointAtLength(t){if(!this.attrs.data)return null;return t>this.pathLength?null:jy.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=jy.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),s=this.glyphInfo,r=-1!==e.indexOf("underline"),a=-1!==e.indexOf("line-through");r&&t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),this.partialText=s[e].text,t.fillStrokeShape(this),r&&(0===e&&t.moveTo(0,n/2+1),t.lineTo(s[e].width,n/2+1)),t.restore()}if(r&&(t.strokeStyle=i,t.lineWidth=n/20,t.stroke()),a){t.beginPath();for(let e=0;e<s.length;e++){t.save();const i=s[e].p0;t.translate(i.x,i.y),t.rotate(s[e].rotation),0===e&&t.moveTo(0,0),t.lineTo(s[e].width,0),t.restore()}t.strokeStyle=i,t.lineWidth=n/20,t.stroke()}t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;i<e.length;i++){const n=e[i].p1;t.lineTo(n.x,n.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Vv.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return wx.prototype.setText.call(this,t)}_getContextFont(){return wx.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const i=e.measureText(t);return e.restore(),{width:i.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const t=cx(this.text()),e=[];let i=0;for(let n=0;n<t.length;n++)e.push({char:t[n],width:this._getTextSize(t[n]).width}),i+=e[n].width;const{height:n}=this._getTextSize(this.attrs.text);if(this.textWidth=i,this.textHeight=n,this.glyphInfo=[],!this.attrs.data)return null;const s=this.letterSpacing(),r=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*s,0);let h=0;"center"===r&&(h=Math.max(0,this.pathLength/2-o/2)),"right"===r&&(h=Math.max(0,this.pathLength-o));let l=h;for(let i=0;i<e.length;i++){const n=this._getPointAtLength(l);if(!n)return;const h=e[i].char;let c=e[i].width+s;if(" "===h&&"justify"===r){const t=this.text().split(" ").length-1;c+=(this.pathLength-o)/t}const d=this._getPointAtLength(l+c);if(!d)return;const u=jy.getLineLength(n.x,n.y,d.x,d.y);let p=0;if(a)try{p=a(e[i-1].char,h)*this.fontSize()}catch(t){p=0}n.x+=p,d.x+=p,this.textWidth+=p;const m=jy.getPointOnLine(p+u/2,n.x,n.y,d.x,d.y),f=Math.atan2(d.y-n.y,d.x-n.x);this.glyphInfo.push({transposeX:m.x,transposeY:m.y,text:t[i],rotation:f,p0:n,p1:d,width:u}),l+=c}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,i,n=t[0]||0,s=t[0]||0,r=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],i=t[2*o+1],n=Math.min(n,e),s=Math.max(s,e),r=Math.min(r,i),a=Math.max(a,i);const o=this.fontSize();return{x:n-o/2,y:r-o/2,width:s-n+o,height:a-r+o}}destroy(){return Vv.releaseCanvas(this.dummyCanvas),super.destroy()}}Ax.prototype._fillFunc=Tx,Ax.prototype._strokeFunc=Ex,Ax.prototype._fillFuncHit=Tx,Ax.prototype._strokeFuncHit=Ex,Ax.prototype.className="TextPath",Ax.prototype._attrsAffectingSize=["text","fontSize","data"],Iv(Ax),d_.addGetterSetter(Ax,"data"),d_.addGetterSetter(Ax,"fontFamily","Arial"),d_.addGetterSetter(Ax,"fontSize",12,n_()),d_.addGetterSetter(Ax,"fontStyle",Mx),d_.addGetterSetter(Ax,"align","left"),d_.addGetterSetter(Ax,"letterSpacing",0,n_()),d_.addGetterSetter(Ax,"textBaseline","middle"),d_.addGetterSetter(Ax,"fontVariant",Mx),d_.addGetterSetter(Ax,"text",""),d_.addGetterSetter(Ax,"textDecoration",""),d_.addGetterSetter(Ax,"kerningFunc",void 0);const Cx="tr-konva",Lx=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${Cx}`).join(" "),Rx="nodesRect",Ix=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],Px={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Dx="ontouchstart"in Rv._global;const Ox=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Nx(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:s}}function Ux(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return Nx(t,e,i)}let Fx=0;class Bx extends Sy{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(Lx,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return Vv.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Cx+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(Vv.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(i,e)}t.on(Ix.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,i=>{if(!e)return;const n=t.getAbsolutePosition(),s=n.x-e.x,r=n.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+s,y:n.y+r}),e.startDrag(i)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Rx),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(Rx,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),i){const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),s=t.getAbsoluteScale(i),r=t.getAbsolutePosition(i),a=n.x*s.x-t.offsetX()*s.x,o=n.y*s.y-t.offsetY()*s.y,h=(Rv.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Nx({x:r.x+a*Math.cos(h)+o*Math.sin(-h),y:r.y+o*Math.cos(h)+a*Math.sin(h),width:n.width*s.x,height:n.height*s.y,rotation:h},-Rv.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],s=e.getAbsoluteTransform();n.forEach(function(e){const i=s.point(e);t.push(i)})});const e=new Dv;e.rotate(-Rv.getAngle(this.rotation()));let i=1/0,n=1/0,s=-1/0,r=-1/0;t.forEach(function(t){const a=e.point(t);void 0===i&&(i=s=a.x,n=r=a.y),i=Math.min(i,a.x),n=Math.min(n,a.y),s=Math.max(s,a.x),r=Math.max(r,a.y)}),e.invert();const a=e.point({x:i,y:n});return{x:a.x,y:a.y,width:s-i,height:r-n,rotation:Rv.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Ox.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(t){const e=new sx({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Dx?10:"auto"}),i=this;e.on("mousedown touchstart",function(t){i._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const i=Rv.getAngle(this.rotation()),n=this.rotateAnchorCursor(),s=function(t,e,i){if("rotater"===t)return i;e+=Vv.degToRad(Px[t]||0);const n=(Vv.radToDeg(e)%360+360)%360;return Vv._inRange(n,337.5,360)||Vv._inRange(n,0,22.5)?"ns-resize":Vv._inRange(n,22.5,67.5)?"nesw-resize":Vv._inRange(n,67.5,112.5)?"ew-resize":Vv._inRange(n,112.5,157.5)?"nwse-resize":Vv._inRange(n,157.5,202.5)?"ns-resize":Vv._inRange(n,202.5,247.5)?"nesw-resize":Vv._inRange(n,247.5,292.5)?"ew-resize":Vv._inRange(n,292.5,337.5)?"nwse-resize":(Vv.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,i,n);e.getStage().content&&(e.getStage().content.style.cursor=s),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new vy({name:"back",width:0,height:0,sceneFunc(t,e){const i=e.getParent(),n=i.padding(),s=e.width(),r=e.height();if(t.beginPath(),t.rect(-n,-n,s+2*n,r+2*n),i.rotateEnabled()&&i.rotateLineVisible()){const e=i.rotateAnchorAngle(),n=i.rotateAnchorOffset(),a=Vv.degToRad(e),o=Math.sin(a),h=-Math.cos(a),l=s/2,c=r/2;let d=1/0;h<0?d=Math.min(d,-c/h):h>0&&(d=Math.min(d,(r-c)/h)),o<0?d=Math.min(d,-l/o):o>0&&(d=Math.min(d,(s-l)/o));const u=l+o*d,p=c+h*d,m=Vv._sign(r),f=u+o*n*m,g=p+h*n*m;t.moveTo(u,p),t.lineTo(f,g)}t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const r=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-r.x,y:a.y-r.y},Fx++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,i,n;const s=this.findOne("."+this._movingAnchorName),r=s.getStage();r.setPointersPositions(t);const a=r.getPointerPosition();let o={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const h=s.getAbsolutePosition();this.anchorDragBoundFunc()&&(o=this.anchorDragBoundFunc()(h,o,t)),s.setAbsolutePosition(o);const l=s.getAbsolutePosition();if(h.x===l.x&&h.y===l.y)return;if("rotater"===this._movingAnchorName){const n=this._getNodeRect();e=s.x()-n.width/2,i=-s.y()+n.height/2;const r=Rv.getAngle(this.rotateAnchorAngle());let a=Math.atan2(-i,e)+Math.PI/2-r;n.height<0&&(a-=Math.PI);const o=Rv.getAngle(this.rotation())+a,h=Rv.getAngle(this.rotationSnapTolerance()),l=function(t,e,i){let n=e;for(let s=0;s<t.length;s++){const r=Rv.getAngle(t[s]),a=Math.abs(r-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<i&&(n=r)}return n}(this.rotationSnaps(),o,h),c=Ux(n,l-n.rotation);return void this._fitNodesInto(c,t)}const c=this.shiftBehavior();let d;d="inverted"===c?this.keepRatio()&&!t.shiftKey:"none"===c?this.keepRatio():this.keepRatio()||t.shiftKey;let u=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(t.y-s.y(),2));const r=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-i)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(s.y());else if("top-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(t.y-s.y(),2));const r=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-i)}var p=s.position();this.findOne(".top-left").y(p.y),this.findOne(".bottom-right").x(p.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(s.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(s.x());else if("bottom-left"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(t.x-s.x(),2)+Math.pow(s.y()-t.y,2));const r=t.x<s.x()?-1:1,a=s.y()<t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,s.x(t.x-e),s.y(t.y+i)}p=s.position(),this.findOne(".top-left").x(p.x),this.findOne(".bottom-right").y(p.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(s.y());else if("bottom-right"===this._movingAnchorName){if(d){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(s.x()-t.x,2)+Math.pow(s.y()-t.y,2));const r=this.findOne(".bottom-right").x()<t.x?-1:1,a=this.findOne(".bottom-right").y()<t.y?-1:1;e=n*this.cos*r,i=n*this.sin*a,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+i)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(u=this.centeredScaling()||t.altKey,u){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),i=t.x(),n=t.y(),s=this.getWidth()-e.x(),r=this.getHeight()-e.y();e.move({x:-i,y:-n}),t.move({x:s,y:r})}const m=this.findOne(".top-left").getAbsolutePosition();e=m.x,i=m.y;const f=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:i,width:f,height:g,rotation:Rv.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const i=this.getNode();Fx--,this._fire("transformend",{evt:t,target:i}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),i&&this._nodes.forEach(e=>{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e){const i=this._getNodeRect();if(Vv._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(Vv._inRange(t.height,2*-this.padding()-1,1))return void this.update();const n=new Dv;if(n.rotate(Rv.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=n.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=n.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=n.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=n.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(i,t);e?t=e:Vv.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,r=new Dv;r.translate(i.x,i.y),r.rotate(i.rotation),r.scale(i.width/s,i.height/s);const a=new Dv,o=t.width/s,h=t.height/s;!1===this.flipEnabled()?(a.translate(t.x,t.y),a.rotate(t.rotation),a.translate(t.width<0?t.width:0,t.height<0?t.height:0),a.scale(Math.abs(o),Math.abs(h))):(a.translate(t.x,t.y),a.rotate(t.rotation),a.scale(o,h));const l=a.multiply(r.invert());this._nodes.forEach(t=>{var e;if(!t.getStage())return;const i=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());const s=new Dv;s.multiply(i.copy().invert()).multiply(l).multiply(i).multiply(n);const r=s.decompose();t.setAttrs(r),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(Vv._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(Vv._getRotation(e.rotation));const i=e.width,n=e.height,s=this.enabledAnchors(),r=this.resizeEnabled(),a=this.padding(),o=this.anchorSize(),h=this.find("._anchor");h.forEach(t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+a,offsetY:o/2+a,visible:r&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+a,visible:r&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-a,offsetY:o/2+a,visible:r&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:o/2+a,visible:r&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:o/2-a,visible:r&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:o/2+a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:o/2-a,visible:r&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:o/2-a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-right")>=0});const l=this.rotateAnchorAngle(),c=this.rotateAnchorOffset(),d=Vv.degToRad(l),u=Math.sin(d),p=-Math.cos(d),m=i/2,f=n/2;let g=1/0;p<0?g=Math.min(g,-f/p):p>0&&(g=Math.min(g,(n-f)/p)),u<0?g=Math.min(g,-m/u):u>0&&(g=Math.min(g,(i-m)/u));const v=m+u*g,_=f+p*g,y=Vv._sign(n);this._batchChangeChild(".rotater",{x:v+u*c*y,y:_+p*c*y-a*p,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(t=>t.draggable()),x:0,y:0});const x=this.anchorStyleFunc();x&&h.forEach(t=>{x(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Sy.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return E_.prototype.toObject.call(this)}clone(t){return E_.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Bx.isTransforming=()=>Fx>0,Bx.prototype.className="Transformer",Iv(Bx),d_.addGetterSetter(Bx,"enabledAnchors",Ox,function(t){return t instanceof Array||Vv.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===Ox.indexOf(t)&&Vv.warn("Unknown anchor name: "+t+". Available names are: "+Ox.join(", "))}),t||[]}),d_.addGetterSetter(Bx,"flipEnabled",!0,h_()),d_.addGetterSetter(Bx,"resizeEnabled",!0),d_.addGetterSetter(Bx,"anchorSize",10,n_()),d_.addGetterSetter(Bx,"rotateEnabled",!0),d_.addGetterSetter(Bx,"rotateLineVisible",!0),d_.addGetterSetter(Bx,"rotationSnaps",[]),d_.addGetterSetter(Bx,"rotateAnchorOffset",50,n_()),d_.addGetterSetter(Bx,"rotateAnchorAngle",0,n_()),d_.addGetterSetter(Bx,"rotateAnchorCursor","crosshair"),d_.addGetterSetter(Bx,"rotationSnapTolerance",5,n_()),d_.addGetterSetter(Bx,"borderEnabled",!0),d_.addGetterSetter(Bx,"anchorStroke","rgb(0, 161, 255)"),d_.addGetterSetter(Bx,"anchorStrokeWidth",1,n_()),d_.addGetterSetter(Bx,"anchorFill","white"),d_.addGetterSetter(Bx,"anchorCornerRadius",0,n_()),d_.addGetterSetter(Bx,"borderStroke","rgb(0, 161, 255)"),d_.addGetterSetter(Bx,"borderStrokeWidth",1,n_()),d_.addGetterSetter(Bx,"borderDash"),d_.addGetterSetter(Bx,"keepRatio",!0),d_.addGetterSetter(Bx,"shiftBehavior","default"),d_.addGetterSetter(Bx,"centeredScaling",!1),d_.addGetterSetter(Bx,"ignoreStroke",!1),d_.addGetterSetter(Bx,"padding",0,n_()),d_.addGetterSetter(Bx,"nodes"),d_.addGetterSetter(Bx,"node"),d_.addGetterSetter(Bx,"boundBoxFunc"),d_.addGetterSetter(Bx,"anchorDragBoundFunc"),d_.addGetterSetter(Bx,"anchorStyleFunc"),d_.addGetterSetter(Bx,"shouldOverdrawWholeArea",!1),d_.addGetterSetter(Bx,"useSingleNodeRotation",!0),d_.backCompat(Bx,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class kx extends vy{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,Rv.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}function zx(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}kx.prototype.className="Wedge",kx.prototype._centroid=!0,kx.prototype._attrsAffectingSize=["radius"],Iv(kx),d_.addGetterSetter(kx,"radius",0,n_()),d_.addGetterSetter(kx,"angle",0,n_()),d_.addGetterSetter(kx,"clockwise",!1),d_.backCompat(kx,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const Gx=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Hx=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];d_.addGetterSetter(E_,"blurRadius",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"brightness",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"contrast",0,n_(),d_.afterSetFilter);function Vx(t,e,i,n,s){const r=i-e,a=s-n;if(0===r)return n+a/2;if(0===a)return n;let o=(t-e)/r;return o=a*o+n,o}d_.addGetterSetter(E_,"embossStrength",.5,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"embossWhiteLevel",.5,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"embossDirection","top-left",void 0,d_.afterSetFilter),d_.addGetterSetter(E_,"embossBlend",!1,void 0,d_.afterSetFilter);d_.addGetterSetter(E_,"enhance",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"hue",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"saturation",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"luminance",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"hue",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"saturation",0,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"value",0,n_(),d_.afterSetFilter);function Wx(t,e,i){let n=4*(i*t.width+e);const s=[];return s.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),s}function jx(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}d_.addGetterSetter(E_,"kaleidoscopePower",2,n_(),d_.afterSetFilter),d_.addGetterSetter(E_,"kaleidoscopeAngle",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"threshold",0,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"noise",.2,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"pixelSize",8,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"levels",.5,n_(),d_.afterSetFilter);d_.addGetterSetter(E_,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"blue",0,i_,d_.afterSetFilter);d_.addGetterSetter(E_,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),d_.addGetterSetter(E_,"blue",0,i_,d_.afterSetFilter),d_.addGetterSetter(E_,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t});d_.addGetterSetter(E_,"threshold",.5,n_(),d_.afterSetFilter);const Xx=Iy.Util._assign(Iy,{Arc:Py,Arrow:Xy,Circle:Yy,Ellipse:qy,Image:Zy,Label:ix,Tag:nx,Line:Uy,Path:jy,Rect:sx,RegularPolygon:rx,Ring:ox,Sprite:hx,Star:lx,Text:wx,TextPath:Ax,Transformer:Bx,Wedge:kx,Filters:{Blur:function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,n=t.width,s=t.height;let r,a,o,h,l,c,d,u,p,m,f,g,v,_,y,x,b,S,w,M;const T=e+e+1,E=n-1,A=s-1,C=e+1,L=C*(C+1)/2,R=new zx,I=Gx[e],P=Hx[e];let D=null,O=R,N=null,U=null;for(let t=1;t<T;t++)O=O.next=new zx,t===C&&(D=O);O.next=R,o=a=0;for(let t=0;t<s;t++){g=v=_=y=h=l=c=d=0,u=C*(x=i[a]),p=C*(b=i[a+1]),m=C*(S=i[a+2]),f=C*(w=i[a+3]),h+=L*x,l+=L*b,c+=L*S,d+=L*w,O=R;for(let t=0;t<C;t++)O.r=x,O.g=b,O.b=S,O.a=w,O=O.next;for(let t=1;t<C;t++)r=a+((E<t?E:t)<<2),h+=(O.r=x=i[r])*(M=C-t),l+=(O.g=b=i[r+1])*M,c+=(O.b=S=i[r+2])*M,d+=(O.a=w=i[r+3])*M,g+=x,v+=b,_+=S,y+=w,O=O.next;N=R,U=D;for(let t=0;t<n;t++)i[a+3]=w=d*I>>P,0!==w?(w=255/w,i[a]=(h*I>>P)*w,i[a+1]=(l*I>>P)*w,i[a+2]=(c*I>>P)*w):i[a]=i[a+1]=i[a+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,r=o+((r=t+e+1)<E?r:E)<<2,g+=N.r=i[r],v+=N.g=i[r+1],_+=N.b=i[r+2],y+=N.a=i[r+3],h+=g,l+=v,c+=_,d+=y,N=N.next,u+=x=U.r,p+=b=U.g,m+=S=U.b,f+=w=U.a,g-=x,v-=b,_-=S,y-=w,U=U.next,a+=4;o+=n}for(let t=0;t<n;t++){v=_=y=g=l=c=d=h=0,a=t<<2,u=C*(x=i[a]),p=C*(b=i[a+1]),m=C*(S=i[a+2]),f=C*(w=i[a+3]),h+=L*x,l+=L*b,c+=L*S,d+=L*w,O=R;for(let t=0;t<C;t++)O.r=x,O.g=b,O.b=S,O.a=w,O=O.next;let o=n;for(let s=1;s<=e;s++)a=o+t<<2,h+=(O.r=x=i[a])*(M=C-s),l+=(O.g=b=i[a+1])*M,c+=(O.b=S=i[a+2])*M,d+=(O.a=w=i[a+3])*M,g+=x,v+=b,_+=S,y+=w,O=O.next,s<A&&(o+=n);a=t,N=R,U=D;for(let e=0;e<s;e++)r=a<<2,i[r+3]=w=d*I>>P,w>0?(w=255/w,i[r]=(h*I>>P)*w,i[r+1]=(l*I>>P)*w,i[r+2]=(c*I>>P)*w):i[r]=i[r+1]=i[r+2]=0,h-=u,l-=p,c-=m,d-=f,u-=N.r,p-=N.g,m-=N.b,f-=N.a,r=t+((r=e+C)<A?r:A)*n<<2,h+=g+=N.r=i[r],l+=v+=N.g=i[r+1],c+=_+=N.b=i[r+2],d+=y+=N.a=i[r+3],N=N.next,u+=x=U.r,p+=b=U.g,m+=S=U.b,f+=w=U.a,g-=x,v-=b,_-=S,y-=w,U=U.next,a+=n}}(t,e)},Brightness:function(t){const e=this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]=Math.min(255,i[t]*e),i[t+1]=Math.min(255,i[t+1]*e),i[t+2]=Math.min(255,i[t+2]*e)},Brighten:function(t){const e=255*this.brightness(),i=t.data,n=i.length;for(let t=0;t<n;t+=4)i[t]+=e,i[t+1]+=e,i[t+2]+=e},Contrast:function(t){const e=Math.pow((this.contrast()+100)/100,2),i=t.data,n=i.length;let s=150,r=150,a=150;for(let t=0;t<n;t+=4)s=i[t],r=i[t+1],a=i[t+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,r/=255,r-=.5,r*=e,r+=.5,r*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,s=s<0?0:s>255?255:s,r=r<0?0:r>255?255:r,a=a<0?0:a>255?255:a,i[t]=s,i[t+1]=r,i[t+2]=a},Emboss:function(t){var e,i,n,s,r,a,o,h,l;const c=t.data,d=t.width,u=t.height,p=Math.min(1,Math.max(0,null!==(i=null===(e=this.embossStrength)||void 0===e?void 0:e.call(this))&&void 0!==i?i:.5)),m=Math.min(1,Math.max(0,null!==(s=null===(n=this.embossWhiteLevel)||void 0===n?void 0:n.call(this))&&void 0!==s?s:.5)),f=null!==(o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[null!==(a=null===(r=this.embossDirection)||void 0===r?void 0:r.call(this))&&void 0!==a?a:"top-left"])&&void 0!==o?o:315,g=!(null===(l=null===(h=this.embossBlend)||void 0===h?void 0:h.call(this))||void 0===l||!l),v=10*p,_=255*m,y=f*Math.PI/180,x=Math.cos(y),b=Math.sin(y),S=128/1020*v,w=new Uint8ClampedArray(c),M=new Float32Array(d*u);for(let t=0,e=0;e<c.length;e+=4,t++)M[t]=.2126*w[e]+.7152*w[e+1]+.0722*w[e+2];const T=[-1,0,1,-2,0,2,-1,0,1],E=[-1,-2,-1,0,0,0,1,2,1],A=[-d-1,-d,1-d,-1,0,1,d-1,d,d+1],C=t=>t<0?0:t>255?255:t;for(let t=1;t<u-1;t++)for(let e=1;e<d-1;e++){const i=t*d+e;let n=0,s=0;n+=M[i+A[0]]*T[0],s+=M[i+A[0]]*E[0],n+=M[i+A[1]]*T[1],s+=M[i+A[1]]*E[1],n+=M[i+A[2]]*T[2],s+=M[i+A[2]]*E[2],n+=M[i+A[3]]*T[3],s+=M[i+A[3]]*E[3],n+=M[i+A[5]]*T[5],s+=M[i+A[5]]*E[5],n+=M[i+A[6]]*T[6],s+=M[i+A[6]]*E[6],n+=M[i+A[7]]*T[7],s+=M[i+A[7]]*E[7],n+=M[i+A[8]]*T[8],s+=M[i+A[8]]*E[8];const r=C(_+(x*n+b*s)*S),a=4*i;if(g){const t=r-_;c[a]=C(w[a]+t),c[a+1]=C(w[a+1]+t),c[a+2]=C(w[a+2]+t),c[a+3]=w[a+3]}else c[a]=c[a+1]=c[a+2]=r,c[a+3]=w[a+3]}for(let t=0;t<d;t++){let e=4*t,i=4*((u-1)*d+t);c[e]=w[e],c[e+1]=w[e+1],c[e+2]=w[e+2],c[e+3]=w[e+3],c[i]=w[i],c[i+1]=w[i+1],c[i+2]=w[i+2],c[i+3]=w[i+3]}for(let t=1;t<u-1;t++){let e=t*d*4,i=4*(t*d+(d-1));c[e]=w[e],c[e+1]=w[e+1],c[e+2]=w[e+2],c[e+3]=w[e+3],c[i]=w[i],c[i+1]=w[i+1],c[i+2]=w[i+2],c[i+3]=w[i+3]}return t},Enhance:function(t){const e=t.data,i=e.length;let n,s,r,a=e[0],o=a,h=e[1],l=h,c=e[2],d=c;const u=this.enhance();if(0===u)return;for(let t=0;t<i;t+=4)n=e[t+0],n<a?a=n:n>o&&(o=n),s=e[t+1],s<h?h=s:s>l&&(l=s),r=e[t+2],r<c?c=r:r>d&&(d=r);let p,m,f,g,v,_;if(o===a&&(o=255,a=0),l===h&&(l=255,h=0),d===c&&(d=255,c=0),u>0)p=o+u*(255-o),m=a-u*(a-0),f=l+u*(255-l),g=h-u*(h-0),v=d+u*(255-d),_=c-u*(c-0);else{const t=.5*(o+a);p=o+u*(o-t),m=a+u*(a-t);const e=.5*(l+h);f=l+u*(l-e),g=h+u*(h-e);const i=.5*(d+c);v=d+u*(d-i),_=c+u*(c-i)}for(let t=0;t<i;t+=4)e[t+0]=Vx(e[t+0],a,o,m,p),e[t+1]=Vx(e[t+1],h,l,g,f),e[t+2]=Vx(e[t+2],c,d,_,v)},Grayscale:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=i,e[t+1]=i,e[t+2]=i}},HSL:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,r=127*this.luminance(),a=1*n*Math.cos(s*Math.PI/180),o=1*n*Math.sin(s*Math.PI/180),h=.299+.701*a+.167*o,l=.587-.587*a+.33*o,c=.114-.114*a-.497*o,d=.299-.299*a-.328*o,u=.587+.413*a+.035*o,p=.114-.114*a+.293*o,m=.299-.3*a+1.25*o,f=.587-.586*a-1.05*o,g=.114+.886*a-.2*o;let v,_,y,x;for(let t=0;t<i;t+=4)v=e[t+0],_=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=h*v+l*_+c*y+r,e[t+1]=d*v+u*_+p*y+r,e[t+2]=m*v+f*_+g*y+r,e[t+3]=x},HSV:function(t){const e=t.data,i=e.length,n=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),r=Math.abs(this.hue()+360)%360,a=n*s*Math.cos(r*Math.PI/180),o=n*s*Math.sin(r*Math.PI/180),h=.299*n+.701*a+.167*o,l=.587*n-.587*a+.33*o,c=.114*n-.114*a-.497*o,d=.299*n-.299*a-.328*o,u=.587*n+.413*a+.035*o,p=.114*n-.114*a+.293*o,m=.299*n-.3*a+1.25*o,f=.587*n-.586*a-1.05*o,g=.114*n+.886*a-.2*o;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2],r=e[t+3];e[t+0]=h*i+l*n+c*s,e[t+1]=d*i+u*n+p*s,e[t+2]=m*i+f*n+g*s,e[t+3]=r}},Invert:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]},Kaleidoscope:function(t){const e=t.width,i=t.height;let n,s,r,a,o,h,l,c,d,u,p=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),f=Math.floor(e*(m%360)/360);if(p<1)return;const g=Vv.createCanvasElement();g.width=e,g.height=i;const v=g.getContext("2d").getImageData(0,0,e,i);Vv.releaseCanvas(g),function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=r-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=r,f=360/m*Math.PI/180;for(let t=0;t<m;t+=1){const e=Math.sin(t*f),i=Math.cos(t*f);for(let a=0;a<p;a+=1){c=Math.floor(o+l*a/p*i),d=Math.floor(h+l*a/p*e);let u=4*(d*r+c);const m=n[u+0],f=n[u+1],g=n[u+2],v=n[u+3];u=4*(t+a*r),s[u+0]=m,s[u+1]=f,s[u+2]=g,s[u+3]=v}}}(t,v,{polarCenterX:e/2,polarCenterY:i/2});let _=e/Math.pow(2,p);for(;_<=8;)_*=2,p-=1;_=Math.ceil(_);let y=_,x=0,b=y,S=1;for(f+_>e&&(x=y,b=0,S=-1),s=0;s<i;s+=1)for(n=x;n!==b;n+=S)r=Math.round(n+f)%e,d=4*(e*s+r),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*s+n),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;for(s=0;s<i;s+=1)for(y=Math.floor(_),a=0;a<p;a+=1){for(n=0;n<y+1;n+=1)d=4*(e*s+n),o=v.data[d+0],h=v.data[d+1],l=v.data[d+2],c=v.data[d+3],u=4*(e*s+2*y-n-1),v.data[u+0]=o,v.data[u+1]=h,v.data[u+2]=l,v.data[u+3]=c;y*=2}!function(t,e,i){const n=t.data,s=e.data,r=t.width,a=t.height,o=i.polarCenterX||r/2,h=i.polarCenterY||a/2;let l=Math.sqrt(o*o+h*h),c=r-o,d=a-h;const u=Math.sqrt(c*c+d*d);l=u>l?u:l;const p=a,m=r;let f,g;for(c=0;c<r;c+=1)for(d=0;d<a;d+=1){const t=c-o,e=d-h,i=Math.sqrt(t*t+e*e)*p/l;let a=(180*Math.atan2(e,t)/Math.PI+360+0)%360;a=a*m/360,f=Math.floor(a),g=Math.floor(i);let u=4*(g*r+f);const v=n[u+0],_=n[u+1],y=n[u+2],x=n[u+3];u=4*(d*r+c),s[u+0]=v,s[u+1]=_,s[u+2]=y,s[u+3]=x}}(v,t,{})},Mask:function(t){let e=function(t,e){const i=Wx(t,0,0),n=Wx(t,t.width-1,0),s=Wx(t,0,t.height-1),r=Wx(t,t.width-1,t.height-1),a=e||10;if(jx(i,n)<a&&jx(n,r)<a&&jx(r,s)<a&&jx(s,i)<a){const e=function(t){const e=[0,0,0];for(let i=0;i<t.length;i++)e[0]+=t[i][0],e[1]+=t[i][1],e[2]+=t[i][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([n,i,r,s]),o=[];for(let i=0;i<t.width*t.height;i++){const n=jx(e,[t.data[4*i],t.data[4*i+1],t.data[4*i+2]]);o[i]=n<a?0:255}return o}}(t,this.threshold());return e&&(e=function(t,e,i){const n=[1,1,1,1,0,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*s+l];c+=t[d*e+u]*i}}a[l]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1,1,1,1,1,1,1,1,1],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*s+l];c+=t[d*e+u]*i}}a[l]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o<i;o++)for(let h=0;h<e;h++){const l=o*e+h;let c=0;for(let a=0;a<s;a++)for(let l=0;l<s;l++){const d=o+a-r,u=h+l-r;if(d>=0&&d<i&&u>=0&&u<e){const i=n[a*s+l];c+=t[d*e+u]*i}}a[l]=c}return a}(e,t.width,t.height),function(t,e){for(let i=0;i<t.width*t.height;i++)t.data[4*i+3]=e[i]}(t,e)),t},Noise:function(t){const e=255*this.noise(),i=t.data,n=i.length,s=e/2;for(let t=0;t<n;t+=4)i[t+0]+=s-2*s*Math.random(),i[t+1]+=s-2*s*Math.random(),i[t+2]+=s-2*s*Math.random()},Pixelate:function(t){let e=Math.ceil(this.pixelSize()),i=t.width,n=t.height,s=Math.ceil(i/e),r=Math.ceil(n/e),a=t.data;if(e<=0)Vv.error("pixelSize value can not be <= 0");else for(let t=0;t<s;t+=1)for(let s=0;s<r;s+=1){let r=0,o=0,h=0,l=0;const c=t*e,d=c+e,u=s*e,p=u+e;let m=0;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const s=4*(i*e+t);r+=a[s+0],o+=a[s+1],h+=a[s+2],l+=a[s+3],m+=1}r/=m,o/=m,h/=m,l/=m;for(let t=c;t<d;t+=1)if(!(t>=i))for(let e=u;e<p;e+=1){if(e>=n)continue;const s=4*(i*e+t);a[s+0]=r,a[s+1]=o,a[s+2]=h,a[s+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,s=255/e;for(let t=0;t<n;t+=1)i[t]=Math.floor(i[t]/s)*s},RGB:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue();for(let t=0;t<i;t+=4){const i=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=i*n,e[t+1]=i*s,e[t+2]=i*r,e[t+3]=e[t+3]}},RGBA:function(t){const e=t.data,i=e.length,n=this.red(),s=this.green(),r=this.blue(),a=this.alpha();for(let t=0;t<i;t+=4){const i=1-a;e[t]=n*a+e[t]*i,e[t+1]=s*a+e[t+1]*i,e[t+2]=r*a+e[t+2]*i}},Sepia:function(t){const e=t.data,i=e.length;for(let t=0;t<i;t+=4){const i=e[t+0],n=e[t+1],s=e[t+2];e[t+0]=Math.min(255,.393*i+.769*n+.189*s),e[t+1]=Math.min(255,.349*i+.686*n+.168*s),e[t+2]=Math.min(255,.272*i+.534*n+.131*s)}},Solarize:function(t){const e=t.data;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],s=e[t+2];.2126*i+.7152*n+.0722*s>=128&&(e[t]=255-i,e[t+1]=255-n,e[t+2]=255-s)}return t},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t<n;t+=1)i[t]=i[t]<e?0:255}}});class Yx{screenToWorld(t){return{x:t.x,y:t.y,z:0}}worldToScreen(t){return{x:t.x,y:t.y}}getScale(){return{x:1,y:1,z:1}}}class qx{constructor(t,e,i){this.setColor(t,e,i)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,i){this.R=t,this.G=e,this.B=i,this.HEX=this.rgbToHex(t,e,i)}rgbToHex(t,e,i){const n=t=>{const e=t.toString(16);return"0"===e?"00":e};return n(t)+n(e)+n(i)}}const Zx=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Kx{constructor(t,e=null,i=new Yx){var n,s;if(this._worldTransformer=i,e){this._ref=e;let t=this._ref.getAttr("wcsPoints");if(!t){t=[];const e=this._ref.points();let i;for(let n=0;n<e.length;n+=2)i=this._worldTransformer.screenToWorld({x:e[n],y:e[n+1]}),t.push({x:i.x,y:i.y,z:i.z});this._ref.setAttr("wcsPoints",t)}return}t||(t={}),t.points||(t.points=[{x:0,y:0},{x:100,y:100}]);const r=[],a=[];t.points.forEach(t=>{r.push(t.x,t.y);const e=this._worldTransformer.screenToWorld({x:t.x,y:t.y});a.push({x:e.x,y:e.y,z:e.z})}),this._ref=new Xx.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(s=t.width)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:r,draggable:!0,strokeScaleEnabled:!1,dash:Zx.get(t.type)||[]}),this._ref.setAttr("wcsPoints",a),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)}),this._ref.on("transformend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let s=0;s<i.length;s+=2){const r=t.point({x:i[s],y:i[s+1]});n=this._worldTransformer.screenToWorld({x:r.x,y:r.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.on("dragend",()=>{const t=this._ref.getAbsoluteTransform(),e=[],i=this._ref.points();let n;for(let s=0;s<i.length;s+=2){const r=t.point({x:i[s],y:i[s+1]});n=this._worldTransformer.screenToWorld({x:r.x,y:r.y}),e.push({x:n.x,y:n.y,z:n.z})}this._ref.setAttr("wcsPoints",e)}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Line"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){return this._ref.points()}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}getLineType(){let t;switch(this._ref.dash()||[]){case Zx.get("dot"):t="dot";break;case Zx.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Zx.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();const i=this._ref.getAttr("wcsPoints");t.forEach(t=>{e=e.concat([t.x,t.y]);const n=this._worldTransformer.screenToWorld(t);i.push(n)}),this._ref.points(e)}updateScreenCoordinates(){const t=this._ref.getAttr("wcsPoints"),e=[];let i=this._ref.getAbsoluteTransform().copy();i=i.invert(),t.forEach(t=>{let n=this._worldTransformer.worldToScreen(t);n=i.point({x:n.x,y:n.y}),e.push(n.x),e.push(n.y)}),this._ref.points([]),this._ref.points(e),this._ref.clearCache()}}class Jx{constructor(t,e=null,i=new Yx){var n,s,r;if(this.TEXT_FONT_FAMILY="Calibri",this._worldTransformer=i,e){this._ref=e;return void(this._ref.getAttr("wcsStart")||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.text||(t.text="default"),this._ref=new Xx.Text({x:t.position.x,y:t.position.y,text:t.text,fontSize:null!==(n=t.fontSize)&&void 0!==n?n:34,fontFamily:this.TEXT_FONT_FAMILY,fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",align:"left",draggable:!0,rotation:null!==(r=t.rotation)&&void 0!==r?r:0}),this._ref.width(this._ref.getTextWidth()),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY);s<50&&(s=50),r<Math.round(this.getFontSize())&&(r=Math.round(this.getFontSize())),i&&this._ref.width(s),n&&this._ref.height(r),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Text"}getColor(){return this._ref.fill()}setColor(t){this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getText(){return this._ref.text()}setText(t){this._ref.text(t)}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));let e=this._ref.getStage().getAbsoluteTransform().copy();e=e.invert();const i=e.point(t);this._ref.position({x:i.x,y:i.y})}}class Qx{constructor(t,e=null,i=new Yx){var n,s,r,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200),this._ref=new Xx.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,width:null!==(r=t.width)&&void 0!==r?r:200,height:null!==(a=t.height)&&void 0!==a?a:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY);s<50&&(s=50),r<50&&(r=50),i&&this._ref.width(s),n&&this._ref.height(r),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeight(){return this._ref.height()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Rectangle"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}setLineWidth(t){this._ref.strokeWidth(t)}getLineWidth(){return this._ref.strokeWidth()}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),s=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(s.x-n.x)),this._ref.height(Math.abs(s.y-n.y))}}function $x(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}class tb{constructor(t,e=null,i=new Yx){var n,s,r;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsPosition"),i=this._ref.getAttr("wcsRadiusX"),n=this._ref.getAttr("wcsRadiusY");return t||this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),i||this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:e.x()+e.radiusX(),y:e.y()})),void(n||this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()+e.radiusY()})))}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(null!==(n=t.radius)&&void 0!==n||(t.radius={x:0,y:0}),t.radius.x=$x(t.position,t.position2),t.position3?t.radius.y=$x(t.position,t.position3):t.radius.x=t.radius.y):t.radius||(t.radius={x:25,y:25}),this._ref=new Xx.Ellipse({stroke:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:null!==(r=t.lineWidth)&&void 0!==r?r:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",x:t.position.x,y:t.position.y,radiusX:t.radius.x,radiusY:t.radius.y,draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t.radius.x,y:this._ref.y()})),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t.radius.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.radiusX();i&&(s*=e.scaleX);let r=this._ref.radiusY();n&&(r*=e.scaleY);s<25&&(s=25),r<25&&(r=25),t.evt.ctrlKey||t.evt.shiftKey?i?this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:r}),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform(),e=t.point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld(e));const i=t.point({x:this._ref.x()+this._ref.radiusX(),y:this._ref.y()});this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld(i));const n=t.point({x:this._ref.x(),y:this._ref.y()+this._ref.radiusY()});this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld(n))}),this._ref.id(this._ref._id.toString())}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsPosition",this._worldTransformer.screenToWorld({x:t,y:e}))}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t),this._ref.setAttr("wcsRadiusX",this._worldTransformer.screenToWorld({x:this._ref.x()+t,y:this._ref.y()}))}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(t),this._ref.setAttr("wcsRadiusY",this._worldTransformer.screenToWorld({x:this._ref.x(),y:this._ref.y()+t}))}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Ellipse"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX")),i=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));let n=this._ref.getStage().getAbsoluteTransform().copy();n=n.invert();const s=n.point({x:t.x,y:t.y});this._ref.position({x:s.x,y:s.y}),this._ref.radius({x:Math.abs(n.point(e).x-s.x),y:Math.abs(n.point(i).y-s.y)})}}class eb{constructor(t,e=null,i=new Yx){var n,s;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");return t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.points()[0],y:e.points()[1]})),void(i||this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:e.points()[2],y:e.points()[3]})))}t||(t={}),t.start||(t.start={x:0,y:0}),t.end||(t.end={x:100,y:100}),this._ref=new Xx.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(s=t.color)&&void 0!==s?s:"#ff0000",strokeWidth:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:[t.start.x,t.start.y,t.end.x,t.end.y],draggable:!0,strokeScaleEnabled:!1}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.start.x,y:t.start.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.end.x,y:t.end.y})),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.points(),n=this._ref.getAbsoluteTransform(),s=n.point({x:i[0],y:i[1]}),r=n.point({x:i[2],y:i[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(s)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(r))}),this._ref.on("dragend",t=>{const e=this._ref.points(),i=t.target.getAbsoluteTransform(),n=i.point({x:e[0],y:e[1]}),s=i.point({x:e[2],y:e[3]});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(n)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld(s))}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Arrow"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t),this._ref.fill(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPoints(){const t=this._ref.points();return[{x:t[0],y:t[1]},{x:t[2],y:t[3]}]}setPoints(t){2===t.length&&(this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t[0].x,y:t[0].y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t[1].x,y:t[1].y})),this._ref.points([t[0].x,t[0].y,t[1].x,t[1].y]))}getStartPoint(){const t=this._ref.points();return{x:t[0],y:t[1]}}setStartPoint(t,e){const i=this._ref.points();this._ref.points([t,e,i[2],i[3]]),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}))}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const i=this._ref.points();this._ref.points([i[0],i[1],t,e]),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t,y:e}))}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getAbsoluteTransform().copy();i=i.invert();const n=i.point({x:t.x,y:t.y}),s=i.point({x:e.x,y:e.y});this._ref.points([n.x,n.y,s.x,s.y])}}class ib{constructor(t,e=null,i=new Yx){var n,s;if(this._ratio=1,this.EPSILON=1e-5,this.BASE64_HEADER_START="data:image/",this.BASE64_NOT_FOUND="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=",this._worldTransformer=i,e){e.src&&e.src.startsWith(this.BASE64_HEADER_START)||(e.src=this.BASE64_NOT_FOUND),e.height()<=this.EPSILON&&e.height(32),e.width()<=this.EPSILON&&e.width(32),this._ref=e,this._canvasImage=e.image(),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width();const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),t.position2&&(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y),this._canvasImage=new Image,this._canvasImage.onload=()=>{if(this._ref.image(this._canvasImage),this._ref.height()<=this.EPSILON&&this._ref.height(this._canvasImage.height),this._ref.width()<=this.EPSILON&&this._ref.width(this._canvasImage.width),this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width(),(t.width<=this.EPSILON||t.height<=this.EPSILON)&&(t.maxWidth>=this.EPSILON||t.maxWidth>=this.EPSILON)){const e=t.maxHeight-this._canvasImage.height,i=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||i<=this.EPSILON)&&(i<=this.EPSILON&&i<e/this._ratio?(this._ref.height(t.maxWidth*this._ratio),this._ref.width(t.maxWidth)):(this._ref.width(t.maxHeight/this._ratio),this._ref.height(t.maxHeight)))}const e=this._worldTransformer.screenToWorld({x:t.position.x+this._ref.width(),y:t.position.y+this._ref.height()});this._ref.setAttr("wcsEnd",e)},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Xx.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(s=t.height)&&void 0!==s?s:0,draggable:!0}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),t.position2&&this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?i?(this._ref.width(s),this._ref.height(s*this._ratio)):(this._ref.width(r/this._ratio),this._ref.height(r)):(i&&this._ref.width(s),n&&this._ref.height(r)),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.id(this._ref._id.toString())}getSrc(){return this._canvasImage.src}setSrc(t){this._canvasImage.src=t}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t),this._ref.height(t*this._ratio);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Image"}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.getPosition()}setPosition(t,e){this._ref.setPosition({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),s=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(s.x-n.x)),this._ref.height(Math.abs(s.y-n.y))}}class nb{constructor(t,e=null,i=new Yx){var n,s,r,a;if(this._worldTransformer=i,e){this._ref=e;const t=this._ref.getAttr("wcsStart"),i=this._ref.getAttr("wcsEnd");if(t||this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:e.x(),y:e.y()})),!i){const t={x:e.x()+e.width(),y:e.y()+e.height()};this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x,y:t.y}))}return}t||(t={}),t.position||(t.position={x:0,y:0}),t.position2?(t.width=t.position2.x-t.position.x,t.height=t.position2.y-t.position.y):t.width&&t.height?t.position2={x:t.position.x+t.width,y:t.position.y+t.height}:(t.position2={x:200,y:200},t.width=200,t.height=200);this._ref=new Xx.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(s=t.height)&&void 0!==s?s:200,stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(a=t.lineWidth)&&void 0!==a?a:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const i=this._ref.width(),n=this._ref.height(),s=[{x:0,y:0},{x:0+i,y:0},{x:0+i,y:0+n},{x:0,y:0+n},{x:0,y:0}];function r(r,a){const o={x:(h={x:0,y:0}).x+i/2,y:h.y+n/2};var h;t.beginPath();for(let e=0;e<s.length-1;e++){let i=a;const n=s[e+1].x-s[e].x,h=s[e+1].y-s[e].y,l=Math.sqrt(n*n+h*h),c=Math.floor(l/i);i=a+c/(l%i);let d=s[e].x+n/c/2,u=s[e].y+h/c/2;const p=s[e+1].x,m=s[e+1].y,f=Math.atan((m-u)/(p-d)),g=f+Math.PI,v=d>o.x&&u>o.y;for(let e=0;e<c;e++)v?t.arc(d,u,r,f,g):t.arc(d,u,r,g,f),d+=n/c,u+=h/c}t.closePath(),t.fillStrokeShape(e)}i>=49||n>=49?r(8,15):i>=25||n>=25?r(4,7.5):(t.beginPath(),t.lineTo(s[1].x,s[1].y),t.lineTo(s[2].x,s[2].y),t.lineTo(s[3].x,s[3].y),t.lineTo(s[4].x,s[4].y),t.closePath(),t.fillStrokeShape(e))}}),this._ref.className="Cloud",this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t.position.x,y:t.position.y})),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.position2.x,y:t.position2.y})),this._ref.on("transform",t=>{const e=t.target.attrs,i=Math.abs(e.scaleX-1)>1e-5,n=Math.abs(e.scaleY-1)>1e-5;let s=this._ref.width();i&&(s*=e.scaleX);let r=this._ref.height();n&&(r*=e.scaleY),s<50&&(s=50),r<50&&(r=50),i&&this._ref.width(s),n&&this._ref.height(r),this._ref.scale({x:1,y:1})}),this._ref.on("transformend",t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const i=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(i)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:i.x+this._ref.width(),y:i.y+this._ref.height()}))}),this._ref.on("dragend",()=>{const t=this._ref.getStage().getAbsoluteTransform().point({x:this._ref.x(),y:this._ref.y()});this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld(t)),this._ref.setAttr("wcsEnd",this._worldTransformer.screenToWorld({x:t.x+this._ref.width(),y:t.y+this._ref.height()}))}),this._ref.getSelfRect=()=>({x:-8,y:-8,width:this._ref.width()+16,height:this._ref.height()+16}),this._ref.id(this._ref._id.toString())}ref(){return this._ref}id(){return this._ref.id()}enableMouseEditing(t){this._ref.draggable(t)}type(){return"Cloud"}getColor(){return this._ref.stroke()}setColor(t){this._ref.stroke(t)}getRotation(){return this._ref.rotation()}setRotation(t){this._ref.rotation(t)}getZIndex(){return this._ref.zIndex()}setZIndex(t){this._ref.zIndex(t)}delete(){this._ref.destroy(),this._ref=null}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.position({x:t,y:e}),this._ref.setAttr("wcsStart",this._worldTransformer.screenToWorld({x:t,y:e}));const i={x:t+this._ref.width(),y:e+this._ref.y()},n=this._worldTransformer.screenToWorld(i);this._ref.setAttr("wcsEnd",n)}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t);const e={x:this._ref.x()+t,y:this._ref.y()+this._ref.height()},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t);const e={x:this._ref.x()+this._ref.width(),y:this._ref.y()+t},i=this._worldTransformer.screenToWorld(e);this._ref.setAttr("wcsEnd",i)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}updateScreenCoordinates(){const t=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart")),e=this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));let i=this._ref.getStage().getAbsoluteTransform().copy();i=i.invert();const n=i.point(t),s=i.point(e);this._ref.position({x:n.x,y:n.y}),this._ref.width(Math.abs(s.x-n.x)),this._ref.height(Math.abs(s.y-n.y))}}const sb={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null,...i)=>new Kx(e,t,...i)},Text:{name:"Text",initializer:(t,e=null,...i)=>new Jx(e,t,...i)},Rectangle:{name:"Rect",initializer:(t,e=null,...i)=>new Qx(e,t,...i)},Ellipse:{name:"Ellipse",initializer:(t,e=null,...i)=>new tb(e,t,...i)},Arrow:{name:"Arrow",initializer:(t,e=null,...i)=>new eb(e,t,...i)},Image:{name:"Image",initializer:(t,e=null,...i)=>new ib(e,t,...i)},Cloud:{name:"Cloud",initializer:(t,e=null,...i)=>new nb(e,t,...i)}};class rb{constructor(){this._markupIsActive=!1,this._markupColor=new qx(255,0,0),this.lineWidth=4,this.lineType="solid",this.fontSize=34,this.changeActiveDragger=t=>{const e=t.data;this._markupContainer.className=this._container.className.split(" ").filter(t=>!t.startsWith("oda-cursor-")).filter(t=>t).concat(`oda-cursor-${e.toLowerCase()}`).join(" "),this.removeTextInput(),this.removeImageInput(),this.enableEditMode(e)},this.resizeContainer=()=>{const{offsetLeft:t,offsetTop:e,offsetWidth:i,offsetHeight:n}=this._container;i&&n&&(this._markupContainer.style.left=`${t}px`,this._markupContainer.style.top=`${e}px`,this._konvaStage.width(i),this._konvaStage.height(n),this.getObjects().forEach(t=>{t.updateScreenCoordinates()}))},this.pan=()=>{this.updateScreenCoordinatesForAll()},this.zoomAt=()=>{this.updateScreenCoordinatesForAll()},this.changeCameraMode=()=>{this.clearOverlay()},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const i=e.getAbsoluteTransform().copy();return i.invert(),i.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,i,n){this._viewer=i,this._worldTransformer=null!=n?n:new Yx,this._container=t,this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";this._container.parentElement.appendChild(this._markupContainer),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(t),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt),this._viewer.addEventListener("changecameramode",this.changeCameraMode))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("changecameramode",this.changeCameraMode),this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,this.destroyKonva(),null===(e=this._markupContainer)||void 0===e||e.remove(),this._markupContainer=void 0,this._container=void 0,this._viewer=void 0,this._worldTransformer=void 0,this._markupIsActive=!1}syncOverlay(){}clearOverlay(){this.removeTextInput(),this.removeImageInput(),this.clearSelected(),this.getObjects().forEach(t=>t.delete())}getMarkupColor(){return this._markupColor.asRGB()}setMarkupColor(t,e,i){this._markupColor.setColor(t,e,i),this.redirectToViewer({type:"changemarkupcolor",data:{r:t,g:e,b:i}})}colorizeAllMarkup(t,e,i){this.setMarkupColor(t,e,i);const n=new qx(t,e,i).asHex();this.getObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}colorizeSelectedMarkups(t,e,i){const n=new qx(t,e,i).asHex();this.getSelectedObjects().filter(t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,n)})}setViewpoint(t){var e,i,n,s,r,a,o,h;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const l=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(l.r,l.g,l.b),null===(i=t.lines)||void 0===i||i.forEach(t=>{const e=[];t.points.forEach(t=>{const i=this._worldTransformer.worldToScreen(t);e.push(i.x),e.push(i.y)}),this.addLine(e,t.color,t.type,t.width,t.id)}),null===(n=t.texts)||void 0===n||n.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addText(t.text,e,t.angle,t.color,t.text_size,t.font_size,t.id)}),null===(s=t.rectangles)||void 0===s||s.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addRectangle(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(r=t.ellipses)||void 0===r||r.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null,n=t.position3?this._worldTransformer.worldToScreen(t.position3):null;this.addEllipse(e,i,n,t.radius,t.line_width,t.color,t.id)}),null===(a=t.arrows)||void 0===a||a.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.start),i=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,i,t.color,t.id)}),null===(o=t.clouds)||void 0===o||o.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addCloud(e,i,t.width,t.height,t.line_width,t.color,t.id)}),null===(h=t.images)||void 0===h||h.forEach(t=>{const e=this._worldTransformer.worldToScreen(t.position),i=t.position2?this._worldTransformer.worldToScreen(t.position2):null;this.addImage(e,i,t.src,t.width,t.height,t.id)})}getViewpoint(t){return t||(t={custom_fields:{}}),t.lines=this.getMarkupLines(),t.texts=this.getMarkupTexts(),t.arrows=this.getMarkupArrows(),t.clouds=this.getMarkupClouds(),t.ellipses=this.getMarkupEllipses(),t.images=this.getMarkupImages(),t.rectangles=this.getMarkupRectangles(),t.custom_fields.markup_color=this.getMarkupColor(),t}getSnapshot(t="image/jpeg",e=.25){this.clearSelected();const i=document.createElement("canvas");if(this._konvaStage){i.width=this._konvaStage.width(),i.height=this._konvaStage.height();const t=i.getContext("2d");this._container instanceof HTMLCanvasElement&&t.drawImage(this._container,0,0),t.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return i.toDataURL(t,e)}enableEditMode(t){return t&&sb[t]?(this._markupMode=t,this._markupContainer.style.pointerEvents="all",this._markupIsActive=!0):(this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._markupContainer.style.pointerEvents="none",this._markupIsActive=!1),this}createObject(t,e){const i=sb[t];if(!i||!i.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const n=i.initializer(null,e,this._worldTransformer);return this.addObject(n),n}getObjects(){const t=[];return Object.keys(sb).forEach(e=>{const i=sb[e];this.konvaLayerFind(e).forEach(e=>t.push(i.initializer(e,null,this._worldTransformer)))}),t}getSelectedObjects(){if(!this._konvaTransformer)return[];const t=this._konvaTransformer.nodes().filter(t=>{try{return null!==t.getLayer()&&null!==t.getParent()}catch{return!1}});return t.length!==this._konvaTransformer.nodes().length&&this._konvaTransformer.nodes(t),t.map(t=>{const e=t.className,i=Object.values(sb).find(t=>t.name===e);return i?i.initializer(t,null,this._worldTransformer):null}).filter(t=>t)}selectObjects(t){if(!this._konvaTransformer)return;const e=this._konvaTransformer.nodes().concat(t.map(t=>t.ref()));this._konvaTransformer.nodes(e)}clearSelected(){this._konvaTransformer&&this._konvaTransformer.nodes([])}addObject(t){"Image"===t.type()?this._groupImages.add(t.ref()):"Text"===t.type()?this._groupTexts.add(t.ref()):this._groupGeometry.add(t.ref())}konvaLayerFind(t){if(!this._konvaLayer)return[];const e=sb[t];return e&&e.initializer?this._konvaLayer.find(e.name).filter(t=>t.parent===this._konvaLayer||t.parent===this._groupImages||t.parent===this._groupGeometry||t.parent===this._groupTexts):[]}updateScreenCoordinatesForAll(){this.getObjects().forEach(t=>{t.updateScreenCoordinates()})}initializeKonva(){const t=new Xx.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Xx.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Xx.Group,e.add(this._groupImages),this._groupGeometry=new Xx.Group,e.add(this._groupGeometry),this._groupTexts=new Xx.Group,e.add(this._groupTexts),this._konvaLayer=e;const i=new Xx.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(i),this._konvaTransformer=i;let n,s,r,a=!1;t.on("mousedown touchstart",e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&i.nodes().length>0)return void i.nodes([]);const r=this.getRelativePointerPosition(t);s=r,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some(t=>t===this._markupMode),"Line"===this._markupMode&&(n=this.addLine([r.x,r.y,r.x,r.y]))}),t.on("mouseup touchend",()=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,n=i?s.x:Math.min(s.x,e.x),r=i?s.y:Math.min(s.y,e.y),a=i?200:Math.abs(s.x-e.x),o=i?200:Math.abs(s.y-e.y);i&&("Rectangle"===this._markupMode?this.addRectangle({x:n,y:r},null,a,o):"Ellipse"===this._markupMode?this.addEllipse({x:n,y:r},null,null,{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:s.x,y:s.y},{x:i?s.x+200:e.x,y:i?r:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:n,y:r},null,Math.max(100,a),Math.max(100,o)))}r=void 0,a=!1}}),t.on("mousemove touchmove",()=>{if(!this._markupIsActive)return;if(!a)return;const e=this.getRelativePointerPosition(t),i=s&&e.x===s.x&&e.y===s.y,o=i?s.x:Math.min(s.x,e.x),h=i?s.y:Math.min(s.y,e.y),l=i?200:Math.abs(s.x-e.x),c=i?200:Math.abs(s.y-e.y);"Line"===this._markupMode?n.addPoints([{x:e.x,y:e.y}]):"Arrow"===this._markupMode?r?r.setEndPoint(e.x,e.y):r=this.addArrow({x:s.x,y:s.y},{x:e.x,y:e.y}):"Rectangle"===this._markupMode?r?(r.setPosition(o,h),r.setWidth(l),r.setHeight(c)):r=this.addRectangle({x:o,y:h},null,l,c):"Ellipse"===this._markupMode?r?(r.setPosition(o,h),r.setRadiusX(l),r.setRadiusY(c)):r=this.addEllipse({x:o,y:h},null,null,{x:l,y:c}):"Cloud"===this._markupMode&&(r?(r.setPosition(o,h),r.setWidth(Math.max(100,l)),r.setHeight(Math.max(100,c))):r=this.addCloud({x:o,y:h},null,l,c))}),t.on("click tap",e=>{if(!this._markupIsActive)return;if(e.target===t){if("Text"===this._markupMode){if(this._textInputRef&&this._textInputRef.value)this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle);else if(0===i.nodes().length){const i=this.getRelativePointerPosition(t);this.createTextInput(i,e.evt.pageX,e.evt.pageY,0,null)}}else if("Image"===this._markupMode)if(this._imageInputRef&&this._imageInputRef.value)this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===i.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void i.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._textInputRef&&this._textInputRef.value?this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle):this.createTextInput({x:e.target.attrs.x,y:e.target.attrs.y},e.evt.pageX,e.evt.pageY,e.target.attrs.rotation,e.target.attrs.text));this.removeTextInput()}if("Image"===this._markupMode||"SelectMarkup"===this._markupMode){if("Image"===e.target.className&&1===i.nodes().length&&i.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,null,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}i.nodes().filter(t=>"Cloud"===t.className||"Image"===t.className).length>0||"Cloud"===e.target.className||"Image"===e.target.className?i.rotateEnabled(!1):i.rotateEnabled(!0);const n=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,s=i.nodes().indexOf(e.target)>=0;if(n||s){if(n&&s){const t=i.nodes().slice();t.splice(t.indexOf(e.target),1),i.nodes(t)}else if(n&&!s){const t=i.nodes().concat([e.target]);i.nodes(t)}}else i.nodes([e.target])});const o=t.container();o.tabIndex=1,o.focus(),o.addEventListener("keydown",t=>{if(this._markupIsActive)return"Delete"===t.code?(this.getSelectedObjects().forEach(t=>t.delete()),void this.clearSelected()):void t.preventDefault()})}destroyKonva(){var t;this.removeTextInput(),this.removeImageInput(),this.clearOverlay(),null===(t=this._konvaStage)||void 0===t||t.destroy(),this._groupImages=void 0,this._groupGeometry=void 0,this._groupTexts=void 0,this._konvaLayer=void 0,this._konvaTransformer=void 0,this._konvaStage=void 0}getMarkupLines(){const t=[];return this.konvaLayerFind("Line").forEach(e=>{const i=e.getAttr("wcsPoints");if(!i)return;const n=new Kx(null,e,this._worldTransformer),s={id:n.id(),points:i,color:n.getColor()||"#ff0000",type:n.getLineType()||this.lineType,width:n.getLineWidth()||this.lineWidth};t.push(s)}),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach(e=>{const i=this._worldTransformer.getScale(),n=e.getAttr("wcsStart"),s=this._konvaStage.getAbsoluteTransform(),r=new Jx(null,e,this._worldTransformer),a={id:r.id(),position:n,text:r.getText(),text_size:.02*i.y,angle:r.getRotation(),color:r.getColor(),font_size:r.getFontSize()*s.getMatrix()[0]};t.push(a)}),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),r=this._worldTransformer.worldToScreen(n),a=new Qx(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(s.x-r.x),height:Math.abs(s.y-r.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach(e=>{const i=e.getAttr("wcsPosition"),n=e.getAttr("wcsRadiusX"),s=e.getAttr("wcsRadiusY"),r=this._konvaStage.getAbsoluteTransform().getMatrix()[0],a=new tb(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,position3:s,radius:{x:e.getRadiusX()*r,y:e.getRadiusY()*r},line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=new eb(null,e,this._worldTransformer),r={id:s.id(),start:i,end:n,color:s.getColor()};t.push(r)}),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=this._konvaStage.getAbsoluteTransform().getMatrix()[0],r=new ib(null,e,this._worldTransformer),a={id:r.id(),position:i,position2:n,src:r.getSrc(),width:r.getWidth()*s,height:r.getHeight()*s};t.push(a)}),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach(e=>{const i=e.getAttr("wcsStart"),n=e.getAttr("wcsEnd"),s=this._worldTransformer.worldToScreen(i),r=this._worldTransformer.worldToScreen(n),a=new nb(null,e,this._worldTransformer),o={id:a.id(),position:i,position2:n,width:Math.abs(s.x-r.x),height:Math.abs(s.y-r.y),line_width:a.getLineWidth(),color:a.getColor()};t.push(o)}),t}addLine(t,e,i,n,s){if(!t||0===t.length)return;const r=[];for(let e=0;e<t.length;e+=2)r.push({x:t[e],y:t[e+1]});const a=new Kx({points:r,type:i||this.lineType,width:n||this.lineWidth,color:e||this._markupColor.asHex(),id:s},null,this._worldTransformer);return this.addObject(a),a}createTextInput(t,e,i,n,s){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=n,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=i+"px",this._textInputRef.style.left=e+"px",this._textInputRef.style.fontSize=`${this.fontSize}px`,this._textInputRef.style.color=`${this._markupColor.asHex()}`,this._textInputRef.style.fontFamily="Calibri",this._textInputRef.onkeydown=t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.addText(this._textInputRef.value,this._textInputPos,this._textInputAngle)),"Escape"===t.key&&(t.preventDefault(),this.removeTextInput())},s&&(this._textInputRef.value=s),document.body.appendChild(this._textInputRef),setTimeout(()=>{this._textInputRef.focus()},50))}removeTextInput(){var t;null===(t=this._textInputRef)||void 0===t||t.remove(),this._textInputRef=null,this._textInputPos=null,this._textInputAngle=0}createImageInput(t){if(this._imageInputRef)this.removeImageInput();else{const e=t=>new Promise((e,i)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{e(n.result)},n.onerror=t=>{i(t)}});this._imageInputPos=t,this._imageInputRef=document.createElement("input"),this._imageInputRef.style.display="none",this._imageInputRef.type="file",this._imageInputRef.accept="image/png, image/jpeg",this._imageInputRef.onchange=async t=>{const i=t.target.files[0],n=await e(i);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},null,n.toString(),0,0)},this._imageInputRef.oncancel=()=>{this.removeImageInput()},document.body.appendChild(this._imageInputRef),setTimeout(()=>{this._imageInputRef.click()},50)}}removeImageInput(){var t;null===(t=this._imageInputRef)||void 0===t||t.remove(),this._imageInputRef=null,this._imageInputPos=null}addText(t,e,i,n,s,r,a){var o;if(!t)return;null===(o=this.getSelectedObjects().shift())||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const h=1e-6;if(s&&s>h&&(!r||r<h)){const t=.02;r=s/(this._worldTransformer.getScale().y/t)/34}const l=new Jx({position:{x:e.x,y:e.y},text:t,rotation:i,fontSize:r||this.fontSize,color:n||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(l),l}addRectangle(t,e,i,n,s,r,a){if(!t)return;const o=new Qx({position:t,position2:e,width:i,height:n,lineWidth:s||this.lineWidth,color:r||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addEllipse(t,e,i,n,s,r,a){if(!t)return;const o=new tb({position:t,position2:e,position3:i,radius:n,lineWidth:s,color:r||this._markupColor.asHex(),id:a},null,this._worldTransformer);return this.addObject(o),o}addArrow(t,e,i,n){if(!t||!e)return;const s=new eb({start:t,end:e,color:i||this._markupColor.asHex(),id:n},null,this._worldTransformer);return this.addObject(s),s}addCloud(t,e,i,n,s,r,a){if(!t||!i||!n)return;const o=new nb({position:t,position2:e,width:i,height:n,color:r||this._markupColor.asHex(),lineWidth:s||this.lineWidth,id:a},null,this._worldTransformer);return this.addObject(o),o}addImage(t,e,i,n,s,r){var a;if(!t||!i)return;null===(a=this.getSelectedObjects().shift())||void 0===a||a.delete(),this.clearSelected(),this.removeImageInput();const o=new ib({position:t,position2:e,src:i,width:n,height:s,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:r},null,this._worldTransformer);return this.addObject(o),o}}class ab extends xr{constructor(){super(...arguments),this.oldAutoClear=!1,this.oldClippingPlanes=[]}onBeforeRender(t){this.oldAutoClear=t.autoClear,this.oldClippingPlanes=t.clippingPlanes,t.autoClear=!1,t.clippingPlanes=[]}onAfterRender(t){t.clippingPlanes=this.oldClippingPlanes,t.autoClear=this.oldAutoClear}}"undefined"!=typeof window&&(window.THREE=lm),t.CANVAS_EVENTS=v,t.CanvasEvents=g,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.GLTFLoadingManager=Dg,t.Info=_,t.Loader=c,t.Markup=rb,t.ModelImpl=_g,t.Options=f,t.Viewer=class extends Av{constructor(t){super(),this.client=t,this.options=new f(this),this.loaders=[],this.models=[],this.info=new _,this.canvasEvents=v.slice(),this.canvaseventlistener=t=>this.emit(t),this.selected=[],this.extents=new Qi,this.target=new Li(0,0,0),this._activeDragger=null,this._components=[],this._updateDelay=1e3,this._renderNeeded=!1,this._renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new rb}get markup(){return this._markup}get draggers(){return[...Vf.getDraggers().keys()]}get components(){return[...vg.getComponents().keys()]}initialize(t,e){this.addEventListener("optionschange",t=>this.syncOptions(t.data)),this.scene=new xr,this.helpers=new ab;const i=window.devicePixelRatio,n=t.parentElement.getBoundingClientRect(),s=n.width||1,r=n.height||1,a=s/r;this.camera=new cr(45,a,.001,1e3),this.camera.up.set(0,1,0),this.camera.position.set(0,0,1),this.camera.lookAt(this.target),this.camera.updateProjectionMatrix(),this.renderer=new hm({canvas:t,antialias:!0,alpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance",logarithmicDepthBuffer:!0}),this.renderer.setPixelRatio(i),this.renderer.setSize(s,r),this.renderer.outputColorSpace=Ge,this.renderPass=new gv(this.scene,this.camera),this.helpersPass=new gv(this.helpers,this.camera),this.helpersPass.clear=!1,this.fxaaPass=new _v,this.smaaPass=new Sv,this.ssaaRenderPass=new wv([this.scene,this.helpers],this.camera),this.ssaaRenderPass.unbiased=!0,this.outputPass=new Ev,this.composer=new fv(this.renderer),this.composer.addPass(this.renderPass),this.composer.addPass(this.helpersPass),this.composer.addPass(this.smaaPass),this.composer.addPass(this.fxaaPass),this.composer.addPass(this.ssaaRenderPass),this.composer.addPass(this.outputPass),this.composer.setSize(s,r),this.canvas=t,this.canvasEvents.forEach(e=>t.addEventListener(e,this.canvaseventlistener)),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(const t of vg.getComponents().keys())this._components.push(vg.createComponent(t,this));if(this.syncOptions(),this.syncOverlay(),this._renderTime=performance.now(),"function"==typeof e){e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1}))}return this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),this.update(!0),Promise.resolve(this)}dispose(){return this.cancel(),this.clear(),this.emitEvent({type:"dispose"}),this.removeAllListeners(),this.setActiveDragger(),this._components.forEach(t=>t.dispose()),this._components=[],this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach(t=>this.canvas.removeEventListener(t,this.canvaseventlistener)),this.canvas=void 0),this.composer&&this.composer.dispose(),this.renderPass&&this.renderPass.dispose(),this.helpersPass&&this.helpersPass.dispose(),this.fxaaPass&&this.fxaaPass.dispose(),this.smaaPass&&this.smaaPass.dispose(),this.ssaaRenderPass&&this.ssaaRenderPass.dispose(),this.outputPass&&this.outputPass.dispose(),this.renderer&&this.renderer.dispose(),this.scene=void 0,this.helpers=void 0,this.camera=void 0,this.renderer=void 0,this.renderPass=void 0,this.helpersPass=void 0,this.fxaaPass=void 0,this.smaaPass=void 0,this.ssaaRenderPass=void 0,this.outputPass=void 0,this.composer=void 0,this}isInitialized(){return!!this.renderer}setSize(t,e,i=!0){if(!this.renderer)return;const n=this.camera,s=t/e;n.isPerspectiveCamera&&(n.aspect=s,n.updateProjectionMatrix()),n.isOrthographicCamera&&(n.left=n.bottom*s,n.right=n.top*s,n.updateProjectionMatrix()),this.renderer.setSize(t,e,i),this.composer.setSize(t,e),this.emitEvent({type:"resize",width:t,height:e}),this.update(!0)}update(t=!1){const e=performance.now();t=t||e-this._renderTime>=this._updateDelay,this._renderNeeded=!0,t&&this.render(e),this.emitEvent({type:"update",force:t})}render(t,e=!1){if(!this.renderer)return;if(!this._renderNeeded&&!e)return;t||(t=performance.now());const i=(t-this._renderTime)/1e3;this._renderTime=t,this._renderNeeded=!1,this.renderer.info.autoReset=!1,this.renderer.info.reset(),!0===this.options.antialiasing||"msaa"===this.options.antialiasing?(this.renderer.render(this.scene,this.camera),this.renderer.render(this.helpers,this.camera)):this.composer.render(i),this.emitEvent({type:"render",time:t,deltaTime:i})}loadReferences(t){return Promise.resolve(this)}async open(t,e={}){if(!this.renderer)return this;const i=e.mode||"file";"assembly"!==i&&"a"!==i&&"append"!==i&&(this.cancel(),this.clear()),this.emitEvent({type:"open",mode:i,file:t});let n=t;if(n&&"function"==typeof n.getModels){const e=await n.getModels();n=e.find(t=>t.default)||e[0]||t}n&&"string"==typeof n.database&&(t=n.file);let s=e.format;!s&&t&&"string"==typeof t.type&&(s=t.type.split(".").pop()),s||"string"!=typeof t||(s=t.split(".").pop()),!s&&t instanceof globalThis.File&&(s=t.name.split(".").pop());const r=av.createLoader(this,n,s);if(!r)throw new Error(`Format not supported (${s})`);this.loaders.push(r),this.emitEvent({type:"geometrystart",file:t,model:n});try{await this.loadReferences(n),await r.load(n,s,e)}catch(e){throw this.emitEvent({type:"geometryerror",data:e,file:t,model:n}),e}return this.emitEvent({type:"geometryend",file:t,model:n}),this.update(!0),this}cancel(){return this.loaders.forEach(t=>t.cancel()),this.emitEvent({type:"cancel"}),this}clear(){return this.renderer?(this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.loaders.forEach(t=>t.dispose()),this.loaders=[],this.models.forEach(t=>t.dispose()),this.models=[],this.scene.clear(),this.helpers.clear(),this.extents.makeEmpty(),this.syncOptions(),this.syncOverlay(),this.emitEvent({type:"clear"}),this.update(!0),this):this}is3D(){return!0}syncOptions(t=this.options){this.renderer&&(this.fxaaPass.enabled="fxaa"===t.antialiasing,this.smaaPass.enabled="smaa"===t.antialiasing,this.ssaaRenderPass.enabled="ssaa"===t.antialiasing,this.renderPass.enabled=!this.ssaaRenderPass.enabled,this.helpersPass.enabled=!this.ssaaRenderPass.enabled,this.update())}syncOverlay(){this.renderer&&(this._markup.syncOverlay(),this.update())}clearOverlay(){this.renderer&&(this._markup.clearOverlay(),this.update())}clearSlices(){this.renderer&&(this.renderer.clippingPlanes=[],this.update())}getSelected(){return this.executeCommand("getSelected")}getSelected2(){return this.executeCommand("getSelected2")}setSelected(t){this.executeCommand("setSelected",t)}setSelected2(t){this.executeCommand("setSelected2",t)}clearSelected(){this.executeCommand("clearSelected")}hideSelected(){this.executeCommand("hideSelected")}isolateSelected(){this.executeCommand("isolateSelected")}showAll(){this.executeCommand("showAll")}explode(t=0){this.executeCommand("explode",t)}collect(){this.executeCommand("collect")}activeDragger(){return this._activeDragger}setActiveDragger(t=""){if(!this._activeDragger||this._activeDragger.name!==t){const e=this._activeDragger;let i=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()&&(i=Vf.createDragger(t,this),this._activeDragger=i);const n=this.canvas;n&&(e&&n.classList.remove(`oda-cursor-${e.name.toLowerCase()}`),i&&n.classList.add(`oda-cursor-${i.name.toLowerCase()}`)),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}getComponent(t){return this._components.find(e=>e.name===t)}drawViewpoint(t){var e,i,n,s;if(!this.renderer)return;const r=({x:t,y:e,z:i})=>new Li(t,e,i),a=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{if(t){const e=this.extents.getSize(new Li).length()||1,i=this.renderer.getSize(new Ai),n=i.x/i.y,s=new Bl;s.top=t.field_height/2,s.bottom=-t.field_height/2,s.left=s.bottom*n,s.right=s.top*n,s.near=1e3*-e,s.far=1e3*e,s.zoom=t.view_to_world_scale,s.updateProjectionMatrix(),s.up.copy(r(t.up_vector)),s.position.copy(r(t.view_point)),s.lookAt(r(t.direction).add(s.position)),s.updateMatrixWorld(),this.camera=s,this.renderPass.camera=s,this.helpersPass.camera=s,this.ssaaRenderPass.camera=s,this.options.cameraMode="orthographic",this.emitEvent({type:"changecameramode",mode:"orthographic"})}})(t.orthogonal_camera),(t=>{if(t){const e=this.extents.getSize(new Li).length()||1,i=this.renderer.getSize(new Ai),n=i.x/i.y,s=new cr;s.fov=t.field_of_view,s.aspect=n,s.near=e/1e3,s.far=1e3*e,s.updateProjectionMatrix(),s.up.copy(r(t.up_vector)),s.position.copy(r(t.view_point)),s.lookAt(r(t.direction).add(s.position)),s.updateMatrixWorld(),this.camera=s,this.renderPass.camera=s,this.helpersPass.camera=s,this.ssaaRenderPass.camera=s,this.options.cameraMode="perspective",this.emitEvent({type:"changecameramode",mode:"perspective"})}})(t.perspective_camera),(t=>{t&&t.forEach(t=>{const e=new ga;e.setFromNormalAndCoplanarPoint(r(t.direction),r(t.location)),this.renderer.clippingPlanes.push(e)})})(t.clipping_planes),(t=>{t&&this.setSelected(t.map(t=>t.handle))})((null===(i=t.custom_fields)||void 0===i?void 0:i.selection2)||t.selection),this._markup.setViewpoint(t),this.target.copy(r(null!==(s=null===(n=t.custom_fields)||void 0===n?void 0:n.camera_target)&&void 0!==s?s:this.target)),this.syncOverlay(),this.setActiveDragger(a),this.emitEvent({type:"drawviewpoint",data:t}),this.update(!0)}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:i})=>({x:t,y:e,z:i}),e={custom_fields:{}};return e.orthogonal_camera=(()=>this.camera.isOrthographicCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Li)),up_vector:t(this.camera.up),field_width:this.camera.right-this.camera.left,field_height:this.camera.top-this.camera.bottom,view_to_world_scale:this.camera.zoom}:void 0)(),e.perspective_camera=(()=>this.camera.isPerspectiveCamera?{view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Li)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}:void 0)(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach(i=>{const n={location:t(i.coplanarPoint(new Li)),direction:t(i.normal)};e.push(n)}),e})(),e.selection=(()=>this.getSelected().map(t=>({handle:t})))(),e.description=(new Date).toDateString(),e.snapshot={data:this.getSnapshot()},this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),e.custom_fields.selection2=(()=>this.getSelected2().map(t=>({handle:t})))(),this.emitEvent({type:"createviewpoint",data:e}),e}getSnapshot(t,e){return this.executeCommand("getSnapshot",t,e)}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),i=t.x/(e.width/2)-1,n=-t.y/(e.height/2)+1;if(this.camera.isPerspectiveCamera){const t=new Oc,e=new Ai(i,n);t.setFromCamera(e,this.camera);const s=new Li;this.camera.getWorldDirection(s);const r=(new ga).setFromNormalAndCoplanarPoint(s,this.target),a=new Li;if(t.ray.intersectPlane(r,a),!a){const t=new Li(i,n,-1);return t.unproject(this.camera),{x:t.x,y:t.y,z:t.z}}return{x:a.x,y:a.y,z:a.z}}const s=new Li(i,n,-1);return s.unproject(this.camera),{x:s.x,y:s.y,z:s.z}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new Li(t.x,t.y,t.z);e.project(this.camera);const i=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(i.width/2),y:(1-e.y)*(i.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return qf.executeCommand(t,this,...e)}},t.commands=qf,t.commandsRegistry=n,t.components=vg,t.componentsRegistry=l,t.defaultOptions=m,t.draggers=Vf,t.draggersRegistry=a,t.loaders=av,t.loadersRegistry=p});
|