@inweb/viewer-three 25.12.1 → 26.1.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 +52994 -52727
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -3
- package/dist/viewer-three.module.js +1571 -1444
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +4 -4
- package/lib/Viewer/commands/ApplyModelTransform.d.ts +3 -1
- package/lib/Viewer/commands/ClearMarkup.d.ts +2 -1
- package/lib/Viewer/commands/ClearSelected.d.ts +2 -1
- package/lib/Viewer/commands/ClearSlices.d.ts +2 -1
- package/lib/Viewer/commands/CreatePreview.d.ts +2 -1
- package/lib/Viewer/commands/Explode.d.ts +3 -1
- package/lib/Viewer/commands/GetDefaultViewPositions.d.ts +1 -1
- package/lib/Viewer/commands/GetModels.d.ts +2 -1
- package/lib/Viewer/commands/GetSelected.d.ts +2 -1
- package/lib/Viewer/commands/HideSelected.d.ts +2 -1
- package/lib/Viewer/commands/IsolateSelected.d.ts +2 -1
- package/lib/Viewer/commands/RegenerateAll.d.ts +2 -1
- package/lib/Viewer/commands/ResetView.d.ts +2 -1
- package/lib/Viewer/commands/SelectModel.d.ts +2 -1
- package/lib/Viewer/commands/SetActiveDragger.d.ts +2 -1
- package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +2 -0
- package/lib/Viewer/commands/SetMarkupColor.d.ts +2 -1
- package/lib/Viewer/commands/SetSelected.d.ts +2 -1
- package/lib/Viewer/commands/ShowAll.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToExtents.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToObjects.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToSelected.d.ts +2 -1
- package/lib/Viewer/commands/index.d.ts +22 -22
- package/lib/Viewer/components/AxesHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/BackgroundComponent.d.ts +2 -2
- package/lib/Viewer/components/DefaultPositionComponent.d.ts +2 -3
- package/lib/Viewer/components/ExtentsComponent.d.ts +2 -2
- package/lib/Viewer/components/ExtentsHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/LightComponent.d.ts +2 -2
- package/lib/Viewer/components/RenderLoopComponent.d.ts +2 -2
- package/lib/Viewer/components/ResizeCanvasComponent.d.ts +2 -2
- package/lib/Viewer/components/SelectionComponent.d.ts +2 -2
- package/lib/Viewer/components/ViewPositionComponent.d.ts +2 -3
- package/lib/Viewer/components/WCSHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/index.d.ts +40 -0
- package/lib/Viewer/draggers/OrbitDragger.d.ts +2 -2
- package/lib/Viewer/draggers/WalkDragger.d.ts +2 -1
- package/lib/Viewer/draggers/index.d.ts +39 -0
- package/lib/index.d.ts +4 -1
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +37 -68
- package/src/Viewer/commands/ApplyModelTransform.ts +2 -6
- package/src/Viewer/commands/ClearMarkup.ts +3 -3
- package/src/Viewer/commands/ClearSelected.ts +1 -5
- package/src/Viewer/commands/ClearSlices.ts +3 -2
- package/src/Viewer/commands/CreatePreview.ts +1 -4
- package/src/Viewer/commands/Explode.ts +4 -5
- package/src/Viewer/commands/GetDefaultViewPositions.ts +1 -4
- package/src/Viewer/commands/GetModels.ts +2 -6
- package/src/Viewer/commands/GetSelected.ts +1 -4
- package/src/Viewer/commands/HideSelected.ts +1 -4
- package/src/Viewer/commands/IsolateSelected.ts +1 -5
- package/src/Viewer/commands/RegenerateAll.ts +1 -5
- package/src/Viewer/commands/ResetView.ts +1 -4
- package/src/Viewer/commands/SelectModel.ts +1 -4
- package/src/Viewer/commands/SetActiveDragger.ts +2 -3
- package/src/Viewer/commands/SetDefaultViewPosition.ts +1 -26
- package/src/Viewer/commands/SetMarkupColor.ts +3 -5
- package/src/Viewer/commands/SetSelected.ts +1 -4
- package/src/Viewer/commands/ShowAll.ts +1 -4
- package/src/Viewer/commands/ZoomToExtents.ts +1 -6
- package/src/Viewer/commands/ZoomToObjects.ts +1 -5
- package/src/Viewer/commands/ZoomToSelected.ts +1 -5
- package/src/Viewer/commands/index.ts +98 -22
- package/src/Viewer/components/AxesHelperComponent.ts +2 -2
- package/src/Viewer/components/BackgroundComponent.ts +2 -2
- package/src/Viewer/components/DefaultPositionComponent.ts +2 -3
- package/src/Viewer/components/ExtentsComponent.ts +2 -2
- package/src/Viewer/components/ExtentsHelperComponent.ts +2 -2
- package/src/Viewer/components/LightComponent.ts +2 -2
- package/src/Viewer/components/RenderLoopComponent.ts +2 -2
- package/src/Viewer/components/ResizeCanvasComponent.ts +2 -2
- package/src/Viewer/components/SelectionComponent.ts +2 -2
- package/src/Viewer/components/ViewPositionComponent.ts +2 -3
- package/src/Viewer/components/WCSHelperComponent.ts +2 -2
- package/src/Viewer/components/index.ts +91 -0
- package/src/Viewer/draggers/OrbitDragger.ts +3 -2
- package/src/Viewer/draggers/WalkDragger.ts +2 -1
- package/src/Viewer/draggers/index.ts +83 -0
- package/src/index.ts +5 -2
- package/lib/Viewer/IDisposable.d.ts +0 -6
- package/src/Viewer/IDisposable.ts +0 -29
package/dist/viewer-three.min.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
!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,n,i){this._commands.set(t,{id:t,handler:e,thisArg:i,description:n})}registerCommandAlias(t,e){this.registerCommand(e,((e,...n)=>this.executeCommand(t,e,...n)))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach(((e,n)=>t.set(n,e))),t}executeCommand(t,e,...n){const i=this._commands.get(t);if(!i){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:r,thisArg:s}=i,a=r.apply(s,[e,...n]);return null==e||e.emit({type:"command",data:t,args:n}),a}}const n=new Map;function i(t=""){let i=n.get(t);return i||(i=new e,n.set(t,i)),i}function r(){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"}}i("").registerCommand("noop",(()=>{})),i("VisualizeJS").registerCommand("noop",(()=>{})),i("ThreeJS").registerCommand("noop",(()=>{}));class s{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"},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"}}notifierChangeEvent(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}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=s.defaults(),n=t.reduce(((t,n)=>(t[n]=e[n],t)),{});this.data={...this.data,...n}}else this.data={...this.data,...s.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,n=!e&&t.sceneGraph;this._data={...s.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:n},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()}}const a=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],o=a;i("ThreeJS").registerCommand("applyModelTransform",(function(t,e){console.warn("applyModelTransform not implemented")})),i("ThreeJS").registerCommand("clearMarkup",(t=>t.clearOverlay())),i("ThreeJS").registerCommandAlias("clearMarkup","clearOverlay");
|
|
1
|
+
!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,n,i){this._commands.set(t,{id:t,handler:e,thisArg:i,description:n})}registerCommandAlias(t,e){this.registerCommand(e,((e,...n)=>this.executeCommand(t,e,...n)))}getCommand(t){return this._commands.get(t)}getCommands(){const t=new Map;return this._commands.forEach(((e,n)=>t.set(n,e))),t}executeCommand(t,e,...n){const i=this._commands.get(t);if(!i){if(e){if(e.draggers.includes(t))return e.setActiveDragger(t)}return void console.warn(`Command '${t}' not found`)}const{handler:r,thisArg:s}=i,a=r.apply(s,[e,...n]);return null==e||e.emit({type:"command",data:t,args:n}),a}}const n=new Map;function i(t=""){let i=n.get(t);return i||(i=new e,n.set(t,i)),i}class r{constructor(){this._draggers=new Map}registerDragger(t,e){this._draggers.set(t,e)}registerDraggerAlias(t,e){const n=this.getDragger(t);n&&this.registerDragger(e,(t=>n(t)))}getDragger(t){return this._draggers.get(t)}getDraggers(){const t=new Map;return this._draggers.forEach(((e,n)=>t.set(n,e))),t}createDragger(t,e){const n=this.getDragger(t);if(!n)return null;const i=n(e);return i.name=t,i}}const s=new Map;function a(t=""){let e=s.get(t);return e||(e=new r,s.set(t,e)),e}class o{constructor(){this._components=new Map}registerComponent(t,e){this._components.set(t,e)}registerComponentAlias(t,e){const n=this.getComponent(t);n&&this.registerComponent(e,(t=>n(t)))}getComponent(t){return this._components.get(t)}getComponents(){const t=new Map;return this._components.forEach(((e,n)=>t.set(n,e))),t}createComponent(t,e){const n=this.getComponent(t);if(!n)return null;const i=n(e);return i.name=t,i}}const l=new Map;function h(t=""){let e=l.get(t);return e||(e=new o,l.set(t,e)),e}function c(){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"}}class d{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"},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"}}notifierChangeEvent(){console.warn("Options.notifierChangeEvent() has been deprecated since 25.3 and will be removed in a future release, use Options.change() instead."),this.change()}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=d.defaults(),n=t.reduce(((t,n)=>(t[n]=e[n],t)),{});this.data={...this.data,...n}}else this.data={...this.data,...d.defaults()}}get data(){return this._data}set data(t){const e=!!t.enableStreamingMode&&t.enablePartialMode,n=!e&&t.sceneGraph;this._data={...d.defaults(),...this._data,...t,enablePartialMode:e,sceneGraph:n},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()}}const u=["click","contextmenu","dblclick","mousedown","mouseleave","mousemove","mouseup","pointercancel","pointerdown","pointerleave","pointermove","pointerup","touchcancel","touchend","touchmove","touchstart","wheel"],p=u;var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var g,_={exports:{}},v={},y={},x={};function S(){return g||(g=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==f?f:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.16",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:n=>t.Konva.angleDeg?n*e:n,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,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(x)),x}var b,M={};function w(){return b||(b=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=S();class n{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 n(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),n=Math.sin(t),i=this.m[0]*e+this.m[2]*n,r=this.m[1]*e+this.m[3]*n,s=this.m[0]*-n+this.m[2]*e,a=this.m[1]*-n+this.m[3]*e;return this.m[0]=i,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const n=this.m[0]+this.m[2]*e,i=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=n,this.m[1]=i,this.m[2]=r,this.m[3]=s,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],n=this.m[1]*t.m[0]+this.m[3]*t.m[1],i=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=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]=n,this.m[2]=i,this.m[3]=r,this.m[4]=s,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,n=-this.m[1]*t,i=-this.m[2]*t,r=this.m[0]*t,s=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]=n,this.m[2]=i,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const e=this.m[0],n=this.m[1],i=this.m[2],r=this.m[3],s=e*r-n*i,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=n){const t=Math.sqrt(e*e+n*n);a.rotation=n>0?Math.acos(e/t):-Math.acos(e/t),a.scaleX=t,a.scaleY=s/t,a.skewX=(e*i+n*r)/s,a.skewY=0}else if(0!=i||0!=r){const t=Math.sqrt(i*i+r*r);a.rotation=Math.PI/2-(r>0?Math.acos(-i/t):-Math.acos(i/t)),a.scaleX=s/t,a.scaleY=t,a.skewX=0,a.skewY=(e*i+n*r)/s}return a.rotation=t.Util._getRotation(a.rotation),a}}t.Transform=n;let i=Math.PI/180,r=180/Math.PI,s="Konva error: ",a={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]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,l=[];const h="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_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){l.push(t),1===l.length&&h((function(){const t=l;l=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,n){const i=t.Util.createImageElement();i.onload=function(){n(i)},i.src=e},_rgbToHex:(t,e,n)=>((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");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"#"+t},getRGB(t){let e;return t in a?(e=a[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.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:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=a[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,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),i=Number(n[0])/360,r=Number(n[1])/100,s=Number(n[2])/100;let a,o,l;if(0===r)return l=255*s,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};a=s<.5?s*(1+r):s+r-s*r;const h=2*s-a,c=[0,0,0];for(let t=0;t<3;t++)o=i+1/3*-(t-1),o<0&&o++,o>1&&o--,l=6*o<1?h+6*(a-h)*o:2*o<1?a:3*o<2?h+(a-h)*(2/3-o)*6:h,c[t]=255*l;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 n in t)this._isPlainObject(t[n])?e[n]=this.cloneObject(t[n]):this._isArray(t[n])?e[n]=this.cloneArray(t[n]):e[n]=t[n];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*i,radToDeg:t=>t*r,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:n=>e.Konva.angleDeg?t.Util.radToDeg(n):n,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(s+t)},error(t){console.error(s+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const n in t)e(n,t[n])},_inRange:(t,e,n)=>e<=t&&t<n,_getProjectionToSegment(t,e,n,i,r,s){let a,o,l;const h=(t-n)*(t-n)+(e-i)*(e-i);if(0==h)a=t,o=e,l=(r-n)*(r-n)+(s-i)*(s-i);else{const c=((r-t)*(n-t)+(s-e)*(i-e))/h;c<0?(a=t,o=e,l=(t-r)*(t-r)+(e-s)*(e-s)):c>1?(a=n,o=i,l=(n-r)*(n-r)+(i-s)*(i-s)):(a=t+c*(n-t),o=e+c*(i-e),l=(a-r)*(a-r)+(o-s)*(o-s))}return[a,o,l]},_getProjectionToLine(e,n,i){const r=t.Util.cloneObject(e);let s=Number.MAX_VALUE;return n.forEach((function(a,o){if(!i&&o===n.length-1)return;const l=n[(o+1)%n.length],h=t.Util._getProjectionToSegment(a.x,a.y,l.x,l.y,e.x,e.y),c=h[0],d=h[1],u=h[2];u<s&&(r.x=c,r.y=d,s=u)})),r},_prepareArrayForTween(e,n,i){let r,s=[],a=[];if(e.length>n.length){const t=n;n=e,e=t}for(r=0;r<e.length;r+=2)s.push({x:e[r],y:e[r+1]});for(r=0;r<n.length;r+=2)a.push({x:n[r],y:n[r+1]});const o=[];return a.forEach((function(e){const n=t.Util._getProjectionToLine(e,s,i);o.push(n.x),o.push(n.y)})),o},_prepareToStringify(e){let n;e.visitedByCircularReferenceRemoval=!0;for(const i in e)if(e.hasOwnProperty(i)&&e[i]&&"object"==typeof e[i])if(n=Object.getOwnPropertyDescriptor(e,i),e[i].visitedByCircularReferenceRemoval||t.Util._isElement(e[i])){if(!n.configurable)return null;delete e[i]}else if(null===t.Util._prepareToStringify(e[i])){if(!n.configurable)return null;delete e[i]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(const n in e)t[n]=e[n];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,n,i){let r=0,s=0,a=0,o=0;"number"==typeof i?r=s=a=o=Math.min(i,e/2,n/2):(r=Math.min(i[0]||0,e/2,n/2),s=Math.min(i[1]||0,e/2,n/2),o=Math.min(i[2]||0,e/2,n/2),a=Math.min(i[3]||0,e/2,n/2)),t.moveTo(r,0),t.lineTo(e-s,0),t.arc(e-s,s,s,3*Math.PI/2,0,!1),t.lineTo(e,n-o),t.arc(e-o,n-o,o,0,Math.PI/2,!1),t.lineTo(a,n),t.arc(a,n-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(M)),M}var E,T,A={},C={},R={};function P(){if(E)return R;E=1,Object.defineProperty(R,"__esModule",{value:!0}),R.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},R.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},R.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isNumber(t)||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a number.'),t}},R.getNumberOrArrayOfNumbersValidator=function(i){if(t.Konva.isUnminified)return function(t,r){const s=e.Util._isNumber(t),a=e.Util._isArray(t)&&t.length==i;return s||a||e.Util.warn(n(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+i+")"),t}},R.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a number or "auto".'),t}},R.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isString(t)||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a string.'),t}},R.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,i){const r=e.Util._isString(t),s="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return r||s||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a string or a native gradient.'),t}},R.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isFunction(t)||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a function.'),t}},R.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,i){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&t instanceof r||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+i+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a array of numbers.')),t}},R.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,i){return!0===t||!1===t||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a boolean.'),t}},R.getComponentValidator=function(i){if(t.Konva.isUnminified)return function(t,r){return null==t||e.Util.isObject(t)||e.Util.warn(n(t)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+i),t}};const t=S(),e=w();function n(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return R}function L(){return T||(T=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=w(),n=P(),i="get",r="set";t.Factory={addGetterSetter(e,n,i,r,s){t.Factory.addGetter(e,n,i),t.Factory.addSetter(e,n,r,s),t.Factory.addOverloadedGetterSetter(e,n)},addGetter(t,n,r){const s=i+e.Util._capitalize(n);t.prototype[s]=t.prototype[s]||function(){const t=this.attrs[n];return void 0===t?r:t}},addSetter(n,i,s,a){const o=r+e.Util._capitalize(i);n.prototype[o]||t.Factory.overWriteSetter(n,i,s,a)},overWriteSetter(t,n,i,s){const a=r+e.Util._capitalize(n);t.prototype[a]=function(t){return i&&null!=t&&(t=i.call(this,t,n)),this._setAttr(n,t),s&&s.call(this),this}},addComponentsGetterSetter(s,a,o,l,h){let c,d,u=o.length,p=e.Util._capitalize,f=i+p(a),m=r+p(a);s.prototype[f]=function(){const t={};for(c=0;c<u;c++)d=o[c],t[d]=this.getAttr(a+p(d));return t};const g=(0,n.getComponentValidator)(o);s.prototype[m]=function(t){let e,n=this.attrs[a];for(e in l&&(t=l.call(this,t)),g&&g.call(this,t,a),t)t.hasOwnProperty(e)&&this._setAttr(a+p(e),t[e]);return t||o.forEach((t=>{this._setAttr(a+p(t),void 0)})),this._fireChangeEvent(a,n,t),h&&h.call(this),this},t.Factory.addOverloadedGetterSetter(s,a)},addOverloadedGetterSetter(t,n){const s=e.Util._capitalize(n),a=r+s,o=i+s;t.prototype[n]=function(){return arguments.length?(this[a](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(n,r,s,a){e.Util.error("Adding deprecated "+r);const o=i+e.Util._capitalize(r),l=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";n.prototype[o]=function(){e.Util.error(l);const t=this.attrs[r];return void 0===t?s:t},t.Factory.addSetter(n,r,a,(function(){e.Util.error(l)})),t.Factory.addOverloadedGetterSetter(n,r)},backCompat(t,n){e.Util.each(n,(function(n,s){const a=t.prototype[s],o=i+e.Util._capitalize(n),l=r+e.Util._capitalize(n);function h(){a.apply(this,arguments),e.Util.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+s+'" instead.')}t.prototype[n]=h,t.prototype[o]=h,t.prototype[l]=h}))},afterSetFilter(){this._filterUpToDate=!1}}}(C)),C}var I,D,N={},U={};function O(){if(I)return U;I=1,Object.defineProperty(U,"__esModule",{value:!0}),U.HitContext=U.SceneContext=U.Context=void 0;const t=w(),e=S();const n=["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 i=class{constructor(t){this.canvas=t,e.Konva.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(e,n){let i,r,s,a,o=this.traceArr,l=o.length,h="";for(i=0;i<l;i++)r=o[i],s=r.method,s?(a=r.args,h+=s,e?h+="()":t.Util._isArray(a[0])?h+="(["+a.join(",")+"])":(n&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),h+="("+a.join(",")+")")):(h+=r.property,e||(h+="="+r.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,n=this.traceArr;n.push(t),e=n.length,e>=100&&n.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)}setAttr(t,e){this._context[t]=e}arc(t,e,n,i,r,s){this._context.arc(t,e,n,i,r,s)}arcTo(t,e,n,i,r){this._context.arcTo(t,e,n,i,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,n,i,r,s){this._context.bezierCurveTo(t,e,n,i,r,s)}clearRect(t,e,n,i){this._context.clearRect(t,e,n,i)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const n=arguments;return 2===n.length?this._context.createImageData(t,e):1===n.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,n,i){return this._context.createLinearGradient(t,e,n,i)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,n,i,r,s){return this._context.createRadialGradient(t,e,n,i,r,s)}drawImage(t,e,n,i,r,s,a,o,l){const h=arguments,c=this._context;3===h.length?c.drawImage(t,e,n):5===h.length?c.drawImage(t,e,n,i,r):9===h.length&&c.drawImage(t,e,n,i,r,s,a,o,l)}ellipse(t,e,n,i,r,s,a,o){this._context.ellipse(t,e,n,i,r,s,a,o)}isPointInPath(t,e,n,i){return n?this._context.isPointInPath(n,t,e,i):this._context.isPointInPath(t,e,i)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,n,i){this._context.fillRect(t,e,n,i)}strokeRect(t,e,n,i){this._context.strokeRect(t,e,n,i)}fillText(t,e,n,i){i?this._context.fillText(t,e,n,i):this._context.fillText(t,e,n)}measureText(t){return this._context.measureText(t)}getImageData(t,e,n,i){return this._context.getImageData(t,e,n,i)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,n,i){this._context.rect(t,e,n,i)}roundRect(t,e,n,i,r){this._context.roundRect(t,e,n,i,r)}putImageData(t,e,n){this._context.putImageData(t,e,n)}quadraticCurveTo(t,e,n,i){this._context.quadraticCurveTo(t,e,n,i)}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,n,i,r,s){this._context.setTransform(t,e,n,i,r,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,n,i){this._context.strokeText(t,e,n,i)}transform(t,e,n,i,r,s){this._context.transform(t,e,n,i,r,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,i,r=this,s=n.length,a=this.setAttr;const o=function(e){let n,s=r[e];r[e]=function(){return i=function(e){let n,i,r=[],s=e.length,a=t.Util;for(n=0;n<s;n++)i=e[n],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),r.push(i);return r}(Array.prototype.slice.call(arguments,0)),n=s.apply(r,arguments),r._trace({method:e,args:i}),n}};for(e=0;e<s;e++)o(n[e]);r.setAttr=function(){a.apply(r,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),r._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};U.Context=i,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(i.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));U.SceneContext=class extends i{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(),n=t.getFillPriority();if(e&&"color"===n)return void this._fillColor(t);const i=t.getFillPatternImage();if(i&&"pattern"===n)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===n)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===n?this._fillRadialGradient(t):e?this._fillColor(t):i?this._fillPattern(t):r?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),n=t.getStrokeLinearGradientEndPoint(),i=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,n.x,n.y);if(i){for(let t=0;t<i.length;t+=2)r.addColorStop(i[t],i[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),n=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!n){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),n||this.restore()}}_applyShadow(t){var e,n,i;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(n=t.getShadowBlur())&&void 0!==n?n:5,a=null!==(i=t.getShadowOffset())&&void 0!==i?i:{x:0,y:0},o=t.getAbsoluteScale(),l=this.canvas.getPixelRatio(),h=o.x*l,c=o.y*l;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",s*Math.min(Math.abs(h),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*h),this.setAttr("shadowOffsetY",a.y*c)}};return U.HitContext=class extends i{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 n=t.hitStrokeWidth(),i="auto"===n?t.strokeWidth():n;this.setAttr("lineWidth",i),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},U}function F(){if(D)return N;D=1,Object.defineProperty(N,"__esModule",{value:!0}),N.HitCanvas=N.SceneCanvas=N.Canvas=void 0;const t=w(),e=O(),n=S(),i=L(),r=P();let s;let a=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const i=(e||{}).pixelRatio||n.Konva.pixelRatio||function(){if(s)return s;const e=t.Util.createCanvasElement(),i=e.getContext("2d");return s=(n.Konva._global.devicePixelRatio||1)/(i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1),t.Util.releaseCanvas(e),s}();this.pixelRatio=i,this._canvas=t.Util.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(e,n){try{return this._canvas.toDataURL(e,n)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};N.Canvas=a,i.Factory.addGetterSetter(a,"pixelRatio",void 0,(0,r.getNumberValidator)());N.SceneCanvas=class extends a{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return N.HitCanvas=class extends a{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},N}var k,B,z={};function G(){return k||(k=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=S(),n=w();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const i=[];t.DD._dragElements.forEach(((t,r)=>{const{node:s}=t,a=s.getStage();a.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=n.Util._getFirstPointerId(e));const o=a._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){const n=s.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<n)return;if(s.startDrag({evt:e}),!s.isDragging())return}s._setDragPosition(e,t),i.push(s)}})),i.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(n){const i=[];t.DD._dragElements.forEach((r=>{const{node:s}=r,a=s.getStage();n&&a.setPointersPositions(n);if(!a._changedPointerPositions.find((t=>t.id===r.pointerId)))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");const o=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;o&&-1===i.indexOf(o)&&i.push(o)})),i.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((n,i)=>{"stopped"===n.dragStatus&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:e},!0),"dragging"!==n.dragStatus&&t.DD._dragElements.delete(i)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(z)),z}function H(){if(B)return A;B=1,Object.defineProperty(A,"__esModule",{value:!0}),A.Node=void 0;const t=w(),e=L(),n=F(),i=S(),r=G(),s=P(),a="absoluteOpacity",o="allEventListeners",l="absoluteTransform",h="absoluteScale",c="canvas",d="listening",u="mouseenter",p="mouseleave",f="Shape",m=" ",g="stage",_="transform",v="visible",y=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(m);let x=1,b=class e{constructor(t){this._id=x++,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!==_&&t!==l||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let n=this._cache.get(t);return(void 0===n||(t===_||t===l)&&!0===n.dirty)&&(n=e.call(this),this._cache.set(t,n)),n}_calculate(t,e,n){if(!this._attachedDepsListeners.get(t)){const n=e.map((t=>t+"Change.konva")).join(m);this.on(n,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,n)}_getCanvasCache(){return this._cache.get(c)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===l&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(c)){const{scene:e,filter:n,hit:i}=this._cache.get(c);t.Util.releaseCanvas(e,n,i),this._cache.delete(c)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const i=e||{};let r={};void 0!==i.x&&void 0!==i.y&&void 0!==i.width&&void 0!==i.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let s=Math.ceil(i.width||r.width),o=Math.ceil(i.height||r.height),l=i.pixelRatio,d=void 0===i.x?Math.floor(r.x):i.x,u=void 0===i.y?Math.floor(r.y):i.y,p=i.offset||0,f=i.drawBorder||!1,m=i.hitCanvasPixelRatio||1;if(!s||!o)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");s+=2*p+(Math.abs(Math.round(r.x)-d)>.5?1:0),o+=2*p+(Math.abs(Math.round(r.y)-u)>.5?1:0),d-=p,u-=p;const g=new n.SceneCanvas({pixelRatio:l,width:s,height:o}),_=new n.SceneCanvas({pixelRatio:l,width:0,height:0,willReadFrequently:!0}),v=new n.HitCanvas({pixelRatio:m,width:s,height:o}),y=g.getContext(),x=v.getContext();return v.isCache=!0,g.isCache=!0,this._cache.delete(c),this._filterUpToDate=!1,!1===i.imageSmoothingEnabled&&(g.getContext()._context.imageSmoothingEnabled=!1,_.getContext()._context.imageSmoothingEnabled=!1),y.save(),x.save(),y.translate(-d,-u),x.translate(-d,-u),this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(h),this.drawScene(g,this),this.drawHit(v,this),this._isUnderCache=!1,y.restore(),x.restore(),f&&(y.save(),y.beginPath(),y.rect(0,0,s,o),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),this._cache.set(c,{scene:g,filter:_,hit:v,x:d,y:u}),this._requestDraw(),this}isCached(){return this._cache.has(c)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const n=[{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 i=1/0,r=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return n.forEach((function(t){const e=o.point(t);void 0===i&&(i=s=e.x,r=a=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)})),{x:i,y:r,width:s-i,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const n=this._getCachedSceneCanvas(),i=n.pixelRatio;t.drawImage(n._canvas,0,0,n.width/i,n.height/i),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),n=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),t.restore()}_getCachedSceneCanvas(){let e,n,i,r,s=this.filters(),a=this._getCanvasCache(),o=a.scene,l=a.filter,h=l.getContext();if(s){if(!this._filterUpToDate){const a=o.pixelRatio;l.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(e=s.length,h.clear(),h.drawImage(o._canvas,0,0,o.getWidth()/a,o.getHeight()/a),n=h.getImageData(0,0,l.getWidth(),l.getHeight()),i=0;i<e;i++)r=s[i],"function"==typeof r?(r.call(this,n),h.putImageData(n,0,0)):t.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return l}return o}on(t,e){if(this._cache&&this._cache.delete(o),3===arguments.length)return this._delegate.apply(this,arguments);let n,i,r,s,a,l=t.split(m),h=l.length;for(n=0;n<h;n++)i=l[n],r=i.split("."),s=r[0],a=r[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){let n,i,r,s,a,l,h=(t||"").split(m),c=h.length;if(this._cache&&this._cache.delete(o),!t)for(i in this.eventListeners)this._off(i);for(n=0;n<c;n++)if(r=h[n],s=r.split("."),a=s[0],l=s[1],a)this.eventListeners[a]&&this._off(a,l,e);else for(i in this.eventListeners)this._off(i,l,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(e,n,i){const r=this;this.on(e,(function(e){const s=e.target.findAncestors(n,!0,r);for(let n=0;n<s.length;n++)(e=t.Util.cloneObject(e)).currentTarget=s[n],i.call(s[n],e)}))}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(g),this._clearSelfAndDescendantCache(v),this._clearSelfAndDescendantCache(d)}_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(e){const n="get"+t.Util._capitalize(e);return t.Util._isFunction(this[n])?this[n]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let n,i;if(!e)return this;for(n in e)"children"!==n&&(i="set"+t.Util._capitalize(n),t.Util._isFunction(this[i])?this[i](e[n]):this._setAttr(n,e[n]))})),this}isListening(){return this._getCache(d,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(v,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 n=this.getLayer();let s=!1;r.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===n)&&(s=!0)}));const a=!e&&!i.Konva.hitOnDragEnabled&&(s||i.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,n,i,r=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(l){for(t=[],e=l.length,n=0;n<e;n++)i=l[n],a++,i.nodeType!==f&&(t=t.concat(i.getChildren().slice())),i._id===s._id&&(n=e);t.length>0&&t[0].getDepth()<=r&&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(_),this._clearSelfAndDescendantCache(l)),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 n=this.getAbsoluteTransform().copy();return n.invert(),n.point(e)}getAbsolutePosition(e){let n=!1,i=this.parent;for(;i;){if(i.isCached()){n=!0;break}i=i.parent}n&&!e&&(e=!0);const r=this.getAbsoluteTransform(e).getMatrix(),s=new t.Transform,a=this.offset();return s.m=r.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:n,...i}=this._clearTransform();this.attrs.x=e,this.attrs.y=n,this._clearCache(_);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(i),this.setPosition({x:t.x,y:t.y}),this._clearCache(_),this._clearSelfAndDescendantCache(l),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,n=t.y,i=this.x(),r=this.y();return void 0!==e&&(i+=e),void 0!==n&&(r+=n),this.setPosition({x:i,y:r}),this}_eachAncestorReverse(t,e){let n,i,r=[],s=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);s&&(!e||s._id!==e._id);)r.unshift(s),s=s.parent;for(n=r.length,i=0;i<n;i++)t(r[i])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" 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 n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(a,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 e,n,i,r,s,a=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(e in a)n=a[e],s=t.Util.isObject(n)&&!t.Util._isPlainObject(n)&&!t.Util._isArray(n),s||(i="function"==typeof this[e]&&this[e],delete a[e],r=i?i.call(this):null,a[e]=n,r!==n&&(o.attrs[e]=n));return t.Util._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,n){const i=[];e&&this._isMatch(t)&&i.push(this);let r=this.parent;for(;r;){if(r===n)return i;r._isMatch(t)&&i.push(r),r=r.parent}return i}isAncestorOf(t){return!1}findAncestor(t,e,n){return this.findAncestors(t,e,n)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);let n,i,r=e.replace(/ /g,"").split(","),s=r.length;for(n=0;n<s;n++)if(i=r[n],t.Util.isValidSelector(i)||(t.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.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(g,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},n){return e.target=e.target||this,n?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(l,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let n;if(e)return n=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?n.multiply(t.getTransform()):"position"===e&&n.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),n;{n=this._cache.get(l)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const e=this.transformsEnabled();if("all"===e)n.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,i=this.attrs.offsetX||0,r=this.attrs.offsetY||0;n.translate(t-i,e-r)}return n.dirty=!1,n}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const n=this.getAbsoluteTransform(t).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(_,this._getTransform)}_getTransform(){var e,n;const r=this._cache.get(_)||new t.Transform;r.reset();const s=this.x(),a=this.y(),o=i.Konva.getAngle(this.rotation()),l=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,h=null!==(n=this.attrs.scaleY)&&void 0!==n?n:1,c=this.attrs.skewX||0,d=this.attrs.skewY||0,u=this.attrs.offsetX||0,p=this.attrs.offsetY||0;return 0===s&&0===a||r.translate(s,a),0!==o&&r.rotate(o),0===c&&0===d||r.skew(c,d),1===l&&1===h||r.scale(l,h),0===u&&0===p||r.translate(-1*u,-1*p),r.dirty=!1,r}clone(e){let n,i,r,s,a,o=t.Util.cloneObject(this.attrs);for(n in e)o[n]=e[n];const l=new this.constructor(o);for(n in this.eventListeners)for(i=this.eventListeners[n],r=i.length,s=0;s<r;s++)a=i[s],a.name.indexOf("konva")<0&&(l.eventListeners[n]||(l.eventListeners[n]=[]),l.eventListeners[n].push(a));return l}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new n.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:a}),l=o.getContext(),h=new n.SceneCanvas({width:o.width/o.pixelRatio+Math.abs(r),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return!1===t.imageSmoothingEnabled&&(l._context.imageSmoothingEnabled=!1),l.save(),(r||s)&&l.translate(-1*r,-1*s),this.drawScene(o,void 0,h),l.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,n=t.quality||null,i=this._toKonvaCanvas(t).toDataURL(e,n);return t.callback&&t.callback(i),i}toImage(e){return new Promise(((n,i)=>{try{const i=null==e?void 0:e.callback;i&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){n(t),null==i||i(t)}))}catch(t){i(t)}}))}toBlob(t){return new Promise(((e,n)=>{try{const n=null==t?void 0:t.callback;n&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==n||n(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){n(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():i.Konva.dragDistance}_off(t,e,n){let i,r,s,a=this.eventListeners[t];for(i=0;i<a.length;i++)if(r=a[i].name,s=a[i].handler,!("konva"===r&&"konva"!==e||e&&r!==e||n&&n!==s)){if(a.splice(i,1),0===a.length){delete this.eventListeners[t];break}i--}}_fireChangeEvent(t,e,n){this._fire(t+"Change",{oldVal:e,newVal:n})}addName(t){if(!this.hasName(t)){const e=this.name(),n=e?e+" "+t:t;this.name(n)}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),n=e.indexOf(t);return-1!==n&&(e.splice(n,1),this.name(e.join(" "))),this}setAttr(e,n){const i=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(i)?i.call(this,n):this._setAttr(e,n),this}_requestDraw(){if(i.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,n){const i=this.attrs[e];(i!==n||t.Util.isObject(n))&&(null==n?delete this.attrs[e]:this.attrs[e]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(e,i,n),this._requestDraw())}_setComponentAttr(t,e,n){let i;void 0!==n&&(i=this.attrs[t],i||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=n,this._fireChangeEvent(t,i,n))}_fireAndBubble(t,e,n){e&&this.nodeType===f&&(e.target=this);if(!((t===u||t===p)&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n))){this._fire(t,e);const i=(t===u||t===p)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!i&&(n&&n.parent?this._fireAndBubble.call(this.parent,t,e,n):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,n,i;const r=null!==(e=this._cache.get(o))&&void 0!==e?e:{};let s=null==r?void 0:r[t];if(void 0===s){s=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(i=null===(n=e.eventListeners)||void 0===n?void 0:n[t])&&void 0!==i?i:[];s.push(...r),e=Object.getPrototypeOf(e)}r[t]=s,this._cache.set(o,r)}return s}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const n=this._getProtoListeners(t);if(n)for(var i=0;i<n.length;i++)n[i].handler.call(this,e);const r=this.eventListeners[t];if(r)for(i=0;i<r.length;i++)r[i].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,n=this.getStage(),i=this.getAbsolutePosition();if(!n)return;const s=n._getPointerById(e)||n._changedPointerPositions[0]||i;r.DD._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-i.x,y:s.y-i.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){r.DD._dragElements.has(this._id)||this._createDragElement(t);r.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(e,n){const i=this.getStage()._getPointerById(n.pointerId);if(!i)return;let r={x:i.x-n.offset.x,y:i.y-n.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const n=s.call(this,r,e);n?r=n:t.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=r.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),r.DD._endDragBefore(t),r.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=r.DD._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)||i.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;r.DD._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=r.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,n=t&&"ready"===t.dragStatus;e?this.stopDrag():n&&r.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const n=this.getStage();if(!n)return!1;const i={x:-e.x,y:-e.y,width:n.width()+2*e.x,height:n.height()+2*e.y};return t.Util.haveIntersection(i,this.getClientRect())}static create(e,n){return t.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,n)}static _createNode(n,r){let s,a,o,l=e.prototype.getClassName.call(n),h=n.children;r&&(n.attrs.container=r),i.Konva[l]||(t.Util.warn('Can not find a node with class name "'+l+'". Fallback to "Shape".'),l="Shape");if(s=new(0,i.Konva[l])(n.attrs),h)for(a=h.length,o=0;o<a;o++)s.add(e._createNode(h[o]));return s}};A.Node=b,b.prototype.nodeType="Node",b.prototype._attrsAffectingSize=[],b.prototype.eventListeners={},b.prototype.on.call(b.prototype,y,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(_),this._clearSelfAndDescendantCache(l))})),b.prototype.on.call(b.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(v)})),b.prototype.on.call(b.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(d)})),b.prototype.on.call(b.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(a)}));const M=e.Factory.addGetterSetter;return M(b,"zIndex"),M(b,"absolutePosition"),M(b,"position"),M(b,"x",0,(0,s.getNumberValidator)()),M(b,"y",0,(0,s.getNumberValidator)()),M(b,"globalCompositeOperation","source-over",(0,s.getStringValidator)()),M(b,"opacity",1,(0,s.getNumberValidator)()),M(b,"name","",(0,s.getStringValidator)()),M(b,"id","",(0,s.getStringValidator)()),M(b,"rotation",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"scale",["x","y"]),M(b,"scaleX",1,(0,s.getNumberValidator)()),M(b,"scaleY",1,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"skew",["x","y"]),M(b,"skewX",0,(0,s.getNumberValidator)()),M(b,"skewY",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(b,"offset",["x","y"]),M(b,"offsetX",0,(0,s.getNumberValidator)()),M(b,"offsetY",0,(0,s.getNumberValidator)()),M(b,"dragDistance",null,(0,s.getNumberValidator)()),M(b,"width",0,(0,s.getNumberValidator)()),M(b,"height",0,(0,s.getNumberValidator)()),M(b,"listening",!0,(0,s.getBooleanValidator)()),M(b,"preventDefault",!0,(0,s.getBooleanValidator)()),M(b,"filters",null,(function(t){return this._filterUpToDate=!1,t})),M(b,"visible",!0,(0,s.getBooleanValidator)()),M(b,"transformsEnabled","all",(0,s.getStringValidator)()),M(b,"size"),M(b,"dragBoundFunc"),M(b,"draggable",!1,(0,s.getBooleanValidator)()),e.Factory.backCompat(b,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),A}var V,W={};function X(){if(V)return W;V=1,Object.defineProperty(W,"__esModule",{value:!0}),W.Container=void 0;const t=L(),e=H(),n=P();let i=class extends e.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[],n=[];return e.forEach((function(e){t(e)&&n.push(e)})),n}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 n=[];return this._descendants((i=>{const r=i._isMatch(t);return r&&n.push(i),!(!r||!e)})),n}_descendants(t){let e=!1;const n=this.getChildren();for(const i of n){if(e=t(i),e)return!0;if(i.hasChildren()&&(e=i._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.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 n=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){n.add(t.clone())})),n}getAllIntersections(t){const e=[];return this.find("Shape").forEach((n=>{n.isVisible()&&n.intersects(t)&&e.push(n)})),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,n){const i=this.getLayer(),r=t||i&&i.getCanvas(),s=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,l=r&&r.isCache;if(!this.isVisible()&&!l)return this;if(o){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore()}else this._drawChildren("drawScene",r,e,n);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const n=this.getLayer(),i=t||n&&n.hitCanvas,r=i&&i.getContext(),s=this._getCanvasCache();if(s&&s.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",i,e);return this}_drawChildren(t,e,n,i){var r;const s=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),l=this.clipFunc(),h="number"==typeof a&&"number"==typeof o||l,c=n===this;if(h){s.save();const t=this.getAbsoluteTransform(n);let e,i=t.getMatrix();if(s.transform(i[0],i[1],i[2],i[3],i[4],i[5]),s.beginPath(),l)e=l.call(this,s,this);else{const t=this.clipX(),e=this.clipY();s.rect(t||0,e||0,a,o)}s.clip.apply(s,e),i=t.copy().invert().getMatrix(),s.transform(i[0],i[1],i[2],i[3],i[4],i[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(s.save(),s._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[t](e,n,i)})),d&&s.restore(),h&&s.restore()}getClientRect(t={}){var e;const n=t.skipTransform,i=t.relativeTo;let r,s,a,o,l={x:1/0,y:1/0,width:0,height:0};const h=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const n=e.getClientRect({relativeTo:h,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===n.width&&0===n.height||(void 0===r?(r=n.x,s=n.y,a=n.x+n.width,o=n.y+n.height):(r=Math.min(r,n.x),s=Math.min(s,n.y),a=Math.max(a,n.x+n.width),o=Math.max(o,n.y+n.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 l=d&&void 0!==r?{x:r,y:s,width:a-r,height:o-s}:{x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,i)}};return W.Container=i,t.Factory.addComponentsGetterSetter(i,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(i,"clipX",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipY",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipWidth",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipHeight",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipFunc"),W}var j,Y,q={},K={};function Z(){if(j)return K;j=1,Object.defineProperty(K,"__esModule",{value:!0}),K.getCapturedShape=function(t){return e.get(t)},K.createEvent=i,K.hasPointerCapture=function(t,n){return e.get(t)===n},K.setPointerCapture=function(t,s){r(t);if(!s.getStage())return;e.set(t,s),n&&s._fire("gotpointercapture",i(new PointerEvent("gotpointercapture")))},K.releaseCapture=r;const t=S(),e=new Map,n=void 0!==t.Konva._global.PointerEvent;function i(t){return{evt:t,pointerId:t.pointerId}}function r(t,r){const s=e.get(t);if(!s)return;const a=s.getStage();a&&a.content,e.delete(t),n&&s._fire("lostpointercapture",i(new PointerEvent("lostpointercapture")))}return K}var Q,J,$={},tt={};function et(){return Q||(Q=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=S(),n=w(),i=L(),r=H(),s=P(),a=S(),o=Z(),l="hasShadow",h="shadowRGBA",c="patternImage",d="linearGradient",u="radialGradient";let p;function f(){return p||(p=n.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class m extends r.Node{constructor(e){let i;for(super(e);i=n.Util.getRandomColor(),!i||i in t.shapes;);this.colorKey=i,t.shapes[i]=this}getContext(){return n.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return n.Util.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(l,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(c,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=f().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const i=new n.Transform;i.translate(this.fillPatternX(),this.fillPatternY()),i.rotate(e.Konva.getAngle(this.fillPatternRotation())),i.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),i.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=i.getMatrix(),s="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(d,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=f(),n=this.fillLinearGradientStartPoint(),i=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(n.x,n.y,i.x,i.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=f(),n=this.fillRadialGradientStartPoint(),i=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),i.x,i.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(h,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=n.Util.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 n=e.bufferHitCanvas;n.getContext().clear(),this.drawHit(n,void 0,!0);return n.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return r.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const n=t||this.hasFill(),i=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(n&&i&&r)return!0;const s=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(n&&i&&s&&a)}setStrokeHitEnabled(t){n.Util.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,n=this.getParent();for(;n;){if(n.isCached()){e=!0;break}n=n.getParent()}const i=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,s=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,l=s.height+a,h=!t.skipShadow&&this.hasShadow(),c=h?this.shadowOffsetX():0,d=h?this.shadowOffsetY():0,u=o+Math.abs(c),p=l+Math.abs(d),f=h&&this.shadowBlur()||0,m={width:u+2*f,height:p+2*f,x:-(a/2+f)+Math.min(c,0)+s.x,y:-(a/2+f)+Math.min(d,0)+s.y};return i?m:this._transformedRect(m,r)}drawScene(t,e,n){const i=this.getLayer();let r,s,a=t||i.getCanvas(),o=a.getContext(),l=this._getCanvasCache(),h=this.getSceneFunc(),c=this.hasShadow();const d=a.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(l){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!h)return this;if(o.save(),this._useBufferCanvas()&&!d){r=this.getStage();const t=n||r.bufferCanvas;s=t.getContext(),s.clear(),s.save(),s._applyLineJoin(this);var p=this.getAbsoluteTransform(e).getMatrix();s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),h.call(this,s,this),s.restore();const i=t.pixelRatio;c&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/i,t.height/i)}else{if(o._applyLineJoin(this),!u){p=this.getAbsoluteTransform(e).getMatrix();o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}c&&o._applyShadow(this),h.call(this,o,this)}return o.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const r=this.getLayer(),s=t||r.hitCanvas,a=s&&s.getContext(),o=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),h=l&&l.hit;if(this.colorKey||n.Util.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){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;a.save(),a._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(t=0){let e,i,r,s,a,o,l=this._getCanvasCache(),h=this._getCachedSceneCanvas(),c=l.hit,d=c.getContext(),u=c.getWidth(),p=c.getHeight();d.clear(),d.drawImage(h._canvas,0,0,u,p);try{for(e=d.getImageData(0,0,u,p),i=e.data,r=i.length,s=n.Util._hexToRgb(this.colorKey),a=0;a<r;a+=4)o=i[a+3],o>t?(i[a]=s.r,i[a+1]=s.g,i[a+2]=s.b,i[a+3]=255):i[a+3]=0;d.putImageData(e,0,0)}catch(t){n.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=m,m.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFunc=function(t){t.stroke()},m.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFuncHit=function(t){t.stroke()},m.prototype._centroid=!1,m.prototype.nodeType="Shape",(0,a._registerNode)(m),m.prototype.eventListeners={},m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(c)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(d)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),i.Factory.addGetterSetter(m,"stroke",void 0,(0,s.getStringOrGradientValidator)()),i.Factory.addGetterSetter(m,"strokeWidth",2,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillAfterStrokeEnabled",!1),i.Factory.addGetterSetter(m,"hitStrokeWidth","auto",(0,s.getNumberOrAutoValidator)()),i.Factory.addGetterSetter(m,"strokeHitEnabled",!0,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(m,"perfectDrawEnabled",!0,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(m,"shadowForStrokeEnabled",!0,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(m,"lineJoin"),i.Factory.addGetterSetter(m,"lineCap"),i.Factory.addGetterSetter(m,"sceneFunc"),i.Factory.addGetterSetter(m,"hitFunc"),i.Factory.addGetterSetter(m,"dash"),i.Factory.addGetterSetter(m,"dashOffset",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"shadowColor",void 0,(0,s.getStringValidator)()),i.Factory.addGetterSetter(m,"shadowBlur",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"shadowOpacity",1,(0,s.getNumberValidator)()),i.Factory.addComponentsGetterSetter(m,"shadowOffset",["x","y"]),i.Factory.addGetterSetter(m,"shadowOffsetX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"shadowOffsetY",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternImage"),i.Factory.addGetterSetter(m,"fill",void 0,(0,s.getStringOrGradientValidator)()),i.Factory.addGetterSetter(m,"fillPatternX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternY",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillLinearGradientColorStops"),i.Factory.addGetterSetter(m,"strokeLinearGradientColorStops"),i.Factory.addGetterSetter(m,"fillRadialGradientStartRadius",0),i.Factory.addGetterSetter(m,"fillRadialGradientEndRadius",0),i.Factory.addGetterSetter(m,"fillRadialGradientColorStops"),i.Factory.addGetterSetter(m,"fillPatternRepeat","repeat"),i.Factory.addGetterSetter(m,"fillEnabled",!0),i.Factory.addGetterSetter(m,"strokeEnabled",!0),i.Factory.addGetterSetter(m,"shadowEnabled",!0),i.Factory.addGetterSetter(m,"dashEnabled",!0),i.Factory.addGetterSetter(m,"strokeScaleEnabled",!0),i.Factory.addGetterSetter(m,"fillPriority","color"),i.Factory.addComponentsGetterSetter(m,"fillPatternOffset",["x","y"]),i.Factory.addGetterSetter(m,"fillPatternOffsetX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternOffsetY",0,(0,s.getNumberValidator)()),i.Factory.addComponentsGetterSetter(m,"fillPatternScale",["x","y"]),i.Factory.addGetterSetter(m,"fillPatternScaleX",1,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternScaleY",1,(0,s.getNumberValidator)()),i.Factory.addComponentsGetterSetter(m,"fillLinearGradientStartPoint",["x","y"]),i.Factory.addComponentsGetterSetter(m,"strokeLinearGradientStartPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillLinearGradientStartPointX",0),i.Factory.addGetterSetter(m,"strokeLinearGradientStartPointX",0),i.Factory.addGetterSetter(m,"fillLinearGradientStartPointY",0),i.Factory.addGetterSetter(m,"strokeLinearGradientStartPointY",0),i.Factory.addComponentsGetterSetter(m,"fillLinearGradientEndPoint",["x","y"]),i.Factory.addComponentsGetterSetter(m,"strokeLinearGradientEndPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillLinearGradientEndPointX",0),i.Factory.addGetterSetter(m,"strokeLinearGradientEndPointX",0),i.Factory.addGetterSetter(m,"fillLinearGradientEndPointY",0),i.Factory.addGetterSetter(m,"strokeLinearGradientEndPointY",0),i.Factory.addComponentsGetterSetter(m,"fillRadialGradientStartPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillRadialGradientStartPointX",0),i.Factory.addGetterSetter(m,"fillRadialGradientStartPointY",0),i.Factory.addComponentsGetterSetter(m,"fillRadialGradientEndPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillRadialGradientEndPointX",0),i.Factory.addGetterSetter(m,"fillRadialGradientEndPointY",0),i.Factory.addGetterSetter(m,"fillPatternRotation",0),i.Factory.addGetterSetter(m,"fillRule",void 0,(0,s.getStringValidator)()),i.Factory.backCompat(m,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(tt)),tt}function nt(){if(J)return $;J=1,Object.defineProperty($,"__esModule",{value:!0}),$.Layer=void 0;const t=w(),e=X(),n=H(),i=L(),r=F(),s=P(),a=et(),o=S(),l=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],h=l.length;let c=class extends e.Container{constructor(t){super(t),this.canvas=new r.SceneCanvas,this.hitCanvas=new r.HitCanvas({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(){n.Node.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(!n.Node.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(n.Node.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(n.Node.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 e=this.getNativeCanvasElement();return n.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),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(e){const n=e.getType();"Group"!==n&&"Shape"!==n&&t.Util.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(),n.Node.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(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,n=!1;for(;;){for(let i=0;i<h;i++){const r=l[i],s=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),a=s.shape;if(a)return a;if(n=!!s.antialiased,!s.antialiased)break}if(!n)return null;e+=1}}_getIntersection(e){const n=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(e.x*n),Math.round(e.y*n),1,1).data,r=i[3];if(255===r){const e=t.Util._rgbToHex(i[0],i[1],i[2]),n=a.shapes["#"+e];return n?{shape:n}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,n){const i=this.getLayer(),r=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),e.Container.prototype.drawScene.call(this,r,n),this._fire("draw",{node:this}),this}drawHit(t,n){const i=this.getLayer(),r=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,r,n),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.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 t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return $.Layer=c,c.prototype.nodeType="Layer",(0,o._registerNode)(c),i.Factory.addGetterSetter(c,"imageSmoothingEnabled",!0),i.Factory.addGetterSetter(c,"clearBeforeDraw",!0),i.Factory.addGetterSetter(c,"hitGraphEnabled",!0,(0,s.getBooleanValidator)()),$}var it,rt={};var st,at={};function ot(){if(st)return at;st=1,Object.defineProperty(at,"__esModule",{value:!0}),at.Group=void 0;const t=w(),e=X(),n=S();class i extends e.Container{_validateAdd(e){const n=e.getType();"Group"!==n&&"Shape"!==n&&t.Util.throw("You may only add groups and shapes to groups.")}}return at.Group=i,i.prototype.nodeType="Group",(0,n._registerNode)(i),at}var lt,ht={};function ct(){if(lt)return ht;lt=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.Animation=void 0;const t=S(),e=w(),n=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let i=class t{constructor(e,i){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:n(),frameRate:0},this.func=e,this.setLayers(i)}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,n=e.length;for(let i=0;i<n;i++)if(e[i]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,n=e.length;for(let t=0;t<n;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=n(),t._addAnimation(this),this}stop(){return t._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,n=this.animations,i=n.length;for(let t=0;t<i;t++)if(n[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 r=e[i],s=r.layers,a=r.func;r._updateFrameObject(n());const o=s.length;let l;if(l=!a||!1!==a.call(r,r.frame),l)for(let e=0;e<o;e++){const n=s[e];void 0!==n._id&&(t[n._id]=n)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const n=t;n.animations.length?(n._runFrames(),e.Util.requestAnimFrame(n._animationLoop)):n.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return ht.Animation=i,i.animations=[],i.animIdCounter=0,i.animRunning=!1,ht}var dt,ut,pt={};function ft(){return ut||(ut=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=S(),n=w(),i=H(),r=X(),s=(Y||(Y=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=w(),n=L(),i=X(),r=S(),s=F(),a=G(),o=S(),l=Z(),h="mouseleave",c="mouseover",d="mouseenter",u="mousemove",p="mousedown",f="mouseup",m="pointermove",g="pointerdown",_="pointerup",v="pointercancel",y="pointerout",x="pointerleave",b="pointerover",M="pointerenter",E="contextmenu",T="touchstart",A="touchend",C="touchmove",R="touchcancel",P="wheel",I=[[d,"_pointerenter"],[p,"_pointerdown"],[u,"_pointermove"],[f,"_pointerup"],[h,"_pointerleave"],[T,"_pointerdown"],[C,"_pointermove"],[A,"_pointerup"],[R,"_pointercancel"],[c,"_pointerover"],[P,"_wheel"],[E,"_contextmenu"],[g,"_pointerdown"],[m,"_pointermove"],[_,"_pointerup"],[v,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],D={mouse:{[y]:"mouseout",[x]:h,[b]:c,[M]:d,[m]:u,[g]:p,[_]:f,[v]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[x]:"touchleave",[b]:"touchover",[M]:"touchenter",[m]:C,[g]:T,[_]:A,[v]:R,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[x]:x,[b]:b,[M]:M,[m]:m,[g]:g,[_]:_,[v]:v,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},N=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",U=t=>{const e=N(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&D.pointer:"touch"===e?D.touch:"mouse"===e?D.mouse:void 0};function O(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class k extends i.Container{constructor(e){super(O(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{O(this.attrs)})),this._checkVisibility()}_validateAdd(t){const n="Layer"===t.getType(),i="FastLayer"===t.getType();n||i||e.Util.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){if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var e;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(){let t,e=this.children,n=e.length;for(t=0;t<n;t++)e[t].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),i.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const n=this.content;n&&e.Util._isInDocument(n)&&this.container().removeChild(n);const i=t.stages.indexOf(this);return i>-1&&t.stages.splice(i,1),e.Util.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}:(e.Util.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 s.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),n=e.getContext()._context,i=this.children;return(t.x||t.y)&&n.translate(-1*t.x,-1*t.y),i.forEach((function(e){if(!e.isVisible())return;const i=e._toKonvaCanvas(t);n.drawImage(i._canvas,t.x,t.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())})),e}getIntersection(t){if(!t)return null;let e,n=this.children;for(e=n.length-1;e>=0;e--){const i=n[e].getIntersection(t);if(i)return i}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((n=>{n.setSize({width:t,height:e}),n.draw()}))}add(t,...n){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&&e.Util.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(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return l.hasPointerCapture(t,this)}setPointerCapture(t){l.setPointerCapture(t,this)}releaseCapture(t){l.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){r.Konva.isBrowser&&I.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=U(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=U(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=U(t.type),n=N(t.type);if(!e)return;this.setPointersPositions(t);const i=this._getTargetShape(n),s=!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled;i&&s?(i._fireAndBubble(e.pointerout,{evt:t}),i._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"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=U(t.type),n=N(t.type);if(!e)return;this.setPointersPositions(t);let i=!1;this._changedPointerPositions.forEach((s=>{const o=this.getIntersection(s);if(a.DD.justDragged=!1,r.Konva["_"+n+"ListenClick"]=!0,!o||!o.isListening())return void(this[n+"ClickStartShape"]=void 0);r.Konva.capturePointerEventsEnabled&&o.setPointerCapture(s.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),i=!0;const l=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&l&&t.preventDefault()})),i||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=U(t.type),n=N(t.type);if(!e)return;if(r.Konva.isDragging()&&a.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(r.Konva.isDragging()||r.Konva.isTransforming())&&!r.Konva.hitOnDragEnabled)return;const i={};let s=!1;const o=this._getTargetShape(n);this._changedPointerPositions.forEach((r=>{const a=l.getCapturedShape(r.id)||this.getIntersection(r),h=r.id,c={evt:t,pointerId:h},d=o!==a;if(d&&o&&(o._fireAndBubble(e.pointerout,{...c},a),o._fireAndBubble(e.pointerleave,{...c},a)),a){if(i[a._id])return;i[a._id]=!0}a&&a.isListening()?(s=!0,d&&(a._fireAndBubble(e.pointerover,{...c},o),a._fireAndBubble(e.pointerenter,{...c},o),this[n+"targetShape"]=a),a._fireAndBubble(e.pointermove,{...c})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[n+"targetShape"]=null)})),s||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=U(t.type),n=N(t.type);if(!e)return;this.setPointersPositions(t);const i=this[n+"ClickStartShape"],s=this[n+"ClickEndShape"],o={};let h=!1;this._changedPointerPositions.forEach((c=>{const d=l.getCapturedShape(c.id)||this.getIntersection(c);if(d){if(d.releaseCapture(c.id),o[d._id])return;o[d._id]=!0}const u=c.id,p={evt:t,pointerId:u};let f=!1;r.Konva["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(this[n+"DblTimeout"])):a.DD.justDragged||(r.Konva["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout((function(){r.Konva["_"+n+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),d&&d.isListening()?(h=!0,this[n+"ClickEndShape"]=d,d._fireAndBubble(e.pointerup,{...p}),r.Konva["_"+n+"ListenClick"]&&i&&i===d&&(d._fireAndBubble(e.pointerclick,{...p}),f&&s&&s===d&&d._fireAndBubble(e.pointerdblclick,{...p}))):(this[n+"ClickEndShape"]=null,r.Konva["_"+n+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),h||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(E,{evt:t}):this._fire(E,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(P,{evt:t}):this._fire(P,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=l.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(_,l.createEvent(t)),l.releaseCapture(t.pointerId)}_lostpointercapture(t){l.releaseCapture(t.pointerId)}setPointersPositions(t){let n=this._getContentPosition(),i=null,r=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-n.left)/n.scaleX,y:(t.clientY-n.top)/n.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-n.left)/n.scaleX,y:(t.clientY-n.top)/n.scaleY})}))):(i=(t.clientX-n.left)/n.scaleX,r=(t.clientY-n.top)/n.scaleY,this.pointerPos={x:i,y:r},this._pointerPositions=[{x:i,y:r,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:r,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.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 s.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!r.Konva.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 e.Util.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}}t.Stage=k,k.prototype.nodeType="Stage",(0,o._registerNode)(k),n.Factory.addGetterSetter(k,"container"),r.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(q)),q),a=nt(),o=function(){if(it)return rt;it=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.FastLayer=void 0;const t=w(),e=nt(),n=S();let i=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return rt.FastLayer=i,i.prototype.nodeType="FastLayer",(0,n._registerNode)(i),rt}(),l=ot(),h=G(),c=et(),d=ct(),u=(dt||(dt=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=w(),n=ct(),i=H(),r=S();let s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},a=0,o=["fill","stroke","shadowColor"];class l{constructor(t,e,n,i,r,s,a){this.prop=t,this.propFunc=e,this.begin=i,this._pos=i,this.duration=s,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=r-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 h{constructor(i){let o,c,d=this,u=i.node,p=u._id,f=i.easing||t.Easings.Linear,m=!!i.yoyo;o=void 0===i.duration?.3:0===i.duration?.001:i.duration,this.node=u,this._id=a++;const g=u.getLayer()||(u instanceof r.Konva.Stage?u.getLayers():null);for(c in g||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new n.Animation((function(){d.tween.onEnterFrame()}),g),this.tween=new l(c,(function(t){d._tweenFunc(t)}),f,0,1,1e3*o,m),this._addListeners(),h.attrs[p]||(h.attrs[p]={}),h.attrs[p][this._id]||(h.attrs[p][this._id]={}),h.tweens[p]||(h.tweens[p]={}),i)void 0===s[c]&&this._addAttr(c,i[c]);this.reset(),this.onFinish=i.onFinish,this.onReset=i.onReset,this.onUpdate=i.onUpdate}_addAttr(t,n){let i,r,s,a,l,c,d,u,p=this.node,f=p._id;if(s=h.tweens[f][t],s&&delete h.attrs[f][s][t],i=p.getAttr(t),e.Util._isArray(n))if(r=[],l=Math.max(n.length,i.length),"points"===t&&n.length!==i.length&&(n.length>i.length?(d=i,i=e.Util._prepareArrayForTween(i,n,p.closed())):(c=n,n=e.Util._prepareArrayForTween(n,i,p.closed()))),0===t.indexOf("fill"))for(a=0;a<l;a++)if(a%2==0)r.push(n[a]-i[a]);else{const t=e.Util.colorToRGBA(i[a]);u=e.Util.colorToRGBA(n[a]),i[a]=t,r.push({r:u.r-t.r,g:u.g-t.g,b:u.b-t.b,a:u.a-t.a})}else for(a=0;a<l;a++)r.push(n[a]-i[a]);else-1!==o.indexOf(t)?(i=e.Util.colorToRGBA(i),u=e.Util.colorToRGBA(n),r={r:u.r-i.r,g:u.g-i.g,b:u.b-i.b,a:u.a-i.a}):r=n-i;h.attrs[f][this._id][t]={start:i,diff:r,end:n,trueEnd:c,trueStart:d},h.tweens[f][t]=this._id}_tweenFunc(t){let n,i,r,s,a,l,c,d,u=this.node,p=h.attrs[u._id][this._id];for(n in p){if(i=p[n],r=i.start,s=i.diff,d=i.end,e.Util._isArray(r))if(a=[],c=Math.max(r.length,d.length),0===n.indexOf("fill"))for(l=0;l<c;l++)l%2==0?a.push((r[l]||0)+s[l]*t):a.push("rgba("+Math.round(r[l].r+s[l].r*t)+","+Math.round(r[l].g+s[l].g*t)+","+Math.round(r[l].b+s[l].b*t)+","+(r[l].a+s[l].a*t)+")");else for(l=0;l<c;l++)a.push((r[l]||0)+s[l]*t);else a=-1!==o.indexOf(n)?"rgba("+Math.round(r.r+s.r*t)+","+Math.round(r.g+s.g*t)+","+Math.round(r.b+s.b*t)+","+(r.a+s.a*t)+")":r+s*t;u.setAttr(n,a)}}_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=h.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=h.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(){let t,e=this.node._id,n=this._id,i=h.tweens[e];for(t in this.pause(),i)delete h.tweens[e][t];delete h.attrs[e][n]}}t.Tween=h,h.attrs={},h.tweens={},i.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new h(t).play()},t.Easings={BackEaseIn(t,e,n,i){const r=1.70158;return n*(t/=i)*t*((r+1)*t-r)+e},BackEaseOut(t,e,n,i){const r=1.70158;return n*((t=t/i-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,n,i){let r=1.70158;return(t/=i/2)<1?n/2*(t*t*((1+(r*=1.525))*t-r))+e:n/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,n,i,r,s){let a=0;return 0===t?e:1==(t/=i)?e+n:(s||(s=.3*i),!r||r<Math.abs(n)?(r=n,a=s/4):a=s/(2*Math.PI)*Math.asin(n/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/s)+e)},ElasticEaseOut(t,e,n,i,r,s){let a=0;return 0===t?e:1==(t/=i)?e+n:(s||(s=.3*i),!r||r<Math.abs(n)?(r=n,a=s/4):a=s/(2*Math.PI)*Math.asin(n/r),r*Math.pow(2,-10*t)*Math.sin((t*i-a)*(2*Math.PI)/s)+n+e)},ElasticEaseInOut(t,e,n,i,r,s){let a=0;return 0===t?e:2==(t/=i/2)?e+n:(s||(s=i*(.3*1.5)),!r||r<Math.abs(n)?(r=n,a=s/4):a=s/(2*Math.PI)*Math.asin(n/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/s)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/s)*.5+n+e)},BounceEaseOut:(t,e,n,i)=>(t/=i)<1/2.75?n*(7.5625*t*t)+e:t<2/2.75?n*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?n*(7.5625*(t-=2.25/2.75)*t+.9375)+e:n*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,n,i,r)=>i-t.Easings.BounceEaseOut(r-e,0,i,r)+n,BounceEaseInOut:(e,n,i,r)=>e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,i,r)+n:.5*t.Easings.BounceEaseOut(2*e-r,0,i,r)+.5*i+n,EaseIn:(t,e,n,i)=>n*(t/=i)*t+e,EaseOut:(t,e,n,i)=>-n*(t/=i)*(t-2)+e,EaseInOut:(t,e,n,i)=>(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,n,i)=>n*(t/=i)*t*t*t*t+e,StrongEaseOut:(t,e,n,i)=>n*((t=t/i-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,n,i)=>(t/=i/2)<1?n/2*t*t*t*t*t+e:n/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,n,i)=>n*t/i+e}}(pt)),pt),p=O(),f=F();t.Konva=n.Util._assign(e.Konva,{Util:n.Util,Transform:n.Transform,Node:i.Node,Container:r.Container,Stage:s.Stage,stages:s.stages,Layer:a.Layer,FastLayer:o.FastLayer,Group:l.Group,DD:h.DD,Shape:c.Shape,shapes:c.shapes,Animation:d.Animation,Tween:u.Tween,Easings:u.Easings,Context:p.Context,Canvas:f.Canvas}),t.default=t.Konva}(y)),y}var mt,gt={};var _t,vt={},yt={};function xt(){if(_t)return yt;_t=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.Line=void 0;const t=L(),e=S(),n=et(),i=P();function r(t,e,n,i,r,s,a){const o=Math.sqrt(Math.pow(n-t,2)+Math.pow(i-e,2)),l=Math.sqrt(Math.pow(r-n,2)+Math.pow(s-i,2)),h=a*o/(o+l),c=a*l/(o+l);return[n-h*(r-t),i-h*(s-e),n+c*(r-t),i+c*(s-e)]}function s(t,e){const n=t.length,i=[];for(let s=2;s<n-2;s+=2){const n=r(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(n[0])||(i.push(n[0]),i.push(n[1]),i.push(t[s]),i.push(t[s+1]),i.push(n[2]),i.push(n[3]))}return i}class a extends n.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){let e,n,i,r=this.points(),s=r.length,a=this.tension(),o=this.closed(),l=this.bezier();if(s){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==a&&s>4){for(e=this.getTensionPoints(),n=e.length,i=o?0:4,o||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);i<n-2;)t.bezierCurveTo(e[i++],e[i++],e[i++],e[i++],e[i++],e[i++]);o||t.quadraticCurveTo(e[n-2],e[n-1],r[s-2],r[s-1])}else if(l)for(i=2;i<s;)t.bezierCurveTo(r[i++],r[i++],r[i++],r[i++],r[i++],r[i++]);else for(i=2;i<s;i+=2)t.lineTo(r[i],r[i+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():s(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,n=this.tension(),i=r(t[e-2],t[e-1],t[0],t[1],t[2],t[3],n),a=r(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],n),o=s(t,n);return[i[2],i[3]].concat(o).concat([a[0],a[1],t[e-2],t[e-1],a[2],a[3],i[0],i[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.points();let e,n,i=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],n=t[2*o+1],i=Math.min(i,e),r=Math.max(r,e),s=Math.min(s,n),a=Math.max(a,n);return{x:i,y:s,width:r-i,height:a-s}}}return yt.Line=a,a.prototype.className="Line",a.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(a),t.Factory.addGetterSetter(a,"closed",!1),t.Factory.addGetterSetter(a,"bezier",!1),t.Factory.addGetterSetter(a,"tension",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(a,"points",[],(0,i.getNumberArrayValidator)()),yt}var St,bt,Mt,wt={},Et={};function Tt(){if(bt)return wt;bt=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.Path=void 0;const t=L(),e=et(),n=S(),i=(St||(St=1,function(t){function e(t,e,i){const r=n(1,i,t),s=n(1,i,e),a=r*r+s*s;return Math.sqrt(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.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]],t.cValues=[[],[],[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]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(n,i,r)=>{let s,a;const o=r/2;s=0;for(let r=0;r<20;r++)a=o*t.tValues[20][r]+o,s+=t.cValues[20][r]*e(n,i,a);return o*s},t.getQuadraticArcLength=(t,e,n)=>{void 0===n&&(n=1);const i=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],s=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(i*i+r*r),l=4*(i*s+r*a),h=s*s+a*a;if(0===o)return n*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=l/(2*o),d=n+c,u=h/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,f=c*c+u>0?Math.sqrt(c*c+u):0,m=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+f))):0;return Math.sqrt(o)/2*(d*p-c*f+m)};const n=(e,i,r)=>{const s=r.length-1;let a,o;if(0===s)return 0;if(0===e){o=0;for(let e=0;e<=s;e++)o+=t.binomialCoefficients[s][e]*Math.pow(1-i,s-e)*Math.pow(i,e)*r[e];return o}a=new Array(s);for(let t=0;t<s;t++)a[t]=s*(r[t+1]-r[t]);return n(e-1,i,a)};t.t2length=(t,e,n)=>{let i=1,r=t/e,s=(t-n(r))/e,a=0;for(;i>.001;){const o=n(r+s),l=Math.abs(t-o)/e;if(l<i)i=l,r+=s;else{const a=n(r-s),o=Math.abs(t-a)/e;o<i?(i=o,r-=s):s/=2}if(a++,a>500)break}return r}}(Et)),Et);let r=class t extends e.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let n=!1;for(let f=0;f<e.length;f++){const m=e[f].command,g=e[f].points;switch(m){case"L":t.lineTo(g[0],g[1]);break;case"M":t.moveTo(g[0],g[1]);break;case"C":t.bezierCurveTo(g[0],g[1],g[2],g[3],g[4],g[5]);break;case"Q":t.quadraticCurveTo(g[0],g[1],g[2],g[3]);break;case"A":var i=g[0],r=g[1],s=g[2],a=g[3],o=g[4],l=g[5],h=g[6],c=g[7],d=s>a?s:a,u=s>a?1:s/a,p=s>a?a/s:1;t.translate(i,r),t.rotate(h),t.scale(u,p),t.arc(0,0,d,o,o+l,1-c),t.scale(1/u,1/p),t.rotate(-h),t.translate(-i,-r);break;case"z":n=!0,t.closePath()}}n||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach((function(n){if("A"===n.command){const i=n.points[4],r=n.points[5],s=n.points[4]+r;let a=Math.PI/180;if(Math.abs(i-s)<a&&(a=Math.abs(i-s)),r<0)for(let r=i-a;r>s;r-=a){const i=t.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],r,0);e.push(i.x,i.y)}else for(let r=i+a;r<s;r+=a){const i=t.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],r,0);e.push(i.x,i.y)}}else if("C"===n.command)for(let i=0;i<=1;i+=.01){const r=t.getPointOnCubicBezier(i,n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3],n.points[4],n.points[5]);e.push(r.x,r.y)}else e=e.concat(n.points)}));let n,i,r=e[0],s=e[0],a=e[1],o=e[1];for(let t=0;t<e.length/2;t++)n=e[2*t],i=e[2*t+1],isNaN(n)||(r=Math.min(r,n),s=Math.max(s,n)),isNaN(i)||(a=Math.min(a,i),o=Math.max(o,i));return{x:r,y:a,width:s-r,height:o-a}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,n,i){return Math.sqrt((n-t)*(n-t)+(i-e)*(i-e))}static getPathLength(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n].pathLength;return e}static getPointAtLengthOfDataArray(e,n){let r,s=0,a=n.length;if(!a)return null;for(;s<a&&e>n[s].pathLength;)e-=n[s].pathLength,++s;if(s===a)return r=n[s-1].points.slice(-2),{x:r[0],y:r[1]};if(e<.01)return r=n[s].points.slice(0,2),{x:r[0],y:r[1]};const o=n[s],l=o.points;switch(o.command){case"L":return t.getPointOnLine(e,o.start.x,o.start.y,l[0],l[1]);case"C":return t.getPointOnCubicBezier((0,i.t2length)(e,t.getPathLength(n),(t=>(0,i.getCubicArcLength)([o.start.x,l[0],l[2],l[4]],[o.start.y,l[1],l[3],l[5]],t))),o.start.x,o.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case"Q":return t.getPointOnQuadraticBezier((0,i.t2length)(e,t.getPathLength(n),(t=>(0,i.getQuadraticArcLength)([o.start.x,l[0],l[2]],[o.start.y,l[1],l[3]],t))),o.start.x,o.start.y,l[0],l[1],l[2],l[3]);case"A":var h=l[0],c=l[1],d=l[2],u=l[3],p=l[4],f=l[5],m=l[6];return p+=f*e/o.pathLength,t.getPointOnEllipticalArc(h,c,d,u,p,m)}return null}static getPointOnLine(t,e,n,i,r,s,a){s=null!=s?s:e,a=null!=a?a:n;const o=this.getLineLength(e,n,i,r);if(o<1e-10)return{x:e,y:n};if(i===e)return{x:s,y:a+(r>n?t:-t)};const l=(r-n)/(i-e),h=Math.sqrt(t*t/(1+l*l))*(i<e?-1:1),c=l*h;if(Math.abs(a-n-l*(s-e))<1e-10)return{x:s+h,y:a+c};const d=((s-e)*(i-e)+(a-n)*(r-n))/(o*o),u=e+d*(i-e),p=n+d*(r-n),f=this.getLineLength(s,a,u,p),m=Math.sqrt(t*t-f*f),g=Math.sqrt(m*m/(1+l*l))*(i<e?-1:1);return{x:u+g,y:p+l*g}}static getPointOnCubicBezier(t,e,n,i,r,s,a,o,l){function h(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*h(t)+s*c(t)+i*d(t)+e*u(t),y:l*h(t)+a*c(t)+r*d(t)+n*u(t)}}static getPointOnQuadraticBezier(t,e,n,i,r,s,a){function o(t){return t*t}function l(t){return 2*t*(1-t)}function h(t){return(1-t)*(1-t)}return{x:s*o(t)+i*l(t)+e*h(t),y:a*o(t)+r*l(t)+n*h(t)}}static getPointOnEllipticalArc(t,e,n,i,r,s){const a=Math.cos(s),o=Math.sin(s),l=n*Math.cos(r),h=i*Math.sin(r);return{x:t+(l*a-h*o),y:e+(l*o+h*a)}}static parsePathData(t){if(!t)return[];let e=t;const n=["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(var i=0;i<n.length;i++)e=e.replace(new RegExp(n[i],"g"),"|"+n[i]);const r=e.split("|"),s=[],a=[];let o=0,l=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(i=1;i<r.length;i++){let t=r[i],e=t.charAt(0);for(t=t.slice(1),a.length=0;c=h.exec(t);)a.push(c[0]);const n=[];for(let t=0,e=a.length;t<e;t++){if("00"===a[t]){n.push(0,0);continue}const e=parseFloat(a[t]);isNaN(e)?n.push(0):n.push(e)}for(;n.length>0&&!isNaN(n[0]);){let t="",i=[];const r=o,a=l;var d,u,p,f,m,g,_,v,y,x;switch(e){case"l":o+=n.shift(),l+=n.shift(),t="L",i.push(o,l);break;case"L":o=n.shift(),l=n.shift(),i.push(o,l);break;case"m":var S=n.shift(),b=n.shift();if(o+=S,l+=b,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){o=s[t].points[0]+S,l=s[t].points[1]+b;break}i.push(o,l),e="l";break;case"M":o=n.shift(),l=n.shift(),t="M",i.push(o,l),e="L";break;case"h":o+=n.shift(),t="L",i.push(o,l);break;case"H":o=n.shift(),t="L",i.push(o,l);break;case"v":l+=n.shift(),t="L",i.push(o,l);break;case"V":l=n.shift(),t="L",i.push(o,l);break;case"C":i.push(n.shift(),n.shift(),n.shift(),n.shift()),o=n.shift(),l=n.shift(),i.push(o,l);break;case"c":i.push(o+n.shift(),l+n.shift(),o+n.shift(),l+n.shift()),o+=n.shift(),l+=n.shift(),t="C",i.push(o,l);break;case"S":u=o,p=l,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=l+(l-d.points[3])),i.push(u,p,n.shift(),n.shift()),o=n.shift(),l=n.shift(),t="C",i.push(o,l);break;case"s":u=o,p=l,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=l+(l-d.points[3])),i.push(u,p,o+n.shift(),l+n.shift()),o+=n.shift(),l+=n.shift(),t="C",i.push(o,l);break;case"Q":i.push(n.shift(),n.shift()),o=n.shift(),l=n.shift(),i.push(o,l);break;case"q":i.push(o+n.shift(),l+n.shift()),o+=n.shift(),l+=n.shift(),t="Q",i.push(o,l);break;case"T":u=o,p=l,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=l+(l-d.points[1])),o=n.shift(),l=n.shift(),t="Q",i.push(u,p,o,l);break;case"t":u=o,p=l,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=l+(l-d.points[1])),o+=n.shift(),l+=n.shift(),t="Q",i.push(u,p,o,l);break;case"A":f=n.shift(),m=n.shift(),g=n.shift(),_=n.shift(),v=n.shift(),y=o,x=l,o=n.shift(),l=n.shift(),t="A",i=this.convertEndpointToCenterParameterization(y,x,o,l,_,v,f,m,g);break;case"a":f=n.shift(),m=n.shift(),g=n.shift(),_=n.shift(),v=n.shift(),y=o,x=l,o+=n.shift(),l+=n.shift(),t="A",i=this.convertEndpointToCenterParameterization(y,x,o,l,_,v,f,m,g)}s.push({command:t||e,points:i,start:{x:r,y:a},pathLength:this.calcLength(r,a,t||e,i)})}"z"!==e&&"Z"!==e||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,n,r,s){let a,o,l,h;const c=t;switch(r){case"L":return c.getLineLength(e,n,s[0],s[1]);case"C":return(0,i.getCubicArcLength)([e,s[0],s[2],s[4]],[n,s[1],s[3],s[5]],1);case"Q":return(0,i.getQuadraticArcLength)([e,s[0],s[2]],[n,s[1],s[3]],1);case"A":a=0;var d=s[4],u=s[5],p=s[4]+u,f=Math.PI/180;if(Math.abs(d-p)<f&&(f=Math.abs(d-p)),o=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(h=d-f;h>p;h-=f)l=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),a+=c.getLineLength(o.x,o.y,l.x,l.y),o=l;else for(h=d+f;h<p;h+=f)l=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),a+=c.getLineLength(o.x,o.y,l.x,l.y),o=l;return l=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],p,0),a+=c.getLineLength(o.x,o.y,l.x,l.y),a}return 0}static convertEndpointToCenterParameterization(t,e,n,i,r,s,a,o,l){const h=l*(Math.PI/180),c=Math.cos(h)*(t-n)/2+Math.sin(h)*(e-i)/2,d=-1*Math.sin(h)*(t-n)/2+Math.cos(h)*(e-i)/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)));r===s&&(p*=-1),isNaN(p)&&(p=0);const f=p*a*d/o,m=p*-o*c/a,g=(t+n)/2+Math.cos(h)*f-Math.sin(h)*m,_=(e+i)/2+Math.sin(h)*f+Math.cos(h)*m,v=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])/(v(t)*v(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},S=x([1,0],[(c-f)/a,(d-m)/o]),b=[(c-f)/a,(d-m)/o],M=[(-1*c-f)/a,(-1*d-m)/o];let w=x(b,M);return y(b,M)<=-1&&(w=Math.PI),y(b,M)>=1&&(w=0),0===s&&w>0&&(w-=2*Math.PI),1===s&&w<0&&(w+=2*Math.PI),[g,_,a,o,S,w,h,s]}};return wt.Path=r,r.prototype.className="Path",r.prototype._attrsAffectingSize=["data"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"data"),wt}var At,Ct={};var Rt,Pt={};var Lt,It={};var Dt,Nt={};var Ut,Ot={};function Ft(){if(Ut)return Ot;Ut=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Rect=void 0;const t=L(),e=et(),n=S(),i=w(),r=P();let s=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),n=this.width(),r=this.height();t.beginPath(),e?i.Util.drawRoundedRectPath(t,n,r,e):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}};return Ot.Rect=s,s.prototype.className="Rect",(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),Ot}var kt,Bt={};var zt,Gt={};var Ht,Vt={};var Wt,Xt={};var jt,Yt={};function qt(){if(jt)return Yt;jt=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.Text=void 0,Yt.stringToArray=a;const t=w(),e=L(),n=et(),i=S(),r=P(),s=S();function a(t){return[...t].reduce(((t,e,n,i)=>(/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?(?:\u200D\p{Emoji_Presentation})+/u.test(e)?t.push(e):/\p{Regional_Indicator}{2}/u.test(e+(i[n+1]||""))?t.push(e+i[n+1]):n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:t.push(e),t)),[])}const o="auto",l="inherit",h="justify",c="left",d="middle",u="normal",p=" ",f="none",m=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],g=m.length;let _;function v(){return _||(_=t.Util.createCanvasElement().getContext("2d"),_)}let y=class extends n.Shape{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<g;t++)this.on(m[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,n=e.length;if(!this.text())return;let r,s=this.padding(),o=this.fontSize(),u=this.lineHeight()*o,p=this.verticalAlign(),f=this.direction(),m=0,g=this.align(),_=this.getWidth(),v=this.letterSpacing(),y=this.fill(),x=this.textDecoration(),S=-1!==x.indexOf("underline"),b=-1!==x.indexOf("line-through");f=f===l?t.direction:f;let M=u/2,w=d;if(i.Konva._fixTextRendering){const t=this.measureSize("M");w="alphabetic",M=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+u/2}var E=0,T=0;for("rtl"===f&&t.setAttr("direction",f),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",w),t.setAttr("textAlign",c),p===d?m=(this.getHeight()-n*u-2*s)/2:"bottom"===p&&(m=this.getHeight()-n*u-2*s),t.translate(s,m+s),r=0;r<n;r++){E=0,T=0;var A,C,R,P=e[r],L=P.text,I=P.width,D=P.lastInParagraph;if(t.save(),"right"===g?E+=_-I-2*s:"center"===g&&(E+=(_-I-2*s)/2),S){t.save(),t.beginPath();const e=E,n=M+T+(i.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,n),C=0===(A=L.split(" ").length-1),R=g!==h||D?I:_-2*s,t.lineTo(e+Math.round(R),n),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||y,t.stroke(),t.restore()}if(b){t.save(),t.beginPath();const e=i.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(E,M+T+e),C=0===(A=L.split(" ").length-1),R=g===h&&D&&!C?_-2*s:I,t.lineTo(E+Math.round(R),M+T+e),t.lineWidth=o/15;const n=this._getLinearGradient();t.strokeStyle=n||y,t.stroke(),t.restore()}if("rtl"===f||0===v&&g!==h)0!==v&&t.setAttr("letterSpacing",`${v}px`),this._partialTextX=E,this._partialTextY=M+T,this._partialText=L,t.fillStrokeShape(this);else{A=L.split(" ").length-1;const e=a(L);for(let n=0;n<e.length;n++){const i=e[n];" "!==i||D||g!==h||(E+=(_-2*s-I)/A),this._partialTextX=E,this._partialTextY=M+T,this._partialText=i,t.fillStrokeShape(this),E+=this.measureSize(i).width+v}}t.restore(),n>1&&(M+=u)}}_hitFunc(t){const e=this.getWidth(),n=this.getHeight();t.beginPath(),t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)}setText(e){const n=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",n),this}getWidth(){return this.attrs.width===o||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===o||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.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,n,i,r,s,a,o,l,h,c,d;let u,p=v(),f=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const m=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*m,actualBoundingBoxDescent:null!==(n=u.actualBoundingBoxDescent)&&void 0!==n?n:0,actualBoundingBoxLeft:null!==(i=u.actualBoundingBoxLeft)&&void 0!==i?i:-7.421875*m,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*m,alphabeticBaseline:null!==(s=u.alphabeticBaseline)&&void 0!==s?s:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*m,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*m,fontBoundingBoxAscent:null!==(l=u.fontBoundingBoxAscent)&&void 0!==l?l:91*m,fontBoundingBoxDescent:null!==(h=u.fontBoundingBoxDescent)&&void 0!==h?h:21*m,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*m,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*m,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+p+this.fontVariant()+p+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,n=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!n&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===h&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),n=t.length;return v().measureText(t).width+(n?e*(n-1):0)}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),n=0,i=this.lineHeight()*e,r=this.attrs.width,s=this.attrs.height,a=r!==o&&void 0!==r,l=s!==o&&void 0!==s,h=this.padding(),c=r-2*h,d=s-2*h,u=0,m=this.wrap(),g="char"!==m&&m!==f,_=this.ellipsis();this.textArr=[],v().font=this._getContextFont();const y=_?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let s=t[e],o=this._getTextWidth(s);if(a&&o>c)for(;s.length>0;){let t=0,e=s.length,r="",a=0;for(;t<e;){const n=t+e>>>1,i=s.slice(0,n+1),o=this._getTextWidth(i)+y;o<=c?(t=n+1,r=i,a=o):e=n}if(!r)break;if(g){var x;const e=s[r.length];(x=(e===p||"-"===e)&&a<=c?r.length:Math.max(r.lastIndexOf(p),r.lastIndexOf("-"))+1)>0&&(t=x,r=r.slice(0,t),a=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),n=Math.max(n,a),u+=i;if(this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}if(s=s.slice(t),s=s.trimLeft(),s.length>0&&(o=this._getTextWidth(s),o<=c)){this._addTextLine(s),u+=i,n=Math.max(n,o);break}}else this._addTextLine(s),u+=i,n=Math.max(n,o),this._shouldHandleEllipsis(u)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&u+i>d)break}this.textHeight=e,this.textWidth=n}_shouldHandleEllipsis(t){const e=+this.fontSize(),n=this.lineHeight()*e,i=this.attrs.height,r=i!==o&&void 0!==i,s=i-2*this.padding();return!(this.wrap()!==f)||r&&t+n>s}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==o&&void 0!==t,n=t-2*this.padding(),i=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&i){if(e){this._getTextWidth(r.text+"…")<n||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.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()}};return Yt.Text=y,y.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype.className="Text",y.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,s._registerNode)(y),e.Factory.overWriteSetter(y,"width",(0,r.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(y,"height",(0,r.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(y,"direction",l),e.Factory.addGetterSetter(y,"fontFamily","Arial"),e.Factory.addGetterSetter(y,"fontSize",12,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"fontStyle",u),e.Factory.addGetterSetter(y,"fontVariant",u),e.Factory.addGetterSetter(y,"padding",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"align",c),e.Factory.addGetterSetter(y,"verticalAlign","top"),e.Factory.addGetterSetter(y,"lineHeight",1,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"wrap","word"),e.Factory.addGetterSetter(y,"ellipsis",!1,(0,r.getBooleanValidator)()),e.Factory.addGetterSetter(y,"letterSpacing",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"text","",(0,r.getStringValidator)()),e.Factory.addGetterSetter(y,"textDecoration",""),Yt}var Kt,Zt={};var Qt,Jt={};function $t(){if(Qt)return Jt;Qt=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Transformer=void 0;const t=w(),e=L(),n=H(),i=et(),r=Ft(),s=ot(),a=S(),o=P(),l=S(),h="tr-konva",c=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${h}`)).join(" "),d="nodesRect",u=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],p={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},f="ontouchstart"in a.Konva._global;const m=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function g(t,e,n){const i=n.x+(t.x-n.x)*Math.cos(e)-(t.y-n.y)*Math.sin(e),r=n.y+(t.x-n.x)*Math.sin(e)+(t.y-n.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:i,y:r}}function _(t,e){const n=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 g(t,e,n)}let v=0,y=class extends s.Group{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(c,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return h+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const n=e.filter((e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=e=n,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[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()},n=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(n,e),t.on(u.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()}`,(n=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(n,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(n=>{if(!e)return;const i=t.getAbsolutePosition(),r=i.x-e.x,s=i.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const i=e.getAbsolutePosition();e.setAbsolutePosition({x:i.x+r,y:i.y+s}),e.startDrag(n)})),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(d),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(d,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),n){const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(n),s=t.getAbsolutePosition(n),o=i.x*r.x-t.offsetX()*r.x,l=i.y*r.y-t.offsetY()*r.y,h=(a.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return g({x:s.x+o*Math.cos(h)+l*Math.sin(-h),y:s.y+l*Math.cos(h)+o*Math.sin(h),width:i.width*r.x,height:i.height*r.y,rotation:h},-a.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],r=t.getAbsoluteTransform();i.forEach((function(t){const n=r.point(t);e.push(n)}))}));const n=new t.Transform;n.rotate(-a.Konva.getAngle(this.rotation()));let i=1/0,r=1/0,s=-1/0,o=-1/0;e.forEach((function(t){const e=n.point(t);void 0===i&&(i=s=e.x,r=o=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),o=Math.max(o,e.y)})),n.invert();const l=n.point({x:i,y:r});return{x:l.x,y:l.y,width:s-i,height:o-r,rotation:a.Konva.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(),m.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(e){const n=new r.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:f?10:"auto"}),i=this;n.on("mousedown touchstart",(function(t){i._handleMouseDown(t)})),n.on("dragstart",(t=>{n.stopDrag(),t.cancelBubble=!0})),n.on("dragend",(t=>{t.cancelBubble=!0})),n.on("mouseenter",(()=>{const i=a.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(e,n,i){if("rotater"===e)return i;n+=t.Util.degToRad(p[e]||0);const r=(t.Util.radToDeg(n)%360+360)%360;return t.Util._inRange(r,337.5,360)||t.Util._inRange(r,0,22.5)?"ns-resize":t.Util._inRange(r,22.5,67.5)?"nesw-resize":t.Util._inRange(r,67.5,112.5)?"ew-resize":t.Util._inRange(r,112.5,157.5)?"nwse-resize":t.Util._inRange(r,157.5,202.5)?"ns-resize":t.Util._inRange(r,202.5,247.5)?"nesw-resize":t.Util._inRange(r,247.5,292.5)?"ew-resize":t.Util._inRange(r,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(e,i,r);n.getStage().content&&(n.getStage().content.style.cursor=s),this._cursorChange=!0})),n.on("mouseout",(()=>{n.getStage().content&&(n.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(n)}_createBack(){const e=new i.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,n){const i=n.getParent(),r=i.padding();e.beginPath(),e.rect(-r,-r,n.width()+2*r,n.height()+2*r),e.moveTo(n.width()/2,-r),i.rotateEnabled()&&i.rotateLineVisible()&&e.lineTo(n.width()/2,-i.rotateAnchorOffset()*t.Util._sign(n.height())-r),e.fillStrokeShape(n)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const n=this.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.fillStrokeShape(e)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t=>{t.cancelBubble=!0})),e.on("dragmove",(t=>{t.cancelBubble=!0})),e.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(),n=e.width,i=e.height,r=Math.sqrt(Math.pow(n,2)+Math.pow(i,2));this.sin=Math.abs(i/r),this.cos=Math.abs(n/r),"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 s=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-s.x,y:a.y-s.y},v++,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,n,i;const r=this.findOne("."+this._movingAnchorName),s=r.getStage();s.setPointersPositions(t);const o=s.getPointerPosition();let l={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const h=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(l=this.anchorDragBoundFunc()(h,l,t)),r.setAbsolutePosition(l);const c=r.getAbsolutePosition();if(h.x===c.x&&h.y===c.y)return;if("rotater"===this._movingAnchorName){const i=this._getNodeRect();e=r.x()-i.width/2,n=-r.y()+i.height/2;let s=Math.atan2(-n,e)+Math.PI/2;i.height<0&&(s-=Math.PI);const o=a.Konva.getAngle(this.rotation())+s,l=a.Konva.getAngle(this.rotationSnapTolerance()),h=function(t,e,n){let i=e;for(let r=0;r<t.length;r++){const s=a.Konva.getAngle(t[r]),o=Math.abs(s-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<n&&(i=s)}return i}(this.rotationSnaps(),o,l),c=_(i,h-i.rotation);return void this._fitNodesInto(c,t)}const d=this.shiftBehavior();let u;u="inverted"===d?this.keepRatio()&&!t.shiftKey:"none"===d?this.keepRatio():this.keepRatio()||t.shiftKey;var p=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){var f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};i=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(f.y-r.y(),2));var m=this.findOne(".top-left").x()>f.x?-1:1,g=this.findOne(".top-left").y()>f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,this.findOne(".top-left").x(f.x-e),this.findOne(".top-left").y(f.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(u){f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};i=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(f.y-r.y(),2));m=this.findOne(".top-right").x()<f.x?-1:1,g=this.findOne(".top-right").y()>f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,this.findOne(".top-right").x(f.x+e),this.findOne(".top-right").y(f.y-n)}var v=r.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(u){f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};i=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(r.y()-f.y,2));m=f.x<r.x()?-1:1,g=r.y()<f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,r.x(f.x-e),r.y(f.y+n)}v=r.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(u){f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};i=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(r.y()-f.y,2));m=this.findOne(".bottom-right").x()<f.x?-1:1,g=this.findOne(".bottom-right").y()<f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,this.findOne(".bottom-right").x(f.x+e),this.findOne(".bottom-right").y(f.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(p=this.centeredScaling()||t.altKey){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),n=t.x(),i=t.y(),r=this.getWidth()-e.x(),s=this.getHeight()-e.y();e.move({x:-n,y:-i}),t.move({x:r,y:s})}const y=this.findOne(".top-left").getAbsolutePosition();e=y.x,n=y.y;const x=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),S=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:n,width:x,height:S,rotation:a.Konva.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 n=this.getNode();v--,this._fire("transformend",{evt:t,target:n}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),n&&this._nodes.forEach((e=>{var n;e._fire("transformend",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(e,n){const i=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=new t.Transform;if(r.rotate(a.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const n=this.boundBoxFunc()(i,e);n?e=n:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,o=new t.Transform;o.translate(i.x,i.y),o.rotate(i.rotation),o.scale(i.width/s,i.height/s);const l=new t.Transform,h=e.width/s,c=e.height/s;!1===this.flipEnabled()?(l.translate(e.x,e.y),l.rotate(e.rotation),l.translate(e.width<0?e.width:0,e.height<0?e.height:0),l.scale(Math.abs(h),Math.abs(c))):(l.translate(e.x,e.y),l.rotate(e.rotation),l.scale(h,c));const d=l.multiply(o.invert());this._nodes.forEach((e=>{var n;const i=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const s=new t.Transform;s.multiply(i.copy().invert()).multiply(d).multiply(i).multiply(r);const a=s.decompose();e.setAttrs(a),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:n,target:t}),t._fire("transform",{evt:n,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const n=this._getNodeRect();this.rotation(t.Util._getRotation(n.rotation));const i=n.width,r=n.height,s=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),l=this.anchorSize(),h=this.find("._anchor");h.forEach((t=>{t.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+o,offsetY:l/2+o,visible:a&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:l/2+o,visible:a&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:l/2-o,offsetY:l/2+o,visible:a&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:l/2+o,visible:a&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:r/2,offsetX:l/2-o,visible:a&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:l/2+o,offsetY:l/2-o,visible:a&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:r,offsetY:l/2-o,visible:a&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:r,offsetX:l/2-o,offsetY:l/2-o,visible:a&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*t.Util._sign(r)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const c=this.anchorStyleFunc();c&&h.forEach((t=>{c(t)})),null===(e=this.getLayer())||void 0===e||e.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=""),s.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return n.Node.prototype.toObject.call(this)}clone(t){return n.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return Jt.Transformer=y,y.isTransforming=()=>v>0,y.prototype.className="Transformer",(0,l._registerNode)(y),e.Factory.addGetterSetter(y,"enabledAnchors",m,(function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===m.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+m.join(", "))})),e||[]})),e.Factory.addGetterSetter(y,"flipEnabled",!0,(0,o.getBooleanValidator)()),e.Factory.addGetterSetter(y,"resizeEnabled",!0),e.Factory.addGetterSetter(y,"anchorSize",10,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateEnabled",!0),e.Factory.addGetterSetter(y,"rotateLineVisible",!0),e.Factory.addGetterSetter(y,"rotationSnaps",[]),e.Factory.addGetterSetter(y,"rotateAnchorOffset",50,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(y,"rotationSnapTolerance",5,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderEnabled",!0),e.Factory.addGetterSetter(y,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"anchorStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"anchorFill","white"),e.Factory.addGetterSetter(y,"anchorCornerRadius",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"borderStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderDash"),e.Factory.addGetterSetter(y,"keepRatio",!0),e.Factory.addGetterSetter(y,"shiftBehavior","default"),e.Factory.addGetterSetter(y,"centeredScaling",!1),e.Factory.addGetterSetter(y,"ignoreStroke",!1),e.Factory.addGetterSetter(y,"padding",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"node"),e.Factory.addGetterSetter(y,"nodes"),e.Factory.addGetterSetter(y,"boundBoxFunc"),e.Factory.addGetterSetter(y,"anchorDragBoundFunc"),e.Factory.addGetterSetter(y,"anchorStyleFunc"),e.Factory.addGetterSetter(y,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(y,"useSingleNodeRotation",!0),e.Factory.backCompat(y,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),Jt}var te,ee={};var ne,ie={};function re(){if(ne)return ie;ne=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.Blur=void 0;const t=L(),e=H(),n=P();function i(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const r=[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],s=[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];return ie.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const n=t.data,a=t.width,o=t.height;let l,h,c,d,u,p,f,m,g,_,v,y,x,S,b,M,w,E,T,A,C,R,P,L,I=e+e+1,D=a-1,N=o-1,U=e+1,O=U*(U+1)/2,F=new i,k=null,B=F,z=null,G=null,H=r[e],V=s[e];for(c=1;c<I;c++)B=B.next=new i,c===U&&(k=B);for(B.next=F,f=p=0,h=0;h<o;h++){for(M=w=E=T=m=g=_=v=0,y=U*(A=n[p]),x=U*(C=n[p+1]),S=U*(R=n[p+2]),b=U*(P=n[p+3]),m+=O*A,g+=O*C,_+=O*R,v+=O*P,B=F,c=0;c<U;c++)B.r=A,B.g=C,B.b=R,B.a=P,B=B.next;for(c=1;c<U;c++)d=p+((D<c?D:c)<<2),m+=(B.r=A=n[d])*(L=U-c),g+=(B.g=C=n[d+1])*L,_+=(B.b=R=n[d+2])*L,v+=(B.a=P=n[d+3])*L,M+=A,w+=C,E+=R,T+=P,B=B.next;for(z=F,G=k,l=0;l<a;l++)n[p+3]=P=v*H>>V,0!==P?(P=255/P,n[p]=(m*H>>V)*P,n[p+1]=(g*H>>V)*P,n[p+2]=(_*H>>V)*P):n[p]=n[p+1]=n[p+2]=0,m-=y,g-=x,_-=S,v-=b,y-=z.r,x-=z.g,S-=z.b,b-=z.a,d=f+((d=l+e+1)<D?d:D)<<2,M+=z.r=n[d],w+=z.g=n[d+1],E+=z.b=n[d+2],T+=z.a=n[d+3],m+=M,g+=w,_+=E,v+=T,z=z.next,y+=A=G.r,x+=C=G.g,S+=R=G.b,b+=P=G.a,M-=A,w-=C,E-=R,T-=P,G=G.next,p+=4;f+=a}for(l=0;l<a;l++){for(w=E=T=M=g=_=v=m=0,p=l<<2,y=U*(A=n[p]),x=U*(C=n[p+1]),S=U*(R=n[p+2]),b=U*(P=n[p+3]),m+=O*A,g+=O*C,_+=O*R,v+=O*P,B=F,c=0;c<U;c++)B.r=A,B.g=C,B.b=R,B.a=P,B=B.next;for(u=a,c=1;c<=e;c++)p=u+l<<2,m+=(B.r=A=n[p])*(L=U-c),g+=(B.g=C=n[p+1])*L,_+=(B.b=R=n[p+2])*L,v+=(B.a=P=n[p+3])*L,M+=A,w+=C,E+=R,T+=P,B=B.next,c<N&&(u+=a);for(p=l,z=F,G=k,h=0;h<o;h++)d=p<<2,n[d+3]=P=v*H>>V,P>0?(P=255/P,n[d]=(m*H>>V)*P,n[d+1]=(g*H>>V)*P,n[d+2]=(_*H>>V)*P):n[d]=n[d+1]=n[d+2]=0,m-=y,g-=x,_-=S,v-=b,y-=z.r,x-=z.g,S-=z.b,b-=z.a,d=l+((d=h+U)<N?d:N)*a<<2,m+=M+=z.r=n[d],g+=w+=z.g=n[d+1],_+=E+=z.b=n[d+2],v+=T+=z.a=n[d+3],z=z.next,y+=A=G.r,x+=C=G.g,S+=R=G.b,b+=P=G.a,M-=A,w-=C,E-=R,T-=P,G=G.next,p+=a}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),ie}var se,ae={};var oe,le={};var he,ce={};var de,ue={};var pe,fe={};var me,ge={};var _e,ve={};var ye,xe={};var Se,be={};function Me(){if(Se)return be;Se=1,Object.defineProperty(be,"__esModule",{value:!0}),be.Kaleidoscope=void 0;const t=L(),e=H(),n=w(),i=P();return be.Kaleidoscope=function(t){const e=t.width,i=t.height;let r,s,a,o,l,h,c,d,u,p,f=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(m%360)/360);if(f<1)return;const _=n.Util.createCanvasElement();_.width=e,_.height=i;const v=_.getContext("2d").getImageData(0,0,e,i);n.Util.releaseCanvas(_),function(t,e,n){let i,r,s,a,o=t.data,l=e.data,h=t.width,c=t.height,d=n.polarCenterX||h/2,u=n.polarCenterY||c/2,p=0,f=0,m=0,g=0,_=Math.sqrt(d*d+u*u);r=h-d,s=c-u,a=Math.sqrt(r*r+s*s),_=a>_?a:_;let v,y,x,S,b=c,M=h,w=360/M*Math.PI/180;for(y=0;y<M;y+=1)for(x=Math.sin(y*w),S=Math.cos(y*w),v=0;v<b;v+=1)r=Math.floor(d+_*v/b*S),s=Math.floor(u+_*v/b*x),i=4*(s*h+r),p=o[i+0],f=o[i+1],m=o[i+2],g=o[i+3],i=4*(y+v*h),l[i+0]=p,l[i+1]=f,l[i+2]=m,l[i+3]=g}(t,v,{polarCenterX:e/2,polarCenterY:i/2});let y=e/Math.pow(2,f);for(;y<=8;)y*=2,f-=1;y=Math.ceil(y);let x=y,S=0,b=x,M=1;for(g+y>e&&(S=x,b=0,M=-1),s=0;s<i;s+=1)for(r=S;r!==b;r+=M)a=Math.round(r+g)%e,u=4*(e*s+a),l=v.data[u+0],h=v.data[u+1],c=v.data[u+2],d=v.data[u+3],p=4*(e*s+r),v.data[p+0]=l,v.data[p+1]=h,v.data[p+2]=c,v.data[p+3]=d;for(s=0;s<i;s+=1)for(x=Math.floor(y),o=0;o<f;o+=1){for(r=0;r<x+1;r+=1)u=4*(e*s+r),l=v.data[u+0],h=v.data[u+1],c=v.data[u+2],d=v.data[u+3],p=4*(e*s+2*x-r-1),v.data[p+0]=l,v.data[p+1]=h,v.data[p+2]=c,v.data[p+3]=d;x*=2}!function(t,e,n){let i,r,s,a,o,l,h=t.data,c=e.data,d=t.width,u=t.height,p=n.polarCenterX||d/2,f=n.polarCenterY||u/2,m=0,g=0,_=0,v=0,y=Math.sqrt(p*p+f*f);r=d-p,s=u-f,l=Math.sqrt(r*r+s*s),y=l>y?l:y;let x,S,b,M,w=u,E=d;for(r=0;r<d;r+=1)for(s=0;s<u;s+=1)a=r-p,o=s-f,x=Math.sqrt(a*a+o*o)*w/y,S=(180*Math.atan2(o,a)/Math.PI+360+0)%360,S=S*E/360,b=Math.floor(S),M=Math.floor(x),i=4*(M*d+b),m=h[i+0],g=h[i+1],_=h[i+2],v=h[i+3],i=4*(s*d+r),c[i+0]=m,c[i+1]=g,c[i+2]=_,c[i+3]=v}(v,t,{polarRotation:0})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),be}var we,Ee={};function Te(){if(we)return Ee;we=1,Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.Mask=void 0;const t=L(),e=H(),n=P();function i(t,e,n){let i=4*(n*t.width+e);const r=[];return r.push(t.data[i++],t.data[i++],t.data[i++],t.data[i++]),r}function r(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))}return Ee.Mask=function(t){let e=function(t,e){const n=i(t,0,0),s=i(t,t.width-1,0),a=i(t,0,t.height-1),o=i(t,t.width-1,t.height-1),l=e||10;if(r(n,s)<l&&r(s,o)<l&&r(o,a)<l&&r(a,n)<l){const e=function(t){const e=[0,0,0];for(let n=0;n<t.length;n++)e[0]+=t[n][0],e[1]+=t[n][1],e[2]+=t[n][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([s,n,o,a]),i=[];for(let n=0;n<t.width*t.height;n++){const s=r(e,[t.data[4*n],t.data[4*n+1],t.data[4*n+2]]);i[n]=s<l?0:255}return i}}(t,this.threshold());return e&&(e=function(t,e,n){const i=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(i.length)),s=Math.floor(r/2),a=[];for(let o=0;o<n;o++)for(let l=0;l<e;l++){const h=o*e+l;let c=0;for(let a=0;a<r;a++)for(let h=0;h<r;h++){const d=o+a-s,u=l+h-s;if(d>=0&&d<n&&u>=0&&u<e){const n=i[a*r+h];c+=t[d*e+u]*n}}a[h]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const i=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(i.length)),s=Math.floor(r/2),a=[];for(let o=0;o<n;o++)for(let l=0;l<e;l++){const h=o*e+l;let c=0;for(let a=0;a<r;a++)for(let h=0;h<r;h++){const d=o+a-s,u=l+h-s;if(d>=0&&d<n&&u>=0&&u<e){const n=i[a*r+h];c+=t[d*e+u]*n}}a[h]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const i=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(i.length)),s=Math.floor(r/2),a=[];for(let o=0;o<n;o++)for(let l=0;l<e;l++){const h=o*e+l;let c=0;for(let a=0;a<r;a++)for(let h=0;h<r;h++){const d=o+a-s,u=l+h-s;if(d>=0&&d<n&&u>=0&&u<e){const n=i[a*r+h];c+=t[d*e+u]*n}}a[h]=c}return a}(e,t.width,t.height),function(t,e){for(let n=0;n<t.width*t.height;n++)t.data[4*n+3]=e[n]}(t,e)),t},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Ee}var Ae,Ce={};var Re,Pe={};var Le,Ie={};var De,Ne={};var Ue,Oe={};var Fe,ke={};var Be,ze={};var Ge,He,Ve={};function We(){if(He)return v;He=1,Object.defineProperty(v,"__esModule",{value:!0}),v.Konva=void 0;const t=ft(),e=function(){if(mt)return gt;mt=1,Object.defineProperty(gt,"__esModule",{value:!0}),gt.Arc=void 0;const t=L(),e=et(),n=S(),i=P(),r=S();let s=class extends e.Shape{_sceneFunc(t){const e=n.Konva.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(),r=n.Konva.getAngle(i?360-this.angle():this.angle()),s=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),o=Math.sin(Math.min(r,Math.PI/2)),l=s*(s>0?t:e),h=a*(a>0?t:e),c=o*(o>0?e:t);return{x:l,y:i?-1*c:h,width:1*e-l,height:c-h}}};return gt.Arc=s,s.prototype._centroid=!0,s.prototype.className="Arc",s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1,(0,i.getBooleanValidator)()),gt}(),n=function(){if(Mt)return vt;Mt=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.Arrow=void 0;const t=L(),e=xt(),n=P(),i=S(),r=Tt();let s=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,n=this.points();let i=n;const s=0!==this.tension()&&n.length>4;s&&(i=this.getTensionPoints());const a=this.pointerLength(),o=n.length;let l,h;if(s){const t=[i[i.length-4],i[i.length-3],i[i.length-2],i[i.length-1],n[o-2],n[o-1]],e=r.Path.calcLength(i[i.length-4],i[i.length-3],"C",t),s=r.Path.getPointOnQuadraticBezier(Math.min(1,1-a/e),t[0],t[1],t[2],t[3],t[4],t[5]);l=n[o-2]-s.x,h=n[o-1]-s.y}else l=n[o-2]-n[o-4],h=n[o-1]-n[o-3];const c=(Math.atan2(h,l)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(n[o-2],n[o-1]),t.rotate(c),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(n[0],n[1]),s?(l=(i[0]+i[2])/2-n[0],h=(i[1]+i[3])/2-n[1]):(l=n[2]-n[0],h=n[3]-n[1]),t.rotate((Math.atan2(-h,-l)+e)%e),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/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-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}};return vt.Arrow=s,s.prototype.className="Arrow",(0,i._registerNode)(s),t.Factory.addGetterSetter(s,"pointerLength",10,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerWidth",10,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerAtBeginning",!1),t.Factory.addGetterSetter(s,"pointerAtEnding",!0),vt}(),i=function(){if(At)return Ct;At=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.Circle=void 0;const t=L(),e=et(),n=P(),i=S();let r=class extends e.Shape{_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)}};return Ct.Circle=r,r.prototype._centroid=!0,r.prototype.className="Circle",r.prototype._attrsAffectingSize=["radius"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,n.getNumberValidator)()),Ct}(),r=function(){if(Rt)return Pt;Rt=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.Ellipse=void 0;const t=L(),e=et(),n=P(),i=S();let r=class extends e.Shape{_sceneFunc(t){const e=this.radiusX(),n=this.radiusY();t.beginPath(),t.save(),e!==n&&t.scale(1,n/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)}};return Pt.Ellipse=r,r.prototype.className="Ellipse",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,i._registerNode)(r),t.Factory.addComponentsGetterSetter(r,"radius",["x","y"]),t.Factory.addGetterSetter(r,"radiusX",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"radiusY",0,(0,n.getNumberValidator)()),Pt}(),s=function(){if(Lt)return It;Lt=1,Object.defineProperty(It,"__esModule",{value:!0}),It.Image=void 0;const t=w(),e=L(),n=et(),i=S(),r=P();class s extends n.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(e){const n=this.getWidth(),i=this.getHeight(),r=this.cornerRadius(),s=this.attrs.image;let a;if(s){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;a=t&&e?[s,this.cropX(),this.cropY(),t,e,0,0,n,i]:[s,0,0,n,i]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?t.Util.drawRoundedRectPath(e,n,i,r):e.rect(0,0,n,i),e.closePath(),e.fillStrokeShape(this)),s&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){const n=this.width(),i=this.height(),r=this.cornerRadius();e.beginPath(),r?t.Util.drawRoundedRectPath(e,n,i,r):e.rect(0,0,n,i),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,n,i=null){const r=t.Util.createImageElement();r.onload=function(){const t=new s({image:r});n(t)},r.onerror=i,r.crossOrigin="Anonymous",r.src=e}}return It.Image=s,s.prototype.className="Image",(0,i._registerNode)(s),e.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(s,"image"),e.Factory.addComponentsGetterSetter(s,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(s,"cropX",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropY",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropWidth",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropHeight",0,(0,r.getNumberValidator)()),It}(),a=function(){if(Dt)return Nt;Dt=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.Tag=Nt.Label=void 0;const t=L(),e=et(),n=ot(),i=P(),r=S(),s=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],a="up",o="right",l="down",h="left",c=s.length;let d=class extends n.Group{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,n=this;const i=function(){n._sync()};for(e=0;e<c;e++)t.on(s[e]+"Change.konva",i)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,n,i,r,s,c,d=this.getText(),u=this.getTag();if(d&&u){switch(t=d.width(),e=d.height(),n=u.pointerDirection(),i=u.pointerWidth(),c=u.pointerHeight(),r=0,s=0,n){case a:r=t/2,s=-1*c;break;case o:r=t+i,s=e/2;break;case l:r=t/2,s=e+c;break;case h:r=-1*i,s=e/2}u.setAttrs({x:-1*r,y:-1*s,width:t,height:e}),d.setAttrs({x:-1*r,y:-1*s})}}};Nt.Label=d,d.prototype.className="Label",(0,r._registerNode)(d);class u extends e.Shape{_sceneFunc(t){const e=this.width(),n=this.height(),i=this.pointerDirection(),r=this.pointerWidth(),s=this.pointerHeight(),c=this.cornerRadius();let d=0,u=0,p=0,f=0;"number"==typeof c?d=u=p=f=Math.min(c,e/2,n/2):(d=Math.min(c[0]||0,e/2,n/2),u=Math.min(c[1]||0,e/2,n/2),f=Math.min(c[2]||0,e/2,n/2),p=Math.min(c[3]||0,e/2,n/2)),t.beginPath(),t.moveTo(d,0),i===a&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*s),t.lineTo((e+r)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),i===o&&(t.lineTo(e,(n-s)/2),t.lineTo(e+r,n/2),t.lineTo(e,(n+s)/2)),t.lineTo(e,n-f),t.arc(e-f,n-f,f,0,Math.PI/2,!1),i===l&&(t.lineTo((e+r)/2,n),t.lineTo(e/2,n+s),t.lineTo((e-r)/2,n)),t.lineTo(p,n),t.arc(p,n-p,p,Math.PI/2,Math.PI,!1),i===h&&(t.lineTo(0,(n+s)/2),t.lineTo(-1*r,n/2),t.lineTo(0,(n-s)/2)),t.lineTo(0,d),t.arc(d,d,d,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,n=this.pointerWidth(),i=this.pointerHeight(),r=this.pointerDirection(),s=this.width(),c=this.height();return r===a?(e-=i,c+=i):r===l?c+=i:r===h?(t-=1.5*n,s+=n):r===o&&(s+=1.5*n),{x:t,y:e,width:s,height:c}}}return Nt.Tag=u,u.prototype.className="Tag",(0,r._registerNode)(u),t.Factory.addGetterSetter(u,"pointerDirection","none"),t.Factory.addGetterSetter(u,"pointerWidth",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(u,"pointerHeight",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(u,"cornerRadius",0,(0,i.getNumberOrArrayOfNumbersValidator)(4)),Nt}(),o=xt(),l=Tt(),h=Ft(),c=function(){if(kt)return Bt;kt=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.RegularPolygon=void 0;const t=L(),e=et(),n=P(),i=S();let r=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,n=[];for(let i=0;i<t;i++)n.push({x:e*Math.sin(2*i*Math.PI/t),y:-1*e*Math.cos(2*i*Math.PI/t)});return n}getSelfRect(){const t=this._getPoints();let e=t[0].x,n=t[0].y,i=t[0].x,r=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),n=Math.max(n,t.x),i=Math.min(i,t.y),r=Math.max(r,t.y)})),{x:e,y:i,width:n-e,height:r-i}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return Bt.RegularPolygon=r,r.prototype.className="RegularPolygon",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radius"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"sides",0,(0,n.getNumberValidator)()),Bt}(),d=function(){if(zt)return Gt;zt=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.Ring=void 0;const t=L(),e=et(),n=P(),i=S(),r=2*Math.PI;let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,r,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),r,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)}};return Gt.Ring=s,s.prototype.className="Ring",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,i._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,n.getNumberValidator)()),Gt}(),u=function(){if(Ht)return Vt;Ht=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.Sprite=void 0;const t=L(),e=et(),n=ct(),i=P(),r=S();class s extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new n.Animation((()=>{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(),n=this.frameIndex(),i=4*n,r=this.animations()[e],s=this.frameOffsets(),a=r[i+0],o=r[i+1],l=r[i+2],h=r[i+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,l,h),t.closePath(),t.fillStrokeShape(this)),c)if(s){const i=s[e],r=2*n;t.drawImage(c,a,o,l,h,i[r+0],i[r+1],l,h)}else t.drawImage(c,a,o,l,h,0,0,l,h)}_hitFunc(t){const e=this.animation(),n=this.frameIndex(),i=4*n,r=this.animations()[e],s=this.frameOffsets(),a=r[i+2],o=r[i+3];if(t.beginPath(),s){const i=s[e],r=2*n;t.rect(i[r+0],i[r+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)}}return Vt.Sprite=s,s.prototype.className="Sprite",(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"animation"),t.Factory.addGetterSetter(s,"animations"),t.Factory.addGetterSetter(s,"frameOffsets"),t.Factory.addGetterSetter(s,"image"),t.Factory.addGetterSetter(s,"frameIndex",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"frameRate",17,(0,i.getNumberValidator)()),t.Factory.backCompat(s,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Vt}(),p=function(){if(Wt)return Xt;Wt=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.Star=void 0;const t=L(),e=et(),n=P(),i=S();let r=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),n=this.outerRadius(),i=this.numPoints();t.beginPath(),t.moveTo(0,0-n);for(let r=1;r<2*i;r++){const s=r%2==0?n:e,a=s*Math.sin(r*Math.PI/i),o=-1*s*Math.cos(r*Math.PI/i);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)}};return Xt.Star=r,r.prototype.className="Star",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"numPoints",5,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"innerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"outerRadius",0,(0,n.getNumberValidator)()),Xt}(),f=qt(),m=function(){if(Kt)return Zt;Kt=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.TextPath=void 0;const t=w(),e=L(),n=et(),i=Tt(),r=qt(),s=P(),a=S(),o="normal";function l(t){t.fillText(this.partialText,0,0)}function h(t){t.strokeText(this.partialText,0,0)}let c=class extends n.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.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 i.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:i.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=i.Path.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(),n=this.fill(),i=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(let n=0;n<r.length;n++){t.save();const s=r[n].p0;t.translate(s.x,s.y),t.rotate(r[n].rotation),this.partialText=r[n].text,t.fillStrokeShape(this),"underline"===e&&(0===n&&t.moveTo(0,i/2+1),t.lineTo(i,i/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=n,t.lineWidth=i/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const n=e[0].p0;t.moveTo(n.x,n.y)}for(let n=0;n<e.length;n++){const i=e[n].p1;t.lineTo(i.x,i.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return r.Text.prototype.setText.call(this,t)}_getContextFont(){return r.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const n=e.measureText(t);return e.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const n=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);let l=0;"center"===s&&(l=Math.max(0,this.pathLength/2-o/2)),"right"===s&&(l=Math.max(0,this.pathLength-o));const h=(0,r.stringToArray)(this.text());let c=l;for(let t=0;t<h.length;t++){const e=this._getPointAtLength(c);if(!e)return;let r=this._getTextSize(h[t]).width+n;if(" "===h[t]&&"justify"===s){const t=this.text().split(" ").length-1;r+=(this.pathLength-o)/t}const l=this._getPointAtLength(c+r);if(!l)return;const d=i.Path.getLineLength(e.x,e.y,l.x,l.y);let u=0;if(a)try{u=a(h[t-1],h[t])*this.fontSize()}catch(t){u=0}e.x+=u,l.x+=u,this.textWidth+=u;const p=i.Path.getPointOnLine(u+d/2,e.x,e.y,l.x,l.y),f=Math.atan2(l.y-e.y,l.x-e.x);this.glyphInfo.push({transposeX:p.x,transposeY:p.y,text:h[t],rotation:f,p0:e,p1:l}),c+=r}}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,n,i=t[0]||0,r=t[0]||0,s=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],n=t[2*o+1],i=Math.min(i,e),r=Math.max(r,e),s=Math.min(s,n),a=Math.max(a,n);const o=this.fontSize();return{x:i-o/2,y:s-o/2,width:r-i+o,height:a-s+o}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return Zt.TextPath=c,c.prototype._fillFunc=l,c.prototype._strokeFunc=h,c.prototype._fillFuncHit=l,c.prototype._strokeFuncHit=h,c.prototype.className="TextPath",c.prototype._attrsAffectingSize=["text","fontSize","data"],(0,a._registerNode)(c),e.Factory.addGetterSetter(c,"data"),e.Factory.addGetterSetter(c,"fontFamily","Arial"),e.Factory.addGetterSetter(c,"fontSize",12,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"fontStyle",o),e.Factory.addGetterSetter(c,"align","left"),e.Factory.addGetterSetter(c,"letterSpacing",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"textBaseline","middle"),e.Factory.addGetterSetter(c,"fontVariant",o),e.Factory.addGetterSetter(c,"text",""),e.Factory.addGetterSetter(c,"textDecoration",null),e.Factory.addGetterSetter(c,"kerningFunc",null),Zt}(),g=$t(),_=function(){if(te)return ee;te=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.Wedge=void 0;const t=L(),e=et(),n=S(),i=P(),r=S();let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,n.Konva.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)}};return ee.Wedge=s,s.prototype.className="Wedge",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1),t.Factory.backCompat(s,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),ee}(),y=re(),x=function(){if(se)return ae;se=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.Brighten=void 0;const t=L(),e=H(),n=P();return ae.Brighten=function(t){let e,n=255*this.brightness(),i=t.data,r=i.length;for(e=0;e<r;e+=4)i[e]+=n,i[e+1]+=n,i[e+2]+=n},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),ae}(),b=function(){if(oe)return le;oe=1,Object.defineProperty(le,"__esModule",{value:!0}),le.Contrast=void 0;const t=L(),e=H(),n=P();return le.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2);let n,i=t.data,r=i.length,s=150,a=150,o=150;for(n=0;n<r;n+=4)s=i[n],a=i[n+1],o=i[n+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,s=s<0?0:s>255?255:s,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,i[n]=s,i[n+1]=a,i[n+2]=o},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),le}(),M=function(){if(he)return ce;he=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.Emboss=void 0;const t=L(),e=H(),n=w(),i=P();return ce.Emboss=function(t){let e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),r=this.embossDirection(),s=this.embossBlend(),a=0,o=0,l=t.data,h=t.width,c=t.height,d=4*h,u=c;switch(r){case"top-left":a=-1,o=-1;break;case"top":a=-1,o=0;break;case"top-right":a=-1,o=1;break;case"right":a=0,o=1;break;case"bottom-right":a=1,o=1;break;case"bottom":a=1,o=0;break;case"bottom-left":a=1,o=-1;break;case"left":a=0,o=-1;break;default:n.Util.error("Unknown emboss direction: "+r)}do{const t=(u-1)*d;let n=a;u+n<1&&(n=0),u+n>c&&(n=0);const r=(u-1+n)*h*4;let p=h;do{const n=t+4*(p-1);let a=o;p+a<1&&(a=0),p+a>h&&(a=0);const c=r+4*(p-1+a),d=l[n]-l[c],u=l[n+1]-l[c+1],f=l[n+2]-l[c+2];let m=d;const g=m>0?m:-m;if((u>0?u:-u)>g&&(m=u),(f>0?f:-f)>g&&(m=f),m*=e,s){const t=l[n]+m,e=l[n+1]+m,i=l[n+2]+m;l[n]=t>255?255:t<0?0:t,l[n+1]=e>255?255:e<0?0:e,l[n+2]=i>255?255:i<0?0:i}else{let t=i-m;t<0?t=0:t>255&&(t=255),l[n]=l[n+1]=l[n+2]=t}}while(--p)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",null,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,null,t.Factory.afterSetFilter),ce}(),E=function(){if(de)return ue;de=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.Enhance=void 0;const t=L(),e=H(),n=P();function i(t,e,n,i,r){let s,a=n-e,o=r-i;return 0===a?i+o/2:0===o?i:(s=(t-e)/a,s=o*s+i,s)}return ue.Enhance=function(t){let e,n,r,s,a=t.data,o=a.length,l=a[0],h=l,c=a[1],d=c,u=a[2],p=u;const f=this.enhance();if(0===f)return;for(s=0;s<o;s+=4)e=a[s+0],e<l?l=e:e>h&&(h=e),n=a[s+1],n<c?c=n:n>d&&(d=n),r=a[s+2],r<u?u=r:r>p&&(p=r);let m,g,_,v,y,x,S,b,M;for(h===l&&(h=255,l=0),d===c&&(d=255,c=0),p===u&&(p=255,u=0),f>0?(g=h+f*(255-h),_=l-f*(l-0),y=d+f*(255-d),x=c-f*(c-0),b=p+f*(255-p),M=u-f*(u-0)):(m=.5*(h+l),g=h+f*(h-m),_=l+f*(l-m),v=.5*(d+c),y=d+f*(d-v),x=c+f*(c-v),S=.5*(p+u),b=p+f*(p-S),M=u+f*(u-S)),s=0;s<o;s+=4)a[s+0]=i(a[s+0],l,h,_,g),a[s+1]=i(a[s+1],c,d,x,y),a[s+2]=i(a[s+2],u,p,M,b)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),ue}(),T=(pe||(pe=1,Object.defineProperty(fe,"__esModule",{value:!0}),fe.Grayscale=void 0,fe.Grayscale=function(t){let e,n,i=t.data,r=i.length;for(e=0;e<r;e+=4)n=.34*i[e]+.5*i[e+1]+.16*i[e+2],i[e]=n,i[e+1]=n,i[e+2]=n}),fe),A=function(){if(me)return ge;me=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.HSL=void 0;const t=L(),e=H(),n=P();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),ge.HSL=function(t){let e,n=t.data,i=n.length,r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=127*this.luminance();const o=1*r*Math.cos(s*Math.PI/180),l=1*r*Math.sin(s*Math.PI/180),h=.299+.701*o+.167*l,c=.587-.587*o+.33*l,d=.114-.114*o-.497*l,u=.299-.299*o-.328*l,p=.587+.413*o+.035*l,f=.114-.114*o+.293*l,m=.299-.3*o+1.25*l,g=.587-.586*o-1.05*l,_=.114+.886*o-.2*l;let v,y,x,S;for(e=0;e<i;e+=4)v=n[e+0],y=n[e+1],x=n[e+2],S=n[e+3],n[e+0]=h*v+c*y+d*x+a,n[e+1]=u*v+p*y+f*x+a,n[e+2]=m*v+g*y+_*x+a,n[e+3]=S},ge}(),C=function(){if(_e)return ve;_e=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.HSV=void 0;const t=L(),e=H(),n=P();return ve.HSV=function(t){const e=t.data,n=e.length,i=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=i*r*Math.cos(s*Math.PI/180),o=i*r*Math.sin(s*Math.PI/180),l=.299*i+.701*a+.167*o,h=.587*i-.587*a+.33*o,c=.114*i-.114*a-.497*o,d=.299*i-.299*a-.328*o,u=.587*i+.413*a+.035*o,p=.114*i-.114*a+.293*o,f=.299*i-.3*a+1.25*o,m=.587*i-.586*a-1.05*o,g=.114*i+.886*a-.2*o;let _,v,y,x;for(let t=0;t<n;t+=4)_=e[t+0],v=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=l*_+h*v+c*y,e[t+1]=d*_+u*v+p*y,e[t+2]=f*_+m*v+g*y,e[t+3]=x},t.Factory.addGetterSetter(e.Node,"hue",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),ve}(),R=(ye||(ye=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.Invert=void 0,xe.Invert=function(t){let e,n=t.data,i=n.length;for(e=0;e<i;e+=4)n[e]=255-n[e],n[e+1]=255-n[e+1],n[e+2]=255-n[e+2]}),xe),I=Me(),D=Te(),N=function(){if(Ae)return Ce;Ae=1,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.Noise=void 0;const t=L(),e=H(),n=P();return Ce.Noise=function(t){const e=255*this.noise(),n=t.data,i=n.length,r=e/2;for(let t=0;t<i;t+=4)n[t+0]+=r-2*r*Math.random(),n[t+1]+=r-2*r*Math.random(),n[t+2]+=r-2*r*Math.random()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Ce}(),U=function(){if(Re)return Pe;Re=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.Pixelate=void 0;const t=L(),e=w(),n=H(),i=P();return Pe.Pixelate=function(t){let n,i,r,s,a,o,l,h,c,d,u,p,f,m,g=Math.ceil(this.pixelSize()),_=t.width,v=t.height,y=Math.ceil(_/g),x=Math.ceil(v/g),S=t.data;if(g<=0)e.Util.error("pixelSize value can not be <= 0");else for(p=0;p<y;p+=1)for(f=0;f<x;f+=1){for(s=0,a=0,o=0,l=0,h=p*g,c=h+g,d=f*g,u=d+g,m=0,n=h;n<c;n+=1)if(!(n>=_))for(i=d;i<u;i+=1)i>=v||(r=4*(_*i+n),s+=S[r+0],a+=S[r+1],o+=S[r+2],l+=S[r+3],m+=1);for(s/=m,a/=m,o/=m,l/=m,n=h;n<c;n+=1)if(!(n>=_))for(i=d;i<u;i+=1)i>=v||(r=4*(_*i+n),S[r+0]=s,S[r+1]=a,S[r+2]=o,S[r+3]=l)}},t.Factory.addGetterSetter(n.Node,"pixelSize",8,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Pe}(),O=function(){if(Le)return Ie;Le=1,Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.Posterize=void 0;const t=L(),e=H(),n=P();return Ie.Posterize=function(t){let e,n=Math.round(254*this.levels())+1,i=t.data,r=i.length,s=255/n;for(e=0;e<r;e+=1)i[e]=Math.floor(i[e]/s)*s},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Ie}(),F=function(){if(De)return Ne;De=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.RGB=void 0;const t=L(),e=H(),n=P();return Ne.RGB=function(t){let e,n,i=t.data,r=i.length,s=this.red(),a=this.green(),o=this.blue();for(e=0;e<r;e+=4)n=(.34*i[e]+.5*i[e+1]+.16*i[e+2])/255,i[e]=n*s,i[e+1]=n*a,i[e+2]=n*o,i[e+3]=i[e+3]},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,n.RGBComponent,t.Factory.afterSetFilter),Ne}(),k=function(){if(Ue)return Oe;Ue=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.RGBA=void 0;const t=L(),e=H(),n=P();return Oe.RGBA=function(t){const e=t.data,n=e.length,i=this.red(),r=this.green(),s=this.blue(),a=this.alpha();for(let t=0;t<n;t+=4){const n=1-a;e[t]=i*a+e[t]*n,e[t+1]=r*a+e[t+1]*n,e[t+2]=s*a+e[t+2]*n}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,n.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),Oe}(),B=(Fe||(Fe=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.Sepia=void 0,ke.Sepia=function(t){let e,n,i,r,s=t.data,a=s.length;for(e=0;e<a;e+=4)n=s[e+0],i=s[e+1],r=s[e+2],s[e+0]=Math.min(255,.393*n+.769*i+.189*r),s[e+1]=Math.min(255,.349*n+.686*i+.168*r),s[e+2]=Math.min(255,.272*n+.534*i+.131*r)}),ke),z=(Be||(Be=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.Solarize=void 0,ze.Solarize=function(t){const e=t.data,n=t.width,i=4*n;let r=t.height;do{const t=(r-1)*i;let s=n;do{const n=t+4*(s-1);let i=e[n],r=e[n+1],a=e[n+2];i>127&&(i=255-i),r>127&&(r=255-r),a>127&&(a=255-a),e[n]=i,e[n+1]=r,e[n+2]=a}while(--s)}while(--r)}),ze),G=function(){if(Ge)return Ve;Ge=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Threshold=void 0;const t=L(),e=H(),n=P();return Ve.Threshold=function(t){const e=255*this.threshold(),n=t.data,i=n.length;for(let t=0;t<i;t+=1)n[t]=n[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Ve}();return v.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:n.Arrow,Circle:i.Circle,Ellipse:r.Ellipse,Image:s.Image,Label:a.Label,Tag:a.Tag,Line:o.Line,Path:l.Path,Rect:h.Rect,RegularPolygon:c.RegularPolygon,Ring:d.Ring,Sprite:u.Sprite,Star:p.Star,Text:f.Text,TextPath:m.TextPath,Transformer:g.Transformer,Wedge:_.Wedge,Filters:{Blur:y.Blur,Brighten:x.Brighten,Contrast:b.Contrast,Emboss:M.Emboss,Enhance:E.Enhance,Grayscale:T.Grayscale,HSL:A.HSL,HSV:C.HSV,Invert:R.Invert,Kaleidoscope:I.Kaleidoscope,Mask:D.Mask,Noise:N.Noise,Pixelate:U.Pixelate,Posterize:O.Posterize,RGB:F.RGB,RGBA:k.RGBA,Sepia:B.Sepia,Solarize:z.Solarize,Threshold:G.Threshold}}),v}var Xe,je=_.exports;var Ye=m(function(){if(Xe)return _.exports;Xe=1,Object.defineProperty(je,"__esModule",{value:!0});const t=We();return _.exports=t.Konva,_.exports}());class qe{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 Ke{constructor(t,e,n){this.setColor(t,e,n)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,n){this.R=t,this.G=e,this.B=n,this.HEX=this.rgbToHex(t,e,n)}rgbToHex(t,e,n){const i=t=>{const e=t.toString(16);return"0"===e?"00":e};return i(t)+i(e)+i(n)}}const Ze=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class Qe{constructor(t,e=null){var n,i;if(e)return void(this._ref=e);t||(t={}),t.points||(t.points=[{x:50,y:50},{x:100,y:100}]);const r=[];t.points.forEach((t=>r.push(t.x,t.y))),this._ref=new Ye.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(i=t.width)&&void 0!==i?i:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:r,draggable:!0,strokeScaleEnabled:!1,dash:Ze.get(t.type)||[]}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),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 Ze.get("dot"):t="dot";break;case Ze.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=Ze.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();t.forEach((t=>{e=e.concat([t.x,t.y])})),this._ref.points(e)}}class Je{constructor(t,e=null){var n,i,r;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.text||(t.text="default"),this._ref=new Ye.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!==(i=t.color)&&void 0!==i?i:"#ff0000",align:"left",draggable:!0,rotation:null!==(r=t.rotation)&&void 0!==r?r:0}),this._ref.width(this._ref.getTextWidth()),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY);r<50&&(r=50),s<Math.round(this.getFontSize())&&(s=Math.round(this.getFontSize())),n&&this._ref.width(r),i&&this._ref.height(s),this._ref.scale({x:1,y:1})})),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})}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}}class $e{constructor(t,e=null){var n,i,r,s;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),this._ref=new Ye.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(i=t.lineWidth)&&void 0!==i?i: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!==(s=t.height)&&void 0!==s?s:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY);r<50&&(r=50),s<50&&(s=50),n&&this._ref.width(r),i&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t)}setHeight(t){this._ref.height(t)}setPosition(t,e){this._ref.setPosition({x:t,y:e})}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()}}class tn{constructor(t,e=null){var n,i;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.radius||(t.radius={x:25,y:25}),this._ref=new Ye.Ellipse({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(i=t.lineWidth)&&void 0!==i?i: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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();n&&(r*=e.scaleX);let s=this._ref.radiusY();i&&(s*=e.scaleY);r<25&&(r=25),s<25&&(s=25),t.evt.ctrlKey||t.evt.shiftKey?n?this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:s}),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t)}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(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}}class en{constructor(t,e=null){var n,i;e?this._ref=e:(t||(t={}),t.start||(t.start={x:50,y:50}),t.end||(t.end={x:100,y:100}),this._ref=new Ye.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(i=t.color)&&void 0!==i?i:"#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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),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.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 n=this._ref.points();this._ref.points([t,e,n[2],n[3]])}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const n=this._ref.points();this._ref.points([n[0],n[1],t,e])}}class nn{constructor(t,e=null){var n,i;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=",e)return 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(),void(this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width());t||(t={}),t.position||(t.position={x:50,y:50}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),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,n=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||n<=this.EPSILON)&&(n<=this.EPSILON&&n<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)))}},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new Ye.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(i=t.height)&&void 0!==i?i:0,draggable:!0}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?n?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(s/this._ratio),this._ref.height(s)):(n&&this._ref.width(r),i&&this._ref.height(s)),this._ref.scale({x:1,y:1})})),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)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio)}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})}}class rn{constructor(t,e=null){var n,i,r,s;if(e)return void(this._ref=e);t||(t={}),t.position||(t.position={x:100,y:100});const a=16;this._ref=new Ye.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(i=t.height)&&void 0!==i?i:200,stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const n=[{x:0,y:0},{x:0+this._ref.width(),y:0},{x:0+this._ref.width(),y:0+this._ref.height()},{x:0,y:0+this._ref.height()},{x:0,y:0}],i=(r={x:0,y:0},s=this._ref.width(),o=this._ref.height(),{x:r.x+s/2,y:r.y+o/2});var r,s,o;t.beginPath();for(let e=0;e<n.length-1;e++){let r=30;const s=n[e+1].x-n[e].x,o=n[e+1].y-n[e].y,l=Math.sqrt(s*s+o*o),h=Math.floor(l/r);r=30+h/(l%r);let c=n[e].x+s/h/2,d=n[e].y+o/h/2;const u=n[e+1].x,p=n[e+1].y,f=Math.atan((p-d)/(u-c)),m=f+Math.PI,g=c>i.x&&d>i.y;for(let e=0;e<h;e++)g?t.arc(c,d,a,f,m):t.arc(c,d,a,m,f),c+=s/h,d+=o/h}t.closePath(),t.fillStrokeShape(e)}}),this._ref.className="Cloud",this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY);r<100&&(r=100),s<100&&(s=100),n&&this._ref.width(r),i&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.getSelfRect=()=>({x:-16,y:-16,width:this._ref.width()+32,height:this._ref.height()+32}),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})}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}}const sn={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null)=>new Qe(e,t)},Text:{name:"Text",initializer:(t,e=null)=>new Je(e,t)},Rectangle:{name:"Rect",initializer:(t,e=null)=>new $e(e,t)},Ellipse:{name:"Ellipse",initializer:(t,e=null)=>new tn(e,t)},Arrow:{name:"Arrow",initializer:(t,e=null)=>new en(e,t)},Image:{name:"Image",initializer:(t,e=null)=>new nn(e,t)},Cloud:{name:"Cloud",initializer:(t,e=null)=>new rn(e,t)}};class an{constructor(){this._containerEvents=[],this._markupIsActive=!1,this._markupColor=new Ke(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=t=>{const{width:e,height:n}=t[0].contentRect;e&&n&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(n))},this.pan=t=>{const e={x:this._konvaStage.x()+t.dX,y:this._konvaStage.y()+t.dY};this._konvaStage.position(e)},this.zoomAt=t=>{const e=this._konvaStage.scaleX()*t.data;this._konvaStage.scale({x:e,y:e});const n={x:t.x-(t.x-this._konvaStage.x())*t.data,y:t.y-(t.y-this._konvaStage.y())*t.data};this._konvaStage.position(n)},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const n=e.getAbsoluteTransform().copy();return n.invert(),n.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,n,i){if(!Ye)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=n,this._worldTransformer=null!=i?i:new qe,this._container=t,this._containerEvents=null!=e?e:[],this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";const r=this._container.parentElement;r.appendChild(this._markupContainer),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(r),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,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,n){this._markupColor.setColor(t,e,n),this._viewer.emit({type:"changemarkupcolor",data:{r:t,g:e,b:n}})}colorizeAllMarkup(t,e,n){const i=new Ke(t,e,n).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,i)}))}colorizeSelectedMarkups(t,e,n){const i=new Ke(t,e,n).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,i)}))}setViewpoint(t){var e,n,i,r,s,a,o,l;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const h=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(h.r,h.g,h.b),null===(n=t.lines)||void 0===n||n.forEach((t=>{const e=[];t.points.forEach((t=>{const n=this._worldTransformer.worldToScreen(t);e.push(n.x),e.push(n.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(i=t.texts)||void 0===i||i.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===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addRectangle(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(s=t.ellipses)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addEllipse(e,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),n=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,n,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addCloud(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(l=t.images)||void 0===l||l.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addImage(e,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),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.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&sn[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 n=sn[t];if(!n||!n.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const i=n.initializer(null,e);return this.addObject(i),i}getObjects(){const t=[];return Object.keys(sn).forEach((e=>{const n=sn[e];this.konvaLayerFind(e).forEach((e=>t.push(n.initializer(e))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,n=Object.values(sn).find((t=>t.name===e));return n?n.initializer(t):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=sn[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)):[]}initializeKonva(){const t=new Ye.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new Ye.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new Ye.Group,e.add(this._groupImages),this._groupGeometry=new Ye.Group,e.add(this._groupGeometry),this._groupTexts=new Ye.Group,e.add(this._groupTexts),this._konvaLayer=e;const n=new Ye.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(n),this._konvaTransformer=n;let i,r,s,a=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&n.nodes().length>0)return void n.nodes([]);const s=this.getRelativePointerPosition(t);r=s,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(i=this.addLine([s.x,s.y,s.x,s.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),n=r&&e.x===r.x&&e.y===r.y,i=n?r.x:Math.min(r.x,e.x),s=n?r.y:Math.min(r.y,e.y),a=n?200:Math.abs(r.x-e.x),o=n?200:Math.abs(r.y-e.y);n&&("Rectangle"===this._markupMode?this.addRectangle({x:i,y:s},a,o):"Ellipse"===this._markupMode?this.addEllipse({x:i,y:s},{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:n?r.x+200:e.x,y:n?s:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:i,y:s},Math.max(100,a),Math.max(100,o)))}s=void 0,a=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!a)return;const n=this.getRelativePointerPosition(t),o=r&&n.x===r.x&&n.y===r.y,l=o?r.x:Math.min(r.x,n.x),h=o?r.y:Math.min(r.y,n.y),c=o?200:Math.abs(r.x-n.x),d=o?200:Math.abs(r.y-n.y);"Line"===this._markupMode?i.addPoints([{x:n.x,y:n.y}]):"Arrow"===this._markupMode?s?s.setEndPoint(n.x,n.y):s=this.addArrow({x:r.x,y:r.y},{x:n.x,y:n.y}):"Rectangle"===this._markupMode?s?(s.setPosition(l,h),s.setWidth(c),s.setHeight(d)):s=this.addRectangle({x:l,y:h},c,d):"Ellipse"===this._markupMode?s?(s.setPosition(l,h),s.setRadiusX(c),s.setRadiusY(d)):s=this.addEllipse({x:l,y:h},{x:c,y:d}):"Cloud"===this._markupMode&&(s?(s.setPosition(l,h),s.setWidth(Math.max(100,c)),s.setHeight(Math.max(100,d))):s=this.addCloud({x:l,y:h},c,d))})),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===n.nodes().length){const n=this.getRelativePointerPosition(t);this.createTextInput(n,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},this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===n.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void n.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===n.nodes().length&&n.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===n.nodes().length&&n.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}n.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?n.rotateEnabled(!1):n.rotateEnabled(!0);const i=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=n.nodes().indexOf(e.target)>=0;if(i||r){if(i&&r){const t=n.nodes().slice();t.splice(t.indexOf(e.target),1),n.nodes(t)}else if(i&&!r){const t=n.nodes().concat([e.target]);n.nodes(t)}}else n.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 n=e.points();if(!n)return;const i=[],r=e.getAbsoluteTransform();for(let t=0;t<n.length;t+=2){const e=r.point({x:n[t],y:n[t+1]}),s=this._worldTransformer.screenToWorld(e);i.push(s)}const s=new Qe(null,e),a={id:s.id(),points:i,color:s.getColor()||"#ff0000",type:s.getLineType()||this.lineType,width:s.getLineWidth()||this.lineWidth};t.push(a)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const n=this._worldTransformer.getScale(),i=e.position(),r=this._konvaStage.getAbsoluteTransform(),s=r.point({x:i.x,y:i.y}),a=this._worldTransformer.screenToWorld(s),o=new Je(null,e),l={id:o.id(),position:a,text:o.getText(),text_size:.02*n.y,angle:o.getRotation(),color:o.getColor(),font_size:o.getFontSize()*r.getMatrix()[0]};t.push(l)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new $e(null,e),l={id:o.id(),position:s,width:o.getWidth()*a,height:o.getHeigth()*a,line_width:o.getLineWidth(),color:o.getColor()};t.push(l)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new tn(null,e),l={id:o.id(),position:s,radius:{x:e.getRadiusX()*a,y:e.getRadiusY()*a},line_width:o.getLineWidth(),color:o.getColor()};t.push(l)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const n=e.getAbsoluteTransform(),i=n.point({x:e.points()[0],y:e.points()[1]}),r=this._worldTransformer.screenToWorld(i),s=n.point({x:e.points()[2],y:e.points()[3]}),a=this._worldTransformer.screenToWorld(s),o=new en(null,e),l={id:o.id(),start:r,end:a,color:o.getColor()};t.push(l)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new nn(null,e),l={id:o.id(),position:s,src:o.getSrc(),width:o.getWidth()*a,height:o.getHeight()*a};t.push(l)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new rn(null,e),l={id:o.id(),position:s,width:o.getWidth()*a,height:o.getHeigth()*a,line_width:o.getLineWidth(),color:o.getColor()};t.push(l)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,n,i,r){if(!t||0===t.length)return;const s=[];for(let e=0;e<t.length;e+=2)s.push({x:t[e],y:t[e+1]});const a=new Qe({points:s,type:n||this.lineType,width:i||this.lineWidth,color:e||this._markupColor.asHex(),id:r});return this.addObject(a),a}createTextInput(t,e,n,i,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=i,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=n+"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())},r&&(this._textInputRef.value=r),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,n)=>{const i=new FileReader;i.readAsDataURL(t),i.onload=()=>{e(i.result)},i.onerror=t=>{n(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 n=t.target.files[0],i=await e(n);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},i.toString(),0,0)},this._imageInputRef.oncancel=t=>{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,n,i,r,s,a){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const l=1e-6;if(r&&r>l&&(!s||s<l)){const t=.02;s=r/(this._worldTransformer.getScale().y/t)/34}const h=new Je({position:{x:e.x,y:e.y},text:t,rotation:n,fontSize:s||this.fontSize,color:i||this._markupColor.asHex(),id:a});return this.addObject(h),h}addRectangle(t,e,n,i,r,s){if(!t)return;const a=new $e({position:t,width:e,height:n,lineWidth:i||this.lineWidth,color:r||this._markupColor.asHex(),id:s});return this.addObject(a),a}addEllipse(t,e,n,i,r){if(!t)return;const s=new tn({position:t,radius:e,lineWidth:n,color:i||this._markupColor.asHex(),id:r});return this.addObject(s),s}addArrow(t,e,n,i){if(!t||!e)return;const r=new en({start:t,end:e,color:n||this._markupColor.asHex(),id:i});return this.addObject(r),r}addCloud(t,e,n,i,r,s){if(!t||!e||!n)return;const a=new rn({position:t,width:e,height:n,color:r||this._markupColor.asHex(),lineWidth:i||this.lineWidth,id:s});return this.addObject(a),a}addImage(t,e,n,i,r){var s;if(!t||!e)return;null===(s=this.getSelectedObjects().at(0))||void 0===s||s.delete(),this.clearSelected(),this.removeImageInput();const a=new nn({position:t,src:e,width:n,height:i,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:r});return this.addObject(a),a}}
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2010-2024 Three.js Authors
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
|
-
*/
|
|
7
|
-
const l="170",h=0,c=1,d=2,u=0,p=1,f=2,m=3,g=1,_=2,v=3,y=0,x=1,S=2,b=100,M=101,w=102,E=200,T=201,A=202,C=203,R=204,P=205,L=206,I=207,D=208,N=209,U=210,O=211,F=212,k=213,B=214,z=0,G=1,H=2,V=3,W=4,X=5,j=6,Y=7,q=0,K=1,Z=2,J=0,Q=1,$=2,tt=3,et=4,nt=5,it=6,rt=7,st="attached",at=301,ot=302,lt=306,ht=1e3,ct=1001,dt=1002,ut=1003,pt=1004,ft=1005,mt=1006,gt=1007,_t=1008,vt=1009,yt=1010,xt=1011,St=1012,bt=1013,Mt=1014,wt=1015,Et=1016,Tt=1017,At=1018,Ct=1020,Rt=35902,Pt=1021,Lt=1022,It=1023,Dt=1024,Nt=1025,Ut=1026,Ot=1027,Ft=1028,kt=1029,Bt=1030,zt=1031,Gt=1033,Ht=33776,Vt=33777,Wt=33778,Xt=33779,jt=35840,Yt=35841,qt=35842,Kt=35843,Zt=36196,Jt=37492,Qt=37496,$t=37808,te=37809,ee=37810,ne=37811,ie=37812,re=37813,se=37814,ae=37815,oe=37816,le=37817,he=37818,ce=37819,de=37820,ue=37821,pe=36492,fe=36494,me=36495,ge=36283,_e=36284,ve=36285,ye=36286,xe=2300,Se=2301,be=2302,Me="",we="srgb",Ee="srgb-linear",Te="linear",Ae="srgb",Ce=7680,Re=512,Pe=513,Le=514,Ie=515,De=516,Ne=517,Ue=518,Oe=519,Fe=35044,ke="300 es",Be=2e3,ze=2001;class Ge{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}}const He=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Ve=1234567;const We=Math.PI/180,Xe=180/Math.PI;function je(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(He[255&t]+He[t>>8&255]+He[t>>16&255]+He[t>>24&255]+"-"+He[255&e]+He[e>>8&255]+"-"+He[e>>16&15|64]+He[e>>24&255]+"-"+He[63&n|128]+He[n>>8&255]+"-"+He[n>>16&255]+He[n>>24&255]+He[255&i]+He[i>>8&255]+He[i>>16&255]+He[i>>24&255]).toLowerCase()}function Ye(t,e,n){return Math.max(e,Math.min(n,t))}function qe(t,e){return(t%e+e)%e}function Ke(t,e,n){return(1-n)*t+n*e}function Ze(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Je(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Qe={DEG2RAD:We,RAD2DEG:Xe,generateUUID:je,clamp:Ye,euclideanModulo:qe,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:Ke,damp:function(t,e,n,i){return Ke(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(qe(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(Ve=t);let e=Ve+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*We},radToDeg:function(t){return t*Xe},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),h=s((e+i)/2),c=a((e+i)/2),d=s((e-i)/2),u=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*c,l*d,l*u,o*h);break;case"YZY":t.set(l*u,o*c,l*d,o*h);break;case"ZXZ":t.set(l*d,l*u,o*c,o*h);break;case"XZX":t.set(o*c,l*f,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*f,o*h);break;case"ZYZ":t.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Je,denormalize:Ze};class $e{constructor(t=0,e=0){$e.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Ye(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class tn{constructor(t,e,n,i,r,s,a,o,l){tn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=r,h[5]=o,h[6]=n,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],h=n[4],c=n[7],d=n[2],u=n[5],p=n[8],f=i[0],m=i[3],g=i[6],_=i[1],v=i[4],y=i[7],x=i[2],S=i[5],b=i[8];return r[0]=s*f+a*_+o*x,r[3]=s*m+a*v+o*S,r[6]=s*g+a*y+o*b,r[1]=l*f+h*_+c*x,r[4]=l*m+h*v+c*S,r[7]=l*g+h*y+c*b,r[2]=d*f+u*_+p*x,r[5]=d*m+u*v+p*S,r[8]=d*g+u*y+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*s*h-e*a*l-n*r*h+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=h*s-a*l,d=a*o-h*r,u=l*r-s*o,p=e*c+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=c*f,t[1]=(i*l-h*n)*f,t[2]=(a*n-i*s)*f,t[3]=d*f,t[4]=(h*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=u*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(en.makeScale(t,e)),this}rotate(t){return this.premultiply(en.makeRotation(-t)),this}translate(t,e){return this.premultiply(en.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const en=new tn;function nn(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function rn(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function sn(){const t=rn("canvas");return t.style.display="block",t}const an={};function on(t){t in an||(an[t]=!0,console.warn(t))}const ln={enabled:!0,workingColorSpace:Ee,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===Ae&&(t.r=hn(t.r),t.g=hn(t.g),t.b=hn(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Ae&&(t.r=cn(t.r),t.g=cn(t.g),t.b=cn(t.b)),t):t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===Me?Te:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}};function hn(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function cn(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const dn=[.64,.33,.3,.6,.15,.06],un=[.2126,.7152,.0722],pn=[.3127,.329],fn=(new tn).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mn=(new tn).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);let gn;ln.define({[Ee]:{primaries:dn,whitePoint:pn,transfer:Te,toXYZ:fn,fromXYZ:mn,luminanceCoefficients:un,workingColorSpaceConfig:{unpackColorSpace:we},outputColorSpaceConfig:{drawingBufferColorSpace:we}},[we]:{primaries:dn,whitePoint:pn,transfer:Ae,toXYZ:fn,fromXYZ:mn,luminanceCoefficients:un,outputColorSpaceConfig:{drawingBufferColorSpace:we}}});class _n{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===gn&&(gn=rn("canvas")),gn.width=t.width,gn.height=t.height;const n=gn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=gn}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=rn("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*hn(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*hn(e[t]/255)):e[t]=hn(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let vn=0;class yn{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:vn++}),this.uuid=je(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(xn(i[e].image)):t.push(xn(i[e]))}else t=xn(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function xn(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?_n.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Sn=0;class bn extends Ge{constructor(t=bn.DEFAULT_IMAGE,e=bn.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=It,o=vt,l=bn.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Sn++}),this.uuid=je(),this.name="",this.source=new yn(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new $e(0,0),this.repeat=new $e(1,1),this.center=new $e(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ht:t.x=t.x-Math.floor(t.x);break;case ct:t.x=t.x<0?0:1;break;case dt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case ht:t.y=t.y-Math.floor(t.y);break;case ct:t.y=t.y<0?0:1;break;case dt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}bn.DEFAULT_IMAGE=null,bn.DEFAULT_MAPPING=300,bn.DEFAULT_ANISOTROPY=1;class Mn{constructor(t=0,e=0,n=0,i=1){Mn.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],h=o[4],c=o[8],d=o[1],u=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(h-d)<s&&Math.abs(c-f)<s&&Math.abs(p-m)<s){if(Math.abs(h+d)<a&&Math.abs(c+f)<a&&Math.abs(p+m)<a&&Math.abs(l+u+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(u+1)/2,_=(g+1)/2,v=(h+d)/4,y=(c+f)/4,x=(p+m)/4;return t>o&&t>_?t<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=v/n,r=y/n):o>_?o<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=v/i,r=x/i):_<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(_),n=y/r,i=x/r),this.set(n,i,r,e),this}let _=Math.sqrt((m-p)*(m-p)+(c-f)*(c-f)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(c-f)/_,this.z=(d-h)/_,this.w=Math.acos((l+u+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class wn extends Ge{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Mn(0,0,t,e),this.scissorTest=!1,this.viewport=new Mn(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:mt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new bn(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const s=n.count;for(let t=0;t<s;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++)this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new yn(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class En extends wn{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Tn extends bn{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ut,this.minFilter=ut,this.wrapR=ct,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class An extends bn{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ut,this.minFilter=ut,this.wrapR=ct,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Cn{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,s,a){let o=n[i+0],l=n[i+1],h=n[i+2],c=n[i+3];const d=r[s+0],u=r[s+1],p=r[s+2],f=r[s+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=h,void(t[e+3]=c);if(1===a)return t[e+0]=d,t[e+1]=u,t[e+2]=p,void(t[e+3]=f);if(c!==f||o!==d||l!==u||h!==p){let t=1-a;const e=o*d+l*u+h*p+c*f,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+d*r,l=l*t+u*r,h=h*t+p*r,c=c*t+f*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=t,l*=t,h*=t,c*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],h=n[i+3],c=r[s],d=r[s+1],u=r[s+2],p=r[s+3];return t[e]=a*p+h*c+o*u-l*d,t[e+1]=o*p+h*d+l*c-a*u,t[e+2]=l*p+h*u+a*d-o*c,t[e+3]=h*p-a*c-o*d-l*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),h=a(i/2),c=a(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"YXZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"ZXY":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"ZYX":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"YZX":this._x=d*h*c+l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c-d*u*p;break;case"XZY":this._x=d*h*c-l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],d=n+a+c;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(h-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>c){const t=2*Math.sqrt(1+n-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-n-c);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ye(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=n*h+s*a+i*l-r*o,this._y=i*h+s*o+r*a-n*l,this._z=r*h+s*l+n*o-i*a,this._w=s*h-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(o),h=Math.atan2(l,a),c=Math.sin((1-e)*h)/l,d=Math.sin(e*h)/l;return this._w=s*c+this._w*d,this._x=n*c+this._x*d,this._y=i*c+this._y*d,this._z=r*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Rn{constructor(t=0,e=0,n=0){Rn.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ln.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ln.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),h=2*(a*e-r*i),c=2*(r*n-s*e);return this.x=e+o*l+s*c-a*h,this.y=n+o*h+a*l-r*c,this.z=i+o*c+r*h-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Pn.copy(this).projectOnVector(t),this.sub(Pn)}reflect(t){return this.sub(Pn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Ye(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Pn=new Rn,Ln=new Cn;class In{constructor(t=new Rn(1/0,1/0,1/0),e=new Rn(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Nn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Nn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Nn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}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=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,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}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,Nn):Nn.fromBufferAttribute(i,e),Nn.applyMatrix4(t.matrixWorld),this.expandByPoint(Nn);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Un.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),Un.copy(n.boundingBox)),Un.applyMatrix4(t.matrixWorld),this.union(Un)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}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&&this.min.z<=t.min.z&&t.max.z<=this.max.z}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),(t.z-this.min.z)/(this.max.z-this.min.z))}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&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Nn),Nn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Hn),Vn.subVectors(this.max,Hn),On.subVectors(t.a,Hn),Fn.subVectors(t.b,Hn),kn.subVectors(t.c,Hn),Bn.subVectors(Fn,On),zn.subVectors(kn,Fn),Gn.subVectors(On,kn);let e=[0,-Bn.z,Bn.y,0,-zn.z,zn.y,0,-Gn.z,Gn.y,Bn.z,0,-Bn.x,zn.z,0,-zn.x,Gn.z,0,-Gn.x,-Bn.y,Bn.x,0,-zn.y,zn.x,0,-Gn.y,Gn.x,0];return!!jn(e,On,Fn,kn,Vn)&&(e=[1,0,0,0,1,0,0,0,1],!!jn(e,On,Fn,kn,Vn)&&(Wn.crossVectors(Bn,zn),e=[Wn.x,Wn.y,Wn.z],jn(e,On,Fn,kn,Vn)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Nn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Nn).length()),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}applyMatrix4(t){return this.isEmpty()||(Dn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Dn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Dn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Dn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Dn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Dn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Dn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Dn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Dn)),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)}}const Dn=[new Rn,new Rn,new Rn,new Rn,new Rn,new Rn,new Rn,new Rn],Nn=new Rn,Un=new In,On=new Rn,Fn=new Rn,kn=new Rn,Bn=new Rn,zn=new Rn,Gn=new Rn,Hn=new Rn,Vn=new Rn,Wn=new Rn,Xn=new Rn;function jn(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){Xn.fromArray(t,s);const a=r.x*Math.abs(Xn.x)+r.y*Math.abs(Xn.y)+r.z*Math.abs(Xn.z),o=e.dot(Xn),l=n.dot(Xn),h=i.dot(Xn);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Yn=new In,qn=new Rn,Kn=new Rn;class Zn{constructor(t=new Rn,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Yn.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;qn.subVectors(t,this.center);const e=qn.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(qn,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Kn.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(qn.copy(t.center).add(Kn)),this.expandByPoint(qn.copy(t.center).sub(Kn))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Jn=new Rn,Qn=new Rn,$n=new Rn,ti=new Rn,ei=new Rn,ni=new Rn,ii=new Rn;class ri{constructor(t=new Rn,e=new Rn(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Jn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Jn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Jn.copy(this.origin).addScaledVector(this.direction,e),Jn.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Qn.copy(t).add(e).multiplyScalar(.5),$n.copy(e).sub(t).normalize(),ti.copy(this.origin).sub(Qn);const r=.5*t.distanceTo(e),s=-this.direction.dot($n),a=ti.dot(this.direction),o=-ti.dot($n),l=ti.lengthSq(),h=Math.abs(1-s*s);let c,d,u,p;if(h>0)if(c=s*o-a,d=s*a-o,p=r*h,c>=0)if(d>=-p)if(d<=p){const t=1/h;c*=t,d*=t,u=c*(c+s*d+2*a)+d*(s*c+d+2*o)+l}else d=r,c=Math.max(0,-(s*d+a)),u=-c*c+d*(d+2*o)+l;else d=-r,c=Math.max(0,-(s*d+a)),u=-c*c+d*(d+2*o)+l;else d<=-p?(c=Math.max(0,-(-s*r+a)),d=c>0?-r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l):d<=p?(c=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(c=Math.max(0,-(s*r+a)),d=c>0?r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l);else d=s>0?-r:r,c=Math.max(0,-(s*d+a)),u=-c*c+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,c),i&&i.copy(Qn).addScaledVector($n,d),u}intersectSphere(t,e){Jn.subVectors(t.center,this.origin);const n=Jn.dot(this.direction),i=Jn.dot(Jn)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,s=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,s=(t.min.y-d.y)*h),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),c>=0?(a=(t.min.z-d.z)*c,o=(t.max.z-d.z)*c):(a=(t.max.z-d.z)*c,o=(t.min.z-d.z)*c),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,Jn)}intersectTriangle(t,e,n,i,r){ei.subVectors(e,t),ni.subVectors(n,t),ii.crossVectors(ei,ni);let s,a=this.direction.dot(ii);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}ti.subVectors(this.origin,t);const o=s*this.direction.dot(ni.crossVectors(ti,ni));if(o<0)return null;const l=s*this.direction.dot(ei.cross(ti));if(l<0)return null;if(o+l>a)return null;const h=-s*ti.dot(ii);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class si{constructor(t,e,n,i,r,s,a,o,l,h,c,d,u,p,f,m){si.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,h,c,d,u,p,f,m)}set(t,e,n,i,r,s,a,o,l,h,c,d,u,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=d,g[3]=u,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new si).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/ai.setFromMatrixColumn(t,0).length(),r=1/ai.setFromMatrixColumn(t,1).length(),s=1/ai.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),h=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=s*h,n=s*c,i=a*h,r=a*c;e[0]=o*h,e[4]=-o*c,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*h,n=o*c,i=l*h,r=l*c;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*c,e[5]=s*h,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*h,n=o*c,i=l*h,r=l*c;e[0]=t-r*a,e[4]=-s*c,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*h,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*h,n=s*c,i=a*h,r=a*c;e[0]=o*h,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*c,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*h,e[4]=r-t*c,e[8]=i*c+n,e[1]=c,e[5]=s*h,e[9]=-a*h,e[2]=-l*h,e[6]=n*c+i,e[10]=t-r*c}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*h,e[4]=-c,e[8]=l*h,e[1]=t*c+r,e[5]=s*h,e[9]=n*c-i,e[2]=i*c-n,e[6]=a*h,e[10]=r*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(li,t,hi)}lookAt(t,e,n){const i=this.elements;return ui.subVectors(t,e),0===ui.lengthSq()&&(ui.z=1),ui.normalize(),ci.crossVectors(n,ui),0===ci.lengthSq()&&(1===Math.abs(n.z)?ui.x+=1e-4:ui.z+=1e-4,ui.normalize(),ci.crossVectors(n,ui)),ci.normalize(),di.crossVectors(ui,ci),i[0]=ci.x,i[4]=di.x,i[8]=ui.x,i[1]=ci.y,i[5]=di.y,i[9]=ui.y,i[2]=ci.z,i[6]=di.z,i[10]=ui.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],h=n[1],c=n[5],d=n[9],u=n[13],p=n[2],f=n[6],m=n[10],g=n[14],_=n[3],v=n[7],y=n[11],x=n[15],S=i[0],b=i[4],M=i[8],w=i[12],E=i[1],T=i[5],A=i[9],C=i[13],R=i[2],P=i[6],L=i[10],I=i[14],D=i[3],N=i[7],U=i[11],O=i[15];return r[0]=s*S+a*E+o*R+l*D,r[4]=s*b+a*T+o*P+l*N,r[8]=s*M+a*A+o*L+l*U,r[12]=s*w+a*C+o*I+l*O,r[1]=h*S+c*E+d*R+u*D,r[5]=h*b+c*T+d*P+u*N,r[9]=h*M+c*A+d*L+u*U,r[13]=h*w+c*C+d*I+u*O,r[2]=p*S+f*E+m*R+g*D,r[6]=p*b+f*T+m*P+g*N,r[10]=p*M+f*A+m*L+g*U,r[14]=p*w+f*C+m*I+g*O,r[3]=_*S+v*E+y*R+x*D,r[7]=_*b+v*T+y*P+x*N,r[11]=_*M+v*A+y*L+x*U,r[15]=_*w+v*C+y*I+x*O,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],h=t[2],c=t[6],d=t[10],u=t[14];return t[3]*(+r*o*c-i*l*c-r*a*d+n*l*d+i*a*u-n*o*u)+t[7]*(+e*o*u-e*l*d+r*s*d-i*s*u+i*l*h-r*o*h)+t[11]*(+e*l*c-e*a*u-r*s*c+n*s*u+r*a*h-n*l*h)+t[15]*(-i*a*h-e*o*c+e*a*d+i*s*c-n*s*d+n*o*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=t[9],d=t[10],u=t[11],p=t[12],f=t[13],m=t[14],g=t[15],_=c*m*l-f*d*l+f*o*u-a*m*u-c*o*g+a*d*g,v=p*d*l-h*m*l-p*o*u+s*m*u+h*o*g-s*d*g,y=h*f*l-p*c*l+p*a*u-s*f*u-h*a*g+s*c*g,x=p*c*o-h*f*o-p*a*d+s*f*d+h*a*m-s*c*m,S=e*_+n*v+i*y+r*x;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/S;return t[0]=_*b,t[1]=(f*d*r-c*m*r-f*i*u+n*m*u+c*i*g-n*d*g)*b,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*b,t[3]=(c*o*r-a*d*r-c*i*l+n*d*l+a*i*u-n*o*u)*b,t[4]=v*b,t[5]=(h*m*r-p*d*r+p*i*u-e*m*u-h*i*g+e*d*g)*b,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*b,t[7]=(s*d*r-h*o*r+h*i*l-e*d*l-s*i*u+e*o*u)*b,t[8]=y*b,t[9]=(p*c*r-h*f*r-p*n*u+e*f*u+h*n*g-e*c*g)*b,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*b,t[11]=(h*a*r-s*c*r-h*n*l+e*c*l+s*n*u-e*a*u)*b,t[12]=x*b,t[13]=(h*f*i-p*c*i+p*n*d-e*f*d-h*n*m+e*c*m)*b,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*b,t[15]=(s*c*i-h*a*i+h*n*o-e*c*o-s*n*d+e*a*d)*b,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,h=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,h*a+n,h*o-i*s,0,l*o-i*a,h*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,h=s+s,c=a+a,d=r*l,u=r*h,p=r*c,f=s*h,m=s*c,g=a*c,_=o*l,v=o*h,y=o*c,x=n.x,S=n.y,b=n.z;return i[0]=(1-(f+g))*x,i[1]=(u+y)*x,i[2]=(p-v)*x,i[3]=0,i[4]=(u-y)*S,i[5]=(1-(d+g))*S,i[6]=(m+_)*S,i[7]=0,i[8]=(p+v)*b,i[9]=(m-_)*b,i[10]=(1-(d+f))*b,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=ai.set(i[0],i[1],i[2]).length();const s=ai.set(i[4],i[5],i[6]).length(),a=ai.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],oi.copy(this);const o=1/r,l=1/s,h=1/a;return oi.elements[0]*=o,oi.elements[1]*=o,oi.elements[2]*=o,oi.elements[4]*=l,oi.elements[5]*=l,oi.elements[6]*=l,oi.elements[8]*=h,oi.elements[9]*=h,oi.elements[10]*=h,e.setFromRotationMatrix(oi),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=2e3){const o=this.elements,l=2*r/(e-t),h=2*r/(n-i),c=(e+t)/(e-t),d=(n+i)/(n-i);let u,p;if(a===Be)u=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==ze)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);u=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=h,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=2e3){const o=this.elements,l=1/(e-t),h=1/(n-i),c=1/(s-r),d=(e+t)*l,u=(n+i)*h;let p,f;if(a===Be)p=(s+r)*c,f=-2*c;else{if(a!==ze)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*c,f=-1*c}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const ai=new Rn,oi=new si,li=new Rn(0,0,0),hi=new Rn(1,1,1),ci=new Rn,di=new Rn,ui=new Rn,pi=new si,fi=new Cn;class mi{constructor(t=0,e=0,n=0,i=mi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],h=i[9],c=i[2],d=i[6],u=i[10];switch(e){case"XYZ":this._y=Math.asin(Ye(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ye(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,u),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Ye(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,u));break;case"XZY":this._z=Math.asin(-Ye(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return pi.makeRotationFromQuaternion(t),this.setFromRotationMatrix(pi,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return fi.setFromEuler(this),this.setFromQuaternion(fi,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}mi.DEFAULT_ORDER="XYZ";class gi{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return!!(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let _i=0;const vi=new Rn,yi=new Cn,xi=new si,Si=new Rn,bi=new Rn,Mi=new Rn,wi=new Cn,Ei=new Rn(1,0,0),Ti=new Rn(0,1,0),Ai=new Rn(0,0,1),Ci={type:"added"},Ri={type:"removed"},Pi={type:"childadded",child:null},Li={type:"childremoved",child:null};class Ii extends Ge{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_i++}),this.uuid=je(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ii.DEFAULT_UP.clone();const t=new Rn,e=new mi,n=new Cn,i=new Rn(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new si},normalMatrix:{value:new tn}}),this.matrix=new si,this.matrixWorld=new si,this.matrixAutoUpdate=Ii.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ii.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return yi.setFromAxisAngle(t,e),this.quaternion.multiply(yi),this}rotateOnWorldAxis(t,e){return yi.setFromAxisAngle(t,e),this.quaternion.premultiply(yi),this}rotateX(t){return this.rotateOnAxis(Ei,t)}rotateY(t){return this.rotateOnAxis(Ti,t)}rotateZ(t){return this.rotateOnAxis(Ai,t)}translateOnAxis(t,e){return vi.copy(t).applyQuaternion(this.quaternion),this.position.add(vi.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ei,t)}translateY(t){return this.translateOnAxis(Ti,t)}translateZ(t){return this.translateOnAxis(Ai,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(xi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Si.copy(t):Si.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),bi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xi.lookAt(bi,Si,this.up):xi.lookAt(Si,bi,this.up),this.quaternion.setFromRotationMatrix(xi),i&&(xi.extractRotation(i.matrixWorld),yi.setFromRotationMatrix(xi),this.quaternion.premultiply(yi.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Ci),Pi.child=t,this.dispatchEvent(Pi),Pi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ri),Li.child=t,this.dispatchEvent(Li),Li.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),xi.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),xi.multiply(t.parent.matrixWorld)),t.applyMatrix4(xi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Ci),Pi.child=t,this.dispatchEvent(Pi),Pi.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bi,t,Mi),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bi,wi,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=s(t.geometries),i=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),h=s(t.animations),c=s(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h),c.length>0&&(n.nodes=c)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}Ii.DEFAULT_UP=new Rn(0,1,0),Ii.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ii.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Di=new Rn,Ni=new Rn,Ui=new Rn,Oi=new Rn,Fi=new Rn,ki=new Rn,Bi=new Rn,zi=new Rn,Gi=new Rn,Hi=new Rn,Vi=new Mn,Wi=new Mn,Xi=new Mn;class ji{constructor(t=new Rn,e=new Rn,n=new Rn){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Di.subVectors(t,e),i.cross(Di);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Di.subVectors(i,e),Ni.subVectors(n,e),Ui.subVectors(t,e);const s=Di.dot(Di),a=Di.dot(Ni),o=Di.dot(Ui),l=Ni.dot(Ni),h=Ni.dot(Ui),c=s*l-a*a;if(0===c)return r.set(0,0,0),null;const d=1/c,u=(l*o-a*h)*d,p=(s*h-a*o)*d;return r.set(1-u-p,p,u)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Oi)&&(Oi.x>=0&&Oi.y>=0&&Oi.x+Oi.y<=1)}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,Oi)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Oi.x),o.addScaledVector(s,Oi.y),o.addScaledVector(a,Oi.z),o)}static getInterpolatedAttribute(t,e,n,i,r,s){return Vi.setScalar(0),Wi.setScalar(0),Xi.setScalar(0),Vi.fromBufferAttribute(t,e),Wi.fromBufferAttribute(t,n),Xi.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(Vi,r.x),s.addScaledVector(Wi,r.y),s.addScaledVector(Xi,r.z),s}static isFrontFacing(t,e,n,i){return Di.subVectors(n,e),Ni.subVectors(t,e),Di.cross(Ni).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Di.subVectors(this.c,this.b),Ni.subVectors(this.a,this.b),.5*Di.cross(Ni).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ji.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return ji.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return ji.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return ji.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ji.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Fi.subVectors(i,n),ki.subVectors(r,n),zi.subVectors(t,n);const o=Fi.dot(zi),l=ki.dot(zi);if(o<=0&&l<=0)return e.copy(n);Gi.subVectors(t,i);const h=Fi.dot(Gi),c=ki.dot(Gi);if(h>=0&&c<=h)return e.copy(i);const d=o*c-h*l;if(d<=0&&o>=0&&h<=0)return s=o/(o-h),e.copy(n).addScaledVector(Fi,s);Hi.subVectors(t,r);const u=Fi.dot(Hi),p=ki.dot(Hi);if(p>=0&&u<=p)return e.copy(r);const f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(ki,a);const m=h*p-u*c;if(m<=0&&c-h>=0&&u-p>=0)return Bi.subVectors(r,i),a=(c-h)/(c-h+(u-p)),e.copy(i).addScaledVector(Bi,a);const g=1/(m+f+d);return s=f*g,a=d*g,e.copy(n).addScaledVector(Fi,s).addScaledVector(ki,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Yi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},qi={h:0,s:0,l:0},Ki={h:0,s:0,l:0};function Zi(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Ji{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=we){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ln.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=ln.workingColorSpace){return this.r=t,this.g=e,this.b=n,ln.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=ln.workingColorSpace){if(t=qe(t,1),e=Ye(e,0,1),n=Ye(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Zi(r,i,t+1/3),this.g=Zi(r,i,t),this.b=Zi(r,i,t-1/3)}return ln.toWorkingColorSpace(this,i),this}setStyle(t,e=we){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=we){const n=Yi[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=hn(t.r),this.g=hn(t.g),this.b=hn(t.b),this}copyLinearToSRGB(t){return this.r=cn(t.r),this.g=cn(t.g),this.b=cn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=we){return ln.fromWorkingColorSpace(Qi.copy(this),t),65536*Math.round(Ye(255*Qi.r,0,255))+256*Math.round(Ye(255*Qi.g,0,255))+Math.round(Ye(255*Qi.b,0,255))}getHexString(t=we){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ln.workingColorSpace){ln.fromWorkingColorSpace(Qi.copy(this),e);const n=Qi.r,i=Qi.g,r=Qi.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const h=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=h<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i<r?6:0);break;case i:o=(r-n)/t+2;break;case r:o=(n-i)/t+4}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=ln.workingColorSpace){return ln.fromWorkingColorSpace(Qi.copy(this),e),t.r=Qi.r,t.g=Qi.g,t.b=Qi.b,t}getStyle(t=we){ln.fromWorkingColorSpace(Qi.copy(this),t);const e=Qi.r,n=Qi.g,i=Qi.b;return t!==we?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(qi),this.setHSL(qi.h+t,qi.s+e,qi.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(qi),t.getHSL(Ki);const n=Ke(qi.h,Ki.h,e),i=Ke(qi.s,Ki.s,e),r=Ke(qi.l,Ki.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Qi=new Ji;Ji.NAMES=Yi;let $i=0;class tr extends Ge{static get type(){return"Material"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$i++}),this.uuid=je(),this.name="",this.blending=1,this.side=y,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=b,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ji(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ce,this.stencilZFail=Ce,this.stencilZPass=Ce,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==y&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==b&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ce&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ce&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ce&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class er extends tr{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new Ji(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=q,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const nr=new Rn,ir=new $e;class rr{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=Fe,this.updateRanges=[],this.gpuType=wt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)ir.fromBufferAttribute(this,e),ir.applyMatrix3(t),this.setXY(e,ir.x,ir.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)nr.fromBufferAttribute(this,e),nr.applyMatrix3(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)nr.fromBufferAttribute(this,e),nr.applyMatrix4(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)nr.fromBufferAttribute(this,e),nr.applyNormalMatrix(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)nr.fromBufferAttribute(this,e),nr.transformDirection(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ze(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Je(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ze(e,this.array)),e}setX(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ze(e,this.array)),e}setY(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ze(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ze(e,this.array)),e}setW(t,e){return this.normalized&&(e=Je(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),n=Je(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),n=Je(n,this.array),i=Je(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Je(e,this.array),n=Je(n,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Fe&&(t.usage=this.usage),t}}class sr extends rr{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ar extends rr{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class or extends rr{constructor(t,e,n){super(new Float32Array(t),e,n)}}let lr=0;const hr=new si,cr=new Ii,dr=new Rn,ur=new In,pr=new In,fr=new Rn;class mr extends Ge{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:lr++}),this.uuid=je(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(nn(t)?ar:sr)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new tn).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return hr.makeRotationFromQuaternion(t),this.applyMatrix4(hr),this}rotateX(t){return hr.makeRotationX(t),this.applyMatrix4(hr),this}rotateY(t){return hr.makeRotationY(t),this.applyMatrix4(hr),this}rotateZ(t){return hr.makeRotationZ(t),this.applyMatrix4(hr),this}translate(t,e,n){return hr.makeTranslation(t,e,n),this.applyMatrix4(hr),this}scale(t,e,n){return hr.makeScale(t,e,n),this.applyMatrix4(hr),this}lookAt(t){return cr.lookAt(t),cr.updateMatrix(),this.applyMatrix4(cr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(dr).negate(),this.translate(dr.x,dr.y,dr.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new or(e,3))}else{for(let n=0,i=e.count;n<i;n++){const i=t[n];e.setXYZ(n,i.x,i.y,i.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new In);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Rn(-1/0,-1/0,-1/0),new Rn(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];ur.setFromBufferAttribute(n),this.morphTargetsRelative?(fr.addVectors(this.boundingBox.min,ur.min),this.boundingBox.expandByPoint(fr),fr.addVectors(this.boundingBox.max,ur.max),this.boundingBox.expandByPoint(fr)):(this.boundingBox.expandByPoint(ur.min),this.boundingBox.expandByPoint(ur.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Zn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new Rn,1/0);if(t){const n=this.boundingSphere.center;if(ur.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];pr.setFromBufferAttribute(n),this.morphTargetsRelative?(fr.addVectors(ur.min,pr.min),ur.expandByPoint(fr),fr.addVectors(ur.max,pr.max),ur.expandByPoint(fr)):(ur.expandByPoint(pr.min),ur.expandByPoint(pr.max))}ur.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)fr.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(fr));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],a=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)fr.fromBufferAttribute(s,e),a&&(dr.fromBufferAttribute(t,e),fr.add(dr)),i=Math.max(i,n.distanceToSquared(fr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new rr(new Float32Array(4*n.count),4));const s=this.getAttribute("tangent"),a=[],o=[];for(let t=0;t<n.count;t++)a[t]=new Rn,o[t]=new Rn;const l=new Rn,h=new Rn,c=new Rn,d=new $e,u=new $e,p=new $e,f=new Rn,m=new Rn;function g(t,e,i){l.fromBufferAttribute(n,t),h.fromBufferAttribute(n,e),c.fromBufferAttribute(n,i),d.fromBufferAttribute(r,t),u.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),h.sub(l),c.sub(l),u.sub(d),p.sub(d);const s=1/(u.x*p.y-p.x*u.y);isFinite(s)&&(f.copy(h).multiplyScalar(p.y).addScaledVector(c,-u.y).multiplyScalar(s),m.copy(c).multiplyScalar(u.x).addScaledVector(h,-p.x).multiplyScalar(s),a[t].add(f),a[e].add(f),a[i].add(f),o[t].add(m),o[e].add(m),o[i].add(m))}let _=this.groups;0===_.length&&(_=[{start:0,count:t.count}]);for(let e=0,n=_.length;e<n;++e){const n=_[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const v=new Rn,y=new Rn,x=new Rn,S=new Rn;function b(t){x.fromBufferAttribute(i,t),S.copy(x);const e=a[t];v.copy(e),v.sub(x.multiplyScalar(x.dot(e))).normalize(),y.crossVectors(S,e);const n=y.dot(o[t])<0?-1:1;s.setXYZW(t,v.x,v.y,v.z,n)}for(let e=0,n=_.length;e<n;++e){const n=_[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)b(t.getX(e+0)),b(t.getX(e+1)),b(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new rr(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new Rn,r=new Rn,s=new Rn,a=new Rn,o=new Rn,l=new Rn,h=new Rn,c=new Rn;if(t)for(let d=0,u=t.count;d<u;d+=3){const u=t.getX(d+0),p=t.getX(d+1),f=t.getX(d+2);i.fromBufferAttribute(e,u),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),c.subVectors(i,r),h.cross(c),a.fromBufferAttribute(n,u),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),a.add(h),o.add(h),l.add(h),n.setXYZ(u,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),c.subVectors(i,r),h.cross(c),n.setXYZ(t+0,h.x,h.y,h.z),n.setXYZ(t+1,h.x,h.y,h.z),n.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)fr.fromBufferAttribute(t,e),fr.normalize(),t.setXYZ(e,fr.x,fr.y,fr.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,s=new n.constructor(e.length*i);let a=0,o=0;for(let r=0,l=e.length;r<l;r++){a=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)s[o++]=n[a++]}return new rr(s,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new mr,n=this.index.array,i=this.attributes;for(const r in i){const s=t(i[r],n);e.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],a=r[i];for(let e=0,i=a.length;e<i;e++){const i=t(a[e],n);s.push(i)}e.morphAttributes[i]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,n=s.length;t<n;t++){const n=s[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];s.push(i.toJSON(t.data))}s.length>0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const gr=new si,_r=new ri,vr=new Zn,yr=new Rn,xr=new Rn,Sr=new Rn,br=new Rn,Mr=new Rn,wr=new Rn,Er=new Rn,Tr=new Rn;class Ar extends Ii{constructor(t=new mr,e=new er){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(r&&a){wr.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=a[n],o=r[n];0!==i&&(Mr.fromBufferAttribute(o,t),s?wr.addScaledVector(Mr,i):wr.addScaledVector(Mr.sub(e),i))}e.add(wr)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),vr.copy(n.boundingSphere),vr.applyMatrix4(r),_r.copy(t.ray).recast(t.near),!1===vr.containsPoint(_r.origin)){if(null===_r.intersectSphere(vr,yr))return;if(_r.origin.distanceToSquared(yr)>(t.far-t.near)**2)return}gr.copy(r).invert(),_r.copy(t.ray).applyMatrix4(gr),null!==n.boundingBox&&!1===_r.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,_r)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=d.length;r<o;r++){const o=d[r],p=s[o.materialIndex];for(let r=Math.max(o.start,u.start),s=Math.min(a.count,Math.min(o.start+o.count,u.start+u.count));r<s;r+=3){i=Cr(this,p,t,n,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let r=Math.max(0,u.start),o=Math.min(a.count,u.start+u.count);r<o;r+=3){i=Cr(this,s,t,n,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==o)if(Array.isArray(s))for(let r=0,a=d.length;r<a;r++){const a=d[r],p=s[a.materialIndex];for(let r=Math.max(a.start,u.start),s=Math.min(o.count,Math.min(a.start+a.count,u.start+u.count));r<s;r+=3){i=Cr(this,p,t,n,l,h,c,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let r=Math.max(0,u.start),a=Math.min(o.count,u.start+u.count);r<a;r+=3){i=Cr(this,s,t,n,l,h,c,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function Cr(t,e,n,i,r,s,a,o,l,h){t.getVertexPosition(o,xr),t.getVertexPosition(l,Sr),t.getVertexPosition(h,br);const c=function(t,e,n,i,r,s,a,o){let l;if(l=e.side===x?i.intersectTriangle(a,s,r,!0,o):i.intersectTriangle(r,s,a,e.side===y,o),null===l)return null;Tr.copy(o),Tr.applyMatrix4(t.matrixWorld);const h=n.ray.origin.distanceTo(Tr);return h<n.near||h>n.far?null:{distance:h,point:Tr.clone(),object:t}}(t,e,n,i,xr,Sr,br,Er);if(c){const t=new Rn;ji.getBarycoord(Er,xr,Sr,br,t),r&&(c.uv=ji.getInterpolatedAttribute(r,o,l,h,t,new $e)),s&&(c.uv1=ji.getInterpolatedAttribute(s,o,l,h,t,new $e)),a&&(c.normal=ji.getInterpolatedAttribute(a,o,l,h,t,new Rn),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:l,c:h,normal:new Rn,materialIndex:0};ji.getNormal(xr,Sr,br,e.normal),c.face=e,c.barycoord=t}return c}class Rr extends mr{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],h=[],c=[];let d=0,u=0;function p(t,e,n,i,r,s,p,f,m,g,_){const v=s/m,y=p/g,x=s/2,S=p/2,b=f/2,M=m+1,w=g+1;let E=0,T=0;const A=new Rn;for(let s=0;s<w;s++){const a=s*y-S;for(let o=0;o<M;o++){const d=o*v-x;A[t]=d*i,A[e]=a*r,A[n]=b,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=f>0?1:-1,h.push(A.x,A.y,A.z),c.push(o/m),c.push(1-s/g),E+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const n=d+e+M*t,i=d+e+M*(t+1),r=d+(e+1)+M*(t+1),s=d+(e+1)+M*t;o.push(n,i,s),o.push(i,r,s),T+=6}a.addGroup(u,T,_),u+=T,d+=E}p("z","y","x",-1,-1,n,e,t,s,r,0),p("z","y","x",1,-1,n,e,-t,s,r,1),p("x","z","y",1,1,t,n,e,i,s,2),p("x","z","y",1,-1,t,n,-e,i,s,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new or(l,3)),this.setAttribute("normal",new or(h,3)),this.setAttribute("uv",new or(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Rr(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Pr(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function Lr(t){const e={};for(let n=0;n<t.length;n++){const i=Pr(t[n]);for(const t in i)e[t]=i[t]}return e}function Ir(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:ln.workingColorSpace}const Dr={clone:Pr,merge:Lr};class Nr extends tr{static get type(){return"ShaderMaterial"}constructor(t){super(),this.isShaderMaterial=!0,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Pr(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Ur extends Ii{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new si,this.projectionMatrix=new si,this.projectionMatrixInverse=new si,this.coordinateSystem=Be}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const Or=new Rn,Fr=new $e,kr=new $e;class Br extends Ur{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Xe*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*We*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Xe*Math.atan(Math.tan(.5*We*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Or.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Or.x,Or.y).multiplyScalar(-t/Or.z),Or.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Or.x,Or.y).multiplyScalar(-t/Or.z)}getViewSize(t,e){return this.getViewBounds(t,Fr,kr),e.subVectors(kr,Fr)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*We*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const zr=-90;class Gr extends Ii{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Br(zr,1,t,e);i.layers=this.layers,this.add(i);const r=new Br(zr,1,t,e);r.layers=this.layers,this.add(r);const s=new Br(zr,1,t,e);s.layers=this.layers,this.add(s);const a=new Br(zr,1,t,e);a.layers=this.layers,this.add(a);const o=new Br(zr,1,t,e);o.layers=this.layers,this.add(o);const l=new Br(zr,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===Be)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==ze)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,h]=this.children,c=t.getRenderTarget(),d=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(c,d,u),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Hr extends bn{constructor(t,e,n,i,r,s,a,o,l,h){super(t=void 0!==t?t:[],e=void 0!==e?e:at,n,i,r,s,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Vr extends En{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Hr(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:mt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Rr(5,5,5),r=new Nr({name:"CubemapFromEquirect",uniforms:Pr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:x,blending:0});r.uniforms.tEquirect.value=e;const s=new Ar(i,r),a=e.minFilter;e.minFilter===_t&&(e.minFilter=mt);return new Gr(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}const Wr=new Rn,Xr=new Rn,jr=new tn;class Yr{constructor(t=new Rn(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Wr.subVectors(n,e).cross(Xr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Wr),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||jr.getNormalMatrix(t),i=this.coplanarPoint(Wr).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const qr=new Zn,Kr=new Rn;class Zr{constructor(t=new Yr,e=new Yr,n=new Yr,i=new Yr,r=new Yr,s=new Yr){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3){const n=this.planes,i=t.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],h=i[5],c=i[6],d=i[7],u=i[8],p=i[9],f=i[10],m=i[11],g=i[12],_=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,d-l,m-u,y-g).normalize(),n[1].setComponents(o+r,d+l,m+u,y+g).normalize(),n[2].setComponents(o+s,d+h,m+p,y+_).normalize(),n[3].setComponents(o-s,d-h,m-p,y-_).normalize(),n[4].setComponents(o-a,d-c,m-f,y-v).normalize(),e===Be)n[5].setComponents(o+a,d+c,m+f,y+v).normalize();else{if(e!==ze)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,c,f,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),qr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),qr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(qr)}intersectsSprite(t){return qr.center.set(0,0,0),qr.radius=.7071067811865476,qr.applyMatrix4(t.matrixWorld),this.intersectsSphere(qr)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(Kr.x=i.normal.x>0?t.max.x:t.min.x,Kr.y=i.normal.y>0?t.max.y:t.min.y,Kr.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Kr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Jr(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Qr(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.version<n.version)&&e.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=e.get(n);if(void 0===r)e.set(n,function(e,n){const i=e.array,r=e.usage,s=i.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(n,a),t.bufferData(n,i,r),e.onUploadCallback(),i instanceof Float32Array)o=t.FLOAT;else if(i instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=t.SHORT;else if(i instanceof Uint32Array)o=t.UNSIGNED_INT;else if(i instanceof Int32Array)o=t.INT;else if(i instanceof Int8Array)o=t.BYTE;else if(i instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,size:s}}(n,i));else if(r.version<n.version){if(r.size!==n.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,n,i){const r=n.array,s=n.updateRanges;if(t.bindBuffer(i,e),0===s.length)t.bufferSubData(i,0,r);else{s.sort(((t,e)=>t.start-e.start));let e=0;for(let t=1;t<s.length;t++){const n=s[e],i=s[t];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++e,s[e]=i)}s.length=e+1;for(let e=0,n=s.length;e<n;e++){const n=s[e];t.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}class $r extends mr{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,s=e/2,a=Math.floor(n),o=Math.floor(i),l=a+1,h=o+1,c=t/a,d=e/o,u=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*d-s;for(let n=0;n<l;n++){const i=n*c-r;p.push(i,-e,0),f.push(0,0,1),m.push(n/a),m.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const n=e+l*t,i=e+l*(t+1),r=e+1+l*(t+1),s=e+1+l*t;u.push(n,i,s),u.push(i,r,s)}this.setIndex(u),this.setAttribute("position",new or(p,3)),this.setAttribute("normal",new or(f,3)),this.setAttribute("uv",new or(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $r(t.width,t.height,t.widthSegments,t.heightSegments)}}const ts={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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\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\t\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, roughness * 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 * ( 1.0 - 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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), 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.07, 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:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\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#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 saturate(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.specularColor;\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 * transposeMat3( 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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}\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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * 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\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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 );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\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 )\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_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\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\tuniform sampler2D directionalShadowMap[ 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\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\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 sampler2D pointShadowMap[ 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\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D 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\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\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\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.diffuseColor, material.specularColor, 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\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\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\n\t\t#else\n\t\t\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\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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\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}",distanceRGBA_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}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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 <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 = packDepthToRGBA( dist );\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 <packing>\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 <packing>\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( packNormalToRGB( normal ), 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 <packing>\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 <packing>\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\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\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 <packing>\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 <packing>\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}"},es={common:{diffuse:{value:new Ji(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new tn},alphaMap:{value:null},alphaMapTransform:{value:new tn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new tn}},envmap:{envMap:{value:null},envMapRotation:{value:new tn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new tn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new tn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new tn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new tn},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new tn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new tn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new tn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new tn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ji(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 Ji(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new tn},alphaTest:{value:0},uvTransform:{value:new tn}},sprite:{diffuse:{value:new Ji(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new tn},alphaMap:{value:null},alphaMapTransform:{value:new tn},alphaTest:{value:0}}},ns={basic:{uniforms:Lr([es.common,es.specularmap,es.envmap,es.aomap,es.lightmap,es.fog]),vertexShader:ts.meshbasic_vert,fragmentShader:ts.meshbasic_frag},lambert:{uniforms:Lr([es.common,es.specularmap,es.envmap,es.aomap,es.lightmap,es.emissivemap,es.bumpmap,es.normalmap,es.displacementmap,es.fog,es.lights,{emissive:{value:new Ji(0)}}]),vertexShader:ts.meshlambert_vert,fragmentShader:ts.meshlambert_frag},phong:{uniforms:Lr([es.common,es.specularmap,es.envmap,es.aomap,es.lightmap,es.emissivemap,es.bumpmap,es.normalmap,es.displacementmap,es.fog,es.lights,{emissive:{value:new Ji(0)},specular:{value:new Ji(1118481)},shininess:{value:30}}]),vertexShader:ts.meshphong_vert,fragmentShader:ts.meshphong_frag},standard:{uniforms:Lr([es.common,es.envmap,es.aomap,es.lightmap,es.emissivemap,es.bumpmap,es.normalmap,es.displacementmap,es.roughnessmap,es.metalnessmap,es.fog,es.lights,{emissive:{value:new Ji(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ts.meshphysical_vert,fragmentShader:ts.meshphysical_frag},toon:{uniforms:Lr([es.common,es.aomap,es.lightmap,es.emissivemap,es.bumpmap,es.normalmap,es.displacementmap,es.gradientmap,es.fog,es.lights,{emissive:{value:new Ji(0)}}]),vertexShader:ts.meshtoon_vert,fragmentShader:ts.meshtoon_frag},matcap:{uniforms:Lr([es.common,es.bumpmap,es.normalmap,es.displacementmap,es.fog,{matcap:{value:null}}]),vertexShader:ts.meshmatcap_vert,fragmentShader:ts.meshmatcap_frag},points:{uniforms:Lr([es.points,es.fog]),vertexShader:ts.points_vert,fragmentShader:ts.points_frag},dashed:{uniforms:Lr([es.common,es.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ts.linedashed_vert,fragmentShader:ts.linedashed_frag},depth:{uniforms:Lr([es.common,es.displacementmap]),vertexShader:ts.depth_vert,fragmentShader:ts.depth_frag},normal:{uniforms:Lr([es.common,es.bumpmap,es.normalmap,es.displacementmap,{opacity:{value:1}}]),vertexShader:ts.meshnormal_vert,fragmentShader:ts.meshnormal_frag},sprite:{uniforms:Lr([es.sprite,es.fog]),vertexShader:ts.sprite_vert,fragmentShader:ts.sprite_frag},background:{uniforms:{uvTransform:{value:new tn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ts.background_vert,fragmentShader:ts.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new tn}},vertexShader:ts.backgroundCube_vert,fragmentShader:ts.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ts.cube_vert,fragmentShader:ts.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ts.equirect_vert,fragmentShader:ts.equirect_frag},distanceRGBA:{uniforms:Lr([es.common,es.displacementmap,{referencePosition:{value:new Rn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ts.distanceRGBA_vert,fragmentShader:ts.distanceRGBA_frag},shadow:{uniforms:Lr([es.lights,es.fog,{color:{value:new Ji(0)},opacity:{value:1}}]),vertexShader:ts.shadow_vert,fragmentShader:ts.shadow_frag}};ns.physical={uniforms:Lr([ns.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new tn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new tn},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new tn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new tn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new tn},sheen:{value:0},sheenColor:{value:new Ji(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new tn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new tn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new tn},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new tn},attenuationDistance:{value:0},attenuationColor:{value:new Ji(0)},specularColor:{value:new Ji(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new tn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new tn},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new tn}}]),vertexShader:ts.meshphysical_vert,fragmentShader:ts.meshphysical_frag};const is={r:0,b:0,g:0},rs=new mi,ss=new si;function as(t,e,n,i,r,s,a){const o=new Ji(0);let l,h,c=!0===s?0:1,d=null,u=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;if(i&&i.isTexture){i=(t.backgroundBlurriness>0?n:e).get(i)}return i}function m(e,n){e.getRGB(is,Ir(t)),i.buffers.color.setClear(is.r,is.g,is.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,m(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,m(o,c)},render:function(e){let n=!1;const r=f(e);null===r?m(o,c):r&&r.isColor&&(m(r,1),n=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===lt)?(void 0===h&&(h=new Ar(new Rr(1,1,1),new Nr({name:"BackgroundCubeMaterial",uniforms:Pr(ns.backgroundCube.uniforms),vertexShader:ns.backgroundCube.vertexShader,fragmentShader:ns.backgroundCube.fragmentShader,side:x,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),rs.copy(n.backgroundRotation),rs.x*=-1,rs.y*=-1,rs.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(rs.y*=-1,rs.z*=-1),h.material.uniforms.envMap.value=i,h.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(ss.makeRotationFromEuler(rs)),h.material.toneMapped=ln.getTransfer(i.colorSpace)!==Ae,d===i&&u===i.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=i,u=i.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Ar(new $r(2,2),new Nr({name:"BackgroundMaterial",uniforms:Pr(ns.background.uniforms),vertexShader:ns.background.vertexShader,fragmentShader:ns.background.fragmentShader,side:y,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=ln.getTransfer(i.colorSpace)!==Ae,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),d===i&&u===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=i,u=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))}}}function os(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=h(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function h(t){const e=[],i=[],r=[];for(let t=0;t<n;t++)e[t]=0,i[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function d(t){u(t,0)}function u(e,n){const i=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;i[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==n&&(t.vertexAttribDivisor(e,n),a[e]=n)}function p(){const e=s.newAttributes,n=s.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function f(e,n,i,r,s,a,o){!0===o?t.vertexAttribIPointer(e,n,i,s,a):t.vertexAttribPointer(e,n,i,r,s,a)}function m(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let _=!1;const v=function(e,n,r){const s=!0===r.wireframe;let a=i[e.id];void 0===a&&(a={},i[e.id]=a);let o=a[n.id];void 0===o&&(o={},a[n.id]=o);let l=o[s];void 0===l&&(l=h(t.createVertexArray()),o[s]=l);return l}(m,l,r);s!==v&&(s=v,o(s.object)),_=function(t,e,n,i){const r=s.attributes,a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){const n=r[e];let i=a[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}}return s.attributesNum!==o||s.index!==i}(n,m,l,g),_&&function(t,e,n,i){const r={},a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(_||a)&&(a=!1,function(n,i,r,s){c();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const h=l.buffer,c=l.type,p=l.bytesPerElement,m=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===bt;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)f(r.location+t,a/r.locationSize,c,i,l*p,(g+a/r.locationSize*t)*p,m)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)f(r.location+t,a/r.locationSize,c,i,a*p,a/r.locationSize*t*p,m)}}else if(void 0!==l){const e=l[i];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(n,r,l,m),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const t in i){const e=i[t];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t]}},releaseStatesOfGeometry:function(t){if(void 0===i[t.id])return;const e=i[t.id];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t.id]},releaseStatesOfProgram:function(t){for(const e in i){const n=i[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)l(r[t].object),delete r[t];delete n[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function ls(t,e,n){let i;function r(e,r,s){0!==s&&(t.drawArraysInstanced(i,e,r,s),n.update(r,i,s))}this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];n.update(a,i,1)},this.renderMultiDrawInstances=function(t,s,a,o){if(0===a)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<t.length;e++)r(t[e],s[e],o[e]);else{l.multiDrawArraysInstancedWEBGL(i,t,0,s,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=s[t]*o[t];n.update(e,i,1)}}}function hs(t,e,n,i){let r;function s(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!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,h=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===It||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===Et&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==vt&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==wt&&!r)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:h,maxTextures:c,maxVertexTextures:d,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),vertexTextures:d>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function cs(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new Yr,o=new tn,l={value:null,needsUpdate:!1};function h(t,n,i,r){const s=null!==t?t.length:0;let h=null;if(0!==s){if(h=l.value,!0!==r||null===h){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length<e)&&(h=new Float32Array(e));for(let e=0,n=i;e!==s;++e,n+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(h,n),h[n+3]=a.constant}l.value=h,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||r;return r=e,i=t.length,n},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){n=h(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,f=t.get(a);if(!r||null===d||0===d.length||s&&!p)s?h(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);e.numPlanes=i,e.numIntersection=0}();else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=h(d,o,e,c);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function ds(t){let e=new WeakMap;function n(t,e){return 303===e?t.mapping=at:304===e&&(t.mapping=ot),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(303===s||304===s){if(e.has(r)){return n(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new Vr(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class us extends Ur{constructor(t=-1,e=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,s=n+t,a=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const ps=[.125,.215,.35,.446,.526,.582],fs=20,ms=new us,gs=new Ji;let _s=null,vs=0,ys=0,xs=!1;const Ss=(1+Math.sqrt(5))/2,bs=1/Ss,Ms=[new Rn(-Ss,bs,0),new Rn(Ss,bs,0),new Rn(-bs,0,Ss),new Rn(bs,0,Ss),new Rn(0,Ss,-bs),new Rn(0,Ss,bs),new Rn(-1,1,-1),new Rn(1,1,-1),new Rn(-1,1,1),new Rn(1,1,1)];class ws{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){_s=this._renderer.getRenderTarget(),vs=this._renderer.getActiveCubeFace(),ys=this._renderer.getActiveMipmapLevel(),xs=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Cs(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=As(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.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._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(_s,vs,ys),this._renderer.xr.enabled=xs,t.scissorTest=!1,Ts(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===at||t.mapping===ot?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),_s=this._renderer.getRenderTarget(),vs=this._renderer.getActiveCubeFace(),ys=this._renderer.getActiveMipmapLevel(),xs=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:mt,minFilter:mt,generateMipmaps:!1,type:Et,format:It,colorSpace:Ee,depthBuffer:!1},i=Es(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Es(t,e,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],n=[],i=[];let r=t;const s=t-4+1+ps.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);n.push(s);let o=1/s;a>t-4?o=ps[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),h=-l,c=1+l,d=[h,h,c,h,c,c,h,h,c,c,h,c],u=6,p=6,f=3,m=2,g=1,_=new Float32Array(f*p*u),v=new Float32Array(m*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];_.set(i,f*p*t),v.set(d,m*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new mr;x.setAttribute("position",new rr(_,f)),x.setAttribute("uv",new rr(v,m)),x.setAttribute("faceIndex",new rr(y,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(fs),r=new Rn(0,1,0),s=new Nr({name:"SphericalGaussianBlur",defines:{n:fs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Rs(),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 s}(i,t,e)}return i}_compileMaterial(t){const e=new Ar(this._lodPlanes[0],t);this._renderer.compile(e,ms)}_sceneToCubeUV(t,e,n,i){const r=new Br(90,1,e,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(gs),o.toneMapping=J,o.autoClear=!1;const c=new er({name:"PMREM.Background",side:x,depthWrite:!1,depthTest:!1}),d=new Ar(new Rr,c);let u=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,u=!0):(c.color.copy(gs),u=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===n?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;Ts(i,n*l,e>2?l:0,l,l),o.setRenderTarget(i),u&&o.render(d,r),o.render(t,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=h,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===at||t.mapping===ot;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Cs()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=As());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ar(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;Ts(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,ms)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e<i;e++){const n=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),r=Ms[(i-e-1)%Ms.length];this._blur(t,e-1,e,n,r)}e.autoClear=n}_blur(t,e,n,i,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,n,i,"latitudinal",r),this._halfBlur(s,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const h=new Ar(this._lodPlanes[i],l),c=l.uniforms,d=this._sizeLods[n]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,f=isFinite(r)?1+Math.floor(3*p):fs;f>fs&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<fs;++t){const e=t/p,n=Math.exp(-e*e/2);m.push(n),0===t?g+=n:t<f&&(g+=2*n)}for(let t=0;t<m.length;t++)m[t]=m[t]/g;c.envMap.value=t.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:_}=this;c.dTheta.value=u,c.mipInt.value=_-n;const v=this._sizeLods[i];Ts(e,3*v*(i>_-4?i-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(h,ms)}}function Es(t,e,n){const i=new En(t,e,n);return i.texture.mapping=lt,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ts(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function As(){return new Nr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Rs(),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 Cs(){return new Nr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Rs(),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 Rs(){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 Ps(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=303===s||304===s,o=s===at||s===ot;if(a||o){let s=e.get(r);const l=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new ws(t)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const l=r.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(l)?(null===n&&(n=new ws(t)),s=a?n.fromEquirectangular(r):n.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",i),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Ls(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&on("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Is(t,e,n,i){const r={},s=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]);for(const t in o.morphAttributes){const n=o.morphAttributes[t];for(let t=0,i=n.length;t<i;t++)e.remove(n[t])}o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let a=0;if(null!==i){const t=i.array;a=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],s=t[e+2];n.push(i,r,r,s,s,i)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}}const o=new(nn(n)?ar:sr)(n,1);o.version=a;const l=s.get(t);l&&e.remove(l),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const n in i)e.update(i[n],t.ARRAY_BUFFER);const r=n.morphAttributes;for(const n in r){const i=r[n];for(let n=0,r=i.length;n<r;n++)e.update(i[n],t.ARRAY_BUFFER)}},getWireframeAttribute:function(t){const e=s.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&o(t)}else o(t);return s.get(t)}}}function Ds(t,e,n){let i,r,s;function a(e,a,o){0!==o&&(t.drawElementsInstanced(i,a,r,e*s,o),n.update(a,i,o))}this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(i,a,r,e*s),n.update(a,i,1)},this.renderInstances=a,this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];n.update(o,i,1)},this.renderMultiDrawInstances=function(t,o,l,h){if(0===l)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/s,o[e],h[e]);else{c.multiDrawElementsInstancedWEBGL(i,o,0,r,t,0,h,0,l);let e=0;for(let t=0;t<l;t++)e+=o[t]*h[t];n.update(e,i,1)}}}function Ns(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(n,i,r){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=r*(n/3);break;case t.LINES:e.lines+=r*(n/2);break;case t.LINE_STRIP:e.lines+=r*(n-1);break;case t.LINE_LOOP:e.lines+=r*n;break;case t.POINTS:e.points+=r*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Us(t,e,n){const i=new WeakMap,r=new Mn;return{update:function(s,a,o){const l=s.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==h?h.length:0;let d=i.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,f=void 0!==a.morphAttributes.color,m=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],_=a.morphAttributes.color||[];let v=0;!0===u&&(v=1),!0===p&&(v=2),!0===f&&(v=3);let y=a.attributes.position.count*v,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const S=new Float32Array(y*x*4*c),b=new Tn(S,y,x,c);b.type=wt,b.needsUpdate=!0;const M=4*v;for(let E=0;E<c;E++){const T=m[E],A=g[E],C=_[E],R=y*x*4*E;for(let P=0;P<T.count;P++){const L=P*M;!0===u&&(r.fromBufferAttribute(T,P),S[R+L+0]=r.x,S[R+L+1]=r.y,S[R+L+2]=r.z,S[R+L+3]=0),!0===p&&(r.fromBufferAttribute(A,P),S[R+L+4]=r.x,S[R+L+5]=r.y,S[R+L+6]=r.z,S[R+L+7]=0),!0===f&&(r.fromBufferAttribute(C,P),S[R+L+8]=r.x,S[R+L+9]=r.y,S[R+L+10]=r.z,S[R+L+11]=4===C.itemSize?r.w:1)}}function w(){b.dispose(),i.delete(a),a.removeEventListener("dispose",w)}d={count:c,texture:b,size:new $e(y,x)},i.set(a,d),a.addEventListener("dispose",w)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let I=0;for(let N=0;N<l.length;N++)I+=l[N];const D=a.morphTargetsRelative?1:1-I;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,n),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Os(t,e,n,i){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(a){const o=i.render.frame,l=a.geometry,h=e.get(a,l);if(r.get(h)!==o&&(e.update(h),r.set(h,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(n.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&n.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return h},dispose:function(){r=new WeakMap}}}class Fs extends bn{constructor(t,e,n,i,r,s,a,o,l,h=1026){if(h!==Ut&&h!==Ot)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===Ut&&(n=Mt),void 0===n&&h===Ot&&(n=Ct),super(null,i,r,s,a,o,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:ut,this.minFilter=void 0!==o?o:ut,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}const ks=new bn,Bs=new Fs(1,1),zs=new Tn,Gs=new An,Hs=new Hr,Vs=[],Ws=[],Xs=new Float32Array(16),js=new Float32Array(9),Ys=new Float32Array(4);function qs(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let s=Vs[r];if(void 0===s&&(s=new Float32Array(r),Vs[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function Ks(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function Zs(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function Js(t,e){let n=Ws[e];void 0===n&&(n=new Int32Array(e),Ws[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function Qs(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $s(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Ks(n,e))return;t.uniform2fv(this.addr,e),Zs(n,e)}}function ta(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Ks(n,e))return;t.uniform3fv(this.addr,e),Zs(n,e)}}function ea(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Ks(n,e))return;t.uniform4fv(this.addr,e),Zs(n,e)}}function na(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(Ks(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Zs(n,e)}else{if(Ks(n,i))return;Ys.set(i),t.uniformMatrix2fv(this.addr,!1,Ys),Zs(n,i)}}function ia(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(Ks(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Zs(n,e)}else{if(Ks(n,i))return;js.set(i),t.uniformMatrix3fv(this.addr,!1,js),Zs(n,i)}}function ra(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(Ks(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Zs(n,e)}else{if(Ks(n,i))return;Xs.set(i),t.uniformMatrix4fv(this.addr,!1,Xs),Zs(n,i)}}function sa(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function aa(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Ks(n,e))return;t.uniform2iv(this.addr,e),Zs(n,e)}}function oa(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Ks(n,e))return;t.uniform3iv(this.addr,e),Zs(n,e)}}function la(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Ks(n,e))return;t.uniform4iv(this.addr,e),Zs(n,e)}}function ha(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function ca(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Ks(n,e))return;t.uniform2uiv(this.addr,e),Zs(n,e)}}function da(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Ks(n,e))return;t.uniform3uiv(this.addr,e),Zs(n,e)}}function ua(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Ks(n,e))return;t.uniform4uiv(this.addr,e),Zs(n,e)}}function pa(t,e,n){const i=this.cache,r=n.allocateTextureUnit();let s;i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),this.type===t.SAMPLER_2D_SHADOW?(Bs.compareFunction=Ie,s=Bs):s=ks,n.setTexture2D(e||s,r)}function fa(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||Gs,r)}function ma(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||Hs,r)}function ga(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||zs,r)}function _a(t,e){t.uniform1fv(this.addr,e)}function va(t,e){const n=qs(e,this.size,2);t.uniform2fv(this.addr,n)}function ya(t,e){const n=qs(e,this.size,3);t.uniform3fv(this.addr,n)}function xa(t,e){const n=qs(e,this.size,4);t.uniform4fv(this.addr,n)}function Sa(t,e){const n=qs(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ba(t,e){const n=qs(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Ma(t,e){const n=qs(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function wa(t,e){t.uniform1iv(this.addr,e)}function Ea(t,e){t.uniform2iv(this.addr,e)}function Ta(t,e){t.uniform3iv(this.addr,e)}function Aa(t,e){t.uniform4iv(this.addr,e)}function Ca(t,e){t.uniform1uiv(this.addr,e)}function Ra(t,e){t.uniform2uiv(this.addr,e)}function Pa(t,e){t.uniform3uiv(this.addr,e)}function La(t,e){t.uniform4uiv(this.addr,e)}function Ia(t,e,n){const i=this.cache,r=e.length,s=Js(n,r);Ks(i,s)||(t.uniform1iv(this.addr,s),Zs(i,s));for(let t=0;t!==r;++t)n.setTexture2D(e[t]||ks,s[t])}function Da(t,e,n){const i=this.cache,r=e.length,s=Js(n,r);Ks(i,s)||(t.uniform1iv(this.addr,s),Zs(i,s));for(let t=0;t!==r;++t)n.setTexture3D(e[t]||Gs,s[t])}function Na(t,e,n){const i=this.cache,r=e.length,s=Js(n,r);Ks(i,s)||(t.uniform1iv(this.addr,s),Zs(i,s));for(let t=0;t!==r;++t)n.setTextureCube(e[t]||Hs,s[t])}function Ua(t,e,n){const i=this.cache,r=e.length,s=Js(n,r);Ks(i,s)||(t.uniform1iv(this.addr,s),Zs(i,s));for(let t=0;t!==r;++t)n.setTexture2DArray(e[t]||zs,s[t])}class Oa{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Qs;case 35664:return $s;case 35665:return ta;case 35666:return ea;case 35674:return na;case 35675:return ia;case 35676:return ra;case 5124:case 35670:return sa;case 35667:case 35671:return aa;case 35668:case 35672:return oa;case 35669:case 35673:return la;case 5125:return ha;case 36294:return ca;case 36295:return da;case 36296:return ua;case 35678:case 36198:case 36298:case 36306:case 35682:return pa;case 35679:case 36299:case 36307:return fa;case 35680:case 36300:case 36308:case 36293:return ma;case 36289:case 36303:case 36311:case 36292:return ga}}(e.type)}}class Fa{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return _a;case 35664:return va;case 35665:return ya;case 35666:return xa;case 35674:return Sa;case 35675:return ba;case 35676:return Ma;case 5124:case 35670:return wa;case 35667:case 35671:return Ea;case 35668:case 35672:return Ta;case 35669:case 35673:return Aa;case 5125:return Ca;case 36294:return Ra;case 36295:return Pa;case 36296:return La;case 35678:case 36198:case 36298:case 36306:case 35682:return Ia;case 35679:case 36299:case 36307:return Da;case 35680:case 36300:case 36308:case 36293:return Na;case 36289:case 36303:case 36311:case 36292:return Ua}}(e.type)}}class ka{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,s=i.length;r!==s;++r){const s=i[r];s.setValue(t,e[s.id],n)}}}const Ba=/(\w+)(\])?(\[|\.)?/g;function za(t,e){t.seq.push(e),t.map[e.id]=e}function Ga(t,e,n){const i=t.name,r=i.length;for(Ba.lastIndex=0;;){const s=Ba.exec(i),a=Ba.lastIndex;let o=s[1];const l="]"===s[2],h=s[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===r){za(n,void 0===h?new Oa(o,t,e):new Fa(o,t,e));break}{let t=n.map[o];void 0===t&&(t=new ka(o),za(n,t)),n=t}}}class Ha{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);Ga(n,t.getUniformLocation(e,n.name),this)}}setValue(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=n[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n}}function Va(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const Wa=37297;let Xa=0;const ja=new tn;function Ya(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(i&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const i=parseInt(s[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const n=t.split("\n"),i=[],r=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let t=r;t<s;t++){const r=t+1;i.push(`${r===e?">":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function qa(t,e){const n=function(t){ln._getMatrix(ja,ln.workingColorSpace,t);const e=`mat3( ${ja.elements.map((t=>t.toFixed(4)))} )`;switch(ln.getTransfer(t)){case Te:return[e,"LinearTransferOETF"];case Ae:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Ka(t,e){let n;switch(e){case Q:n="Linear";break;case $:n="Reinhard";break;case tt:n="Cineon";break;case et:n="ACESFilmic";break;case it:n="AgX";break;case rt:n="Neutral";break;case nt:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Za=new Rn;function Ja(){ln.getLuminanceCoefficients(Za);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Za.x.toFixed(4)}, ${Za.y.toFixed(4)}, ${Za.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Qa(t){return""!==t}function $a(t,e){const n=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,n).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 to(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const eo=/^[ \t]*#include +<([\w\d./]+)>/gm;function no(t){return t.replace(eo,ro)}const io=new Map;function ro(t,e){let n=ts[e];if(void 0===n){const t=io.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=ts[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return no(n)}const so=/#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 ao(t){return t.replace(so,oo)}function oo(t,e,n,i){let r="";for(let t=parseInt(e);t<parseInt(n);t++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function lo(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}function ho(t,e,n,i){const r=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=function(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===g?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===_?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===v&&(e="SHADOWMAP_TYPE_VSM"),e}(n),h=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case at:case ot:e="ENVMAP_TYPE_CUBE";break;case lt:e="ENVMAP_TYPE_CUBE_UV"}return e}(n),c=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===ot&&(e="ENVMAP_MODE_REFRACTION");return e}(n),d=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case q:e="ENVMAP_BLENDING_MULTIPLY";break;case K:e="ENVMAP_BLENDING_MIX";break;case Z:e="ENVMAP_BLENDING_ADD"}return e}(n),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Qa).join("\n")}(n),f=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(s),m=r.createProgram();let y,x,S=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Qa).join("\n"),y.length>0&&(y+="\n"),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Qa).join("\n"),x.length>0&&(x+="\n")):(y=[lo(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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(Qa).join("\n"),x=[lo(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+c:"",n.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":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==J?"#define TONE_MAPPING":"",n.toneMapping!==J?ts.tonemapping_pars_fragment:"",n.toneMapping!==J?Ka("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ts.colorspace_pars_fragment,qa("linearToOutputTexel",n.outputColorSpace),Ja(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Qa).join("\n")),a=no(a),a=$a(a,n),a=to(a,n),o=no(o),o=$a(o,n),o=to(o,n),a=ao(a),o=ao(o),!0!==n.isRawShaderMaterial&&(S="#version 300 es\n",y=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+y,x=["#define varying in",n.glslVersion===ke?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ke?"":"#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"+x);const b=S+y+a,M=S+x+o,w=Va(r,r.VERTEX_SHADER,b),E=Va(r,r.FRAGMENT_SHADER,M);function T(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(w).trim(),s=r.getShaderInfoLog(E).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,w,E);else{const t=Ya(r,w,"vertex"),i=Ya(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:y},fragmentShader:{log:s,prefix:x}})}r.deleteShader(w),r.deleteShader(E),A=new Ha(r,m),C=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r),s=i.name;let a=1;i.type===t.FLOAT_MAT2&&(a=2),i.type===t.FLOAT_MAT3&&(a=3),i.type===t.FLOAT_MAT4&&(a=4),n[s]={type:i.type,location:t.getAttribLocation(e,s),locationSize:a}}return n}(r,m)}let A,C;r.attachShader(m,w),r.attachShader(m,E),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===A&&T(this),A},this.getAttributes=function(){return void 0===C&&T(this),C};let R=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===R&&(R=r.getProgramParameter(m,Wa)),R},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Xa++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=E,this}let co=0;class uo{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),s=this._getShaderCacheForMaterial(t);return!1===s.has(i)&&(s.add(i),i.usedTimes++),!1===s.has(r)&&(s.add(r),r.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 n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new po(t),e.set(t,n)),n}}class po{constructor(t){this.id=co++,this.code=t,this.usedTimes=0}}function fo(t,e,n,i,r,s,a){const o=new gi,l=new uo,h=new Set,c=[],d=r.logarithmicDepthBuffer,u=r.vertexTextures;let p=r.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 m(t){return h.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(s,o,c,g,_){const v=g.fog,y=_.geometry,S=s.isMeshStandardMaterial?g.environment:null,b=(s.isMeshStandardMaterial?n:e).get(s.envMap||S),M=b&&b.mapping===lt?b.image.height:null,w=f[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const E=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==E?E.length:0;let A,C,R,P,L=0;if(void 0!==y.morphAttributes.position&&(L=1),void 0!==y.morphAttributes.normal&&(L=2),void 0!==y.morphAttributes.color&&(L=3),w){const t=ns[w];A=t.vertexShader,C=t.fragmentShader}else A=s.vertexShader,C=s.fragmentShader,l.update(s),R=l.getVertexShaderID(s),P=l.getFragmentShaderID(s);const I=t.getRenderTarget(),D=t.state.buffers.depth.getReversed(),N=!0===_.isInstancedMesh,U=!0===_.isBatchedMesh,O=!!s.map,F=!!s.matcap,k=!!b,B=!!s.aoMap,z=!!s.lightMap,G=!!s.bumpMap,H=!!s.normalMap,V=!!s.displacementMap,W=!!s.emissiveMap,X=!!s.metalnessMap,j=!!s.roughnessMap,Y=s.anisotropy>0,q=s.clearcoat>0,K=s.dispersion>0,Z=s.iridescence>0,Q=s.sheen>0,$=s.transmission>0,tt=Y&&!!s.anisotropyMap,et=q&&!!s.clearcoatMap,nt=q&&!!s.clearcoatNormalMap,it=q&&!!s.clearcoatRoughnessMap,rt=Z&&!!s.iridescenceMap,st=Z&&!!s.iridescenceThicknessMap,at=Q&&!!s.sheenColorMap,ot=Q&&!!s.sheenRoughnessMap,ht=!!s.specularMap,ct=!!s.specularColorMap,dt=!!s.specularIntensityMap,ut=$&&!!s.transmissionMap,pt=$&&!!s.thicknessMap,ft=!!s.gradientMap,mt=!!s.alphaMap,gt=s.alphaTest>0,_t=!!s.alphaHash,vt=!!s.extensions;let yt=J;s.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(yt=t.toneMapping));const xt={shaderID:w,shaderType:s.type,shaderName:s.name,vertexShader:A,fragmentShader:C,defines:s.defines,customVertexShaderID:R,customFragmentShaderID:P,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:U,batchingColor:U&&null!==_._colorsTexture,instancing:N,instancingColor:N&&null!==_.instanceColor,instancingMorph:N&&null!==_.morphTexture,supportsVertexTextures:u,outputColorSpace:null===I?t.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:Ee,alphaToCoverage:!!s.alphaToCoverage,map:O,matcap:F,envMap:k,envMapMode:k&&b.mapping,envMapCubeUVHeight:M,aoMap:B,lightMap:z,bumpMap:G,normalMap:H,displacementMap:u&&V,emissiveMap:W,normalMapObjectSpace:H&&1===s.normalMapType,normalMapTangentSpace:H&&0===s.normalMapType,metalnessMap:X,roughnessMap:j,anisotropy:Y,anisotropyMap:tt,clearcoat:q,clearcoatMap:et,clearcoatNormalMap:nt,clearcoatRoughnessMap:it,dispersion:K,iridescence:Z,iridescenceMap:rt,iridescenceThicknessMap:st,sheen:Q,sheenColorMap:at,sheenRoughnessMap:ot,specularMap:ht,specularColorMap:ct,specularIntensityMap:dt,transmission:$,transmissionMap:ut,thicknessMap:pt,gradientMap:ft,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:mt,alphaTest:gt,alphaHash:_t,combine:s.combine,mapUv:O&&m(s.map.channel),aoMapUv:B&&m(s.aoMap.channel),lightMapUv:z&&m(s.lightMap.channel),bumpMapUv:G&&m(s.bumpMap.channel),normalMapUv:H&&m(s.normalMap.channel),displacementMapUv:V&&m(s.displacementMap.channel),emissiveMapUv:W&&m(s.emissiveMap.channel),metalnessMapUv:X&&m(s.metalnessMap.channel),roughnessMapUv:j&&m(s.roughnessMap.channel),anisotropyMapUv:tt&&m(s.anisotropyMap.channel),clearcoatMapUv:et&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:nt&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:rt&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:st&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:at&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:ot&&m(s.sheenRoughnessMap.channel),specularMapUv:ht&&m(s.specularMap.channel),specularColorMapUv:ct&&m(s.specularColorMap.channel),specularIntensityMapUv:dt&&m(s.specularIntensityMap.channel),transmissionMapUv:ut&&m(s.transmissionMap.channel),thicknessMapUv:pt&&m(s.thicknessMap.channel),alphaMapUv:mt&&m(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(H||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===_.isPoints&&!!y.attributes.uv&&(O||mt),fog:!!v,useFog:!0===s.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,reverseDepthBuffer:D,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,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:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,decodeVideoTexture:O&&!0===s.map.isVideoTexture&&ln.getTransfer(s.map.colorSpace)===Ae,decodeVideoTextureEmissive:W&&!0===s.emissiveMap.isVideoTexture&&ln.getTransfer(s.emissiveMap.colorSpace)===Ae,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:s.side===x,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:vt&&!0===s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&!0===s.extensions.multiDraw||U)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return xt.vertexUv1s=h.has(1),xt.vertexUv2s=h.has(2),xt.vertexUv3s=h.has(3),h.clear(),xt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.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)}(n,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0);e.instancing&&o.enable(1);e.instancingColor&&o.enable(2);e.instancingMorph&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);e.alphaHash&&o.enable(18);e.batching&&o.enable(19);e.dispersion&&o.enable(20);e.batchingColor&&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.reverseDepthBuffer&&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)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=ns[e];n=Dr.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=c.length;t<e;t++){const e=c[t];if(e.cacheKey===n){i=e,++i.usedTimes;break}}return void 0===i&&(i=new ho(t,n,e,s),c.push(i)),i},releaseProgram:function(t){if(0==--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),t.destroy()}},releaseShaderCache:function(t){l.remove(t)},programs:c,dispose:function(){l.dispose()}}}function mo(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function go(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 _o(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 vo(){const t=[];let e=0;const n=[],i=[],r=[];function s(n,i,r,s,a,o){let l=t[e];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:s,renderOrder:n.renderOrder,z:a,group:o},t[e]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=s,l.renderOrder=n.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){e=0,n.length=0,i.length=0,r.length=0},push:function(t,e,a,o,l,h){const c=s(t,e,a,o,l,h);a.transmission>0?i.push(c):!0===a.transparent?r.push(c):n.push(c)},unshift:function(t,e,a,o,l,h){const c=s(t,e,a,o,l,h);a.transmission>0?i.unshift(c):!0===a.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||go),i.length>1&&i.sort(e||_o),r.length>1&&r.sort(e||_o)}}}function yo(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new vo,t.set(e,[r])):n>=i.length?(r=new vo,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function xo(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Rn,color:new Ji};break;case"SpotLight":n={position:new Rn,direction:new Rn,color:new Ji,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Rn,color:new Ji,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Rn,skyColor:new Ji,groundColor:new Ji};break;case"RectAreaLight":n={color:new Ji,position:new Rn,halfWidth:new Rn,halfHeight:new Rn}}return t[e.id]=n,n}}}let So=0;function bo(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Mo(t){const e=new xo,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={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++)i.probe.push(new Rn);const r=new Rn,s=new si,a=new si;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,h=0,c=0,d=0,u=0,p=0,f=0,m=0,g=0,_=0,v=0;r.sort(bo);for(let t=0,y=r.length;t<y;t++){const y=r[t],x=y.color,S=y.intensity,b=y.distance,M=y.shadow&&y.shadow.map?y.shadow.map.texture:null;if(y.isAmbientLight)s+=x.r*S,a+=x.g*S,o+=x.b*S;else if(y.isLightProbe){for(let t=0;t<9;t++)i.probe[t].addScaledVector(y.sh.coefficients[t],S);v++}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=n.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,i.directionalShadow[l]=e,i.directionalShadowMap[l]=M,i.directionalShadowMatrix[l]=y.shadow.matrix,p++}i.directional[l]=t,l++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(S),t.distance=b,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,i.spot[c]=t;const r=y.shadow;if(y.map&&(i.spotLightMap[g]=y.map,g++,r.updateMatrices(y),y.castShadow&&_++),i.spotLightMatrix[c]=r.matrix,y.castShadow){const t=n.get(y);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,i.spotShadow[c]=t,i.spotShadowMap[c]=M,m++}c++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(S),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),i.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=n.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,i.pointShadow[h]=e,i.pointShadowMap[h]=M,i.pointShadowMatrix[h]=y.shadow.matrix,f++}i.point[h]=t,h++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(S),t.groundColor.copy(y.groundColor).multiplyScalar(S),i.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=es.LTC_FLOAT_1,i.rectAreaLTC2=es.LTC_FLOAT_2):(i.rectAreaLTC1=es.LTC_HALF_1,i.rectAreaLTC2=es.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===h&&y.spotLength===c&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===f&&y.numSpotShadows===m&&y.numSpotMaps===g&&y.numLightProbes===v||(i.directional.length=l,i.spot.length=c,i.rectArea.length=d,i.point.length=h,i.hemi.length=u,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-_,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=v,y.directionalLength=l,y.pointLength=h,y.spotLength=c,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=v,i.version=So++)},setupView:function(t,e){let n=0,o=0,l=0,h=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=i.directional[n];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),n++}else if(u.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),l++}else if(u.isRectAreaLight){const t=i.rectArea[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),s.copy(u.matrixWorld),s.premultiply(d),a.extractRotation(s),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),h++}else if(u.isPointLight){const t=i.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=i.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:i}}function wo(t){const e=new Mo(t),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,n.length=0,i.length=0},state:r,setupLights:function(){e.setup(n)},setupLightsView:function(t){e.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){i.push(t)}}}function Eo(t){let e=new WeakMap;return{get:function(n,i=0){const r=e.get(n);let s;return void 0===r?(s=new wo(t),e.set(n,[s])):i>=r.length?(s=new wo(t),r.push(s)):s=r[i],s},dispose:function(){e=new WeakMap}}}class To extends tr{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Ao extends tr{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Co(t,e,n){let i=new Zr;const r=new $e,s=new $e,a=new Mn,o=new To({depthPacking:3201}),l=new Ao,h={},c=n.maxTextureSize,d={[y]:x,[x]:y,[S]:2},u=new Nr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},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;\n#include <packing>\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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\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 = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\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( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const f=new mr;f.setAttribute("position",new rr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Ar(f,u),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=g;let b=this.type;function M(n,i){const s=e.update(m);u.defines.VSM_SAMPLES!==n.blurSamples&&(u.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new En(r.x,r.y)),u.uniforms.shadow_pass.value=n.map.texture,u.uniforms.resolution.value=n.mapSize,u.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,s,u,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,s,p,m,null)}function w(e,n,i,r){let s=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=s.uuid,e=n.uuid;let i=h[t];void 0===i&&(i={},h[t]=i);let r=i[e];void 0===r&&(r=s.clone(),i[e]=r,n.addEventListener("dispose",T)),s=r}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===v?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=i}return s}function E(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===v)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let h=0,c=e.length;h<c;h++){const c=e[h],d=l[c.materialIndex];if(d&&d.visible){const e=w(n,d,a,o);n.onBeforeShadow(t,n,r,s,i,e,c),t.renderBufferDirect(s,null,i,e,n,c),n.onAfterShadow(t,n,r,s,i,e,c)}}}else if(l.visible){const e=w(n,l,a,o);n.onBeforeShadow(t,n,r,s,i,e,null),t.renderBufferDirect(s,null,i,e,n,null),n.onAfterShadow(t,n,r,s,i,e,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)E(l[t],r,s,a,o)}function T(t){t.target.removeEventListener("dispose",T);for(const e in h){const n=h[e],i=t.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(e,n,o){if(!1===_.enabled)return;if(!1===_.autoUpdate&&!1===_.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),h=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=b!==v&&this.type===v,f=b===v&&this.type!==v;for(let l=0,h=e.length;l<h;l++){const h=e[l],d=h.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",h,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();if(r.multiply(m),s.copy(d.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/m.x),r.x=s.x*m.x,d.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/m.y),r.y=s.y*m.y,d.mapSize.y=s.y)),null===d.map||!0===p||!0===f){const t=this.type!==v?{minFilter:ut,magFilter:ut}:{};null!==d.map&&d.map.dispose(),d.map=new En(r.x,r.y,t),d.map.texture.name=h.name+".shadowMap",d.camera.updateProjectionMatrix()}t.setRenderTarget(d.map),t.clear();const g=d.getViewportCount();for(let t=0;t<g;t++){const e=d.getViewport(t);a.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),u.viewport(a),d.updateMatrices(h,t),i=d.getFrustum(),E(n,o,d.camera,h,this.type)}!0!==d.isPointLightShadow&&this.type===v&&M(d,o),d.needsUpdate=!1}b=this.type,_.needsUpdate=!1,t.setRenderTarget(l,h,d)}}const Ro={[z]:1,[H]:6,[W]:7,[V]:5,[G]:0,[j]:2,[Y]:4,[X]:3};function Po(t,e){const n=new function(){let e=!1;const n=new Mn;let i=null;const r=new Mn(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,s,a,o){!0===o&&(e*=a,i*=a,s*=a),n.set(e,i,s,a),!1===r.equals(n)&&(t.clearColor(e,i,s,a),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,s=null,a=null;return{setReversed:function(t){if(i!==t){const t=e.get("EXT_clip_control");i?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT);const n=a;a=null,this.setClear(n)}i=t},getReversed:function(){return i},setTest:function(e){e?st(t.DEPTH_TEST):at(t.DEPTH_TEST)},setMask:function(e){r===e||n||(t.depthMask(e),r=e)},setFunc:function(e){if(i&&(e=Ro[e]),s!==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)}s=e}},setLocked:function(t){n=t},setClear:function(e){a!==e&&(i&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){n=!1,r=null,s=null,a=null,i=!1}}},r=new function(){let e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,h=null;return{setTest:function(n){e||(n?st(t.STENCIL_TEST):at(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,a){i===e&&r===n&&s===a||(t.stencilFunc(e,n,a),i=e,r=n,s=a)},setOp:function(e,n,i){a===e&&o===n&&l===i||(t.stencilOp(e,n,i),a=e,o=n,l=i)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,h=null}}},s=new WeakMap,a=new WeakMap;let o={},l={},h=new WeakMap,c=[],d=null,u=!1,p=null,f=null,m=null,g=null,_=null,v=null,y=null,S=new Ji(0,0,0),z=0,G=!1,H=null,V=null,W=null,X=null,j=null;const Y=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,K=0;const Z=t.getParameter(t.VERSION);-1!==Z.indexOf("WebGL")?(K=parseFloat(/^WebGL (\d)/.exec(Z)[1]),q=K>=1):-1!==Z.indexOf("OpenGL ES")&&(K=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),q=K>=2);let J=null,Q={};const $=t.getParameter(t.SCISSOR_BOX),tt=t.getParameter(t.VIEWPORT),et=(new Mn).fromArray($),nt=(new Mn).fromArray(tt);function it(e,n,i,r){const s=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<i;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(n,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(n+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const rt={};function st(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function at(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}rt[t.TEXTURE_2D]=it(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=it(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[t.TEXTURE_2D_ARRAY]=it(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=it(t.TEXTURE_3D,t.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),st(t.DEPTH_TEST),i.setFunc(3),ct(!1),dt(1),st(t.CULL_FACE),ht(0);const ot={[b]:t.FUNC_ADD,[M]:t.FUNC_SUBTRACT,[w]:t.FUNC_REVERSE_SUBTRACT};ot[103]=t.MIN,ot[104]=t.MAX;const lt={[E]:t.ZERO,[T]:t.ONE,[A]:t.SRC_COLOR,[R]:t.SRC_ALPHA,[U]:t.SRC_ALPHA_SATURATE,[D]:t.DST_COLOR,[L]:t.DST_ALPHA,[C]:t.ONE_MINUS_SRC_COLOR,[P]:t.ONE_MINUS_SRC_ALPHA,[N]:t.ONE_MINUS_DST_COLOR,[I]:t.ONE_MINUS_DST_ALPHA,[O]:t.CONSTANT_COLOR,[F]:t.ONE_MINUS_CONSTANT_COLOR,[k]:t.CONSTANT_ALPHA,[B]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,n,i,r,s,a,o,l,h,c){if(0!==e){if(!1===u&&(st(t.BLEND),u=!0),5===e)s=s||n,a=a||i,o=o||r,n===f&&s===_||(t.blendEquationSeparate(ot[n],ot[s]),f=n,_=s),i===m&&r===g&&a===v&&o===y||(t.blendFuncSeparate(lt[i],lt[r],lt[a],lt[o]),m=i,g=r,v=a,y=o),!1!==l.equals(S)&&h===z||(t.blendColor(l.r,l.g,l.b,h),S.copy(l),z=h),p=e,G=!1;else if(e!==p||c!==G){if(f===b&&_===b||(t.blendEquation(t.FUNC_ADD),f=b,_=b),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.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.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.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}m=null,g=null,v=null,y=null,S.set(0,0,0),z=0,p=e,G=c}}else!0===u&&(at(t.BLEND),u=!1)}function ct(e){H!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),H=e)}function dt(e){0!==e?(st(t.CULL_FACE),e!==V&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):at(t.CULL_FACE),V=e}function ut(e,n,i){e?(st(t.POLYGON_OFFSET_FILL),X===n&&j===i||(t.polygonOffset(n,i),X=n,j=i)):at(t.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:st,disable:at,bindFramebuffer:function(e,n){return l[e]!==n&&(t.bindFramebuffer(e,n),l[e]=n,e===t.DRAW_FRAMEBUFFER&&(l[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(l[t.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(e,n){let i=c,r=!1;if(e){i=h.get(n),void 0===i&&(i=[],h.set(n,i));const s=e.textures;if(i.length!==s.length||i[0]!==t.COLOR_ATTACHMENT0){for(let e=0,n=s.length;e<n;e++)i[e]=t.COLOR_ATTACHMENT0+e;i.length=s.length,r=!0}}else i[0]!==t.BACK&&(i[0]=t.BACK,r=!0);r&&t.drawBuffers(i)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,s){2===e.side?at(t.CULL_FACE):st(t.CULL_FACE);let a=e.side===x;s&&(a=!a),ct(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),i.setFunc(e.depthFunc),i.setTest(e.depthTest),i.setMask(e.depthWrite),n.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),ut(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?st(t.SAMPLE_ALPHA_TO_COVERAGE):at(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:ct,setCullFace:dt,setLineWidth:function(e){e!==W&&(q&&t.lineWidth(e),W=e)},setPolygonOffset:ut,setScissorTest:function(e){e?st(t.SCISSOR_TEST):at(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+Y-1),J!==e&&(t.activeTexture(e),J=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===J?t.TEXTURE0+Y-1:J);let r=Q[i];void 0===r&&(r={type:void 0,texture:void 0},Q[i]=r),r.type===e&&r.texture===n||(J!==i&&(t.activeTexture(i),J=i),t.bindTexture(e,n||rt[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=Q[J];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.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,n){let i=a.get(n);void 0===i&&(i=new WeakMap,a.set(n,i));let r=i.get(e);void 0===r&&(r=t.getUniformBlockIndex(n,e.name),i.set(e,r))},uniformBlockBinding:function(e,n){const i=a.get(n).get(e);s.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),s.set(n,i))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===et.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),et.copy(e))},viewport:function(e){!1===nt.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),nt.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),i.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={},J=null,Q={},l={},h=new WeakMap,c=[],d=null,u=!1,p=null,f=null,m=null,g=null,_=null,v=null,y=null,S=new Ji(0,0,0),z=0,G=!1,H=null,V=null,W=null,X=null,j=null,et.set(0,0,t.canvas.width,t.canvas.height),nt.set(0,0,t.canvas.width,t.canvas.height),n.reset(),i.reset(),r.reset()}}}function Lo(t,e,n,i){const r=function(t){switch(t){case vt:case yt:return{byteLength:1,components:1};case St:case xt:case Et:return{byteLength:2,components:1};case Tt:case At:return{byteLength:2,components:4};case Mt:case bt:case wt:return{byteLength:4,components:1};case Rt:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(i);switch(n){case Pt:case Dt:return t*e;case Nt:return t*e*2;case Ft:case kt:return t*e/r.components*r.byteLength;case Bt:case zt:return t*e*2/r.components*r.byteLength;case Lt:return t*e*3/r.components*r.byteLength;case It:case Gt:return t*e*4/r.components*r.byteLength;case Ht:case Vt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Wt:case Xt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Yt:case Kt:return Math.max(t,16)*Math.max(e,8)/4;case jt:case qt:return Math.max(t,8)*Math.max(e,8)/2;case Zt:case Jt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Qt:case $t:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case te:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case ee:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case ne:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case ie:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case re:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case se:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case ae:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case oe:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case le:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case he:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case ce:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case de:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case ue:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case pe:case fe:case me:return Math.ceil(t/4)*Math.ceil(e/4)*16;case ge:case _e:return Math.ceil(t/4)*Math.ceil(e/4)*8;case ve:case ye:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Io(t,e,n,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),h=new $e,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 f(t,e){return p?new OffscreenCanvas(t,e):rn("canvas")}function m(t,e,n){let i=1;const r=G(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<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 n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===d&&(d=f(n,s));const a=e?f(n,s):d;a.width=n,a.height=s;return a.getContext("2d").drawImage(t,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function _(e){t.generateMipmap(e)}function v(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(n,i,r,s,a=!1){if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),i===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),i===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),i===t.RGBA){const e=a?Te:ln.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===Ae?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===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,n){let i;return e?null===n||n===Mt||n===Ct?i=t.DEPTH24_STENCIL8:n===wt?i=t.DEPTH32F_STENCIL8:n===St&&(i=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Mt||n===Ct?i=t.DEPTH_COMPONENT24:n===wt?i=t.DEPTH_COMPONENT32F:n===St&&(i=t.DEPTH_COMPONENT16),i}function S(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==ut&&t.minFilter!==mt?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 b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=u.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&w(t),0===Object.keys(r).length&&u.delete(n)}i.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function M(e){const n=e.target;n.removeEventListener("dispose",M),function(e){const n=i.get(e);e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i<n.__webglFramebuffer[e].length;i++)t.deleteFramebuffer(n.__webglFramebuffer[e][i]);else t.deleteFramebuffer(n.__webglFramebuffer[e]);n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[e])}else{if(Array.isArray(n.__webglFramebuffer))for(let e=0;e<n.__webglFramebuffer.length;e++)t.deleteFramebuffer(n.__webglFramebuffer[e]);else t.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let e=0;e<n.__webglColorRenderbuffer.length;e++)n.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(n.__webglColorRenderbuffer[e]);n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,n=r.length;e<n;e++){const n=i.get(r[e]);n.__webglTexture&&(t.deleteTexture(n.__webglTexture),a.memory.textures--),i.remove(r[e])}i.remove(e)}(n)}function w(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);const r=e.source;delete u.get(r)[n.__cacheKey],a.memory.textures--}let E=0;function T(e,r){const s=i.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&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void I(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[ht]:t.REPEAT,[ct]:t.CLAMP_TO_EDGE,[dt]:t.MIRRORED_REPEAT},C={[ut]:t.NEAREST,[pt]:t.NEAREST_MIPMAP_NEAREST,[ft]:t.NEAREST_MIPMAP_LINEAR,[mt]:t.LINEAR,[gt]:t.LINEAR_MIPMAP_NEAREST,[_t]:t.LINEAR_MIPMAP_LINEAR},R={[Re]:t.NEVER,[Oe]:t.ALWAYS,[Pe]:t.LESS,[Ie]:t.LEQUAL,[Le]:t.EQUAL,[Ue]:t.GEQUAL,[De]:t.GREATER,[Ne]:t.NOTEQUAL};function P(n,s){if(s.type!==wt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==mt&&s.magFilter!==gt&&s.magFilter!==ft&&s.magFilter!==_t&&s.minFilter!==mt&&s.minFilter!==gt&&s.minFilter!==ft&&s.minFilter!==_t||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,A[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===ut)return;if(s.minFilter!==ft&&s.minFilter!==_t)return;if(s.type===wt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function L(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",b));const r=n.source;let s=u.get(r);void 0===s&&(s={},u.set(r,s));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()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&w(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function I(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const h=L(e,a),c=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const d=i.get(c);if(c.version!==d.__version||!0===h){n.activeTexture(t.TEXTURE0+o);const e=ln.getPrimaries(ln.workingColorSpace),i=a.colorSpace===Me?null:ln.getPrimaries(a.colorSpace),u=a.colorSpace===Me||e===i?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=m(a.image,!1,r.maxTextureSize);p=z(a,p);const f=s.convert(a.format,a.colorSpace),v=s.convert(a.type);let b,M=y(a.internalFormat,f,v,a.colorSpace,a.isVideoTexture);P(l,a);const w=a.mipmaps,E=!0!==a.isVideoTexture,T=void 0===d.__version||!0===h,A=c.dataReady,C=S(a,p);if(a.isDepthTexture)M=x(a.format===Ot,a.type),T&&(E?n.texStorage2D(t.TEXTURE_2D,1,M,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,M,p.width,p.height,0,f,v,null));else if(a.isDataTexture)if(w.length>0){E&&T&&n.texStorage2D(t.TEXTURE_2D,C,M,w[0].width,w[0].height);for(let e=0,i=w.length;e<i;e++)b=w[e],E?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,v,b.data):n.texImage2D(t.TEXTURE_2D,e,M,b.width,b.height,0,f,v,b.data);a.generateMipmaps=!1}else E?(T&&n.texStorage2D(t.TEXTURE_2D,C,M,p.width,p.height),A&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,p.width,p.height,f,v,p.data)):n.texImage2D(t.TEXTURE_2D,0,M,p.width,p.height,0,f,v,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){E&&T&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,M,w[0].width,w[0].height,p.depth);for(let e=0,i=w.length;e<i;e++)if(b=w[e],a.format!==It)if(null!==f)if(E){if(A)if(a.layerUpdates.size>0){const i=Lo(b.width,b.height,a.format,a.type);for(const r of a.layerUpdates){const s=b.data.subarray(r*i/b.data.BYTES_PER_ELEMENT,(r+1)*i/b.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,b.width,b.height,1,f,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,f,b.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,M,b.width,b.height,p.depth,0,b.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else E?A&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,f,v,b.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,M,b.width,b.height,p.depth,0,f,v,b.data)}else{E&&T&&n.texStorage2D(t.TEXTURE_2D,C,M,w[0].width,w[0].height);for(let e=0,i=w.length;e<i;e++)b=w[e],a.format!==It?null!==f?E?A&&n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,b.data):n.compressedTexImage2D(t.TEXTURE_2D,e,M,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,v,b.data):n.texImage2D(t.TEXTURE_2D,e,M,b.width,b.height,0,f,v,b.data)}else if(a.isDataArrayTexture)if(E){if(T&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,M,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Lo(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,v,r)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,M,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isData3DTexture)E?(T&&n.texStorage3D(t.TEXTURE_3D,C,M,p.width,p.height,p.depth),A&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)):n.texImage3D(t.TEXTURE_3D,0,M,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isFramebufferTexture){if(T)if(E)n.texStorage2D(t.TEXTURE_2D,C,M,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r<C;r++)n.texImage2D(t.TEXTURE_2D,r,M,e,i,0,f,v,null),e>>=1,i>>=1}}else if(w.length>0){if(E&&T){const e=G(w[0]);n.texStorage2D(t.TEXTURE_2D,C,M,e.width,e.height)}for(let e=0,i=w.length;e<i;e++)b=w[e],E?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,f,v,b):n.texImage2D(t.TEXTURE_2D,e,M,f,v,b);a.generateMipmaps=!1}else if(E){if(T){const e=G(p);n.texStorage2D(t.TEXTURE_2D,C,M,e.width,e.height)}A&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,f,v,p)}else n.texImage2D(t.TEXTURE_2D,0,M,f,v,p);g(a)&&_(l),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function D(e,r,a,l,h,c){const d=s.convert(a.format,a.colorSpace),u=s.convert(a.type),p=y(a.internalFormat,d,u,a.colorSpace),f=i.get(r),m=i.get(a);if(m.__renderTarget=r,!f.__hasExternalTextures){const e=Math.max(1,r.width>>c),i=Math.max(1,r.height>>c);h===t.TEXTURE_3D||h===t.TEXTURE_2D_ARRAY?n.texImage3D(h,c,p,e,i,r.depth,0,d,u,null):n.texImage2D(h,c,p,e,i,0,d,u,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,h,m.__webglTexture,0,k(r)):(h===t.TEXTURE_2D||h>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&h<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,h,m.__webglTexture,c),n.bindFramebuffer(t.FRAMEBUFFER,null)}function N(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=x(n.stencilBuffer,s),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=k(n);B(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,h,a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,h,a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r<e.length;r++){const a=e[r],l=s.convert(a.format,a.colorSpace),h=s.convert(a.type),c=y(a.internalFormat,l,h,a.colorSpace),d=k(n);i&&!1===B(n)?t.renderbufferStorageMultisample(t.RENDERBUFFER,d,c,n.width,n.height):B(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,d,c,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,c,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e){const r=i.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=i.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),T(r.depthTexture,0);const a=s.__webglTexture,l=k(r);if(r.depthTexture.format===Ut)B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Ot)throw new Error("Unknown depthTexture format");B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),N(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,s)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),N(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const O=[],F=[];function k(t){return Math.min(r.maxSamples,t.samples)}function B(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function z(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==Ee&&n!==Me&&(ln.getTransfer(n)===Ae?i===It&&r===vt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),e}function G(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(h.width=t.naturalWidth||t.width,h.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(h.width=t.displayWidth,h.height=t.displayHeight):(h.width=t.width,h.height=t.height),h}this.allocateTextureUnit=function(){const t=E;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),E+=1,t},this.resetTextureUnits=function(){E=0},this.setTexture2D=T,this.setTexture2DArray=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=L(e,a),h=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=i.get(h);if(h.version!==c.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=ln.getPrimaries(ln.workingColorSpace),i=a.colorSpace===Me?null:ln.getPrimaries(a.colorSpace),d=a.colorSpace===Me||e===i?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,f=[];for(let t=0;t<6;t++)f[t]=u||p?p?a.image[t].image:a.image[t]:m(a.image[t],!0,r.maxCubemapSize),f[t]=z(a,f[t]);const v=f[0],x=s.convert(a.format,a.colorSpace),b=s.convert(a.type),M=y(a.internalFormat,x,b,a.colorSpace),w=!0!==a.isVideoTexture,E=void 0===c.__version||!0===l,T=h.dataReady;let A,C=S(a,v);if(P(t.TEXTURE_CUBE_MAP,a),u){w&&E&&n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,v.width,v.height);for(let e=0;e<6;e++){A=f[e].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];a.format!==It?null!==x?w?T&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,x,r.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,x,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,x,b,r.data)}}}else{if(A=a.mipmaps,w&&E){A.length>0&&C++;const e=G(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,e.width,e.height)}for(let e=0;e<6;e++)if(p){w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,x,b,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,f[e].width,f[e].height,0,x,b,f[e].data);for(let i=0;i<A.length;i++){const r=A[i].image[e].image;w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,r.width,r.height,x,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,r.width,r.height,0,x,b,r.data)}}else{w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,b,f[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,x,b,f[e]);for(let i=0;i<A.length;i++){const r=A[i];w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,x,b,r.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,x,b,r.image[e])}}}g(a)&&_(t.TEXTURE_CUBE_MAP),c.__version=h.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,n,r){const s=i.get(e);void 0!==n&&D(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&U(e)},this.setupRenderTarget=function(e){const r=e.texture,o=i.get(e),l=i.get(r);e.addEventListener("dispose",M);const h=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=h.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[e][n]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,n=h.length;e<n;e++){const n=i.get(h[e]);void 0===n.__webglTexture&&(n.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===B(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<h.length;n++){const i=h[n];o.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=s.convert(i.format,i.colorSpace),a=s.convert(i.type),l=y(i.internalFormat,r,a,i.colorSpace,!0===e.isXRRenderTarget),c=k(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,o.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),N(o.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)D(o.__webglFramebuffer[n][i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else D(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(r)&&_(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let r=0,s=h.length;r<s;r++){const s=h[r],a=i.get(s);n.bindTexture(t.TEXTURE_2D,a.__webglTexture),P(t.TEXTURE_2D,s),D(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,t.TEXTURE_2D,0),g(s)&&_(t.TEXTURE_2D)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),P(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)D(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,i,n);else D(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,i,0);g(r)&&_(i),n.unbindTexture()}e.depthBuffer&&U(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(g(s)){const e=v(t),r=i.get(s).__webglTexture;n.bindTexture(e,r),_(e),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===B(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const h=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=i.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let n=0;n<r.length;n++){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[n]);const e=i.get(r[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===l&&(O.length=0,F.length=0,O.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&!1===e.resolveDepthBuffer&&(O.push(h),F.push(h),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,F)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,O))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=i.get(r[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=D,this.useMultisampledRTT=B}function Do(t,e){return{convert:function(n,i=""){let r;const s=ln.getTransfer(i);if(n===vt)return t.UNSIGNED_BYTE;if(n===Tt)return t.UNSIGNED_SHORT_4_4_4_4;if(n===At)return t.UNSIGNED_SHORT_5_5_5_1;if(n===Rt)return t.UNSIGNED_INT_5_9_9_9_REV;if(n===yt)return t.BYTE;if(n===xt)return t.SHORT;if(n===St)return t.UNSIGNED_SHORT;if(n===bt)return t.INT;if(n===Mt)return t.UNSIGNED_INT;if(n===wt)return t.FLOAT;if(n===Et)return t.HALF_FLOAT;if(n===Pt)return t.ALPHA;if(n===Lt)return t.RGB;if(n===It)return t.RGBA;if(n===Dt)return t.LUMINANCE;if(n===Nt)return t.LUMINANCE_ALPHA;if(n===Ut)return t.DEPTH_COMPONENT;if(n===Ot)return t.DEPTH_STENCIL;if(n===Ft)return t.RED;if(n===kt)return t.RED_INTEGER;if(n===Bt)return t.RG;if(n===zt)return t.RG_INTEGER;if(n===Gt)return t.RGBA_INTEGER;if(n===Ht||n===Vt||n===Wt||n===Xt)if(s===Ae){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Ht)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Vt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Wt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Xt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Ht)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Vt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Wt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Xt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===jt||n===Yt||n===qt||n===Kt){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===jt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Yt)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===qt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Kt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Zt||n===Jt||n===Qt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===Zt||n===Jt)return s===Ae?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Qt)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===$t||n===te||n===ee||n===ne||n===ie||n===re||n===se||n===ae||n===oe||n===le||n===he||n===ce||n===de||n===ue){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===$t)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===te)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ee)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ne)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ie)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===re)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===se)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ae)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===oe)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===le)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===he)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ce)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===de)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ue)return s===Ae?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===pe||n===fe||n===me){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(n===pe)return s===Ae?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===fe)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===me)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===ge||n===_e||n===ve||n===ye){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===pe)return r.COMPRESSED_RED_RGTC1_EXT;if(n===_e)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ve)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ye)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Ct?t.UNSIGNED_INT_24_8:void 0!==t[n]?t[n]:null}}}class No extends Br{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}let Uo=class extends Ii{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Oo={type:"move"};class Fo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Uo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Uo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Rn,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Rn),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Uo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Rn,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Rn),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),r=this._getHandJoint(l,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,h=.005;l.inputState.pinching&&a>o+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Oo)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new Uo;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class ko{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(null===this.texture){const i=new bn;t.properties.get(i).__webglTexture=e.texture,e.depthNear==n.depthNear&&e.depthFar==n.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new Nr({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 Ar(new $r(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Bo extends Ge{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,h=null,c=null,d=null,u=null,p=null;const f=new ko,m=e.getContextAttributes();let g=null,_=null;const v=[],y=[],x=new $e;let S=null;const b=new Br;b.viewport=new Mn;const M=new Br;M.viewport=new Mn;const w=[b,M],E=new No;let T=null,A=null;function C(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const n=v[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function R(){i.removeEventListener("select",C),i.removeEventListener("selectstart",C),i.removeEventListener("selectend",C),i.removeEventListener("squeeze",C),i.removeEventListener("squeezestart",C),i.removeEventListener("squeezeend",C),i.removeEventListener("end",R),i.removeEventListener("inputsourceschange",P);for(let t=0;t<v.length;t++){const e=y[t];null!==e&&(y[t]=null,v[t].disconnect(e))}T=null,A=null,f.reset(),t.setRenderTarget(g),u=null,d=null,c=null,i=null,_=null,U.stop(),n.isPresenting=!1,t.setPixelRatio(S),t.setSize(x.width,x.height,!1),n.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=y.indexOf(n);i>=0&&(y[i]=null,v[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=y.indexOf(n);if(-1===i){for(let t=0;t<v.length;t++){if(t>=y.length){y.push(n),i=t;break}if(null===y[t]){y[t]=n,i=t;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=v[t];return void 0===e&&(e=new Fo,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new Fo,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new Fo,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(h){if(i=h,null!==i){if(g=t.getRenderTarget(),i.addEventListener("select",C),i.addEventListener("selectstart",C),i.addEventListener("selectend",C),i.addEventListener("squeeze",C),i.addEventListener("squeezestart",C),i.addEventListener("squeezeend",C),i.addEventListener("end",R),i.addEventListener("inputsourceschange",P),!0!==m.xrCompatible&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(x),void 0===i.renderState.layers){const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),_=new En(u.framebufferWidth,u.framebufferHeight,{format:It,type:vt,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?Ot:Ut,s=m.stencil?Ct:Mt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=new XRWebGLBinding(i,e),d=c.createProjectionLayer(o),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new En(d.textureWidth,d.textureHeight,{format:It,type:vt,depthTexture:new Fs(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues})}_.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const L=new Rn,I=new Rn;function D(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===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),E.near=M.near=b.near=e,E.far=M.far=b.far=n,T===E.near&&A===E.far||(i.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,A=E.far),b.layers.mask=2|t.layers.mask,M.layers.mask=4|t.layers.mask,E.layers.mask=b.layers.mask|M.layers.mask;const r=t.parent,s=E.cameras;D(E,r);for(let t=0;t<s.length;t++)D(s[t],r);2===s.length?function(t,e,n){L.setFromMatrixPosition(e.matrixWorld),I.setFromMatrixPosition(n.matrixWorld);const i=L.distanceTo(I),r=e.projectionMatrix.elements,s=n.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],h=(r[9]-1)/r[5],c=(r[8]-1)/r[0],d=(s[8]+1)/s[0],u=a*c,p=a*d,f=i/(-c+d),m=f*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+f,n=o+f,r=u-m,s=p+(i-m),c=l*o/n*e,d=h*o/n*e;t.projectionMatrix.makePerspective(r,s,c,d,e,n),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(E,b,M):E.projectionMatrix.copy(b.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.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*Xe*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,E,r)},this.getCamera=function(){return E},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(E)};let N=null;const U=new Jr;U.setAnimationLoop((function(e,r){if(h=r.getViewerPose(l||s),p=r,null!==h){const e=h.views;null!==u&&(t.setRenderTargetFramebuffer(_,u.framebuffer),t.setRenderTarget(_));let n=!1;e.length!==E.cameras.length&&(E.cameras.length=0,n=!0);for(let i=0;i<e.length;i++){const r=e[i];let s=null;if(null!==u)s=u.getViewport(r);else{const e=c.getViewSubImage(d,r);s=e.viewport,0===i&&(t.setRenderTargetTextures(_,e.colorTexture,d.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(_))}let a=w[i];void 0===a&&(a=new Br,a.layers.enable(i),a.viewport=new Mn,w[i]=a),a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(r.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(E.matrix.copy(a.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),!0===n&&E.cameras.push(a)}const r=i.enabledFeatures;if(r&&r.includes("depth-sensing")){const n=c.getDepthInformation(e[0]);n&&n.isValid&&n.texture&&f.init(t,n,i.renderState)}}for(let t=0;t<v.length;t++){const e=y[t],n=v[t];null!==e&&void 0!==n&&n.update(e,r,l||s)}N&&N(e,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(t){N=t},this.dispose=function(){}}}const zo=new mi,Go=new si;function Ho(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map,n(i.map,t.mapTransform)),i.alphaMap&&(t.alphaMap.value=i.alphaMap,n(i.alphaMap,t.alphaMapTransform)),i.bumpMap&&(t.bumpMap.value=i.bumpMap,n(i.bumpMap,t.bumpMapTransform),t.bumpScale.value=i.bumpScale,i.side===x&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,n(i.normalMap,t.normalMapTransform),t.normalScale.value.copy(i.normalScale),i.side===x&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,n(i.displacementMap,t.displacementMapTransform),t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,t.emissiveMapTransform)),i.specularMap&&(t.specularMap.value=i.specularMap,n(i.specularMap,t.specularMapTransform)),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,zo.copy(a),zo.x*=-1,zo.y*=-1,zo.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(zo.y*=-1,zo.z*=-1),t.envMapRotation.value.setFromMatrix4(Go.makeRotationFromEuler(zo)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,Ir(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){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,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===x&&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,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(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,n(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.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,n(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Vo(t,e,n,i){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function h(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?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const n=e.target;n.removeEventListener("dispose",c);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,d){let u=r[n.id];void 0===u&&(!function(t){const e=t.uniforms;let n=0;const i=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=h(s[t]),a=n%i,o=a%r.boundary,l=a+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);t.__size=n,t.__cache={}}(n),u=function(e){const n=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const i=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=u,n.addEventListener("dispose",c));const p=d.program;i.updateUBOMapping(n,p);const f=e.render.frame;s[n.id]!==f&&(!function(e){const n=r[e.id],i=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let e=0,n=i.length;e<n;e++){const n=Array.isArray(i[e])?i[e]:[i[e]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,e,i,s)){const e=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let s=0;s<n.length;s++){const a=n[s],o=h(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+i,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),s[n.id]=f)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}class Wo{constructor(t={}){const{canvas:e=sn(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:d=!1,reverseDepthBuffer:u=!1}=t;let p;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=s;const f=new Uint32Array(4),m=new Int32Array(4);let g=null,_=null;const v=[],S=[];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._outputColorSpace=we,this.toneMapping=J,this.toneMappingExposure=1;const b=this;let M=!1,w=0,E=0,T=null,A=-1,C=null;const R=new Mn,P=new Mn;let L=null;const I=new Ji(0);let D=0,N=e.width,U=e.height,O=1,F=null,k=null;const B=new Mn(0,0,N,U),z=new Mn(0,0,N,U);let G=!1;const H=new Zr;let V=!1,W=!1;const X=new si,j=new si,Y=new Rn,q=new Mn,K={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Z=!1;function Q(){return null===T?O:1}let $,tt,et,nt,it,rt,st,at,ot,lt,ht,ct,dt,ut,pt,ft,mt,gt,yt,xt,bt,wt,Rt,Pt,Lt=n;function It(t,n){return e.getContext(t,n)}try{const t={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${l}`),e.addEventListener("webglcontextlost",Ut,!1),e.addEventListener("webglcontextrestored",Ot,!1),e.addEventListener("webglcontextcreationerror",Ft,!1),null===Lt){const e="webgl2";if(Lt=It(e,t),null===Lt)throw It(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Dt(){$=new Ls(Lt),$.init(),wt=new Do(Lt,$),tt=new hs(Lt,$,t,wt),et=new Po(Lt,$),tt.reverseDepthBuffer&&u&&et.buffers.depth.setReversed(!0),nt=new Ns(Lt),it=new mo,rt=new Io(Lt,$,et,it,tt,wt,nt),st=new ds(b),at=new Ps(b),ot=new Qr(Lt),Rt=new os(Lt,ot),lt=new Is(Lt,ot,nt,Rt),ht=new Os(Lt,lt,ot,nt),yt=new Us(Lt,tt,rt),ft=new cs(it),ct=new fo(b,st,at,$,tt,Rt,ft),dt=new Ho(b,it),ut=new yo,pt=new Eo($),gt=new as(b,st,at,et,ht,p,o),mt=new Co(b,ht,tt),Pt=new Vo(Lt,nt,tt,et),xt=new ls(Lt,$,nt),bt=new Ds(Lt,$,nt),nt.programs=ct.programs,b.capabilities=tt,b.extensions=$,b.properties=it,b.renderLists=ut,b.shadowMap=mt,b.state=et,b.info=nt}Dt();const Nt=new Bo(b,Lt);function Ut(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function Ot(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;const t=nt.autoReset,e=mt.enabled,n=mt.autoUpdate,i=mt.needsUpdate,r=mt.type;Dt(),nt.autoReset=t,mt.enabled=e,mt.autoUpdate=n,mt.needsUpdate=i,mt.type=r}function Ft(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Bt(t){const e=t.target;e.removeEventListener("dispose",Bt),function(t){(function(t){const e=it.get(t).programs;void 0!==e&&(e.forEach((function(t){ct.releaseProgram(t)})),t.isShaderMaterial&&ct.releaseShaderCache(t))})(t),it.remove(t)}(e)}function Ht(t,e,n){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=x,t.needsUpdate=!0,Qt(t,e,n),t.side=y,t.needsUpdate=!0,Qt(t,e,n),t.side=2):Qt(t,e,n)}this.xr=Nt,this.getContext=function(){return Lt},this.getContextAttributes=function(){return Lt.getContextAttributes()},this.forceContextLoss=function(){const t=$.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=$.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(t){void 0!==t&&(O=t,this.setSize(N,U,!1))},this.getSize=function(t){return t.set(N,U)},this.setSize=function(t,n,i=!0){Nt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(N=t,U=n,e.width=Math.floor(t*O),e.height=Math.floor(n*O),!0===i&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(N*O,U*O).floor()},this.setDrawingBufferSize=function(t,n,i){N=t,U=n,O=i,e.width=Math.floor(t*i),e.height=Math.floor(n*i),this.setViewport(0,0,t,n)},this.getCurrentViewport=function(t){return t.copy(R)},this.getViewport=function(t){return t.copy(B)},this.setViewport=function(t,e,n,i){t.isVector4?B.set(t.x,t.y,t.z,t.w):B.set(t,e,n,i),et.viewport(R.copy(B).multiplyScalar(O).round())},this.getScissor=function(t){return t.copy(z)},this.setScissor=function(t,e,n,i){t.isVector4?z.set(t.x,t.y,t.z,t.w):z.set(t,e,n,i),et.scissor(P.copy(z).multiplyScalar(O).round())},this.getScissorTest=function(){return G},this.setScissorTest=function(t){et.setScissorTest(G=t)},this.setOpaqueSort=function(t){F=t},this.setTransparentSort=function(t){k=t},this.getClearColor=function(t){return t.copy(gt.getClearColor())},this.setClearColor=function(){gt.setClearColor.apply(gt,arguments)},this.getClearAlpha=function(){return gt.getClearAlpha()},this.setClearAlpha=function(){gt.setClearAlpha.apply(gt,arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==T){const e=T.texture.format;t=e===Gt||e===zt||e===kt}if(t){const t=T.texture.type,e=t===vt||t===Mt||t===St||t===Ct||t===Tt||t===At,n=gt.getClearColor(),i=gt.getClearAlpha(),r=n.r,s=n.g,a=n.b;e?(f[0]=r,f[1]=s,f[2]=a,f[3]=i,Lt.clearBufferuiv(Lt.COLOR,0,f)):(m[0]=r,m[1]=s,m[2]=a,m[3]=i,Lt.clearBufferiv(Lt.COLOR,0,m))}else i|=Lt.COLOR_BUFFER_BIT}e&&(i|=Lt.DEPTH_BUFFER_BIT),n&&(i|=Lt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Lt.clear(i)},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",Ut,!1),e.removeEventListener("webglcontextrestored",Ot,!1),e.removeEventListener("webglcontextcreationerror",Ft,!1),ut.dispose(),pt.dispose(),it.dispose(),st.dispose(),at.dispose(),ht.dispose(),Rt.dispose(),Pt.dispose(),ct.dispose(),Nt.dispose(),Nt.removeEventListener("sessionstart",Wt),Nt.removeEventListener("sessionend",Xt),jt.stop()},this.renderBufferDirect=function(t,e,n,i,r,s){null===e&&(e=K);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,n,i,r){!0!==e.isScene&&(e=K);rt.resetTextureUnits();const s=e.fog,a=i.isMeshStandardMaterial?e.environment:null,o=null===T?b.outputColorSpace:!0===T.isXRRenderTarget?T.texture.colorSpace:Ee,l=(i.isMeshStandardMaterial?at:st).get(i.envMap||a),h=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,c=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,u=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=J;i.toneMapped&&(null!==T&&!0!==T.isXRRenderTarget||(f=b.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,v=it.get(i),y=_.state.lights;if(!0===V&&(!0===W||t!==C)){const e=t===C&&i.id===A;ft.setState(i,t,e)}let x=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?x=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?x=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?x=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==l||!0===i.fog&&v.fog!==s?x=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===ft.numPlanes&&v.numIntersection===ft.numIntersection?(v.vertexAlphas!==h||v.vertexTangents!==c||v.morphTargets!==d||v.morphNormals!==u||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,v.__version=i.version);let S=v.currentProgram;!0===x&&(S=Qt(i,e,r));let M=!1,w=!1,E=!1;const R=S.getUniforms(),P=v.uniforms;et.useProgram(S.program)&&(M=!0,w=!0,E=!0);i.id!==A&&(A=i.id,w=!0);if(M||C!==t){et.buffers.depth.getReversed()?(X.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(X),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(X),R.setValue(Lt,"projectionMatrix",X)):R.setValue(Lt,"projectionMatrix",t.projectionMatrix),R.setValue(Lt,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(Lt,Y.setFromMatrixPosition(t.matrixWorld)),tt.logarithmicDepthBuffer&&R.setValue(Lt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(Lt,"isOrthographic",!0===t.isOrthographicCamera),C!==t&&(C=t,w=!0,E=!0)}if(r.isSkinnedMesh){R.setOptional(Lt,r,"bindMatrix"),R.setOptional(Lt,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(Lt,"boneTexture",t.boneTexture,rt))}r.isBatchedMesh&&(R.setOptional(Lt,r,"batchingTexture"),R.setValue(Lt,"batchingTexture",r._matricesTexture,rt),R.setOptional(Lt,r,"batchingIdTexture"),R.setValue(Lt,"batchingIdTexture",r._indirectTexture,rt),R.setOptional(Lt,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(Lt,"batchingColorTexture",r._colorsTexture,rt));const L=n.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||yt.update(r,n,S);(w||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,R.setValue(Lt,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);w&&(R.setValue(Lt,"toneMappingExposure",b.toneMappingExposure),v.needsLights&&(D=E,(I=P).ambientLightColor.needsUpdate=D,I.lightProbe.needsUpdate=D,I.directionalLights.needsUpdate=D,I.directionalLightShadows.needsUpdate=D,I.pointLights.needsUpdate=D,I.pointLightShadows.needsUpdate=D,I.spotLights.needsUpdate=D,I.spotLightShadows.needsUpdate=D,I.rectAreaLights.needsUpdate=D,I.hemisphereLights.needsUpdate=D),s&&!0===i.fog&&dt.refreshFogUniforms(P,s),dt.refreshMaterialUniforms(P,i,O,U,_.state.transmissionRenderTarget[t.id]),Ha.upload(Lt,$t(v),P,rt));var I,D;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Ha.upload(Lt,$t(v),P,rt),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&R.setValue(Lt,"center",r.center);if(R.setValue(Lt,"modelViewMatrix",r.modelViewMatrix),R.setValue(Lt,"normalMatrix",r.normalMatrix),R.setValue(Lt,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++){const n=t[e];Pt.update(n,S),Pt.bind(n,S)}}return S}(t,e,n,i,r);et.setMaterial(i,a);let l=n.index,h=1;if(!0===i.wireframe){if(l=lt.getWireframeAttribute(n),void 0===l)return;h=2}const c=n.drawRange,d=n.attributes.position;let u=c.start*h,p=(c.start+c.count)*h;null!==s&&(u=Math.max(u,s.start*h),p=Math.min(p,(s.start+s.count)*h)),null!==l?(u=Math.max(u,0),p=Math.min(p,l.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const f=p-u;if(f<0||f===1/0)return;let m;Rt.setup(r,i,o,n,l);let g=xt;if(null!==l&&(m=ot.get(l),g=bt,g.setIndex(m)),r.isMesh)!0===i.wireframe?(et.setLineWidth(i.wireframeLinewidth*Q()),g.setMode(Lt.LINES)):g.setMode(Lt.TRIANGLES);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),et.setLineWidth(t*Q()),r.isLineSegments?g.setMode(Lt.LINES):r.isLineLoop?g.setMode(Lt.LINE_LOOP):g.setMode(Lt.LINE_STRIP)}else r.isPoints?g.setMode(Lt.POINTS):r.isSprite&&g.setMode(Lt.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)g.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if($.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,n=r._multiDrawCount,s=l?ot.get(l).bytesPerElement:1,a=it.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)a.setValue(Lt,"_gl_DrawID",i),g.render(t[i]/s,e[i])}else if(r.isInstancedMesh)g.renderInstances(u,f,r.count);else if(n.isInstancedBufferGeometry){const t=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,e=Math.min(n.instanceCount,t);g.renderInstances(u,f,e)}else g.render(u,f)},this.compile=function(t,e,n=null){null===n&&(n=t),_=pt.get(n),_.init(e),S.push(_),n.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(_.pushLight(t),t.castShadow&&_.pushShadow(t))})),t!==n&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(_.pushLight(t),t.castShadow&&_.pushShadow(t))})),_.setupLights();const i=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 r=0;r<e.length;r++){const s=e[r];Ht(s,n,t),i.add(s)}else Ht(e,n,t),i.add(e)})),S.pop(),_=null,i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise((e=>{function n(){i.forEach((function(t){it.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==$.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Vt=null;function Wt(){jt.stop()}function Xt(){jt.start()}const jt=new Jr;function Yt(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)_.pushLight(t),t.castShadow&&_.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||H.intersectsSprite(t)){i&&q.setFromMatrixPosition(t.matrixWorld).applyMatrix4(j);const e=ht.update(t),r=t.material;r.visible&&g.push(t,e,r,n,q.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||H.intersectsObject(t))){const e=ht.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)),q.applyMatrix4(t.matrixWorld).applyMatrix4(j)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s<a;s++){const a=i[s],o=r[a.materialIndex];o&&o.visible&&g.push(t,e,o,n,q.z,a)}}else r.visible&&g.push(t,e,r,n,q.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)Yt(r[t],e,n,i)}function qt(t,e,n,i){const r=t.opaque,s=t.transmissive,a=t.transparent;_.setupLightsView(n),!0===V&&ft.setGlobalState(b.clippingPlanes,n),i&&et.viewport(R.copy(i)),r.length>0&&Zt(r,e,n),s.length>0&&Zt(s,e,n),a.length>0&&Zt(a,e,n),et.buffers.depth.setTest(!0),et.buffers.depth.setMask(!0),et.buffers.color.setMask(!0),et.setPolygonOffset(!1)}function Kt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===_.state.transmissionRenderTarget[i.id]&&(_.state.transmissionRenderTarget[i.id]=new En(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?Et:vt,minFilter:_t,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ln.workingColorSpace}));const s=_.state.transmissionRenderTarget[i.id],a=i.viewport||R;s.setSize(a.z,a.w);const o=b.getRenderTarget();b.setRenderTarget(s),b.getClearColor(I),D=b.getClearAlpha(),D<1&&b.setClearColor(16777215,.5),b.clear(),Z&>.render(n);const l=b.toneMapping;b.toneMapping=J;const h=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),_.setupLightsView(i),!0===V&&ft.setGlobalState(b.clippingPlanes,i),Zt(t,n,i),rt.updateMultisampleRenderTarget(s),rt.updateRenderTargetMipmap(s),!1===$.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,l=s.material,h=s.group;if(2===l.side&&a.layers.test(i.layers)){const e=l.side;l.side=x,l.needsUpdate=!0,Jt(a,n,i,o,l,h),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(rt.updateMultisampleRenderTarget(s),rt.updateRenderTargetMipmap(s))}b.setRenderTarget(o),b.setClearColor(I,D),void 0!==h&&(i.viewport=h),b.toneMapping=l}function Zt(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=s.object,o=s.geometry,l=null===i?s.material:i,h=s.group;a.layers.test(n.layers)&&Jt(a,e,n,o,l,h)}}function Jt(t,e,n,i,r,s){t.onBeforeRender(b,e,n,i,r,s),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(b,e,n,i,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=x,r.needsUpdate=!0,b.renderBufferDirect(n,e,i,r,t,s),r.side=y,r.needsUpdate=!0,b.renderBufferDirect(n,e,i,r,t,s),r.side=2):b.renderBufferDirect(n,e,i,r,t,s),t.onAfterRender(b,e,n,i,r,s)}function Qt(t,e,n){!0!==e.isScene&&(e=K);const i=it.get(t),r=_.state.lights,s=_.state.shadowsArray,a=r.state.version,o=ct.getParameters(t,r.state,s,e,n),l=ct.getProgramCacheKey(o);let h=i.programs;i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=(t.isMeshStandardMaterial?at:st).get(t.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===h&&(t.addEventListener("dispose",Bt),h=new Map,i.programs=h);let c=h.get(l);if(void 0!==c){if(i.currentProgram===c&&i.lightsStateVersion===a)return te(t,o),c}else o.uniforms=ct.getUniforms(t),t.onBeforeCompile(o,b),c=ct.acquireProgram(o,l),h.set(l,c),i.uniforms=o.uniforms;const d=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=ft.uniform),te(t,o),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=a,i.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=c,i.uniformsList=null,c}function $t(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Ha.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function te(t,e){const n=it.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.batchingColor=e.batchingColor,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.instancingMorph=e.instancingMorph,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}jt.setAnimationLoop((function(t){Vt&&Vt(t)})),"undefined"!=typeof self&&jt.setContext(self),this.setAnimationLoop=function(t){Vt=t,Nt.setAnimationLoop(t),null===t?jt.stop():jt.start()},Nt.addEventListener("sessionstart",Wt),Nt.addEventListener("sessionend",Xt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===M)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Nt.enabled&&!0===Nt.isPresenting&&(!0===Nt.cameraAutoUpdate&&Nt.updateCamera(e),e=Nt.getCamera()),!0===t.isScene&&t.onBeforeRender(b,t,e,T),_=pt.get(t,S.length),_.init(e),S.push(_),j.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),H.setFromProjectionMatrix(j),W=this.localClippingEnabled,V=ft.init(this.clippingPlanes,W),g=ut.get(t,v.length),g.init(),v.push(g),!0===Nt.enabled&&!0===Nt.isPresenting){const t=b.xr.getDepthSensingMesh();null!==t&&Yt(t,e,-1/0,b.sortObjects)}Yt(t,e,0,b.sortObjects),g.finish(),!0===b.sortObjects&&g.sort(F,k),Z=!1===Nt.enabled||!1===Nt.isPresenting||!1===Nt.hasDepthSensing(),Z&>.addToRenderList(g,t),this.info.render.frame++,!0===V&&ft.beginShadows();const n=_.state.shadowsArray;mt.render(n,t,e),!0===V&&ft.endShadows(),!0===this.info.autoReset&&this.info.reset();const i=g.opaque,r=g.transmissive;if(_.setupLights(),e.isArrayCamera){const n=e.cameras;if(r.length>0)for(let e=0,s=n.length;e<s;e++){Kt(i,r,t,n[e])}Z&>.render(t);for(let e=0,i=n.length;e<i;e++){const i=n[e];qt(g,t,i,i.viewport)}}else r.length>0&&Kt(i,r,t,e),Z&>.render(t),qt(g,t,e);null!==T&&(rt.updateMultisampleRenderTarget(T),rt.updateRenderTargetMipmap(T)),!0===t.isScene&&t.onAfterRender(b,t,e),Rt.resetDefaultState(),A=-1,C=null,S.pop(),S.length>0?(_=S[S.length-1],!0===V&&ft.setGlobalState(b.clippingPlanes,_.state.camera)):_=null,v.pop(),g=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(t,e,n){it.get(t.texture).__webglTexture=e,it.get(t.depthTexture).__webglTexture=n;const i=it.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===$.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=it.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){T=t,w=e,E=n;let i=!0,r=null,s=!1,a=!1;if(t){const o=it.get(t);if(void 0!==o.__useDefaultFramebuffer)et.bindFramebuffer(Lt.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)rt.setupRenderTarget(t);else if(o.__hasExternalTextures)rt.rebindTextures(t,it.get(t.texture).__webglTexture,it.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&it.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 l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const h=it.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(h[e])?h[e][n]:h[e],s=!0):r=t.samples>0&&!1===rt.useMultisampledRTT(t)?it.get(t).__webglMultisampledFramebuffer:Array.isArray(h)?h[n]:h,R.copy(t.viewport),P.copy(t.scissor),L=t.scissorTest}else R.copy(B).multiplyScalar(O).floor(),P.copy(z).multiplyScalar(O).floor(),L=G;if(et.bindFramebuffer(Lt.FRAMEBUFFER,r)&&i&&et.drawBuffers(t,r),et.viewport(R),et.scissor(P),et.setScissorTest(L),s){const i=it.get(t.texture);Lt.framebufferTexture2D(Lt.FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,Lt.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=it.get(t.texture),r=e||0;Lt.framebufferTextureLayer(Lt.FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}A=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){et.bindFramebuffer(Lt.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(!tt.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Lt.readPixels(e,n,i,r,wt.convert(o),wt.convert(l),s)}finally{const t=null!==T?it.get(T).__webglFramebuffer:null;et.bindFramebuffer(Lt.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,l=a.format,h=a.type;if(!tt.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){et.bindFramebuffer(Lt.FRAMEBUFFER,o);const t=Lt.createBuffer();Lt.bindBuffer(Lt.PIXEL_PACK_BUFFER,t),Lt.bufferData(Lt.PIXEL_PACK_BUFFER,s.byteLength,Lt.STREAM_READ),Lt.readPixels(e,n,i,r,wt.convert(l),wt.convert(h),0);const a=null!==T?it.get(T).__webglFramebuffer:null;et.bindFramebuffer(Lt.FRAMEBUFFER,a);const c=Lt.fenceSync(Lt.SYNC_GPU_COMMANDS_COMPLETE,0);return Lt.flush(),await function(t,e,n){return new Promise((function(i,r){setTimeout((function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}),n)}))}(Lt,c,4),Lt.bindBuffer(Lt.PIXEL_PACK_BUFFER,t),Lt.getBufferSubData(Lt.PIXEL_PACK_BUFFER,0,s),Lt.deleteBuffer(t),Lt.deleteSync(c),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(on("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;rt.setTexture2D(t,0),Lt.copyTexSubImage2D(Lt.TEXTURE_2D,n,0,0,a,o,r,s),et.unbindTexture()},this.copyTextureToTexture=function(t,e,n=null,i=null,r=0){let s,a,o,l,h,c,d,u,p;!0!==t.isTexture&&(on("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],r=arguments[3]||0,n=null);const f=t.isCompressedTexture?t.mipmaps[r]:t.image;null!==n?(s=n.max.x-n.min.x,a=n.max.y-n.min.y,o=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,h=n.min.y,c=n.isBox3?n.min.z:0):(s=f.width,a=f.height,o=f.depth||1,l=0,h=0,c=0),null!==i?(d=i.x,u=i.y,p=i.z):(d=0,u=0,p=0);const m=wt.convert(e.format),g=wt.convert(e.type);let _;e.isData3DTexture?(rt.setTexture3D(e,0),_=Lt.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(rt.setTexture2DArray(e,0),_=Lt.TEXTURE_2D_ARRAY):(rt.setTexture2D(e,0),_=Lt.TEXTURE_2D),Lt.pixelStorei(Lt.UNPACK_FLIP_Y_WEBGL,e.flipY),Lt.pixelStorei(Lt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Lt.pixelStorei(Lt.UNPACK_ALIGNMENT,e.unpackAlignment);const v=Lt.getParameter(Lt.UNPACK_ROW_LENGTH),y=Lt.getParameter(Lt.UNPACK_IMAGE_HEIGHT),x=Lt.getParameter(Lt.UNPACK_SKIP_PIXELS),S=Lt.getParameter(Lt.UNPACK_SKIP_ROWS),b=Lt.getParameter(Lt.UNPACK_SKIP_IMAGES);Lt.pixelStorei(Lt.UNPACK_ROW_LENGTH,f.width),Lt.pixelStorei(Lt.UNPACK_IMAGE_HEIGHT,f.height),Lt.pixelStorei(Lt.UNPACK_SKIP_PIXELS,l),Lt.pixelStorei(Lt.UNPACK_SKIP_ROWS,h),Lt.pixelStorei(Lt.UNPACK_SKIP_IMAGES,c);const M=t.isDataArrayTexture||t.isData3DTexture,w=e.isDataArrayTexture||e.isData3DTexture;if(t.isRenderTargetTexture||t.isDepthTexture){const n=it.get(t),i=it.get(e),f=it.get(n.__renderTarget),m=it.get(i.__renderTarget);et.bindFramebuffer(Lt.READ_FRAMEBUFFER,f.__webglFramebuffer),et.bindFramebuffer(Lt.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let n=0;n<o;n++)M&&Lt.framebufferTextureLayer(Lt.READ_FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,it.get(t).__webglTexture,r,c+n),t.isDepthTexture?(w&&Lt.framebufferTextureLayer(Lt.DRAW_FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,it.get(e).__webglTexture,r,p+n),Lt.blitFramebuffer(l,h,s,a,d,u,s,a,Lt.DEPTH_BUFFER_BIT,Lt.NEAREST)):w?Lt.copyTexSubImage3D(_,r,d,u,p+n,l,h,s,a):Lt.copyTexSubImage2D(_,r,d,u,p+n,l,h,s,a);et.bindFramebuffer(Lt.READ_FRAMEBUFFER,null),et.bindFramebuffer(Lt.DRAW_FRAMEBUFFER,null)}else w?t.isDataTexture||t.isData3DTexture?Lt.texSubImage3D(_,r,d,u,p,s,a,o,m,g,f.data):e.isCompressedArrayTexture?Lt.compressedTexSubImage3D(_,r,d,u,p,s,a,o,m,f.data):Lt.texSubImage3D(_,r,d,u,p,s,a,o,m,g,f):t.isDataTexture?Lt.texSubImage2D(Lt.TEXTURE_2D,r,d,u,s,a,m,g,f.data):t.isCompressedTexture?Lt.compressedTexSubImage2D(Lt.TEXTURE_2D,r,d,u,f.width,f.height,m,f.data):Lt.texSubImage2D(Lt.TEXTURE_2D,r,d,u,s,a,m,g,f);Lt.pixelStorei(Lt.UNPACK_ROW_LENGTH,v),Lt.pixelStorei(Lt.UNPACK_IMAGE_HEIGHT,y),Lt.pixelStorei(Lt.UNPACK_SKIP_PIXELS,x),Lt.pixelStorei(Lt.UNPACK_SKIP_ROWS,S),Lt.pixelStorei(Lt.UNPACK_SKIP_IMAGES,b),0===r&&e.generateMipmaps&&Lt.generateMipmap(_),et.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n=null,i=null,r=0){return!0!==t.isTexture&&(on("WebGLRenderer: copyTextureToTexture3D function signature has changed."),n=arguments[0]||null,i=arguments[1]||null,t=arguments[2],e=arguments[3],r=arguments[4]||0),on('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(t,e,n,i,r)},this.initRenderTarget=function(t){void 0===it.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),et.unbindTexture()},this.resetState=function(){w=0,E=0,T=null,et.reset(),Rt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Be}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=ln._getDrawingBufferColorSpace(t),e.unpackColorSpace=ln._getUnpackColorSpace()}}class Xo extends Ii{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new mi,this.environmentIntensity=1,this.environmentRotation=new mi,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class jo{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Fe,this.updateRanges=[],this.version=0,this.uuid=je()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=je()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=je()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Yo=new Rn;class qo{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Yo.fromBufferAttribute(this,e),Yo.applyMatrix4(t),this.setXYZ(e,Yo.x,Yo.y,Yo.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Yo.fromBufferAttribute(this,e),Yo.applyNormalMatrix(t),this.setXYZ(e,Yo.x,Yo.y,Yo.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Yo.fromBufferAttribute(this,e),Yo.transformDirection(t),this.setXYZ(e,Yo.x,Yo.y,Yo.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Ze(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Je(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Je(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Je(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Je(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Je(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ze(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ze(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ze(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ze(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Je(e,this.array),n=Je(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Je(e,this.array),n=Je(n,this.array),i=Je(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Je(e,this.array),n=Je(n,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new rr(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new qo(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ko extends tr{static get type(){return"SpriteMaterial"}constructor(t){super(),this.isSpriteMaterial=!0,this.color=new Ji(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let Zo;const Jo=new Rn,Qo=new Rn,$o=new Rn,tl=new $e,el=new $e,nl=new si,il=new Rn,rl=new Rn,sl=new Rn,al=new $e,ol=new $e,ll=new $e;let hl=class extends Ii{constructor(t=new Ko){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Zo){Zo=new mr;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new jo(t,5);Zo.setIndex([0,1,2,0,2,3]),Zo.setAttribute("position",new qo(e,3,0,!1)),Zo.setAttribute("uv",new qo(e,2,3,!1))}this.geometry=Zo,this.material=t,this.center=new $e(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Qo.setFromMatrixScale(this.matrixWorld),nl.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),$o.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Qo.multiplyScalar(-$o.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;cl(il.set(-.5,-.5,0),$o,s,Qo,i,r),cl(rl.set(.5,-.5,0),$o,s,Qo,i,r),cl(sl.set(.5,.5,0),$o,s,Qo,i,r),al.set(0,0),ol.set(1,0),ll.set(1,1);let a=t.ray.intersectTriangle(il,rl,sl,!1,Jo);if(null===a&&(cl(rl.set(-.5,.5,0),$o,s,Qo,i,r),ol.set(0,1),a=t.ray.intersectTriangle(il,sl,rl,!1,Jo),null===a))return;const o=t.ray.origin.distanceTo(Jo);o<t.near||o>t.far||e.push({distance:o,point:Jo.clone(),uv:ji.getInterpolation(Jo,il,rl,sl,al,ol,ll,new $e),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}};function cl(t,e,n,i,r,s){tl.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(el.x=s*tl.x-r*tl.y,el.y=r*tl.x+s*tl.y):el.copy(tl),t.copy(e),t.x+=el.x,t.y+=el.y,t.applyMatrix4(nl)}const dl=new Rn,ul=new Mn,pl=new Mn,fl=new Rn,ml=new si,gl=new Rn,_l=new Zn,vl=new si,yl=new ri;class xl extends Ar{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=st,this.bindMatrix=new si,this.bindMatrixInverse=new si,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new In),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,gl),this.boundingBox.expandByPoint(gl)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Zn),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,gl),this.boundingSphere.expandByPoint(gl)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),_l.copy(this.boundingSphere),_l.applyMatrix4(i),!1!==t.ray.intersectsSphere(_l)&&(vl.copy(i).invert(),yl.copy(t.ray).applyMatrix4(vl),null!==this.boundingBox&&!1===yl.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,yl)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Mn,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===st?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;ul.fromBufferAttribute(i.attributes.skinIndex,t),pl.fromBufferAttribute(i.attributes.skinWeight,t),dl.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=pl.getComponent(t);if(0!==i){const r=ul.getComponent(t);ml.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(fl.copy(dl).applyMatrix4(ml),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}class Sl extends Ii{constructor(){super(),this.isBone=!0,this.type="Bone"}}class bl extends bn{constructor(t=null,e=1,n=1,i,r,s,a,o,l=1003,h=1003,c,d){super(null,s,a,o,l,h,i,r,c,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ml=new si,wl=new si;class El{constructor(t=[],e=[]){this.uuid=je(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new si)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new si;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){const r=t[i]?t[i].matrixWorld:wl;Ml.multiplyMatrices(r,e[i]),Ml.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new El(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new bl(e,t,t,It,wt);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let r=e[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new Sl),this.bones.push(r),this.boneInverses.push((new si).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const s=n[i];t.boneInverses.push(s.toArray())}return t}}class Tl extends rr{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Al=new si,Cl=new si,Rl=[],Pl=new In,Ll=new si,Il=new Ar,Dl=new Zn;class Nl extends Ar{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Tl(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,Ll)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new In),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Al),Pl.copy(t.boundingBox).applyMatrix4(Al),this.boundingBox.union(Pl)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new Zn),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Al),Dl.copy(t.boundingSphere).applyMatrix4(Al),this.boundingSphere.union(Dl)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(n.length+1)+1;for(let t=0;t<n.length;t++)n[t]=i[r+t]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Il.geometry=this.geometry,Il.material=this.material,void 0!==Il.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Dl.copy(this.boundingSphere),Dl.applyMatrix4(n),!1!==t.ray.intersectsSphere(Dl)))for(let r=0;r<i;r++){this.getMatrixAt(r,Al),Cl.multiplyMatrices(n,Al),Il.matrixWorld=Cl,Il.raycast(t,Rl);for(let t=0,n=Rl.length;t<n;t++){const n=Rl[t];n.instanceId=r,n.object=this,e.push(n)}Rl.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Tl(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new bl(new Float32Array(i*this.count),i,this.count,Ft,wt));const r=this.morphTexture.source.data.data;let s=0;for(let t=0;t<n.length;t++)s+=n[t];const a=this.geometry.morphTargetsRelative?1:1-s,o=i*t;r[o]=a,r.set(n,o+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class Ul extends tr{static get type(){return"LineBasicMaterial"}constructor(t){super(),this.isLineBasicMaterial=!0,this.color=new Ji(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Ol=new Rn,Fl=new Rn,kl=new si,Bl=new ri,zl=new Zn,Gl=new Rn,Hl=new Rn;let Vl=class extends Ii{constructor(t=new mr,e=new Ul){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)Ol.fromBufferAttribute(e,t-1),Fl.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=Ol.distanceTo(Fl);t.setAttribute("lineDistance",new or(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),zl.copy(n.boundingSphere),zl.applyMatrix4(i),zl.radius+=r,!1===t.ray.intersectsSphere(zl))return;kl.copy(i).invert(),Bl.copy(t.ray).applyMatrix4(kl);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,h=n.index,c=n.attributes.position;if(null!==h){const n=Math.max(0,s.start),i=Math.min(h.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=h.getX(r),i=h.getX(r+1),s=Wl(this,t,Bl,o,n,i);s&&e.push(s)}if(this.isLineLoop){const r=h.getX(i-1),s=h.getX(n),a=Wl(this,t,Bl,o,r,s);a&&e.push(a)}}else{const n=Math.max(0,s.start),i=Math.min(c.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=Wl(this,t,Bl,o,r,r+1);n&&e.push(n)}if(this.isLineLoop){const r=Wl(this,t,Bl,o,i-1,n);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}};function Wl(t,e,n,i,r,s){const a=t.geometry.attributes.position;Ol.fromBufferAttribute(a,r),Fl.fromBufferAttribute(a,s);if(n.distanceSqToSegment(Ol,Fl,Gl,Hl)>i)return;Gl.applyMatrix4(t.matrixWorld);const o=e.ray.origin.distanceTo(Gl);return o<e.near||o>e.far?void 0:{distance:o,point:Hl.clone().applyMatrix4(t.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:t}}const Xl=new Rn,jl=new Rn;class Yl extends Vl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)Xl.fromBufferAttribute(e,t),jl.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Xl.distanceTo(jl);t.setAttribute("lineDistance",new or(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ql extends Vl{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Kl extends tr{static get type(){return"PointsMaterial"}constructor(t){super(),this.isPointsMaterial=!0,this.color=new Ji(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Zl=new si,Jl=new ri,Ql=new Zn,$l=new Rn;class th extends Ii{constructor(t=new mr,e=new Kl){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ql.copy(n.boundingSphere),Ql.applyMatrix4(i),Ql.radius+=r,!1===t.ray.intersectsSphere(Ql))return;Zl.copy(i).invert(),Jl.copy(t.ray).applyMatrix4(Zl);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,h=n.attributes.position;if(null!==l){for(let n=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);n<r;n++){const r=l.getX(n);$l.fromBufferAttribute(h,r),eh($l,r,o,i,t,e,this)}}else{for(let n=Math.max(0,s.start),r=Math.min(h.count,s.start+s.count);n<r;n++)$l.fromBufferAttribute(h,n),eh($l,n,o,i,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function eh(t,e,n,i,r,s,a){const o=Jl.distanceSqToPoint(t);if(o<n){const n=new Rn;Jl.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class nh extends bn{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ih extends mr{constructor(t=1,e=1,n=1,i=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],c=[],d=[],u=[];let p=0;const f=[],m=n/2;let g=0;function _(n){const r=p,s=new $e,f=new Rn;let _=0;const v=!0===n?t:e,y=!0===n?1:-1;for(let t=1;t<=i;t++)c.push(0,m*y,0),d.push(0,y,0),u.push(.5,.5),p++;const x=p;for(let t=0;t<=i;t++){const e=t/i*o+a,n=Math.cos(e),r=Math.sin(e);f.x=v*r,f.y=m*y,f.z=v*n,c.push(f.x,f.y,f.z),d.push(0,y,0),s.x=.5*n+.5,s.y=.5*r*y+.5,u.push(s.x,s.y),p++}for(let t=0;t<i;t++){const e=r+t,i=x+t;!0===n?h.push(i,i+1,e):h.push(i+1,i,e),_+=3}l.addGroup(g,_,!0===n?1:2),g+=_}!function(){const s=new Rn,_=new Rn;let v=0;const y=(e-t)/n;for(let l=0;l<=r;l++){const h=[],g=l/r,v=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*o+a,l=Math.sin(r),f=Math.cos(r);_.x=v*l,_.y=-g*n+m,_.z=v*f,c.push(_.x,_.y,_.z),s.set(l,y,f).normalize(),d.push(s.x,s.y,s.z),u.push(e,1-g),h.push(p++)}f.push(h)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const s=f[i][n],a=f[i+1][n],o=f[i+1][n+1],l=f[i][n+1];(t>0||0!==i)&&(h.push(s,a,l),v+=3),(e>0||i!==r-1)&&(h.push(a,o,l),v+=3)}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&_(!0),e>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new or(c,3)),this.setAttribute("normal",new or(d,3)),this.setAttribute("uv",new or(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ih(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class rh extends mr{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)s[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/l)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const n=Math.floor(e/2);e%2==0?(o(s[t][n+1]),o(s[t+1][n]),o(s[t][n])):(o(s[t][n+1]),o(s[t+1][n+1]),o(s[t+1][n]))}}function o(t){r.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function h(t,e,n,i){i<0&&1===t.x&&(s[e]=t.x-1),0===n.x&&0===n.z&&(s[e]=i/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}!function(t){const n=new Rn,i=new Rn,r=new Rn;for(let s=0;s<e.length;s+=3)l(e[s+0],n),l(e[s+1],i),l(e[s+2],r),a(n,i,r,t)}(i),function(t){const e=new Rn;for(let n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){const t=new Rn;for(let n=0;n<r.length;n+=3){t.x=r[n+0],t.y=r[n+1],t.z=r[n+2];const i=c(t)/2/Math.PI+.5,a=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);s.push(i,1-a)}var e;(function(){const t=new Rn,e=new Rn,n=new Rn,i=new Rn,a=new $e,o=new $e,l=new $e;for(let d=0,u=0;d<r.length;d+=9,u+=6){t.set(r[d+0],r[d+1],r[d+2]),e.set(r[d+3],r[d+4],r[d+5]),n.set(r[d+6],r[d+7],r[d+8]),a.set(s[u+0],s[u+1]),o.set(s[u+2],s[u+3]),l.set(s[u+4],s[u+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=c(i);h(a,u+0,t,p),h(o,u+2,e,p),h(l,u+4,n,p)}})(),function(){for(let t=0;t<s.length;t+=6){const e=s[t+0],n=s[t+2],i=s[t+4],r=Math.max(e,n,i),a=Math.min(e,n,i);r>.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new or(r,3)),this.setAttribute("normal",new or(r.slice(),3)),this.setAttribute("uv",new or(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new rh(t.vertices,t.indices,t.radius,t.details)}}class sh extends rh{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new sh(t.radius,t.detail)}}class ah extends mr{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const o=Math.min(s+a,Math.PI);let l=0;const h=[],c=new Rn,d=new Rn,u=[],p=[],f=[],m=[];for(let u=0;u<=n;u++){const g=[],_=u/n;let v=0;0===u&&0===s?v=.5/e:u===n&&o===Math.PI&&(v=-.5/e);for(let n=0;n<=e;n++){const o=n/e;c.x=-t*Math.cos(i+o*r)*Math.sin(s+_*a),c.y=t*Math.cos(s+_*a),c.z=t*Math.sin(i+o*r)*Math.sin(s+_*a),p.push(c.x,c.y,c.z),d.copy(c).normalize(),f.push(d.x,d.y,d.z),m.push(o+v,1-_),g.push(l++)}h.push(g)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=h[t][i+1],r=h[t][i],a=h[t+1][i],l=h[t+1][i+1];(0!==t||s>0)&&u.push(e,r,l),(t!==n-1||o<Math.PI)&&u.push(r,a,l)}this.setIndex(u),this.setAttribute("position",new or(p,3)),this.setAttribute("normal",new or(f,3)),this.setAttribute("uv",new or(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ah(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class oh extends mr{constructor(t=1,e=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const s=[],a=[],o=[],l=[],h=new Rn,c=new Rn,d=new Rn;for(let s=0;s<=n;s++)for(let u=0;u<=i;u++){const p=u/i*r,f=s/n*Math.PI*2;c.x=(t+e*Math.cos(f))*Math.cos(p),c.y=(t+e*Math.cos(f))*Math.sin(p),c.z=e*Math.sin(f),a.push(c.x,c.y,c.z),h.x=t*Math.cos(p),h.y=t*Math.sin(p),d.subVectors(c,h).normalize(),o.push(d.x,d.y,d.z),l.push(u/i),l.push(s/n)}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+e-1,r=(i+1)*(t-1)+e-1,a=(i+1)*(t-1)+e,o=(i+1)*t+e;s.push(n,r,o),s.push(r,a,o)}this.setIndex(s),this.setAttribute("position",new or(a,3)),this.setAttribute("normal",new or(o,3)),this.setAttribute("uv",new or(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new oh(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class lh extends tr{static get type(){return"MeshStandardMaterial"}constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.color=new Ji(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ji(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new $e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class hh extends lh{static get type(){return"MeshPhysicalMaterial"}constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new $e(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ye(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ji(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ji(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ji(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}function ch(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function dh(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function uh(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function ph(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push.apply(n,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}class fh{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let s;n:{i:if(!(t<i)){for(let s=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(r=i,i=e[++n],t<i)break e}s=e.length;break n}if(t>=r)break t;{const a=e[1];t<a&&(n=2,r=a);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(i=r,r=e[--n-1],t>=r)break e}s=n,n=0}}for(;n<s;){const i=n+s>>>1;t<e[i]?s=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class mh extends fh{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,s=t+1,a=i[r],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case 2401:r=t,a=2*e-n;break;case 2402:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case 2401:s=t,o=2*n-e;break;case 2402:s=1,o=n+i[1]-i[0];break;default:s=t-1,o=e}const l=.5*(n-e),h=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=r*h,this._offsetNext=s*h}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=this._offsetPrev,c=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(n-e)/(i-e),f=p*p,m=f*p,g=-d*m+2*d*f-d*p,_=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,v=(-1-u)*m+(1.5+u)*f+.5*p,y=u*m-u*f;for(let t=0;t!==a;++t)r[t]=g*s[h+t]+_*s[l+t]+v*s[o+t]+y*s[c+t];return r}}class gh extends fh{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=(n-e)/(i-e),c=1-h;for(let t=0;t!==a;++t)r[t]=s[l+t]*c+s[o+t]*h;return r}}class _h extends fh{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class vh{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ch(e,this.TimeBufferType),this.values=ch(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ch(t.times,Array),values:ch(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new _h(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new gh(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new mh(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case xe:e=this.InterpolantFactoryMethodDiscrete;break;case Se:e=this.InterpolantFactoryMethodLinear;break;case be:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return xe;case this.InterpolantFactoryMethodLinear:return Se;case this.InterpolantFactoryMethodSmooth:return be}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,s=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==s&&n[s]>e;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&(a=i,ArrayBuffer.isView(a)&&!(a instanceof DataView)))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}var a;return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===be,r=t.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(i)r=!0;else{const t=a*n,i=t-n,s=t+n;for(let a=0;a!==n;++a){const n=e[t+a];if(n!==e[i+a]||n!==e[s+a]){r=!0;break}}}if(r){if(a!==s){t[s]=t[a];const i=a*n,r=s*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}vh.prototype.TimeBufferType=Float32Array,vh.prototype.ValueBufferType=Float32Array,vh.prototype.DefaultInterpolation=Se;class yh extends vh{constructor(t,e,n){super(t,e,n)}}yh.prototype.ValueTypeName="bool",yh.prototype.ValueBufferType=Array,yh.prototype.DefaultInterpolation=xe,yh.prototype.InterpolantFactoryMethodLinear=void 0,yh.prototype.InterpolantFactoryMethodSmooth=void 0;class xh extends vh{}xh.prototype.ValueTypeName="color";class Sh extends vh{}Sh.prototype.ValueTypeName="number";class bh extends fh{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)Cn.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Mh extends vh{InterpolantFactoryMethodLinear(t){return new bh(this.times,this.values,this.getValueSize(),t)}}Mh.prototype.ValueTypeName="quaternion",Mh.prototype.InterpolantFactoryMethodSmooth=void 0;class wh extends vh{constructor(t,e,n){super(t,e,n)}}wh.prototype.ValueTypeName="string",wh.prototype.ValueBufferType=Array,wh.prototype.DefaultInterpolation=xe,wh.prototype.InterpolantFactoryMethodLinear=void 0,wh.prototype.InterpolantFactoryMethodSmooth=void 0;class Eh extends vh{}Eh.prototype.ValueTypeName="vector";class Th{constructor(t="",e=-1,n=[],i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=je(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(Ah(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(vh.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t<r;t++){let a=[],o=[];a.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const l=dh(a);a=uh(a,1,l),o=uh(o,1,l),i||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new Sh(".morphTargetInfluences["+e[t].name+"]",a,o).scale(1/n))}return new this(t,-1,s)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.name.match(r);if(s&&s.length>1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];ph(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(const n in t){const t=[],s=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),s.push(i.morphTarget===n?1:0)}i.push(new Sh(".morphTargetInfluence["+n+"]",t,s))}o=t.length*s}else{const s=".bones["+e[t].name+"]";n(Eh,s+".position",r,"pos",i),n(Mh,s+".quaternion",r,"rot",i),n(Eh,s+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,o,i,a)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Ah(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Sh;case"vector":case"vector2":case"vector3":case"vector4":return Eh;case"color":return xh;case"quaternion":return Mh;case"bool":case"boolean":return yh;case"string":return wh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];ph(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const Ch={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class Rh{constructor(t,e,n){const i=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===s&&void 0!==i.onStart&&i.onStart(t,a,o),s=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(s=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}}}const Ph=new Rh;class Lh{constructor(t){this.manager=void 0!==t?t:Ph,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Lh.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ih={};class Dh extends Error{constructor(t,e){super(t),this.response=e}}class Nh extends Lh{constructor(t){super(t)}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Ch.get(t);if(void 0!==r)return this.manager.itemStart(t),setTimeout((()=>{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==Ih[t])return void Ih[t].push({onLoad:e,onProgress:n,onError:i});Ih[t]=[],Ih[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=Ih[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}}),(e=>{t.error(e)}))}()}});return new Response(l)}throw new Dh(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{Ch.add(t,e);const n=Ih[t];delete Ih[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}})).catch((e=>{const n=Ih[t];if(void 0===n)throw this.manager.itemError(t),e;delete Ih[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)})).finally((()=>{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Uh extends Lh{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Ch.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const a=rn("img");function o(){h(),Ch.add(t,this),e&&e(this),r.manager.itemEnd(t)}function l(e){h(),i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(t),a.src=t,a}}class Oh extends Lh{constructor(t){super(t)}load(t,e,n,i){const r=new bn,s=new Uh(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)}),n,i),r}}class Fh extends Ii{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ji(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(e.object.target=this.target.uuid),e}}const kh=new si,Bh=new Rn,zh=new Rn;class Gh{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new $e(512,512),this.map=null,this.mapPass=null,this.matrix=new si,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zr,this._frameExtents=new $e(1,1),this._viewportCount=1,this._viewports=[new Mn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Bh.setFromMatrixPosition(t.matrixWorld),e.position.copy(Bh),zh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(zh),e.updateMatrixWorld(),kh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kh),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(kh)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class Hh extends Gh{constructor(){super(new Br(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=2*Xe*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Vh extends Fh{constructor(t,e,n=0,i=Math.PI/3,r=0,s=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ii.DEFAULT_UP),this.updateMatrix(),this.target=new Ii,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Hh}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Wh=new si,Xh=new Rn,jh=new Rn;class Yh extends Gh{constructor(){super(new Br(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new $e(4,2),this._viewportCount=6,this._viewports=[new Mn(2,1,1,1),new Mn(0,1,1,1),new Mn(3,1,1,1),new Mn(1,1,1,1),new Mn(3,0,1,1),new Mn(1,0,1,1)],this._cubeDirections=[new Rn(1,0,0),new Rn(-1,0,0),new Rn(0,0,1),new Rn(0,0,-1),new Rn(0,1,0),new Rn(0,-1,0)],this._cubeUps=[new Rn(0,1,0),new Rn(0,1,0),new Rn(0,1,0),new Rn(0,1,0),new Rn(0,0,1),new Rn(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Xh.setFromMatrixPosition(t.matrixWorld),n.position.copy(Xh),jh.copy(n.position),jh.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(jh),n.updateMatrixWorld(),i.makeTranslation(-Xh.x,-Xh.y,-Xh.z),Wh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Wh)}}class qh extends Fh{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Yh}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Kh extends Gh{constructor(){super(new us(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Zh extends Fh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ii.DEFAULT_UP),this.updateMatrix(),this.target=new Ii,this.shadow=new Kh}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Jh extends Fh{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Qh{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class $h extends Lh{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Ch.get(t);if(void 0!==s)return r.manager.itemStart(t),s.then?void s.then((n=>{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return Ch.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),Ch.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));Ch.add(t,o),r.manager.itemStart(t)}}class tc{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ec(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=ec();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function ec(){return performance.now()}const nc="\\[\\]\\.:\\/",ic=new RegExp("["+nc+"]","g"),rc="[^"+nc+"]",sc="[^"+nc.replace("\\.","")+"]",ac=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",rc)+/(WCOD+)?/.source.replace("WCOD",sc)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",rc)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",rc)+"$"),oc=["material","materials","bones","map"];class lc{constructor(t,e,n){this.path=e,this.parsedPath=n||lc.parseTrackName(e),this.node=lc.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new lc.Composite(t,e,n):new lc(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ic,"")}static parseTrackName(t){const e=ac.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==oc.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const s=n(r.children);if(s)return s}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=lc.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const s=t[i];if(void 0===s){const n=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}lc.Composite=class{constructor(t,e,n){const i=n||lc.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},lc.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},lc.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},lc.prototype.GetterByBindingType=[lc.prototype._getValue_direct,lc.prototype._getValue_array,lc.prototype._getValue_arrayElement,lc.prototype._getValue_toArray],lc.prototype.SetterByBindingTypeAndVersioning=[[lc.prototype._setValue_direct,lc.prototype._setValue_direct_setNeedsUpdate,lc.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[lc.prototype._setValue_array,lc.prototype._setValue_array_setNeedsUpdate,lc.prototype._setValue_array_setMatrixWorldNeedsUpdate],[lc.prototype._setValue_arrayElement,lc.prototype._setValue_arrayElement_setNeedsUpdate,lc.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[lc.prototype._setValue_fromArray,lc.prototype._setValue_fromArray_setNeedsUpdate,lc.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const hc=new si;class cc{constructor(t,e,n=0,i=1/0){this.ray=new ri(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new gi,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return hc.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(hc),this}intersectObject(t,e=!0,n=[]){return uc(t,this,n,e),n.sort(dc),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)uc(t[i],this,n,e);return n.sort(dc),n}}function dc(t,e){return t.distance-e.distance}function uc(t,e,n,i){let r=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,n)&&(r=!1)}if(!0===r&&!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)uc(i[t],e,n,!0)}}class pc{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Ye(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class fc extends Ge{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:l}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=l);class mc{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 $e);if(0!==this.downPosition.distanceTo(e))return;const n=this.getPointerIntersects(e);this.clearSelection(),n.length>0&&this.select(n[0].object),this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.optionsChange=()=>{const{facesColor:t,facesTransparancy:e}=this.viewer.options;this.facesMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.facesMaterial.opacity=(255-e)/255,this.viewer.update()},this.viewer=t,this.raycaster=new cc,this.downPosition=new $e;const{facesColor:e,facesTransparancy:n}=this.viewer.options;this.facesMaterial=new er,this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-n)/255,this.facesMaterial.transparent=!0,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("optionschange",this.optionsChange)}dispose(){this.facesMaterial.dispose(),this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("optionschange",this.optionsChange)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t){const e=this.viewer.canvas.getBoundingClientRect(),n=(t.x-e.left)/e.width*2-1,i=-(t.y-e.top)/e.height*2+1,r=new $e(n,i);this.raycaster.setFromCamera(r,this.viewer.camera);const s=[];return this.viewer.scene.traverseVisible((t=>s.push(t))),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}},this.raycaster.intersectObjects(s,!1)}select(t){t.isSelected||(t.isSelected=!0,t.originalMaterial=t.material,t.material=this.facesMaterial,this.viewer.selected.push(t))}clearSelection(){this.viewer.selected.forEach((t=>{t.isSelected=!1,t.material=t.originalMaterial})),this.viewer.selected.length=0}}function gc(t,e){let n=e;return t.children.forEach((t=>{const i=gc(t,e+1);n<i&&(n=i)})),t.originalPosition=t.position.clone(),n}function _c(t,e=0){e/=100,t.maxDepth||(t.maxDepth=gc(t,1));const n=t.maxDepth;let i=e*(n-1)+1;1===n&&(i=1);!function t(n,r,s,a){const o=(new In).setFromObject(n).getCenter(new Rn),l=a.clone();if(r>0&&r<=i){const t=o.clone().sub(s).multiplyScalar(e);l.add(t)}n.children.forEach((e=>t(e,r+1,o,l)));const h=n.originalPosition;if(n.position.copy(h),e>0){const t=o.sub(s).normalize();n.position.add(t.add(l))}}(t,0,(new In).setFromObject(t).getCenter(new Rn),new Rn(0,0,0))}function vc(t,e=0){t.models.forEach((t=>_c(t.scene,e))),t.update(),t.emitEvent({type:"explode",data:e})}i("ThreeJS").registerCommand("clearSelected",(function(t){const e=new mc(t);e.clearSelection(),e.dispose(),t.update(),t.emitEvent({type:"select",data:void 0,handles:[]})})),i("ThreeJS").registerCommandAlias("clearSelected","unselect"),i("ThreeJS").registerCommand("clearSlices",(t=>t.clearSlices())),i("ThreeJS").registerCommand("createPreview",(function(t,e="image/jpeg",n=.25){return t.update(!0),t.canvas.toDataURL(e,n)})),i("ThreeJS").registerCommand("explode",vc),i("ThreeJS").registerCommand("collect",(t=>vc(t,0)));const yc={top:new Rn(0,0,1),bottom:new Rn(0,0,-1),left:new Rn(-1,0,0),right:new Rn(1,0,0),front:new Rn(0,-1,0),back:new Rn(0,1,0),sw:new Rn(-.5,-.5,1).normalize(),se:new Rn(.5,-.5,1).normalize(),ne:new Rn(.5,.5,1).normalize(),nw:new Rn(-.5,.5,1).normalize()};function xc(t,e){const n=yc[e]||yc.sw,i=t.extents.getCenter(new Rn),r=t.extents.getBoundingSphere(new Zn),s=n.clone().multiplyScalar(r.radius),a=t.camera;a.position.copy(i).add(s),a.lookAt(i),a.updateProjectionMatrix(),a.updateMatrixWorld(),t.target.copy(i),t.update(),t.emit({type:"viewposition",data:e}),t.executeCommand("zoomToExtents")}function Sc(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let n=t.getIndex();if(null===n){const e=[],i=t.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<i.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const i=n.count-2,r=[];if(2===e)for(let t=1;t<=i;t++)r.push(n.getX(0)),r.push(n.getX(t)),r.push(n.getX(t+1));else for(let t=0;t<i;t++)t%2==0?(r.push(n.getX(t)),r.push(n.getX(t+1)),r.push(n.getX(t+2))):(r.push(n.getX(t+2)),r.push(n.getX(t+1)),r.push(n.getX(t)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}i("ThreeJS").registerCommand("setDefaultViewPosition",xc),i("ThreeJS").registerCommand("top",(t=>xc(t,"top"))),i("ThreeJS").registerCommand("bottom",(t=>xc(t,"bottom"))),i("ThreeJS").registerCommand("left",(t=>xc(t,"left"))),i("ThreeJS").registerCommand("right",(t=>xc(t,"right"))),i("ThreeJS").registerCommand("front",(t=>xc(t,"front"))),i("ThreeJS").registerCommand("back",(t=>xc(t,"back"))),i("ThreeJS").registerCommand("sw",(t=>xc(t,"sw"))),i("ThreeJS").registerCommand("se",(t=>xc(t,"se"))),i("ThreeJS").registerCommand("ne",(t=>xc(t,"ne"))),i("ThreeJS").registerCommand("nw",(t=>xc(t,"nw"))),i("ThreeJS").registerCommandAlias("top","k3DViewTop"),i("ThreeJS").registerCommandAlias("bottom","k3DViewBottom"),i("ThreeJS").registerCommandAlias("left","k3DViewLeft"),i("ThreeJS").registerCommandAlias("right","k3DViewRight"),i("ThreeJS").registerCommandAlias("front","k3DViewFront"),i("ThreeJS").registerCommandAlias("back","k3DViewBack"),i("ThreeJS").registerCommandAlias("se","k3DViewSE"),i("ThreeJS").registerCommandAlias("sw","k3DViewSW"),i("ThreeJS").registerCommandAlias("ne","k3DViewNE"),i("ThreeJS").registerCommandAlias("nw","k3DViewNW"),i("ThreeJS").registerCommand("getDefaultViewPositions",(function(){return Object.keys(yc)})),i("ThreeJS").registerCommand("getModels",(function(t){return t.models.map((t=>t.userData.handle||"")).filter((t=>t))})),i("ThreeJS").registerCommand("getSelected",(function(t){return t.selected.map((t=>{var e;return null===(e=t.userData)||void 0===e?void 0:e.handle})).filter((t=>t))})),i("ThreeJS").registerCommand("hideSelected",(function(t){t.selected.forEach((t=>t.visible=!1));const e=new mc(t);e.clearSelection(),e.dispose(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",data:void 0,handles:[]})})),i("ThreeJS").registerCommand("isolateSelected",(function(t){const e=new Set(t.selected);!function t(n,i){let r=!0;return n.children.forEach((n=>{e.has(n)?r=!1:t(n,i+1)})),r&&i>0&&(n.visible=!1),r}(t.scene,0),t.update(),t.emitEvent({type:"isolate"})})),i("ThreeJS").registerCommand("regenerateAll",(function(t){console.warn("regenerateAll not implemented"),t.emit({type:"regenerateall"})})),i("ThreeJS").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.executeCommand("k3DViewSW"),t.emit({type:"resetview"})})),i("ThreeJS").registerCommand("selectModel",(function(t,e){console.warn("selectModel not implemented"),t.emit({type:"select",data:[]})})),i("ThreeJS").registerCommand("setActiveDragger",((t,e="")=>{t.setActiveDragger(e)})),i("ThreeJS").registerCommand("setMarkupColor",((t,e=255,n=0,i=0)=>{console.warn("setMarkupColor not implemented")})),i("ThreeJS").registerCommand("setSelected",(function(t,e=[]){const n=new Set(e),i=[];t.scene.traverseVisible((t=>{var e;n.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&i.push(t)}));const r=new mc(t);r.clearSelection(),i.forEach((t=>r.select(t))),r.dispose(),t.update(),t.emitEvent({type:"select",data:void 0,handles:e})})),i("ThreeJS").registerCommand("showAll",(function(t){t.scene.traverse((t=>t.visible=!0)),t.update(),t.emitEvent({type:"showall"})})),i("ThreeJS").registerCommand("zoomToExtents",(function(t){if(t.extents.isEmpty())return;const e=t.extents.getCenter(new Rn),n=t.extents.getBoundingSphere(new Zn).radius,i=new Rn(0,0,1);i.applyQuaternion(t.camera.quaternion),i.multiplyScalar(3*n),t.camera.position.copy(e).add(i),t.target.copy(e),t.update(),t.emitEvent({type:"zoom"})})),i("ThreeJS").registerCommandAlias("zoomToExtents","zoomExtents"),i("ThreeJS").registerCommand("zoomToObjects",(function(t,e=[]){const n=new Set(e),i=[];t.scene.traverseVisible((t=>{var e;n.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&i.push(t)}));const r=i.reduce(((t,e)=>t.expandByObject(e)),new In),s=r.getCenter(new Rn),a=r.getBoundingSphere(new Zn).radius,o=new Rn(0,0,1);o.applyQuaternion(t.camera.quaternion),o.multiplyScalar(3*a),t.camera.position.copy(s).add(o),t.target.copy(s),t.update(),t.emitEvent({type:"zoom"})})),i("ThreeJS").registerCommand("zoomToSelected",(function(t){const e=t.selected.reduce(((t,e)=>t.expandByObject(e)),new In);e.isEmpty()&&e.copy(t.extents);const n=e.getCenter(new Rn),i=e.getBoundingSphere(new Zn).radius,r=new Rn(0,0,1);r.applyQuaternion(t.camera.quaternion),r.multiplyScalar(3*i),t.camera.position.copy(n).add(r),t.target.copy(n),t.update(),t.emitEvent({type:"zoom"})}));class bc extends Lh{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new Cc(t)})),this.register((function(t){return new Rc(t)})),this.register((function(t){return new kc(t)})),this.register((function(t){return new Bc(t)})),this.register((function(t){return new zc(t)})),this.register((function(t){return new Lc(t)})),this.register((function(t){return new Ic(t)})),this.register((function(t){return new Dc(t)})),this.register((function(t){return new Nc(t)})),this.register((function(t){return new Ac(t)})),this.register((function(t){return new Uc(t)})),this.register((function(t){return new Pc(t)})),this.register((function(t){return new Fc(t)})),this.register((function(t){return new Oc(t)})),this.register((function(t){return new Ec(t)})),this.register((function(t){return new Gc(t)})),this.register((function(t){return new Hc(t)}))}load(t,e,n,i){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const e=Qh.extractUrlBase(t);s=Qh.resolveURL(e,this.path)}else s=Qh.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){i?i(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},o=new Nh(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){try{r.parse(n,s,(function(n){e(n),r.manager.itemEnd(t)}),a)}catch(t){a(t)}}),n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const s={},a={},o=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(o.decode(new Uint8Array(t,0,4))===Vc){try{s[wc.KHR_BINARY_GLTF]=new jc(t)}catch(t){return void(i&&i(t))}r=JSON.parse(s[wc.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new _d(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](l);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[e.name]=e,s[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],n=r.extensionsRequired||[];switch(e){case wc.KHR_MATERIALS_UNLIT:s[e]=new Tc;break;case wc.KHR_DRACO_MESH_COMPRESSION:s[e]=new Yc(r,this.dracoLoader);break;case wc.KHR_TEXTURE_TRANSFORM:s[e]=new qc;break;case wc.KHR_MESH_QUANTIZATION:s[e]=new Kc;break;default:n.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise((function(i,r){n.parse(t,e,i,r)}))}}function Mc(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const wc={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ec{constructor(t){this.parser=t,this.name=wc.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let i=e.cache.get(n);if(i)return i;const r=e.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let a;const o=new Ji(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],Ee);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new Zh(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new qh(o),a.distance=l;break;case"spot":a=new Vh(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,dd(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),i=Promise.resolve(a),e.cache.add(n,i),i}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,i=n.json.nodes[t],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(t){return n._getNodeRef(e.cache,r,t)}))}}class Tc{constructor(){this.name=wc.KHR_MATERIALS_UNLIT}getMaterialType(){return er}extendParams(t,e,n){const i=[];t.color=new Ji(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],Ee),t.opacity=e[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(t,"map",r.baseColorTexture,we))}return Promise.all(i)}}class Ac{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(e.emissiveIntensity=i),Promise.resolve()}}class Cc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new $e(t,t)}return Promise.all(r)}}class Rc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_DISPERSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class Pc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class Lc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Ji(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=i.extensions[this.name];if(void 0!==s.sheenColorFactor){const t=s.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],Ee)}return void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(e,"sheenColorMap",s.sheenColorTexture,we)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class Ic{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class Dc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=(new Ji).setRGB(a[0],a[1],a[2],Ee),Promise.all(r)}}class Nc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class Uc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=(new Ji).setRGB(a[0],a[1],a[2],Ee),void 0!==s.specularColorTexture&&r.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture,we)),Promise.all(r)}}class Oc{constructor(t){this.parser=t,this.name=wc.EXT_MATERIALS_BUMP}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return e.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(n.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class Fc{constructor(t){this.parser=t,this.name=wc.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?hh:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.anisotropyStrength&&(e.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(e.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(n.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class kc{constructor(t){this.parser=t,this.name=wc.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Bc{constructor(t){this.parser=t,this.name=wc.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class zc{constructor(t){this.parser=t,this.name=wc.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Gc{constructor(t){this.name=wc.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class Hc{constructor(t){this.name=wc.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const t of i.primitives)if(t.mode!==$c.TRIANGLES&&t.mode!==$c.TRIANGLE_STRIP&&t.mode!==$c.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const t of n){const e=new si,n=new Rn,s=new Cn,o=new Rn(1,1,1),l=new Nl(t.geometry,t.material,i);for(let t=0;t<i;t++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,t),a.ROTATION&&s.fromBufferAttribute(a.ROTATION,t),a.SCALE&&o.fromBufferAttribute(a.SCALE,t),l.setMatrixAt(t,e.compose(n,s,o));for(const e in a)if("_COLOR_0"===e){const t=a[e];l.instanceColor=new Tl(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,a[e]);Ii.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),r.push(l)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]})))}}const Vc="glTF",Wc=1313821514,Xc=5130562;class jc{constructor(t){this.name=wc.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Vc)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<i;){const e=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===Wc){const i=new Uint8Array(t,12+s,e);this.content=n.decode(i)}else if(i===Xc){const n=12+s;this.body=t.slice(n,n+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Yc{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=wc.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},l={};for(const t in s){const e=rd[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const i=rd[e]||e.toLowerCase();if(void 0!==s[e]){const r=n.accessors[t.attributes[e]],s=td[r.componentType];l[i]=s.name,o[i]=!0===r.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e,n){i.decodeDracoFile(t,(function(t){for(const e in t.attributes){const n=t.attributes[e],i=o[e];void 0!==i&&(n.normalized=i)}e(t)}),a,l,Ee,n)}))}))}}class qc{constructor(){this.name=wc.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class Kc{constructor(){this.name=wc.KHR_MESH_QUANTIZATION}}class Zc extends fh{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let t=0;t!==i;t++)e[t]=n[r+t];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,h=i-e,c=(n-e)/h,d=c*c,u=d*c,p=t*l,f=p-l,m=-2*u+3*d,g=u-d,_=1-m,v=g-d+c;for(let t=0;t!==a;t++){const e=s[f+t+a],n=s[f+t+o]*h,i=s[p+t+a],l=s[p+t]*h;r[t]=_*e+v*n+m*i+g*l}return r}}const Jc=new Cn;class Qc extends Zc{interpolate_(t,e,n,i){const r=super.interpolate_(t,e,n,i);return Jc.fromArray(r).normalize().toArray(r),r}}const $c={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},td={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ed={9728:ut,9729:mt,9984:1004,9985:gt,9986:ft,9987:_t},nd={33071:ct,33648:dt,10497:ht},id={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},rd={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},sd={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ad={CUBICSPLINE:void 0,LINEAR:Se,STEP:xe},od="OPAQUE",ld="MASK",hd="BLEND";function cd(t,e,n){for(const i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function dd(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ud(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,i=n.length;e<i;e++)t.morphTargetDictionary[n[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function pd(t){let e;const n=t.extensions&&t.extensions[wc.KHR_DRACO_MESH_COMPRESSION];if(e=n?"draco:"+n.bufferView+":"+n.indices+":"+fd(n.attributes):t.indices+":"+fd(t.attributes)+":"+t.mode,void 0!==t.targets)for(let n=0,i=t.targets.length;n<i;n++)e+=":"+fd(t.targets[n]);return e}function fd(t){let e="";const n=Object.keys(t).sort();for(let i=0,r=n.length;i<r;i++)e+=n[i]+":"+t[n[i]]+";";return e}function md(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const gd=new si;class _d{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Mc,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);i=n&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new Oh(this.options.manager):this.textureLoader=new $h(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Nh(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return cd(r,s,i),dd(s,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n].joints;for(let e=0,n=i.length;e<n;e++)t[i[e]].isBone=!0}for(let e=0,i=t.length;e<i;e++){const i=t[e];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),r=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne((function(t){return t.loadNode&&t.loadNode(e)}));break;case"mesh":i=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":i=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne((function(t){return t.loadAnimation&&t.loadAnimation(e)}));break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(t,e)})),!i)throw new Error("Unknown type: "+t)}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map((function(e,i){return n.getDependency(t,i)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[wc.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(t,r){n.load(Qh.resolveURL(e.uri,i.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const n=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+n)}))}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse){const t=id[i.type],e=td[i.componentType],n=!0===i.normalized,r=new e(i.count*t);return Promise.resolve(new rr(r,t,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(t){const r=t[0],s=id[i.type],a=td[i.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,h=i.byteOffset||0,c=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,d=!0===i.normalized;let u,p;if(c&&c!==l){const t=Math.floor(h/c),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+t+":"+i.count;let l=e.cache.get(n);l||(u=new a(r,t*c,i.count*c/o),l=new jo(u,c/o),e.cache.add(n,l)),p=new qo(l,s,h%c/o,d)}else u=null===r?new a(i.count*s):new a(r,h,i.count*s),p=new rr(u,s,d);if(void 0!==i.sparse){const e=id.SCALAR,n=td[i.sparse.indices.componentType],o=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,h=new n(t[1],o,i.sparse.count*e),c=new a(t[2],l,i.sparse.count*s);null!==r&&(p=new rr(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let t=0,e=h.length;t<e;t++){const e=h[t];if(p.setX(e,c[t*s]),s>=2&&p.setY(e,c[t*s+1]),s>=3&&p.setZ(e,c[t*s+2]),s>=4&&p.setW(e,c[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p}))}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,n).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return e.magFilter=ed[n.magFilter]||mt,e.minFilter=ed[n.minFilter]||_t,e.wrapS=nd[n.wrapS]||ht,e.wrapT=nd[n.wrapT]||ht,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==ut&&e.minFilter!==mt,i.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(t,e){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const s=i.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then((function(t){l=!0;const e=new Blob([t],{type:s.mimeType});return o=a.createObjectURL(e),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(o).then((function(t){return new Promise((function(n,i){let s=n;!0===e.isImageBitmapLoader&&(s=function(t){const e=new bn(t);e.needsUpdate=!0,n(e)}),e.load(Qh.resolveURL(t,r.path),s,void 0,i)}))})).then((function(t){var e;return!0===l&&a.revokeObjectURL(o),dd(t,s),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t}));return this.sourceCache[t]=h,h}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[wc.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[wc.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[wc.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Kl,tr.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Ul,tr.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||s){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return lh}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},o=[];if((r.extensions||{})[wc.KHR_MATERIALS_UNLIT]){const t=i[wc.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new Ji(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],Ee),a.opacity=t[3]}void 0!==n.baseColorTexture&&o.push(e.assignTexture(a,"map",n.baseColorTexture,we)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=2);const l=r.alphaMode||od;if(l===hd?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===ld&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==er&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new $e(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==er&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==er){const t=r.emissiveFactor;a.emissive=(new Ji).setRGB(t[0],t[1],t[2],Ee)}return void 0!==r.emissiveTexture&&s!==er&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,we)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),dd(n,r),e.associations.set(n,{materials:t}),r.extensions&&cd(i,n,r),n}))}createUniqueName(t){const e=lc.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[wc.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return vd(n,t,e)}))}const s=[];for(let n=0,a=t.length;n<a;n++){const a=t[n],o=pd(a),l=i[o];if(l)s.push(l.promise);else{let t;t=a.extensions&&a.extensions[wc.KHR_DRACO_MESH_COMPRESSION]?r(a):vd(new mr,a,e),i[o]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,i=this.extensions,r=n.meshes[t],s=r.primitives,a=[];for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new lh({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:y})),o.DefaultMaterial):this.getDependency("material",s[t].material);a.push(e)}var o;return a.push(e.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,h=o.length;n<h;n++){const h=o[n],c=s[n];let d;const u=a[n];if(c.mode===$c.TRIANGLES||c.mode===$c.TRIANGLE_STRIP||c.mode===$c.TRIANGLE_FAN||void 0===c.mode)d=!0===r.isSkinnedMesh?new xl(h,u):new Ar(h,u),!0===d.isSkinnedMesh&&d.normalizeSkinWeights(),c.mode===$c.TRIANGLE_STRIP?d.geometry=Sc(d.geometry,1):c.mode===$c.TRIANGLE_FAN&&(d.geometry=Sc(d.geometry,2));else if(c.mode===$c.LINES)d=new Yl(h,u);else if(c.mode===$c.LINE_STRIP)d=new Vl(h,u);else if(c.mode===$c.LINE_LOOP)d=new ql(h,u);else{if(c.mode!==$c.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);d=new th(h,u)}Object.keys(d.geometry.morphAttributes).length>0&&ud(d,r),d.name=e.createUniqueName(r.name||"mesh_"+t),dd(d,r),c.extensions&&cd(i,d,c),e.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n<i;n++)e.associations.set(l[n],{meshes:t,primitives:n});if(1===l.length)return r.extensions&&cd(i,l[0],r),l[0];const h=new Uo;r.extensions&&cd(i,h,r),e.associations.set(h,{meshes:t});for(let t=0,e=l.length;t<e;t++)h.add(l[t]);return h}))}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type];if(i)return"perspective"===n.type?e=new Br(Qe.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(e=new us(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),dd(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],n=[];for(let t=0,i=e.joints.length;t<i;t++)n.push(this._loadNodeShallow(e.joints[t]));return void 0!==e.inverseBindMatrices?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(t){const n=t.pop(),i=t,r=[],s=[];for(let t=0,a=i.length;t<a;t++){const a=i[t];if(a){r.push(a);const e=new si;null!==n&&e.fromArray(n.array,16*t),s.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}return new El(r,s)}))}loadAnimation(t){const e=this.json,n=this,i=e.animations[t],r=i.name?i.name:"animation_"+t,s=[],a=[],o=[],l=[],h=[];for(let t=0,e=i.channels.length;t<e;t++){const e=i.channels[t],n=i.samplers[e.sampler],r=e.target,c=r.node,d=void 0!==i.parameters?i.parameters[n.input]:n.input,u=void 0!==i.parameters?i.parameters[n.output]:n.output;void 0!==r.node&&(s.push(this.getDependency("node",c)),a.push(this.getDependency("accessor",d)),o.push(this.getDependency("accessor",u)),l.push(n),h.push(r))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(h)]).then((function(t){const e=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=[];for(let t=0,r=e.length;t<r;t++){const r=e[t],h=i[t],c=s[t],d=a[t],u=o[t];if(void 0===r)continue;r.updateMatrix&&r.updateMatrix();const p=n._createAnimationTracks(r,h,c,d,u);if(p)for(let t=0;t<p.length;t++)l.push(p[t])}return new Th(r,void 0,l)}))}createNodeMesh(t){const e=this.json,n=this,i=e.nodes[t];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(t){const e=n._getNodeRef(n.meshCache,i.mesh,t);return void 0!==i.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,n=i.weights.length;e<n;e++)t.morphTargetInfluences[e]=i.weights[e]})),e}))}loadNode(t){const e=this,n=this.json.nodes[t],i=e._loadNodeShallow(t),r=[],s=n.children||[];for(let t=0,n=s.length;t<n;t++)r.push(e.getDependency("node",s[t]));const a=void 0===n.skin?Promise.resolve(null):e.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),a]).then((function(t){const e=t[0],n=t[1],i=t[2];null!==i&&e.traverse((function(t){t.isSkinnedMesh&&t.bind(i,gd)}));for(let t=0,i=n.length;t<i;t++)e.add(n[t]);return e}))}_loadNodeShallow(t){const e=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=e.nodes[t],s=r.name?i.createUniqueName(r.name):"",a=[],o=i._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return o&&a.push(o),void 0!==r.camera&&a.push(i.getDependency("camera",r.camera).then((function(t){return i._getNodeRef(i.cameraCache,r.camera,t)}))),i._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){a.push(t)})),this.nodeCache[t]=Promise.all(a).then((function(e){let a;if(a=!0===r.isBone?new Sl:e.length>1?new Uo:1===e.length?e[0]:new Ii,a!==e[0])for(let t=0,n=e.length;t<n;t++)a.add(e[t]);if(r.name&&(a.userData.name=r.name,a.name=s),dd(a,r),r.extensions&&cd(n,a,r),void 0!==r.matrix){const t=new si;t.fromArray(r.matrix),a.applyMatrix4(t)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=t,a})),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],i=this,r=new Uo;n.name&&(r.name=i.createUniqueName(n.name)),dd(r,n),n.extensions&&cd(e,r,n);const s=n.nodes||[],a=[];for(let t=0,e=s.length;t<e;t++)a.push(i.getDependency("node",s[t]));return Promise.all(a).then((function(t){for(let e=0,n=t.length;e<n;e++)r.add(t[e]);return i.associations=(t=>{const e=new Map;for(const[t,n]of i.associations)(t instanceof tr||t instanceof bn)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(r),r}))}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(sd[r.path]===sd.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),sd[r.path]){case sd.weights:l=Sh;break;case sd.rotation:l=Mh;break;case sd.position:case sd.scale:l=Eh;break;default:if(1===n.itemSize)l=Sh;else l=Eh}const h=void 0!==i.interpolation?ad[i.interpolation]:Se,c=this._getArrayFromAccessor(n);for(let t=0,n=o.length;t<n;t++){const n=new l(o[t]+"."+sd[r.path],e.array,c,h);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(n),s.push(n)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const t=md(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*t;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof Mh?Qc:Zc)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function vd(t,e,n){const i=e.attributes,r=[];function s(e,i){return n.getDependency("accessor",e).then((function(e){t.setAttribute(i,e)}))}for(const e in i){const n=rd[e]||e.toLowerCase();n in t.attributes||r.push(s(i[e],n))}if(void 0!==e.indices&&!t.index){const i=n.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(i)}return ln.workingColorSpace!==Ee&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ln.workingColorSpace}" not supported.`),dd(t,e),function(t,e,n){const i=e.attributes,r=new In;if(void 0===i.POSITION)return;{const t=n.json.accessors[i.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new Rn(e[0],e[1],e[2]),new Rn(s[0],s[1],s[2])),t.normalized){const e=md(td[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new Rn,e=new Rn;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,a=i.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),i.normalized){const t=md(td[i.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(t)}t.boundingBox=r;const a=new Zn;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=a}(t,e,n),Promise.all(r).then((function(){return void 0!==e.targets?function(t,e,n){let i=!1,r=!1,s=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(t);const a=[],o=[],l=[];for(let h=0,c=e.length;h<c;h++){const c=e[h];if(i){const e=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):t.attributes.position;a.push(e)}if(r){const e=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):t.attributes.normal;o.push(e)}if(s){const e=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):t.attributes.color;l.push(e)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(e){const n=e[0],a=e[1],o=e[2];return i&&(t.morphAttributes.position=n),r&&(t.morphAttributes.normal=a),s&&(t.morphAttributes.color=o),t.morphTargetsRelative=!0,t}))}(t,e.targets,n):t}))}class yd extends Rh{constructor(t,e=new Map,n={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=n.path||"","string"==typeof t?(this.fileURL=t,this.resourcePath=Qh.extractUrlBase(t)):(e.forEach(((e,n)=>this.fileURL=e===t?n:this.fileURL)),e.set(this.fileURL,t)),e.forEach(((t,e)=>{let n;n="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,n)})),this.setURLModifier((t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),n=this.dataURLs.get(e);return null!=n?n:t}))}dispose(){this.dataURLs.forEach(URL.revokeObjectURL)}}class xd{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 n=this._listeners[t].filter((t=>t!==e));return 0!==n.length?this._listeners[t]=n: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)}}var Sd="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function bd(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Md,wd={exports:{}},Ed={},Td={},Ad={};function Cd(){return Md||(Md=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t._registerNode=t.Konva=t.glob=void 0;const e=Math.PI/180;t.glob=void 0!==Sd?Sd:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},t.Konva={_global:t.glob,version:"9.3.16",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:n=>t.Konva.angleDeg?n*e:n,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,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>t.Konva.DD.isDragging,isTransforming(){var e;return null===(e=t.Konva.Transformer)||void 0===e?void 0:e.isTransforming()},isDragReady:()=>!!t.Konva.DD.node,releaseCanvasOnDestroy:!0,document:t.glob.document,_injectGlobal(e){t.glob.Konva=e}};t._registerNode=e=>{t.Konva[e.prototype.getClassName()]=e},t.Konva._injectGlobal(t.Konva)}(Ad)),Ad}var Rd,Pd={};function Ld(){return Rd||(Rd=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;const e=Cd();class n{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 n(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),n=Math.sin(t),i=this.m[0]*e+this.m[2]*n,r=this.m[1]*e+this.m[3]*n,s=this.m[0]*-n+this.m[2]*e,a=this.m[1]*-n+this.m[3]*e;return this.m[0]=i,this.m[1]=r,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const n=this.m[0]+this.m[2]*e,i=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=n,this.m[1]=i,this.m[2]=r,this.m[3]=s,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],n=this.m[1]*t.m[0]+this.m[3]*t.m[1],i=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=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]=n,this.m[2]=i,this.m[3]=r,this.m[4]=s,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,n=-this.m[1]*t,i=-this.m[2]*t,r=this.m[0]*t,s=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]=n,this.m[2]=i,this.m[3]=r,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const e=this.m[0],n=this.m[1],i=this.m[2],r=this.m[3],s=e*r-n*i,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=n){const t=Math.sqrt(e*e+n*n);a.rotation=n>0?Math.acos(e/t):-Math.acos(e/t),a.scaleX=t,a.scaleY=s/t,a.skewX=(e*i+n*r)/s,a.skewY=0}else if(0!=i||0!=r){const t=Math.sqrt(i*i+r*r);a.rotation=Math.PI/2-(r>0?Math.acos(-i/t):-Math.acos(i/t)),a.scaleX=s/t,a.scaleY=t,a.skewX=0,a.skewY=(e*i+n*r)/s}return a.rotation=t.Util._getRotation(a.rotation),a}}t.Transform=n;let i=Math.PI/180,r=180/Math.PI,s="Konva error: ",a={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]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,l=[];const h="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_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){l.push(t),1===l.length&&h((function(){const t=l;l=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(e,n){const i=t.Util.createImageElement();i.onload=function(){n(i)},i.src=e},_rgbToHex:(t,e,n)=>((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");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"#"+t},getRGB(t){let e;return t in a?(e=a[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=o.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:e=>(e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)),_namedColorToRBA(t){const e=a[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,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),i=Number(n[0])/360,r=Number(n[1])/100,s=Number(n[2])/100;let a,o,l;if(0===r)return l=255*s,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};a=s<.5?s*(1+r):s+r-s*r;const h=2*s-a,c=[0,0,0];for(let t=0;t<3;t++)o=i+1/3*-(t-1),o<0&&o++,o>1&&o--,l=6*o<1?h+6*(a-h)*o:2*o<1?a:3*o<2?h+(a-h)*(2/3-o)*6:h,c[t]=255*l;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 n in t)this._isPlainObject(t[n])?e[n]=this.cloneObject(t[n]):this._isArray(t[n])?e[n]=this.cloneArray(t[n]):e[n]=t[n];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*i,radToDeg:t=>t*r,_degToRad:e=>(t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)),_radToDeg:e=>(t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)),_getRotation:n=>e.Konva.angleDeg?t.Util.radToDeg(n):n,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(s+t)},error(t){console.error(s+t)},warn(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const n in t)e(n,t[n])},_inRange:(t,e,n)=>e<=t&&t<n,_getProjectionToSegment(t,e,n,i,r,s){let a,o,l;const h=(t-n)*(t-n)+(e-i)*(e-i);if(0==h)a=t,o=e,l=(r-n)*(r-n)+(s-i)*(s-i);else{const c=((r-t)*(n-t)+(s-e)*(i-e))/h;c<0?(a=t,o=e,l=(t-r)*(t-r)+(e-s)*(e-s)):c>1?(a=n,o=i,l=(n-r)*(n-r)+(i-s)*(i-s)):(a=t+c*(n-t),o=e+c*(i-e),l=(a-r)*(a-r)+(o-s)*(o-s))}return[a,o,l]},_getProjectionToLine(e,n,i){const r=t.Util.cloneObject(e);let s=Number.MAX_VALUE;return n.forEach((function(a,o){if(!i&&o===n.length-1)return;const l=n[(o+1)%n.length],h=t.Util._getProjectionToSegment(a.x,a.y,l.x,l.y,e.x,e.y),c=h[0],d=h[1],u=h[2];u<s&&(r.x=c,r.y=d,s=u)})),r},_prepareArrayForTween(e,n,i){let r,s=[],a=[];if(e.length>n.length){const t=n;n=e,e=t}for(r=0;r<e.length;r+=2)s.push({x:e[r],y:e[r+1]});for(r=0;r<n.length;r+=2)a.push({x:n[r],y:n[r+1]});const o=[];return a.forEach((function(e){const n=t.Util._getProjectionToLine(e,s,i);o.push(n.x),o.push(n.y)})),o},_prepareToStringify(e){let n;e.visitedByCircularReferenceRemoval=!0;for(const i in e)if(e.hasOwnProperty(i)&&e[i]&&"object"==typeof e[i])if(n=Object.getOwnPropertyDescriptor(e,i),e[i].visitedByCircularReferenceRemoval||t.Util._isElement(e[i])){if(!n.configurable)return null;delete e[i]}else if(null===t.Util._prepareToStringify(e[i])){if(!n.configurable)return null;delete e[i]}return delete e.visitedByCircularReferenceRemoval,e},_assign(t,e){for(const n in e)t[n]=e[n];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){e.Konva.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,n,i){let r=0,s=0,a=0,o=0;"number"==typeof i?r=s=a=o=Math.min(i,e/2,n/2):(r=Math.min(i[0]||0,e/2,n/2),s=Math.min(i[1]||0,e/2,n/2),o=Math.min(i[2]||0,e/2,n/2),a=Math.min(i[3]||0,e/2,n/2)),t.moveTo(r,0),t.lineTo(e-s,0),t.arc(e-s,s,s,3*Math.PI/2,0,!1),t.lineTo(e,n-o),t.arc(e-o,n-o,o,0,Math.PI/2,!1),t.lineTo(a,n),t.arc(a,n-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(Pd)),Pd}var Id,Dd,Nd={},Ud={},Od={};function Fd(){if(Id)return Od;Id=1,Object.defineProperty(Od,"__esModule",{value:!0}),Od.RGBComponent=function(t){if(t>255)return 255;if(t<0)return 0;return Math.round(t)},Od.alphaComponent=function(t){if(t>1)return 1;if(t<1e-4)return 1e-4;return t},Od.getNumberValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isNumber(t)||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a number.'),t}},Od.getNumberOrArrayOfNumbersValidator=function(i){if(t.Konva.isUnminified)return function(t,r){const s=e.Util._isNumber(t),a=e.Util._isArray(t)&&t.length==i;return s||a||e.Util.warn(n(t)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+i+")"),t}},Od.getNumberOrAutoValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isNumber(t)||"auto"===t||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a number or "auto".'),t}},Od.getStringValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isString(t)||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a string.'),t}},Od.getStringOrGradientValidator=function(){if(t.Konva.isUnminified)return function(t,i){const r=e.Util._isString(t),s="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return r||s||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a string or a native gradient.'),t}},Od.getFunctionValidator=function(){if(t.Konva.isUnminified)return function(t,i){return e.Util._isFunction(t)||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a function.'),t}},Od.getNumberArrayValidator=function(){if(t.Konva.isUnminified)return function(t,i){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&t instanceof r||(e.Util._isArray(t)?t.forEach((function(t){e.Util._isNumber(t)||e.Util.warn('"'+i+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a array of numbers.')),t}},Od.getBooleanValidator=function(){if(t.Konva.isUnminified)return function(t,i){return!0===t||!1===t||e.Util.warn(n(t)+' is a not valid value for "'+i+'" attribute. The value should be a boolean.'),t}},Od.getComponentValidator=function(i){if(t.Konva.isUnminified)return function(t,r){return null==t||e.Util.isObject(t)||e.Util.warn(n(t)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+i),t}};const t=Cd(),e=Ld();function n(t){return e.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||e.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}return Od}function kd(){return Dd||(Dd=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;const e=Ld(),n=Fd(),i="get",r="set";t.Factory={addGetterSetter(e,n,i,r,s){t.Factory.addGetter(e,n,i),t.Factory.addSetter(e,n,r,s),t.Factory.addOverloadedGetterSetter(e,n)},addGetter(t,n,r){const s=i+e.Util._capitalize(n);t.prototype[s]=t.prototype[s]||function(){const t=this.attrs[n];return void 0===t?r:t}},addSetter(n,i,s,a){const o=r+e.Util._capitalize(i);n.prototype[o]||t.Factory.overWriteSetter(n,i,s,a)},overWriteSetter(t,n,i,s){const a=r+e.Util._capitalize(n);t.prototype[a]=function(t){return i&&null!=t&&(t=i.call(this,t,n)),this._setAttr(n,t),s&&s.call(this),this}},addComponentsGetterSetter(s,a,o,l,h){let c,d,u=o.length,p=e.Util._capitalize,f=i+p(a),m=r+p(a);s.prototype[f]=function(){const t={};for(c=0;c<u;c++)d=o[c],t[d]=this.getAttr(a+p(d));return t};const g=(0,n.getComponentValidator)(o);s.prototype[m]=function(t){let e,n=this.attrs[a];for(e in l&&(t=l.call(this,t)),g&&g.call(this,t,a),t)t.hasOwnProperty(e)&&this._setAttr(a+p(e),t[e]);return t||o.forEach((t=>{this._setAttr(a+p(t),void 0)})),this._fireChangeEvent(a,n,t),h&&h.call(this),this},t.Factory.addOverloadedGetterSetter(s,a)},addOverloadedGetterSetter(t,n){const s=e.Util._capitalize(n),a=r+s,o=i+s;t.prototype[n]=function(){return arguments.length?(this[a](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(n,r,s,a){e.Util.error("Adding deprecated "+r);const o=i+e.Util._capitalize(r),l=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";n.prototype[o]=function(){e.Util.error(l);const t=this.attrs[r];return void 0===t?s:t},t.Factory.addSetter(n,r,a,(function(){e.Util.error(l)})),t.Factory.addOverloadedGetterSetter(n,r)},backCompat(t,n){e.Util.each(n,(function(n,s){const a=t.prototype[s],o=i+e.Util._capitalize(n),l=r+e.Util._capitalize(n);function h(){a.apply(this,arguments),e.Util.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+s+'" instead.')}t.prototype[n]=h,t.prototype[o]=h,t.prototype[l]=h}))},afterSetFilter(){this._filterUpToDate=!1}}}(Ud)),Ud}var Bd,zd,Gd={},Hd={};function Vd(){if(Bd)return Hd;Bd=1,Object.defineProperty(Hd,"__esModule",{value:!0}),Hd.HitContext=Hd.SceneContext=Hd.Context=void 0;const t=Ld(),e=Cd();const n=["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 i=class{constructor(t){this.canvas=t,e.Konva.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(e,n){let i,r,s,a,o=this.traceArr,l=o.length,h="";for(i=0;i<l;i++)r=o[i],s=r.method,s?(a=r.args,h+=s,e?h+="()":t.Util._isArray(a[0])?h+="(["+a.join(",")+"])":(n&&(a=a.map((t=>"number"==typeof t?Math.floor(t):t))),h+="("+a.join(",")+")")):(h+=r.property,e||(h+="="+r.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,n=this.traceArr;n.push(t),e=n.length,e>=100&&n.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)}setAttr(t,e){this._context[t]=e}arc(t,e,n,i,r,s){this._context.arc(t,e,n,i,r,s)}arcTo(t,e,n,i,r){this._context.arcTo(t,e,n,i,r)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,n,i,r,s){this._context.bezierCurveTo(t,e,n,i,r,s)}clearRect(t,e,n,i){this._context.clearRect(t,e,n,i)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const n=arguments;return 2===n.length?this._context.createImageData(t,e):1===n.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,n,i){return this._context.createLinearGradient(t,e,n,i)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,n,i,r,s){return this._context.createRadialGradient(t,e,n,i,r,s)}drawImage(t,e,n,i,r,s,a,o,l){const h=arguments,c=this._context;3===h.length?c.drawImage(t,e,n):5===h.length?c.drawImage(t,e,n,i,r):9===h.length&&c.drawImage(t,e,n,i,r,s,a,o,l)}ellipse(t,e,n,i,r,s,a,o){this._context.ellipse(t,e,n,i,r,s,a,o)}isPointInPath(t,e,n,i){return n?this._context.isPointInPath(n,t,e,i):this._context.isPointInPath(t,e,i)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,n,i){this._context.fillRect(t,e,n,i)}strokeRect(t,e,n,i){this._context.strokeRect(t,e,n,i)}fillText(t,e,n,i){i?this._context.fillText(t,e,n,i):this._context.fillText(t,e,n)}measureText(t){return this._context.measureText(t)}getImageData(t,e,n,i){return this._context.getImageData(t,e,n,i)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,n,i){this._context.rect(t,e,n,i)}roundRect(t,e,n,i,r){this._context.roundRect(t,e,n,i,r)}putImageData(t,e,n){this._context.putImageData(t,e,n)}quadraticCurveTo(t,e,n,i){this._context.quadraticCurveTo(t,e,n,i)}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,n,i,r,s){this._context.setTransform(t,e,n,i,r,s)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,n,i){this._context.strokeText(t,e,n,i)}transform(t,e,n,i,r,s){this._context.transform(t,e,n,i,r,s)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let e,i,r=this,s=n.length,a=this.setAttr;const o=function(e){let n,s=r[e];r[e]=function(){return i=function(e){let n,i,r=[],s=e.length,a=t.Util;for(n=0;n<s;n++)i=e[n],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),r.push(i);return r}(Array.prototype.slice.call(arguments,0)),n=s.apply(r,arguments),r._trace({method:e,args:i}),n}};for(e=0;e<s;e++)o(n[e]);r.setAttr=function(){a.apply(r,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),r._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}};Hd.Context=i,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(i.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}));Hd.SceneContext=class extends i{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(),n=t.getFillPriority();if(e&&"color"===n)return void this._fillColor(t);const i=t.getFillPatternImage();if(i&&"pattern"===n)return void this._fillPattern(t);const r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===n)return void this._fillLinearGradient(t);const s=t.getFillRadialGradientColorStops();s&&"radial-gradient"===n?this._fillRadialGradient(t):e?this._fillColor(t):i?this._fillPattern(t):r?this._fillLinearGradient(t):s&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),n=t.getStrokeLinearGradientEndPoint(),i=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,n.x,n.y);if(i){for(let t=0;t<i.length;t+=2)r.addColorStop(i[t],i[t+1]);this.setAttr("strokeStyle",r)}}_stroke(t){const e=t.dash(),n=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!n){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),n||this.restore()}}_applyShadow(t){var e,n,i;const r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",s=null!==(n=t.getShadowBlur())&&void 0!==n?n:5,a=null!==(i=t.getShadowOffset())&&void 0!==i?i:{x:0,y:0},o=t.getAbsoluteScale(),l=this.canvas.getPixelRatio(),h=o.x*l,c=o.y*l;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",s*Math.min(Math.abs(h),Math.abs(c))),this.setAttr("shadowOffsetX",a.x*h),this.setAttr("shadowOffsetY",a.y*c)}};return Hd.HitContext=class extends i{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 n=t.hitStrokeWidth(),i="auto"===n?t.strokeWidth():n;this.setAttr("lineWidth",i),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}},Hd}function Wd(){if(zd)return Gd;zd=1,Object.defineProperty(Gd,"__esModule",{value:!0}),Gd.HitCanvas=Gd.SceneCanvas=Gd.Canvas=void 0;const t=Ld(),e=Vd(),n=Cd(),i=kd(),r=Fd();let s;let a=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const i=(e||{}).pixelRatio||n.Konva.pixelRatio||function(){if(s)return s;const e=t.Util.createCanvasElement(),i=e.getContext("2d");return s=(n.Konva._global.devicePixelRatio||1)/(i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1),t.Util.releaseCanvas(e),s}();this.pixelRatio=i,this._canvas=t.Util.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(e,n){try{return this._canvas.toDataURL(e,n)}catch(e){try{return this._canvas.toDataURL()}catch(e){return t.Util.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}};Gd.Canvas=a,i.Factory.addGetterSetter(a,"pixelRatio",void 0,(0,r.getNumberValidator)());Gd.SceneCanvas=class extends a{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new e.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}};return Gd.HitCanvas=class extends a{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new e.HitContext(this),this.setSize(t.width,t.height)}},Gd}var Xd,jd,Yd={};function qd(){return Xd||(Xd=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;const e=Cd(),n=Ld();t.DD={get isDragging(){let e=!1;return t.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){let e;return t.DD._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const i=[];t.DD._dragElements.forEach(((t,r)=>{const{node:s}=t,a=s.getStage();a.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=n.Util._getFirstPointerId(e));const o=a._changedPointerPositions.find((e=>e.id===t.pointerId));if(o){if("dragging"!==t.dragStatus){const n=s.dragDistance();if(Math.max(Math.abs(o.x-t.startPointerPos.x),Math.abs(o.y-t.startPointerPos.y))<n)return;if(s.startDrag({evt:e}),!s.isDragging())return}s._setDragPosition(e,t),i.push(s)}})),i.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(n){const i=[];t.DD._dragElements.forEach((r=>{const{node:s}=r,a=s.getStage();n&&a.setPointersPositions(n);if(!a._changedPointerPositions.find((t=>t.id===r.pointerId)))return;"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");const o=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;o&&-1===i.indexOf(o)&&i.push(o)})),i.forEach((t=>{t.draw()}))},_endDragAfter(e){t.DD._dragElements.forEach(((n,i)=>{"stopped"===n.dragStatus&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:e},!0),"dragging"!==n.dragStatus&&t.DD._dragElements.delete(i)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("touchcancel",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1),window.addEventListener("touchcancel",t.DD._endDragAfter,!1))}(Yd)),Yd}function Kd(){if(jd)return Nd;jd=1,Object.defineProperty(Nd,"__esModule",{value:!0}),Nd.Node=void 0;const t=Ld(),e=kd(),n=Wd(),i=Cd(),r=qd(),s=Fd(),a="absoluteOpacity",o="allEventListeners",l="absoluteTransform",h="absoluteScale",c="canvas",d="listening",u="mouseenter",p="mouseleave",f="Shape",m=" ",g="stage",_="transform",v="visible",y=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(m);let x=1,S=class e{constructor(t){this._id=x++,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!==_&&t!==l||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let n=this._cache.get(t);return(void 0===n||(t===_||t===l)&&!0===n.dirty)&&(n=e.call(this),this._cache.set(t,n)),n}_calculate(t,e,n){if(!this._attachedDepsListeners.get(t)){const n=e.map((t=>t+"Change.konva")).join(m);this.on(n,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,n)}_getCanvasCache(){return this._cache.get(c)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===l&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(c)){const{scene:e,filter:n,hit:i}=this._cache.get(c);t.Util.releaseCanvas(e,n,i),this._cache.delete(c)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){const i=e||{};let r={};void 0!==i.x&&void 0!==i.y&&void 0!==i.width&&void 0!==i.height||(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let s=Math.ceil(i.width||r.width),o=Math.ceil(i.height||r.height),l=i.pixelRatio,d=void 0===i.x?Math.floor(r.x):i.x,u=void 0===i.y?Math.floor(r.y):i.y,p=i.offset||0,f=i.drawBorder||!1,m=i.hitCanvasPixelRatio||1;if(!s||!o)return void t.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");s+=2*p+(Math.abs(Math.round(r.x)-d)>.5?1:0),o+=2*p+(Math.abs(Math.round(r.y)-u)>.5?1:0),d-=p,u-=p;const g=new n.SceneCanvas({pixelRatio:l,width:s,height:o}),_=new n.SceneCanvas({pixelRatio:l,width:0,height:0,willReadFrequently:!0}),v=new n.HitCanvas({pixelRatio:m,width:s,height:o}),y=g.getContext(),x=v.getContext();return v.isCache=!0,g.isCache=!0,this._cache.delete(c),this._filterUpToDate=!1,!1===i.imageSmoothingEnabled&&(g.getContext()._context.imageSmoothingEnabled=!1,_.getContext()._context.imageSmoothingEnabled=!1),y.save(),x.save(),y.translate(-d,-u),x.translate(-d,-u),this._isUnderCache=!0,this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(h),this.drawScene(g,this),this.drawHit(v,this),this._isUnderCache=!1,y.restore(),x.restore(),f&&(y.save(),y.beginPath(),y.rect(0,0,s,o),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),this._cache.set(c,{scene:g,filter:_,hit:v,x:d,y:u}),this._requestDraw(),this}isCached(){return this._cache.has(c)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const n=[{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 i=1/0,r=1/0,s=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return n.forEach((function(t){const e=o.point(t);void 0===i&&(i=s=e.x,r=a=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y)})),{x:i,y:r,width:s-i,height:a-r}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const n=this._getCachedSceneCanvas(),i=n.pixelRatio;t.drawImage(n._canvas,0,0,n.width/i,n.height/i),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),n=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),t.restore()}_getCachedSceneCanvas(){let e,n,i,r,s=this.filters(),a=this._getCanvasCache(),o=a.scene,l=a.filter,h=l.getContext();if(s){if(!this._filterUpToDate){const a=o.pixelRatio;l.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(e=s.length,h.clear(),h.drawImage(o._canvas,0,0,o.getWidth()/a,o.getHeight()/a),n=h.getImageData(0,0,l.getWidth(),l.getHeight()),i=0;i<e;i++)r=s[i],"function"==typeof r?(r.call(this,n),h.putImageData(n,0,0)):t.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){t.Util.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return l}return o}on(t,e){if(this._cache&&this._cache.delete(o),3===arguments.length)return this._delegate.apply(this,arguments);let n,i,r,s,a,l=t.split(m),h=l.length;for(n=0;n<h;n++)i=l[n],r=i.split("."),s=r[0],a=r[1]||"",this.eventListeners[s]||(this.eventListeners[s]=[]),this.eventListeners[s].push({name:a,handler:e});return this}off(t,e){let n,i,r,s,a,l,h=(t||"").split(m),c=h.length;if(this._cache&&this._cache.delete(o),!t)for(i in this.eventListeners)this._off(i);for(n=0;n<c;n++)if(r=h[n],s=r.split("."),a=s[0],l=s[1],a)this.eventListeners[a]&&this._off(a,l,e);else for(i in this.eventListeners)this._off(i,l,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(e,n,i){const r=this;this.on(e,(function(e){const s=e.target.findAncestors(n,!0,r);for(let n=0;n<s.length;n++)(e=t.Util.cloneObject(e)).currentTarget=s[n],i.call(s[n],e)}))}remove(){return this.isDragging()&&this.stopDrag(),r.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(l),this._clearSelfAndDescendantCache(a),this._clearSelfAndDescendantCache(h),this._clearSelfAndDescendantCache(g),this._clearSelfAndDescendantCache(v),this._clearSelfAndDescendantCache(d)}_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(e){const n="get"+t.Util._capitalize(e);return t.Util._isFunction(this[n])?this[n]():this.attrs[e]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{let n,i;if(!e)return this;for(n in e)"children"!==n&&(i="set"+t.Util._capitalize(n),t.Util._isFunction(this[i])?this[i](e[n]):this._setAttr(n,e[n]))})),this}isListening(){return this._getCache(d,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(v,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 n=this.getLayer();let s=!1;r.DD._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===n)&&(s=!0)}));const a=!e&&!i.Konva.hitOnDragEnabled&&(s||i.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,n,i,r=this.getDepth(),s=this,a=0;const o=this.getStage();return"Stage"!==s.nodeType&&o&&function o(l){for(t=[],e=l.length,n=0;n<e;n++)i=l[n],a++,i.nodeType!==f&&(t=t.concat(i.getChildren().slice())),i._id===s._id&&(n=e);t.length>0&&t[0].getDepth()<=r&&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(_),this._clearSelfAndDescendantCache(l)),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 n=this.getAbsoluteTransform().copy();return n.invert(),n.point(e)}getAbsolutePosition(e){let n=!1,i=this.parent;for(;i;){if(i.isCached()){n=!0;break}i=i.parent}n&&!e&&(e=!0);const r=this.getAbsoluteTransform(e).getMatrix(),s=new t.Transform,a=this.offset();return s.m=r.slice(),s.translate(a.x,a.y),s.getTranslation()}setAbsolutePosition(t){const{x:e,y:n,...i}=this._clearTransform();this.attrs.x=e,this.attrs.y=n,this._clearCache(_);const r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(t.x,t.y),t={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(i),this.setPosition({x:t.x,y:t.y}),this._clearCache(_),this._clearSelfAndDescendantCache(l),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,n=t.y,i=this.x(),r=this.y();return void 0!==e&&(i+=e),void 0!==n&&(r+=n),this.setPosition({x:i,y:r}),this}_eachAncestorReverse(t,e){let n,i,r=[],s=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);s&&(!e||s._id!==e._id);)r.unshift(s),s=s.parent;for(n=r.length,i=0;i<n;i++)t(r[i])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return t.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return t.Util.warn("Node has no parent. moveUp function is ignored."),!1;const e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return t.Util.warn("Node has no parent. moveDown function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return t.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return t.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&t.Util.warn("Unexpected value "+e+" 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 n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(a,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 e,n,i,r,s,a=this.getAttrs();const o={attrs:{},className:this.getClassName()};for(e in a)n=a[e],s=t.Util.isObject(n)&&!t.Util._isPlainObject(n)&&!t.Util._isArray(n),s||(i="function"==typeof this[e]&&this[e],delete a[e],r=i?i.call(this):null,a[e]=n,r!==n&&(o.attrs[e]=n));return t.Util._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,n){const i=[];e&&this._isMatch(t)&&i.push(this);let r=this.parent;for(;r;){if(r===n)return i;r._isMatch(t)&&i.push(r),r=r.parent}return i}isAncestorOf(t){return!1}findAncestor(t,e,n){return this.findAncestors(t,e,n)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);let n,i,r=e.replace(/ /g,"").split(","),s=r.length;for(n=0;n<s;n++)if(i=r[n],t.Util.isValidSelector(i)||(t.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),t.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),t.Util.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(g,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},n){return e.target=e.target||this,n?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(l,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let n;if(e)return n=new t.Transform,this._eachAncestorReverse((function(t){const e=t.transformsEnabled();"all"===e?n.multiply(t.getTransform()):"position"===e&&n.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),e),n;{n=this._cache.get(l)||new t.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const e=this.transformsEnabled();if("all"===e)n.multiply(this.getTransform());else if("position"===e){const t=this.attrs.x||0,e=this.attrs.y||0,i=this.attrs.offsetX||0,r=this.attrs.offsetY||0;n.translate(t-i,e-r)}return n.dirty=!1,n}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const n=this.getAbsoluteTransform(t).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(_,this._getTransform)}_getTransform(){var e,n;const r=this._cache.get(_)||new t.Transform;r.reset();const s=this.x(),a=this.y(),o=i.Konva.getAngle(this.rotation()),l=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,h=null!==(n=this.attrs.scaleY)&&void 0!==n?n:1,c=this.attrs.skewX||0,d=this.attrs.skewY||0,u=this.attrs.offsetX||0,p=this.attrs.offsetY||0;return 0===s&&0===a||r.translate(s,a),0!==o&&r.rotate(o),0===c&&0===d||r.skew(c,d),1===l&&1===h||r.scale(l,h),0===u&&0===p||r.translate(-1*u,-1*p),r.dirty=!1,r}clone(e){let n,i,r,s,a,o=t.Util.cloneObject(this.attrs);for(n in e)o[n]=e[n];const l=new this.constructor(o);for(n in this.eventListeners)for(i=this.eventListeners[n],r=i.length,s=0;s<r;s++)a=i[s],a.name.indexOf("konva")<0&&(l.eventListeners[n]||(l.eventListeners[n]=[]),l.eventListeners[n].push(a));return l}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),i=this.getStage(),r=void 0!==t.x?t.x:Math.floor(e.x),s=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new n.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:a}),l=o.getContext(),h=new n.SceneCanvas({width:o.width/o.pixelRatio+Math.abs(r),height:o.height/o.pixelRatio+Math.abs(s),pixelRatio:o.pixelRatio});return!1===t.imageSmoothingEnabled&&(l._context.imageSmoothingEnabled=!1),l.save(),(r||s)&&l.translate(-1*r,-1*s),this.drawScene(o,void 0,h),l.restore(),o}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,n=t.quality||null,i=this._toKonvaCanvas(t).toDataURL(e,n);return t.callback&&t.callback(i),i}toImage(e){return new Promise(((n,i)=>{try{const i=null==e?void 0:e.callback;i&&delete e.callback,t.Util._urlToImage(this.toDataURL(e),(function(t){n(t),null==i||i(t)}))}catch(t){i(t)}}))}toBlob(t){return new Promise(((e,n)=>{try{const n=null==t?void 0:t.callback;n&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==n||n(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){n(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():i.Konva.dragDistance}_off(t,e,n){let i,r,s,a=this.eventListeners[t];for(i=0;i<a.length;i++)if(r=a[i].name,s=a[i].handler,!("konva"===r&&"konva"!==e||e&&r!==e||n&&n!==s)){if(a.splice(i,1),0===a.length){delete this.eventListeners[t];break}i--}}_fireChangeEvent(t,e,n){this._fire(t+"Change",{oldVal:e,newVal:n})}addName(t){if(!this.hasName(t)){const e=this.name(),n=e?e+" "+t:t;this.name(n)}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),n=e.indexOf(t);return-1!==n&&(e.splice(n,1),this.name(e.join(" "))),this}setAttr(e,n){const i=this["set"+t.Util._capitalize(e)];return t.Util._isFunction(i)?i.call(this,n):this._setAttr(e,n),this}_requestDraw(){if(i.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(e,n){const i=this.attrs[e];(i!==n||t.Util.isObject(n))&&(null==n?delete this.attrs[e]:this.attrs[e]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(e,i,n),this._requestDraw())}_setComponentAttr(t,e,n){let i;void 0!==n&&(i=this.attrs[t],i||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=n,this._fireChangeEvent(t,i,n))}_fireAndBubble(t,e,n){e&&this.nodeType===f&&(e.target=this);if(!((t===u||t===p)&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n))){this._fire(t,e);const i=(t===u||t===p)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!i&&(n&&n.parent?this._fireAndBubble.call(this.parent,t,e,n):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,n,i;const r=null!==(e=this._cache.get(o))&&void 0!==e?e:{};let s=null==r?void 0:r[t];if(void 0===s){s=[];let e=Object.getPrototypeOf(this);for(;e;){const r=null!==(i=null===(n=e.eventListeners)||void 0===n?void 0:n[t])&&void 0!==i?i:[];s.push(...r),e=Object.getPrototypeOf(e)}r[t]=s,this._cache.set(o,r)}return s}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const n=this._getProtoListeners(t);if(n)for(var i=0;i<n.length;i++)n[i].handler.call(this,e);const r=this.eventListeners[t];if(r)for(i=0;i<r.length;i++)r[i].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,n=this.getStage(),i=this.getAbsolutePosition();if(!n)return;const s=n._getPointerById(e)||n._changedPointerPositions[0]||i;r.DD._dragElements.set(this._id,{node:this,startPointerPos:s,offset:{x:s.x-i.x,y:s.y-i.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){r.DD._dragElements.has(this._id)||this._createDragElement(t);r.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(e,n){const i=this.getStage()._getPointerById(n.pointerId);if(!i)return;let r={x:i.x-n.offset.x,y:i.y-n.offset.y};const s=this.dragBoundFunc();if(void 0!==s){const n=s.call(this,r,e);n?r=n:t.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=r.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),r.DD._endDragBefore(t),r.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=r.DD._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)||i.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;r.DD._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=r.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,n=t&&"ready"===t.dragStatus;e?this.stopDrag():n&&r.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const n=this.getStage();if(!n)return!1;const i={x:-e.x,y:-e.y,width:n.width()+2*e.x,height:n.height()+2*e.y};return t.Util.haveIntersection(i,this.getClientRect())}static create(e,n){return t.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,n)}static _createNode(n,r){let s,a,o,l=e.prototype.getClassName.call(n),h=n.children;r&&(n.attrs.container=r),i.Konva[l]||(t.Util.warn('Can not find a node with class name "'+l+'". Fallback to "Shape".'),l="Shape");if(s=new(0,i.Konva[l])(n.attrs),h)for(a=h.length,o=0;o<a;o++)s.add(e._createNode(h[o]));return s}};Nd.Node=S,S.prototype.nodeType="Node",S.prototype._attrsAffectingSize=[],S.prototype.eventListeners={},S.prototype.on.call(S.prototype,y,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(_),this._clearSelfAndDescendantCache(l))})),S.prototype.on.call(S.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(v)})),S.prototype.on.call(S.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(d)})),S.prototype.on.call(S.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(a)}));const b=e.Factory.addGetterSetter;return b(S,"zIndex"),b(S,"absolutePosition"),b(S,"position"),b(S,"x",0,(0,s.getNumberValidator)()),b(S,"y",0,(0,s.getNumberValidator)()),b(S,"globalCompositeOperation","source-over",(0,s.getStringValidator)()),b(S,"opacity",1,(0,s.getNumberValidator)()),b(S,"name","",(0,s.getStringValidator)()),b(S,"id","",(0,s.getStringValidator)()),b(S,"rotation",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(S,"scale",["x","y"]),b(S,"scaleX",1,(0,s.getNumberValidator)()),b(S,"scaleY",1,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(S,"skew",["x","y"]),b(S,"skewX",0,(0,s.getNumberValidator)()),b(S,"skewY",0,(0,s.getNumberValidator)()),e.Factory.addComponentsGetterSetter(S,"offset",["x","y"]),b(S,"offsetX",0,(0,s.getNumberValidator)()),b(S,"offsetY",0,(0,s.getNumberValidator)()),b(S,"dragDistance",null,(0,s.getNumberValidator)()),b(S,"width",0,(0,s.getNumberValidator)()),b(S,"height",0,(0,s.getNumberValidator)()),b(S,"listening",!0,(0,s.getBooleanValidator)()),b(S,"preventDefault",!0,(0,s.getBooleanValidator)()),b(S,"filters",null,(function(t){return this._filterUpToDate=!1,t})),b(S,"visible",!0,(0,s.getBooleanValidator)()),b(S,"transformsEnabled","all",(0,s.getStringValidator)()),b(S,"size"),b(S,"dragBoundFunc"),b(S,"draggable",!1,(0,s.getBooleanValidator)()),e.Factory.backCompat(S,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),Nd}var Zd,Jd={};function Qd(){if(Zd)return Jd;Zd=1,Object.defineProperty(Jd,"__esModule",{value:!0}),Jd.Container=void 0;const t=kd(),e=Kd(),n=Fd();let i=class extends e.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){if(!t)return this.children||[];const e=this.children||[],n=[];return e.forEach((function(e){t(e)&&n.push(e)})),n}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 n=[];return this._descendants((i=>{const r=i._isMatch(t);return r&&n.push(i),!(!r||!e)})),n}_descendants(t){let e=!1;const n=this.getChildren();for(const i of n){if(e=t(i),e)return!0;if(i.hasChildren()&&(e=i._descendants(t),e))return!0}return!1}toObject(){const t=e.Node.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 n=e.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){n.add(t.clone())})),n}getAllIntersections(t){const e=[];return this.find("Shape").forEach((n=>{n.isVisible()&&n.intersects(t)&&e.push(n)})),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,n){const i=this.getLayer(),r=t||i&&i.getCanvas(),s=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,l=r&&r.isCache;if(!this.isVisible()&&!l)return this;if(o){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore()}else this._drawChildren("drawScene",r,e,n);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const n=this.getLayer(),i=t||n&&n.hitCanvas,r=i&&i.getContext(),s=this._getCanvasCache();if(s&&s.hit){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",i,e);return this}_drawChildren(t,e,n,i){var r;const s=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),l=this.clipFunc(),h="number"==typeof a&&"number"==typeof o||l,c=n===this;if(h){s.save();const t=this.getAbsoluteTransform(n);let e,i=t.getMatrix();if(s.transform(i[0],i[1],i[2],i[3],i[4],i[5]),s.beginPath(),l)e=l.call(this,s,this);else{const t=this.clipX(),e=this.clipY();s.rect(t||0,e||0,a,o)}s.clip.apply(s,e),i=t.copy().invert().getMatrix(),s.transform(i[0],i[1],i[2],i[3],i[4],i[5])}const d=!c&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;d&&(s.save(),s._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[t](e,n,i)})),d&&s.restore(),h&&s.restore()}getClientRect(t={}){var e;const n=t.skipTransform,i=t.relativeTo;let r,s,a,o,l={x:1/0,y:1/0,width:0,height:0};const h=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const n=e.getClientRect({relativeTo:h,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===n.width&&0===n.height||(void 0===r?(r=n.x,s=n.y,a=n.x+n.width,o=n.y+n.height):(r=Math.min(r,n.x),s=Math.min(s,n.y),a=Math.max(a,n.x+n.width),o=Math.max(o,n.y+n.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 l=d&&void 0!==r?{x:r,y:s,width:a-r,height:o-s}:{x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,i)}};return Jd.Container=i,t.Factory.addComponentsGetterSetter(i,"clip",["x","y","width","height"]),t.Factory.addGetterSetter(i,"clipX",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipY",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipWidth",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipHeight",void 0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(i,"clipFunc"),Jd}var $d,tu,eu={},nu={};function iu(){if($d)return nu;$d=1,Object.defineProperty(nu,"__esModule",{value:!0}),nu.getCapturedShape=function(t){return e.get(t)},nu.createEvent=i,nu.hasPointerCapture=function(t,n){return e.get(t)===n},nu.setPointerCapture=function(t,s){r(t);if(!s.getStage())return;e.set(t,s),n&&s._fire("gotpointercapture",i(new PointerEvent("gotpointercapture")))},nu.releaseCapture=r;const t=Cd(),e=new Map,n=void 0!==t.Konva._global.PointerEvent;function i(t){return{evt:t,pointerId:t.pointerId}}function r(t,r){const s=e.get(t);if(!s)return;const a=s.getStage();a&&a.content,e.delete(t),n&&s._fire("lostpointercapture",i(new PointerEvent("lostpointercapture")))}return nu}var ru,su,au={},ou={};function lu(){return ru||(ru=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;const e=Cd(),n=Ld(),i=kd(),r=Kd(),s=Fd(),a=Cd(),o=iu(),l="hasShadow",h="shadowRGBA",c="patternImage",d="linearGradient",u="radialGradient";let p;function f(){return p||(p=n.Util.createCanvasElement().getContext("2d"),p)}t.shapes={};class m extends r.Node{constructor(e){let i;for(super(e);i=n.Util.getRandomColor(),!i||i in t.shapes;);this.colorKey=i,t.shapes[i]=this}getContext(){return n.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return n.Util.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(l,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(c,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=f().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const i=new n.Transform;i.translate(this.fillPatternX(),this.fillPatternY()),i.rotate(e.Konva.getAngle(this.fillPatternRotation())),i.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),i.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=i.getMatrix(),s="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(s)}return t}}_getLinearGradient(){return this._getCache(d,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=f(),n=this.fillLinearGradientStartPoint(),i=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(n.x,n.y,i.x,i.y);for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}_getRadialGradient(){return this._getCache(u,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=f(),n=this.fillRadialGradientStartPoint(),i=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),i.x,i.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)r.addColorStop(t[e],t[e+1]);return r}}getShadowRGBA(){return this._getCache(h,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=n.Util.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 n=e.bufferHitCanvas;n.getContext().clear(),this.drawHit(n,void 0,!0);return n.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return r.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const n=t||this.hasFill(),i=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(n&&i&&r)return!0;const s=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(n&&i&&s&&a)}setStrokeHitEnabled(t){n.Util.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,n=this.getParent();for(;n;){if(n.isCached()){e=!0;break}n=n.getParent()}const i=t.skipTransform,r=t.relativeTo||e&&this.getStage()||void 0,s=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=s.width+a,l=s.height+a,h=!t.skipShadow&&this.hasShadow(),c=h?this.shadowOffsetX():0,d=h?this.shadowOffsetY():0,u=o+Math.abs(c),p=l+Math.abs(d),f=h&&this.shadowBlur()||0,m={width:u+2*f,height:p+2*f,x:-(a/2+f)+Math.min(c,0)+s.x,y:-(a/2+f)+Math.min(d,0)+s.y};return i?m:this._transformedRect(m,r)}drawScene(t,e,n){const i=this.getLayer();let r,s,a=t||i.getCanvas(),o=a.getContext(),l=this._getCanvasCache(),h=this.getSceneFunc(),c=this.hasShadow();const d=a.isCache,u=e===this;if(!this.isVisible()&&!u)return this;if(l){o.save();const t=this.getAbsoluteTransform(e).getMatrix();return o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!h)return this;if(o.save(),this._useBufferCanvas()&&!d){r=this.getStage();const t=n||r.bufferCanvas;s=t.getContext(),s.clear(),s.save(),s._applyLineJoin(this);var p=this.getAbsoluteTransform(e).getMatrix();s.transform(p[0],p[1],p[2],p[3],p[4],p[5]),h.call(this,s,this),s.restore();const i=t.pixelRatio;c&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(t._canvas,0,0,t.width/i,t.height/i)}else{if(o._applyLineJoin(this),!u){p=this.getAbsoluteTransform(e).getMatrix();o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}c&&o._applyShadow(this),h.call(this,o,this)}return o.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const r=this.getLayer(),s=t||r.hitCanvas,a=s&&s.getContext(),o=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),h=l&&l.hit;if(this.colorKey||n.Util.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){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;a.save(),a._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(t=0){let e,i,r,s,a,o,l=this._getCanvasCache(),h=this._getCachedSceneCanvas(),c=l.hit,d=c.getContext(),u=c.getWidth(),p=c.getHeight();d.clear(),d.drawImage(h._canvas,0,0,u,p);try{for(e=d.getImageData(0,0,u,p),i=e.data,r=i.length,s=n.Util._hexToRgb(this.colorKey),a=0;a<r;a+=4)o=i[a+3],o>t?(i[a]=s.r,i[a+1]=s.g,i[a+2]=s.b,i[a+3]=255):i[a+3]=0;d.putImageData(e,0,0)}catch(t){n.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return o.hasPointerCapture(t,this)}setPointerCapture(t){o.setPointerCapture(t,this)}releaseCapture(t){o.releaseCapture(t,this)}}t.Shape=m,m.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFunc=function(t){t.stroke()},m.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},m.prototype._strokeFuncHit=function(t){t.stroke()},m.prototype._centroid=!1,m.prototype.nodeType="Shape",(0,a._registerNode)(m),m.prototype.eventListeners={},m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(l)})),m.prototype.on.call(m.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(h)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(c)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(d)})),m.prototype.on.call(m.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(u)})),i.Factory.addGetterSetter(m,"stroke",void 0,(0,s.getStringOrGradientValidator)()),i.Factory.addGetterSetter(m,"strokeWidth",2,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillAfterStrokeEnabled",!1),i.Factory.addGetterSetter(m,"hitStrokeWidth","auto",(0,s.getNumberOrAutoValidator)()),i.Factory.addGetterSetter(m,"strokeHitEnabled",!0,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(m,"perfectDrawEnabled",!0,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(m,"shadowForStrokeEnabled",!0,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(m,"lineJoin"),i.Factory.addGetterSetter(m,"lineCap"),i.Factory.addGetterSetter(m,"sceneFunc"),i.Factory.addGetterSetter(m,"hitFunc"),i.Factory.addGetterSetter(m,"dash"),i.Factory.addGetterSetter(m,"dashOffset",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"shadowColor",void 0,(0,s.getStringValidator)()),i.Factory.addGetterSetter(m,"shadowBlur",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"shadowOpacity",1,(0,s.getNumberValidator)()),i.Factory.addComponentsGetterSetter(m,"shadowOffset",["x","y"]),i.Factory.addGetterSetter(m,"shadowOffsetX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"shadowOffsetY",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternImage"),i.Factory.addGetterSetter(m,"fill",void 0,(0,s.getStringOrGradientValidator)()),i.Factory.addGetterSetter(m,"fillPatternX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternY",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillLinearGradientColorStops"),i.Factory.addGetterSetter(m,"strokeLinearGradientColorStops"),i.Factory.addGetterSetter(m,"fillRadialGradientStartRadius",0),i.Factory.addGetterSetter(m,"fillRadialGradientEndRadius",0),i.Factory.addGetterSetter(m,"fillRadialGradientColorStops"),i.Factory.addGetterSetter(m,"fillPatternRepeat","repeat"),i.Factory.addGetterSetter(m,"fillEnabled",!0),i.Factory.addGetterSetter(m,"strokeEnabled",!0),i.Factory.addGetterSetter(m,"shadowEnabled",!0),i.Factory.addGetterSetter(m,"dashEnabled",!0),i.Factory.addGetterSetter(m,"strokeScaleEnabled",!0),i.Factory.addGetterSetter(m,"fillPriority","color"),i.Factory.addComponentsGetterSetter(m,"fillPatternOffset",["x","y"]),i.Factory.addGetterSetter(m,"fillPatternOffsetX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternOffsetY",0,(0,s.getNumberValidator)()),i.Factory.addComponentsGetterSetter(m,"fillPatternScale",["x","y"]),i.Factory.addGetterSetter(m,"fillPatternScaleX",1,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(m,"fillPatternScaleY",1,(0,s.getNumberValidator)()),i.Factory.addComponentsGetterSetter(m,"fillLinearGradientStartPoint",["x","y"]),i.Factory.addComponentsGetterSetter(m,"strokeLinearGradientStartPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillLinearGradientStartPointX",0),i.Factory.addGetterSetter(m,"strokeLinearGradientStartPointX",0),i.Factory.addGetterSetter(m,"fillLinearGradientStartPointY",0),i.Factory.addGetterSetter(m,"strokeLinearGradientStartPointY",0),i.Factory.addComponentsGetterSetter(m,"fillLinearGradientEndPoint",["x","y"]),i.Factory.addComponentsGetterSetter(m,"strokeLinearGradientEndPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillLinearGradientEndPointX",0),i.Factory.addGetterSetter(m,"strokeLinearGradientEndPointX",0),i.Factory.addGetterSetter(m,"fillLinearGradientEndPointY",0),i.Factory.addGetterSetter(m,"strokeLinearGradientEndPointY",0),i.Factory.addComponentsGetterSetter(m,"fillRadialGradientStartPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillRadialGradientStartPointX",0),i.Factory.addGetterSetter(m,"fillRadialGradientStartPointY",0),i.Factory.addComponentsGetterSetter(m,"fillRadialGradientEndPoint",["x","y"]),i.Factory.addGetterSetter(m,"fillRadialGradientEndPointX",0),i.Factory.addGetterSetter(m,"fillRadialGradientEndPointY",0),i.Factory.addGetterSetter(m,"fillPatternRotation",0),i.Factory.addGetterSetter(m,"fillRule",void 0,(0,s.getStringValidator)()),i.Factory.backCompat(m,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(ou)),ou}function hu(){if(su)return au;su=1,Object.defineProperty(au,"__esModule",{value:!0}),au.Layer=void 0;const t=Ld(),e=Qd(),n=Kd(),i=kd(),r=Wd(),s=Fd(),a=lu(),o=Cd(),l=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],h=l.length;let c=class extends e.Container{constructor(t){super(t),this.canvas=new r.SceneCanvas,this.hitCanvas=new r.HitCanvas({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(){n.Node.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(!n.Node.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(n.Node.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(n.Node.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 e=this.getNativeCanvasElement();return n.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),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(e){const n=e.getType();"Group"!==n&&"Shape"!==n&&t.Util.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(),n.Node.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(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,t.Util.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,n=!1;for(;;){for(let i=0;i<h;i++){const r=l[i],s=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),a=s.shape;if(a)return a;if(n=!!s.antialiased,!s.antialiased)break}if(!n)return null;e+=1}}_getIntersection(e){const n=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(e.x*n),Math.round(e.y*n),1,1).data,r=i[3];if(255===r){const e=t.Util._rgbToHex(i[0],i[1],i[2]),n=a.shapes["#"+e];return n?{shape:n}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(t,n){const i=this.getLayer(),r=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),e.Container.prototype.drawScene.call(this,r,n),this._fire("draw",{node:this}),this}drawHit(t,n){const i=this.getLayer(),r=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),e.Container.prototype.drawHit.call(this,r,n),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return t.Util.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 t.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};return au.Layer=c,c.prototype.nodeType="Layer",(0,o._registerNode)(c),i.Factory.addGetterSetter(c,"imageSmoothingEnabled",!0),i.Factory.addGetterSetter(c,"clearBeforeDraw",!0),i.Factory.addGetterSetter(c,"hitGraphEnabled",!0,(0,s.getBooleanValidator)()),au}var cu,du={};var uu,pu={};function fu(){if(uu)return pu;uu=1,Object.defineProperty(pu,"__esModule",{value:!0}),pu.Group=void 0;const t=Ld(),e=Qd(),n=Cd();let i=class extends e.Container{_validateAdd(e){const n=e.getType();"Group"!==n&&"Shape"!==n&&t.Util.throw("You may only add groups and shapes to groups.")}};return pu.Group=i,i.prototype.nodeType="Group",(0,n._registerNode)(i),pu}var mu,gu={};function _u(){if(mu)return gu;mu=1,Object.defineProperty(gu,"__esModule",{value:!0}),gu.Animation=void 0;const t=Cd(),e=Ld(),n=t.glob.performance&&t.glob.performance.now?function(){return t.glob.performance.now()}:function(){return(new Date).getTime()};let i=class t{constructor(e,i){this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:n(),frameRate:0},this.func=e,this.setLayers(i)}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,n=e.length;for(let i=0;i<n;i++)if(e[i]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const e=t.animations,n=e.length;for(let t=0;t<n;t++)if(e[t].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=n(),t._addAnimation(this),this}stop(){return t._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,n=this.animations,i=n.length;for(let t=0;t<i;t++)if(n[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 r=e[i],s=r.layers,a=r.func;r._updateFrameObject(n());const o=s.length;let l;if(l=!a||!1!==a.call(r,r.frame),l)for(let e=0;e<o;e++){const n=s[e];void 0!==n._id&&(t[n._id]=n)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const n=t;n.animations.length?(n._runFrames(),e.Util.requestAnimFrame(n._animationLoop)):n.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,e.Util.requestAnimFrame(this._animationLoop))}};return gu.Animation=i,i.animations=[],i.animIdCounter=0,i.animRunning=!1,gu}var vu,yu,xu={};function Su(){return yu||(yu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;const e=Cd(),n=Ld(),i=Kd(),r=Qd(),s=(tu||(tu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;const e=Ld(),n=kd(),i=Qd(),r=Cd(),s=Wd(),a=qd(),o=Cd(),l=iu(),h="mouseleave",c="mouseover",d="mouseenter",u="mousemove",p="mousedown",f="mouseup",m="pointermove",g="pointerdown",_="pointerup",v="pointercancel",y="pointerout",x="pointerleave",S="pointerover",b="pointerenter",M="contextmenu",w="touchstart",E="touchend",T="touchmove",A="touchcancel",C="wheel",R=[[d,"_pointerenter"],[p,"_pointerdown"],[u,"_pointermove"],[f,"_pointerup"],[h,"_pointerleave"],[w,"_pointerdown"],[T,"_pointermove"],[E,"_pointerup"],[A,"_pointercancel"],[c,"_pointerover"],[C,"_wheel"],[M,"_contextmenu"],[g,"_pointerdown"],[m,"_pointermove"],[_,"_pointerup"],[v,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],P={mouse:{[y]:"mouseout",[x]:h,[S]:c,[b]:d,[m]:u,[g]:p,[_]:f,[v]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y]:"touchout",[x]:"touchleave",[S]:"touchover",[b]:"touchenter",[m]:T,[g]:w,[_]:E,[v]:A,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y]:y,[x]:x,[S]:S,[b]:b,[m]:m,[g]:g,[_]:_,[v]:v,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},L=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=L(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&P.pointer:"touch"===e?P.touch:"mouse"===e?P.mouse:void 0};function D(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];class N extends i.Container{constructor(e){super(D(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),t.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{D(this.attrs)})),this._checkVisibility()}_validateAdd(t){const n="Layer"===t.getType(),i="FastLayer"===t.getType();n||i||e.Util.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){if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var e;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(){let t,e=this.children,n=e.length;for(t=0;t<n;t++)e[t].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),i.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const n=this.content;n&&e.Util._isInDocument(n)&&this.container().removeChild(n);const i=t.stages.indexOf(this);return i>-1&&t.stages.splice(i,1),e.Util.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}:(e.Util.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 s.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),n=e.getContext()._context,i=this.children;return(t.x||t.y)&&n.translate(-1*t.x,-1*t.y),i.forEach((function(e){if(!e.isVisible())return;const i=e._toKonvaCanvas(t);n.drawImage(i._canvas,t.x,t.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())})),e}getIntersection(t){if(!t)return null;let e,n=this.children;for(e=n.length-1;e>=0;e--){const i=n[e].getIntersection(t);if(i)return i}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((n=>{n.setSize({width:t,height:e}),n.draw()}))}add(t,...n){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&&e.Util.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(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return l.hasPointerCapture(t,this)}setPointerCapture(t){l.setPointerCapture(t,this)}releaseCapture(t){l.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){r.Konva.isBrowser&&R.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(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=I(t.type),n=L(t.type);if(!e)return;this.setPointersPositions(t);const i=this._getTargetShape(n),s=!(r.Konva.isDragging()||r.Konva.isTransforming())||r.Konva.hitOnDragEnabled;i&&s?(i._fireAndBubble(e.pointerout,{evt:t}),i._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"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=I(t.type),n=L(t.type);if(!e)return;this.setPointersPositions(t);let i=!1;this._changedPointerPositions.forEach((s=>{const o=this.getIntersection(s);if(a.DD.justDragged=!1,r.Konva["_"+n+"ListenClick"]=!0,!o||!o.isListening())return void(this[n+"ClickStartShape"]=void 0);r.Konva.capturePointerEventsEnabled&&o.setPointerCapture(s.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:s.id}),i=!0;const l=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&l&&t.preventDefault()})),i||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=I(t.type),n=L(t.type);if(!e)return;if(r.Konva.isDragging()&&a.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(r.Konva.isDragging()||r.Konva.isTransforming())&&!r.Konva.hitOnDragEnabled)return;const i={};let s=!1;const o=this._getTargetShape(n);this._changedPointerPositions.forEach((r=>{const a=l.getCapturedShape(r.id)||this.getIntersection(r),h=r.id,c={evt:t,pointerId:h},d=o!==a;if(d&&o&&(o._fireAndBubble(e.pointerout,{...c},a),o._fireAndBubble(e.pointerleave,{...c},a)),a){if(i[a._id])return;i[a._id]=!0}a&&a.isListening()?(s=!0,d&&(a._fireAndBubble(e.pointerover,{...c},o),a._fireAndBubble(e.pointerenter,{...c},o),this[n+"targetShape"]=a),a._fireAndBubble(e.pointermove,{...c})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[n+"targetShape"]=null)})),s||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),n=L(t.type);if(!e)return;this.setPointersPositions(t);const i=this[n+"ClickStartShape"],s=this[n+"ClickEndShape"],o={};let h=!1;this._changedPointerPositions.forEach((c=>{const d=l.getCapturedShape(c.id)||this.getIntersection(c);if(d){if(d.releaseCapture(c.id),o[d._id])return;o[d._id]=!0}const u=c.id,p={evt:t,pointerId:u};let f=!1;r.Konva["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(this[n+"DblTimeout"])):a.DD.justDragged||(r.Konva["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout((function(){r.Konva["_"+n+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),d&&d.isListening()?(h=!0,this[n+"ClickEndShape"]=d,d._fireAndBubble(e.pointerup,{...p}),r.Konva["_"+n+"ListenClick"]&&i&&i===d&&(d._fireAndBubble(e.pointerclick,{...p}),f&&s&&s===d&&d._fireAndBubble(e.pointerdblclick,{...p}))):(this[n+"ClickEndShape"]=null,r.Konva["_"+n+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:u}),f&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:u}))})),h||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(M,{evt:t}):this._fire(M,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(C,{evt:t}):this._fire(C,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=l.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(_,l.createEvent(t)),l.releaseCapture(t.pointerId)}_lostpointercapture(t){l.releaseCapture(t.pointerId)}setPointersPositions(t){let n=this._getContentPosition(),i=null,r=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-n.left)/n.scaleX,y:(t.clientY-n.top)/n.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-n.left)/n.scaleX,y:(t.clientY-n.top)/n.scaleY})}))):(i=(t.clientX-n.left)/n.scaleX,r=(t.clientY-n.top)/n.scaleY,this.pointerPos={x:i,y:r},this._pointerPositions=[{x:i,y:r,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:r,id:e.Util._getFirstPointerId(t)}])}_setPointerPosition(t){e.Util.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 s.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!r.Konva.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 e.Util.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}}t.Stage=N,N.prototype.nodeType="Stage",(0,o._registerNode)(N),n.Factory.addGetterSetter(N,"container"),r.Konva.isBrowser&&document.addEventListener("visibilitychange",(()=>{t.stages.forEach((t=>{t.batchDraw()}))}))}(eu)),eu),a=hu(),o=function(){if(cu)return du;cu=1,Object.defineProperty(du,"__esModule",{value:!0}),du.FastLayer=void 0;const t=Ld(),e=hu(),n=Cd();let i=class extends e.Layer{constructor(e){super(e),this.listening(!1),t.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};return du.FastLayer=i,i.prototype.nodeType="FastLayer",(0,n._registerNode)(i),du}(),l=fu(),h=qd(),c=lu(),d=_u(),u=(vu||(vu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;const e=Ld(),n=_u(),i=Kd(),r=Cd();let s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},a=0,o=["fill","stroke","shadowColor"];class l{constructor(t,e,n,i,r,s,a){this.prop=t,this.propFunc=e,this.begin=i,this._pos=i,this.duration=s,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=r-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 h{constructor(i){let o,c,d=this,u=i.node,p=u._id,f=i.easing||t.Easings.Linear,m=!!i.yoyo;o=void 0===i.duration?.3:0===i.duration?.001:i.duration,this.node=u,this._id=a++;const g=u.getLayer()||(u instanceof r.Konva.Stage?u.getLayers():null);for(c in g||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new n.Animation((function(){d.tween.onEnterFrame()}),g),this.tween=new l(c,(function(t){d._tweenFunc(t)}),f,0,1,1e3*o,m),this._addListeners(),h.attrs[p]||(h.attrs[p]={}),h.attrs[p][this._id]||(h.attrs[p][this._id]={}),h.tweens[p]||(h.tweens[p]={}),i)void 0===s[c]&&this._addAttr(c,i[c]);this.reset(),this.onFinish=i.onFinish,this.onReset=i.onReset,this.onUpdate=i.onUpdate}_addAttr(t,n){let i,r,s,a,l,c,d,u,p=this.node,f=p._id;if(s=h.tweens[f][t],s&&delete h.attrs[f][s][t],i=p.getAttr(t),e.Util._isArray(n))if(r=[],l=Math.max(n.length,i.length),"points"===t&&n.length!==i.length&&(n.length>i.length?(d=i,i=e.Util._prepareArrayForTween(i,n,p.closed())):(c=n,n=e.Util._prepareArrayForTween(n,i,p.closed()))),0===t.indexOf("fill"))for(a=0;a<l;a++)if(a%2==0)r.push(n[a]-i[a]);else{const t=e.Util.colorToRGBA(i[a]);u=e.Util.colorToRGBA(n[a]),i[a]=t,r.push({r:u.r-t.r,g:u.g-t.g,b:u.b-t.b,a:u.a-t.a})}else for(a=0;a<l;a++)r.push(n[a]-i[a]);else-1!==o.indexOf(t)?(i=e.Util.colorToRGBA(i),u=e.Util.colorToRGBA(n),r={r:u.r-i.r,g:u.g-i.g,b:u.b-i.b,a:u.a-i.a}):r=n-i;h.attrs[f][this._id][t]={start:i,diff:r,end:n,trueEnd:c,trueStart:d},h.tweens[f][t]=this._id}_tweenFunc(t){let n,i,r,s,a,l,c,d,u=this.node,p=h.attrs[u._id][this._id];for(n in p){if(i=p[n],r=i.start,s=i.diff,d=i.end,e.Util._isArray(r))if(a=[],c=Math.max(r.length,d.length),0===n.indexOf("fill"))for(l=0;l<c;l++)l%2==0?a.push((r[l]||0)+s[l]*t):a.push("rgba("+Math.round(r[l].r+s[l].r*t)+","+Math.round(r[l].g+s[l].g*t)+","+Math.round(r[l].b+s[l].b*t)+","+(r[l].a+s[l].a*t)+")");else for(l=0;l<c;l++)a.push((r[l]||0)+s[l]*t);else a=-1!==o.indexOf(n)?"rgba("+Math.round(r.r+s.r*t)+","+Math.round(r.g+s.g*t)+","+Math.round(r.b+s.b*t)+","+(r.a+s.a*t)+")":r+s*t;u.setAttr(n,a)}}_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=h.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=h.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(){let t,e=this.node._id,n=this._id,i=h.tweens[e];for(t in this.pause(),i)delete h.tweens[e][t];delete h.attrs[e][n]}}t.Tween=h,h.attrs={},h.tweens={},i.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new h(t).play()},t.Easings={BackEaseIn(t,e,n,i){const r=1.70158;return n*(t/=i)*t*((r+1)*t-r)+e},BackEaseOut(t,e,n,i){const r=1.70158;return n*((t=t/i-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut(t,e,n,i){let r=1.70158;return(t/=i/2)<1?n/2*(t*t*((1+(r*=1.525))*t-r))+e:n/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn(t,e,n,i,r,s){let a=0;return 0===t?e:1==(t/=i)?e+n:(s||(s=.3*i),!r||r<Math.abs(n)?(r=n,a=s/4):a=s/(2*Math.PI)*Math.asin(n/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/s)+e)},ElasticEaseOut(t,e,n,i,r,s){let a=0;return 0===t?e:1==(t/=i)?e+n:(s||(s=.3*i),!r||r<Math.abs(n)?(r=n,a=s/4):a=s/(2*Math.PI)*Math.asin(n/r),r*Math.pow(2,-10*t)*Math.sin((t*i-a)*(2*Math.PI)/s)+n+e)},ElasticEaseInOut(t,e,n,i,r,s){let a=0;return 0===t?e:2==(t/=i/2)?e+n:(s||(s=i*(.3*1.5)),!r||r<Math.abs(n)?(r=n,a=s/4):a=s/(2*Math.PI)*Math.asin(n/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/s)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*(2*Math.PI)/s)*.5+n+e)},BounceEaseOut:(t,e,n,i)=>(t/=i)<1/2.75?n*(7.5625*t*t)+e:t<2/2.75?n*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?n*(7.5625*(t-=2.25/2.75)*t+.9375)+e:n*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(e,n,i,r)=>i-t.Easings.BounceEaseOut(r-e,0,i,r)+n,BounceEaseInOut:(e,n,i,r)=>e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,i,r)+n:.5*t.Easings.BounceEaseOut(2*e-r,0,i,r)+.5*i+n,EaseIn:(t,e,n,i)=>n*(t/=i)*t+e,EaseOut:(t,e,n,i)=>-n*(t/=i)*(t-2)+e,EaseInOut:(t,e,n,i)=>(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,n,i)=>n*(t/=i)*t*t*t*t+e,StrongEaseOut:(t,e,n,i)=>n*((t=t/i-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,n,i)=>(t/=i/2)<1?n/2*t*t*t*t*t+e:n/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,n,i)=>n*t/i+e}}(xu)),xu),p=Vd(),f=Wd();t.Konva=n.Util._assign(e.Konva,{Util:n.Util,Transform:n.Transform,Node:i.Node,Container:r.Container,Stage:s.Stage,stages:s.stages,Layer:a.Layer,FastLayer:o.FastLayer,Group:l.Group,DD:h.DD,Shape:c.Shape,shapes:c.shapes,Animation:d.Animation,Tween:u.Tween,Easings:u.Easings,Context:p.Context,Canvas:f.Canvas}),t.default=t.Konva}(Td)),Td}var bu,Mu={};var wu,Eu={},Tu={};function Au(){if(wu)return Tu;wu=1,Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.Line=void 0;const t=kd(),e=Cd(),n=lu(),i=Fd();function r(t,e,n,i,r,s,a){const o=Math.sqrt(Math.pow(n-t,2)+Math.pow(i-e,2)),l=Math.sqrt(Math.pow(r-n,2)+Math.pow(s-i,2)),h=a*o/(o+l),c=a*l/(o+l);return[n-h*(r-t),i-h*(s-e),n+c*(r-t),i+c*(s-e)]}function s(t,e){const n=t.length,i=[];for(let s=2;s<n-2;s+=2){const n=r(t[s-2],t[s-1],t[s],t[s+1],t[s+2],t[s+3],e);isNaN(n[0])||(i.push(n[0]),i.push(n[1]),i.push(t[s]),i.push(t[s+1]),i.push(n[2]),i.push(n[3]))}return i}let a=class extends n.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(t){let e,n,i,r=this.points(),s=r.length,a=this.tension(),o=this.closed(),l=this.bezier();if(s){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==a&&s>4){for(e=this.getTensionPoints(),n=e.length,i=o?0:4,o||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);i<n-2;)t.bezierCurveTo(e[i++],e[i++],e[i++],e[i++],e[i++],e[i++]);o||t.quadraticCurveTo(e[n-2],e[n-1],r[s-2],r[s-1])}else if(l)for(i=2;i<s;)t.bezierCurveTo(r[i++],r[i++],r[i++],r[i++],r[i++],r[i++]);else for(i=2;i<s;i+=2)t.lineTo(r[i],r[i+1]);o?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():s(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,n=this.tension(),i=r(t[e-2],t[e-1],t[0],t[1],t[2],t[3],n),a=r(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],n),o=s(t,n);return[i[2],i[3]].concat(o).concat([a[0],a[1],t[e-2],t[e-1],a[2],a[3],i[0],i[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.points();let e,n,i=t[0],r=t[0],s=t[1],a=t[1];for(let o=0;o<t.length/2;o++)e=t[2*o],n=t[2*o+1],i=Math.min(i,e),r=Math.max(r,e),s=Math.min(s,n),a=Math.max(a,n);return{x:i,y:s,width:r-i,height:a-s}}};return Tu.Line=a,a.prototype.className="Line",a.prototype._attrsAffectingSize=["points","bezier","tension"],(0,e._registerNode)(a),t.Factory.addGetterSetter(a,"closed",!1),t.Factory.addGetterSetter(a,"bezier",!1),t.Factory.addGetterSetter(a,"tension",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(a,"points",[],(0,i.getNumberArrayValidator)()),Tu}var Cu,Ru,Pu,Lu={},Iu={};function Du(){if(Ru)return Lu;Ru=1,Object.defineProperty(Lu,"__esModule",{value:!0}),Lu.Path=void 0;const t=kd(),e=lu(),n=Cd(),i=(Cu||(Cu=1,function(t){function e(t,e,i){const r=n(1,i,t),s=n(1,i,e),a=r*r+s*s;return Math.sqrt(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.t2length=t.getQuadraticArcLength=t.getCubicArcLength=t.binomialCoefficients=t.cValues=t.tValues=void 0,t.tValues=[[],[],[-.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]],t.cValues=[[],[],[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]],t.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],t.getCubicArcLength=(n,i,r)=>{let s,a;const o=r/2;s=0;for(let r=0;r<20;r++)a=o*t.tValues[20][r]+o,s+=t.cValues[20][r]*e(n,i,a);return o*s},t.getQuadraticArcLength=(t,e,n)=>{void 0===n&&(n=1);const i=t[0]-2*t[1]+t[2],r=e[0]-2*e[1]+e[2],s=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(i*i+r*r),l=4*(i*s+r*a),h=s*s+a*a;if(0===o)return n*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const c=l/(2*o),d=n+c,u=h/o-c*c,p=d*d+u>0?Math.sqrt(d*d+u):0,f=c*c+u>0?Math.sqrt(c*c+u):0,m=c+Math.sqrt(c*c+u)!==0?u*Math.log(Math.abs((d+p)/(c+f))):0;return Math.sqrt(o)/2*(d*p-c*f+m)};const n=(e,i,r)=>{const s=r.length-1;let a,o;if(0===s)return 0;if(0===e){o=0;for(let e=0;e<=s;e++)o+=t.binomialCoefficients[s][e]*Math.pow(1-i,s-e)*Math.pow(i,e)*r[e];return o}a=new Array(s);for(let t=0;t<s;t++)a[t]=s*(r[t+1]-r[t]);return n(e-1,i,a)};t.t2length=(t,e,n)=>{let i=1,r=t/e,s=(t-n(r))/e,a=0;for(;i>.001;){const o=n(r+s),l=Math.abs(t-o)/e;if(l<i)i=l,r+=s;else{const a=n(r-s),o=Math.abs(t-a)/e;o<i?(i=o,r-=s):s/=2}if(a++,a>500)break}return r}}(Iu)),Iu);let r=class t extends e.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=t.parsePathData(this.data()),this.pathLength=t.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let n=!1;for(let f=0;f<e.length;f++){const m=e[f].command,g=e[f].points;switch(m){case"L":t.lineTo(g[0],g[1]);break;case"M":t.moveTo(g[0],g[1]);break;case"C":t.bezierCurveTo(g[0],g[1],g[2],g[3],g[4],g[5]);break;case"Q":t.quadraticCurveTo(g[0],g[1],g[2],g[3]);break;case"A":var i=g[0],r=g[1],s=g[2],a=g[3],o=g[4],l=g[5],h=g[6],c=g[7],d=s>a?s:a,u=s>a?1:s/a,p=s>a?a/s:1;t.translate(i,r),t.rotate(h),t.scale(u,p),t.arc(0,0,d,o,o+l,1-c),t.scale(1/u,1/p),t.rotate(-h),t.translate(-i,-r);break;case"z":n=!0,t.closePath()}}n||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let e=[];this.dataArray.forEach((function(n){if("A"===n.command){const i=n.points[4],r=n.points[5],s=n.points[4]+r;let a=Math.PI/180;if(Math.abs(i-s)<a&&(a=Math.abs(i-s)),r<0)for(let r=i-a;r>s;r-=a){const i=t.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],r,0);e.push(i.x,i.y)}else for(let r=i+a;r<s;r+=a){const i=t.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],r,0);e.push(i.x,i.y)}}else if("C"===n.command)for(let i=0;i<=1;i+=.01){const r=t.getPointOnCubicBezier(i,n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3],n.points[4],n.points[5]);e.push(r.x,r.y)}else e=e.concat(n.points)}));let n,i,r=e[0],s=e[0],a=e[1],o=e[1];for(let t=0;t<e.length/2;t++)n=e[2*t],i=e[2*t+1],isNaN(n)||(r=Math.min(r,n),s=Math.max(s,n)),isNaN(i)||(a=Math.min(a,i),o=Math.max(o,i));return{x:r,y:a,width:s-r,height:o-a}}getLength(){return this.pathLength}getPointAtLength(e){return t.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(t,e,n,i){return Math.sqrt((n-t)*(n-t)+(i-e)*(i-e))}static getPathLength(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n].pathLength;return e}static getPointAtLengthOfDataArray(e,n){let r,s=0,a=n.length;if(!a)return null;for(;s<a&&e>n[s].pathLength;)e-=n[s].pathLength,++s;if(s===a)return r=n[s-1].points.slice(-2),{x:r[0],y:r[1]};if(e<.01)return r=n[s].points.slice(0,2),{x:r[0],y:r[1]};const o=n[s],l=o.points;switch(o.command){case"L":return t.getPointOnLine(e,o.start.x,o.start.y,l[0],l[1]);case"C":return t.getPointOnCubicBezier((0,i.t2length)(e,t.getPathLength(n),(t=>(0,i.getCubicArcLength)([o.start.x,l[0],l[2],l[4]],[o.start.y,l[1],l[3],l[5]],t))),o.start.x,o.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case"Q":return t.getPointOnQuadraticBezier((0,i.t2length)(e,t.getPathLength(n),(t=>(0,i.getQuadraticArcLength)([o.start.x,l[0],l[2]],[o.start.y,l[1],l[3]],t))),o.start.x,o.start.y,l[0],l[1],l[2],l[3]);case"A":var h=l[0],c=l[1],d=l[2],u=l[3],p=l[4],f=l[5],m=l[6];return p+=f*e/o.pathLength,t.getPointOnEllipticalArc(h,c,d,u,p,m)}return null}static getPointOnLine(t,e,n,i,r,s,a){s=null!=s?s:e,a=null!=a?a:n;const o=this.getLineLength(e,n,i,r);if(o<1e-10)return{x:e,y:n};if(i===e)return{x:s,y:a+(r>n?t:-t)};const l=(r-n)/(i-e),h=Math.sqrt(t*t/(1+l*l))*(i<e?-1:1),c=l*h;if(Math.abs(a-n-l*(s-e))<1e-10)return{x:s+h,y:a+c};const d=((s-e)*(i-e)+(a-n)*(r-n))/(o*o),u=e+d*(i-e),p=n+d*(r-n),f=this.getLineLength(s,a,u,p),m=Math.sqrt(t*t-f*f),g=Math.sqrt(m*m/(1+l*l))*(i<e?-1:1);return{x:u+g,y:p+l*g}}static getPointOnCubicBezier(t,e,n,i,r,s,a,o,l){function h(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*h(t)+s*c(t)+i*d(t)+e*u(t),y:l*h(t)+a*c(t)+r*d(t)+n*u(t)}}static getPointOnQuadraticBezier(t,e,n,i,r,s,a){function o(t){return t*t}function l(t){return 2*t*(1-t)}function h(t){return(1-t)*(1-t)}return{x:s*o(t)+i*l(t)+e*h(t),y:a*o(t)+r*l(t)+n*h(t)}}static getPointOnEllipticalArc(t,e,n,i,r,s){const a=Math.cos(s),o=Math.sin(s),l=n*Math.cos(r),h=i*Math.sin(r);return{x:t+(l*a-h*o),y:e+(l*o+h*a)}}static parsePathData(t){if(!t)return[];let e=t;const n=["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(var i=0;i<n.length;i++)e=e.replace(new RegExp(n[i],"g"),"|"+n[i]);const r=e.split("|"),s=[],a=[];let o=0,l=0;const h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(i=1;i<r.length;i++){let t=r[i],e=t.charAt(0);for(t=t.slice(1),a.length=0;c=h.exec(t);)a.push(c[0]);const n=[];for(let t=0,e=a.length;t<e;t++){if("00"===a[t]){n.push(0,0);continue}const e=parseFloat(a[t]);isNaN(e)?n.push(0):n.push(e)}for(;n.length>0&&!isNaN(n[0]);){let t="",i=[];const r=o,a=l;var d,u,p,f,m,g,_,v,y,x;switch(e){case"l":o+=n.shift(),l+=n.shift(),t="L",i.push(o,l);break;case"L":o=n.shift(),l=n.shift(),i.push(o,l);break;case"m":var S=n.shift(),b=n.shift();if(o+=S,l+=b,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){o=s[t].points[0]+S,l=s[t].points[1]+b;break}i.push(o,l),e="l";break;case"M":o=n.shift(),l=n.shift(),t="M",i.push(o,l),e="L";break;case"h":o+=n.shift(),t="L",i.push(o,l);break;case"H":o=n.shift(),t="L",i.push(o,l);break;case"v":l+=n.shift(),t="L",i.push(o,l);break;case"V":l=n.shift(),t="L",i.push(o,l);break;case"C":i.push(n.shift(),n.shift(),n.shift(),n.shift()),o=n.shift(),l=n.shift(),i.push(o,l);break;case"c":i.push(o+n.shift(),l+n.shift(),o+n.shift(),l+n.shift()),o+=n.shift(),l+=n.shift(),t="C",i.push(o,l);break;case"S":u=o,p=l,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=l+(l-d.points[3])),i.push(u,p,n.shift(),n.shift()),o=n.shift(),l=n.shift(),t="C",i.push(o,l);break;case"s":u=o,p=l,"C"===(d=s[s.length-1]).command&&(u=o+(o-d.points[2]),p=l+(l-d.points[3])),i.push(u,p,o+n.shift(),l+n.shift()),o+=n.shift(),l+=n.shift(),t="C",i.push(o,l);break;case"Q":i.push(n.shift(),n.shift()),o=n.shift(),l=n.shift(),i.push(o,l);break;case"q":i.push(o+n.shift(),l+n.shift()),o+=n.shift(),l+=n.shift(),t="Q",i.push(o,l);break;case"T":u=o,p=l,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=l+(l-d.points[1])),o=n.shift(),l=n.shift(),t="Q",i.push(u,p,o,l);break;case"t":u=o,p=l,"Q"===(d=s[s.length-1]).command&&(u=o+(o-d.points[0]),p=l+(l-d.points[1])),o+=n.shift(),l+=n.shift(),t="Q",i.push(u,p,o,l);break;case"A":f=n.shift(),m=n.shift(),g=n.shift(),_=n.shift(),v=n.shift(),y=o,x=l,o=n.shift(),l=n.shift(),t="A",i=this.convertEndpointToCenterParameterization(y,x,o,l,_,v,f,m,g);break;case"a":f=n.shift(),m=n.shift(),g=n.shift(),_=n.shift(),v=n.shift(),y=o,x=l,o+=n.shift(),l+=n.shift(),t="A",i=this.convertEndpointToCenterParameterization(y,x,o,l,_,v,f,m,g)}s.push({command:t||e,points:i,start:{x:r,y:a},pathLength:this.calcLength(r,a,t||e,i)})}"z"!==e&&"Z"!==e||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,n,r,s){let a,o,l,h;const c=t;switch(r){case"L":return c.getLineLength(e,n,s[0],s[1]);case"C":return(0,i.getCubicArcLength)([e,s[0],s[2],s[4]],[n,s[1],s[3],s[5]],1);case"Q":return(0,i.getQuadraticArcLength)([e,s[0],s[2]],[n,s[1],s[3]],1);case"A":a=0;var d=s[4],u=s[5],p=s[4]+u,f=Math.PI/180;if(Math.abs(d-p)<f&&(f=Math.abs(d-p)),o=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],d,0),u<0)for(h=d-f;h>p;h-=f)l=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),a+=c.getLineLength(o.x,o.y,l.x,l.y),o=l;else for(h=d+f;h<p;h+=f)l=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],h,0),a+=c.getLineLength(o.x,o.y,l.x,l.y),o=l;return l=c.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],p,0),a+=c.getLineLength(o.x,o.y,l.x,l.y),a}return 0}static convertEndpointToCenterParameterization(t,e,n,i,r,s,a,o,l){const h=l*(Math.PI/180),c=Math.cos(h)*(t-n)/2+Math.sin(h)*(e-i)/2,d=-1*Math.sin(h)*(t-n)/2+Math.cos(h)*(e-i)/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)));r===s&&(p*=-1),isNaN(p)&&(p=0);const f=p*a*d/o,m=p*-o*c/a,g=(t+n)/2+Math.cos(h)*f-Math.sin(h)*m,_=(e+i)/2+Math.sin(h)*f+Math.cos(h)*m,v=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])/(v(t)*v(e))},x=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},S=x([1,0],[(c-f)/a,(d-m)/o]),b=[(c-f)/a,(d-m)/o],M=[(-1*c-f)/a,(-1*d-m)/o];let w=x(b,M);return y(b,M)<=-1&&(w=Math.PI),y(b,M)>=1&&(w=0),0===s&&w>0&&(w-=2*Math.PI),1===s&&w<0&&(w+=2*Math.PI),[g,_,a,o,S,w,h,s]}};return Lu.Path=r,r.prototype.className="Path",r.prototype._attrsAffectingSize=["data"],(0,n._registerNode)(r),t.Factory.addGetterSetter(r,"data"),Lu}var Nu,Uu={};var Ou,Fu={};var ku,Bu={};var zu,Gu={};var Hu,Vu={};function Wu(){if(Hu)return Vu;Hu=1,Object.defineProperty(Vu,"__esModule",{value:!0}),Vu.Rect=void 0;const t=kd(),e=lu(),n=Cd(),i=Ld(),r=Fd();let s=class extends e.Shape{_sceneFunc(t){const e=this.cornerRadius(),n=this.width(),r=this.height();t.beginPath(),e?i.Util.drawRoundedRectPath(t,n,r,e):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}};return Vu.Rect=s,s.prototype.className="Rect",(0,n._registerNode)(s),t.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),Vu}var Xu,ju={};var Yu,qu={};var Ku,Zu={};var Ju,Qu={};var $u,tp={};function ep(){if($u)return tp;$u=1,Object.defineProperty(tp,"__esModule",{value:!0}),tp.Text=void 0,tp.stringToArray=a;const t=Ld(),e=kd(),n=lu(),i=Cd(),r=Fd(),s=Cd();function a(t){return[...t].reduce(((t,e,n,i)=>(/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?(?:\u200D\p{Emoji_Presentation})+/u.test(e)?t.push(e):/\p{Regional_Indicator}{2}/u.test(e+(i[n+1]||""))?t.push(e+i[n+1]):n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:t.push(e),t)),[])}const o="auto",l="inherit",h="justify",c="left",d="middle",u="normal",p=" ",f="none",m=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],g=m.length;let _;function v(){return _||(_=t.Util.createCanvasElement().getContext("2d"),_)}let y=class extends n.Shape{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<g;t++)this.on(m[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,n=e.length;if(!this.text())return;let r,s=this.padding(),o=this.fontSize(),u=this.lineHeight()*o,p=this.verticalAlign(),f=this.direction(),m=0,g=this.align(),_=this.getWidth(),v=this.letterSpacing(),y=this.fill(),x=this.textDecoration(),S=-1!==x.indexOf("underline"),b=-1!==x.indexOf("line-through");f=f===l?t.direction:f;let M=u/2,w=d;if(i.Konva._fixTextRendering){const t=this.measureSize("M");w="alphabetic",M=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+u/2}var E=0,T=0;for("rtl"===f&&t.setAttr("direction",f),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",w),t.setAttr("textAlign",c),p===d?m=(this.getHeight()-n*u-2*s)/2:"bottom"===p&&(m=this.getHeight()-n*u-2*s),t.translate(s,m+s),r=0;r<n;r++){E=0,T=0;var A,C,R,P=e[r],L=P.text,I=P.width,D=P.lastInParagraph;if(t.save(),"right"===g?E+=_-I-2*s:"center"===g&&(E+=(_-I-2*s)/2),S){t.save(),t.beginPath();const e=E,n=M+T+(i.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,n),C=0===(A=L.split(" ").length-1),R=g!==h||D?I:_-2*s,t.lineTo(e+Math.round(R),n),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||y,t.stroke(),t.restore()}if(b){t.save(),t.beginPath();const e=i.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(E,M+T+e),C=0===(A=L.split(" ").length-1),R=g===h&&D&&!C?_-2*s:I,t.lineTo(E+Math.round(R),M+T+e),t.lineWidth=o/15;const n=this._getLinearGradient();t.strokeStyle=n||y,t.stroke(),t.restore()}if("rtl"===f||0===v&&g!==h)0!==v&&t.setAttr("letterSpacing",`${v}px`),this._partialTextX=E,this._partialTextY=M+T,this._partialText=L,t.fillStrokeShape(this);else{A=L.split(" ").length-1;const e=a(L);for(let n=0;n<e.length;n++){const i=e[n];" "!==i||D||g!==h||(E+=(_-2*s-I)/A),this._partialTextX=E,this._partialTextY=M+T,this._partialText=i,t.fillStrokeShape(this),E+=this.measureSize(i).width+v}}t.restore(),n>1&&(M+=u)}}_hitFunc(t){const e=this.getWidth(),n=this.getHeight();t.beginPath(),t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)}setText(e){const n=t.Util._isString(e)?e:null==e?"":e+"";return this._setAttr("text",n),this}getWidth(){return this.attrs.width===o||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===o||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.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,n,i,r,s,a,o,l,h,c,d;let u,p=v(),f=this.fontSize();p.save(),p.font=this._getContextFont(),u=p.measureText(t),p.restore();const m=f/100;return{actualBoundingBoxAscent:null!==(e=u.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*m,actualBoundingBoxDescent:null!==(n=u.actualBoundingBoxDescent)&&void 0!==n?n:0,actualBoundingBoxLeft:null!==(i=u.actualBoundingBoxLeft)&&void 0!==i?i:-7.421875*m,actualBoundingBoxRight:null!==(r=u.actualBoundingBoxRight)&&void 0!==r?r:75.732421875*m,alphabeticBaseline:null!==(s=u.alphabeticBaseline)&&void 0!==s?s:0,emHeightAscent:null!==(a=u.emHeightAscent)&&void 0!==a?a:100*m,emHeightDescent:null!==(o=u.emHeightDescent)&&void 0!==o?o:-20*m,fontBoundingBoxAscent:null!==(l=u.fontBoundingBoxAscent)&&void 0!==l?l:91*m,fontBoundingBoxDescent:null!==(h=u.fontBoundingBoxDescent)&&void 0!==h?h:21*m,hangingBaseline:null!==(c=u.hangingBaseline)&&void 0!==c?c:72.80000305175781*m,ideographicBaseline:null!==(d=u.ideographicBaseline)&&void 0!==d?d:-21*m,width:u.width,height:f}}_getContextFont(){return this.fontStyle()+p+this.fontVariant()+p+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,n=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!n&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===h&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),n=t.length;return v().measureText(t).width+(n?e*(n-1):0)}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),n=0,i=this.lineHeight()*e,r=this.attrs.width,s=this.attrs.height,a=r!==o&&void 0!==r,l=s!==o&&void 0!==s,h=this.padding(),c=r-2*h,d=s-2*h,u=0,m=this.wrap(),g="char"!==m&&m!==f,_=this.ellipsis();this.textArr=[],v().font=this._getContextFont();const y=_?this._getTextWidth("…"):0;for(let e=0,r=t.length;e<r;++e){let s=t[e],o=this._getTextWidth(s);if(a&&o>c)for(;s.length>0;){let t=0,e=s.length,r="",a=0;for(;t<e;){const n=t+e>>>1,i=s.slice(0,n+1),o=this._getTextWidth(i)+y;o<=c?(t=n+1,r=i,a=o):e=n}if(!r)break;if(g){var x;const e=s[r.length];(x=(e===p||"-"===e)&&a<=c?r.length:Math.max(r.lastIndexOf(p),r.lastIndexOf("-"))+1)>0&&(t=x,r=r.slice(0,t),a=this._getTextWidth(r))}r=r.trimRight(),this._addTextLine(r),n=Math.max(n,a),u+=i;if(this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}if(s=s.slice(t),s=s.trimLeft(),s.length>0&&(o=this._getTextWidth(s),o<=c)){this._addTextLine(s),u+=i,n=Math.max(n,o);break}}else this._addTextLine(s),u+=i,n=Math.max(n,o),this._shouldHandleEllipsis(u)&&e<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&u+i>d)break}this.textHeight=e,this.textWidth=n}_shouldHandleEllipsis(t){const e=+this.fontSize(),n=this.lineHeight()*e,i=this.attrs.height,r=i!==o&&void 0!==i,s=i-2*this.padding();return!(this.wrap()!==f)||r&&t+n>s}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==o&&void 0!==t,n=t-2*this.padding(),i=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&i){if(e){this._getTextWidth(r.text+"…")<n||(r.text=r.text.slice(0,r.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.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()}};return tp.Text=y,y.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},y.prototype.className="Text",y.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,s._registerNode)(y),e.Factory.overWriteSetter(y,"width",(0,r.getNumberOrAutoValidator)()),e.Factory.overWriteSetter(y,"height",(0,r.getNumberOrAutoValidator)()),e.Factory.addGetterSetter(y,"direction",l),e.Factory.addGetterSetter(y,"fontFamily","Arial"),e.Factory.addGetterSetter(y,"fontSize",12,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"fontStyle",u),e.Factory.addGetterSetter(y,"fontVariant",u),e.Factory.addGetterSetter(y,"padding",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"align",c),e.Factory.addGetterSetter(y,"verticalAlign","top"),e.Factory.addGetterSetter(y,"lineHeight",1,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"wrap","word"),e.Factory.addGetterSetter(y,"ellipsis",!1,(0,r.getBooleanValidator)()),e.Factory.addGetterSetter(y,"letterSpacing",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(y,"text","",(0,r.getStringValidator)()),e.Factory.addGetterSetter(y,"textDecoration",""),tp}var np,ip={};var rp,sp={};function ap(){if(rp)return sp;rp=1,Object.defineProperty(sp,"__esModule",{value:!0}),sp.Transformer=void 0;const t=Ld(),e=kd(),n=Kd(),i=lu(),r=Wu(),s=fu(),a=Cd(),o=Fd(),l=Cd(),h="tr-konva",c=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map((t=>t+`.${h}`)).join(" "),d="nodesRect",u=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],p={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},f="ontouchstart"in a.Konva._global;const m=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function g(t,e,n){const i=n.x+(t.x-n.x)*Math.cos(e)-(t.y-n.y)*Math.sin(e),r=n.y+(t.x-n.x)*Math.sin(e)+(t.y-n.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:i,y:r}}function _(t,e){const n=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 g(t,e,n)}let v=0,y=class extends s.Group{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(c,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(e){return t.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return h+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const n=e.filter((e=>!e.isAncestorOf(this)||(t.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=e=n,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[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()},n=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(n,e),t.on(u.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()}`,(n=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(n,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(n=>{if(!e)return;const i=t.getAbsolutePosition(),r=i.x-e.x,s=i.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const i=e.getAbsolutePosition();e.setAbsolutePosition({x:i.x+r,y:i.y+s}),e.startDrag(n)})),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(d),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(d,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),n){const i=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(n),s=t.getAbsolutePosition(n),o=i.x*r.x-t.offsetX()*r.x,l=i.y*r.y-t.offsetY()*r.y,h=(a.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return g({x:s.x+o*Math.cos(h)+l*Math.sin(-h),y:s.y+l*Math.cos(h)+o*Math.sin(h),width:i.width*r.x,height:i.height*r.y,rotation:h},-a.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],r=t.getAbsoluteTransform();i.forEach((function(t){const n=r.point(t);e.push(n)}))}));const n=new t.Transform;n.rotate(-a.Konva.getAngle(this.rotation()));let i=1/0,r=1/0,s=-1/0,o=-1/0;e.forEach((function(t){const e=n.point(t);void 0===i&&(i=s=e.x,r=o=e.y),i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),o=Math.max(o,e.y)})),n.invert();const l=n.point({x:i,y:r});return{x:l.x,y:l.y,width:s-i,height:o-r,rotation:a.Konva.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(),m.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(e){const n=new r.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:f?10:"auto"}),i=this;n.on("mousedown touchstart",(function(t){i._handleMouseDown(t)})),n.on("dragstart",(t=>{n.stopDrag(),t.cancelBubble=!0})),n.on("dragend",(t=>{t.cancelBubble=!0})),n.on("mouseenter",(()=>{const i=a.Konva.getAngle(this.rotation()),r=this.rotateAnchorCursor(),s=function(e,n,i){if("rotater"===e)return i;n+=t.Util.degToRad(p[e]||0);const r=(t.Util.radToDeg(n)%360+360)%360;return t.Util._inRange(r,337.5,360)||t.Util._inRange(r,0,22.5)?"ns-resize":t.Util._inRange(r,22.5,67.5)?"nesw-resize":t.Util._inRange(r,67.5,112.5)?"ew-resize":t.Util._inRange(r,112.5,157.5)?"nwse-resize":t.Util._inRange(r,157.5,202.5)?"ns-resize":t.Util._inRange(r,202.5,247.5)?"nesw-resize":t.Util._inRange(r,247.5,292.5)?"ew-resize":t.Util._inRange(r,292.5,337.5)?"nwse-resize":(t.Util.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}(e,i,r);n.getStage().content&&(n.getStage().content.style.cursor=s),this._cursorChange=!0})),n.on("mouseout",(()=>{n.getStage().content&&(n.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(n)}_createBack(){const e=new i.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(e,n){const i=n.getParent(),r=i.padding();e.beginPath(),e.rect(-r,-r,n.width()+2*r,n.height()+2*r),e.moveTo(n.width()/2,-r),i.rotateEnabled()&&i.rotateLineVisible()&&e.lineTo(n.width()/2,-i.rotateAnchorOffset()*t.Util._sign(n.height())-r),e.fillStrokeShape(n)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const n=this.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.fillStrokeShape(e)}});this.add(e),this._proxyDrag(e),e.on("dragstart",(t=>{t.cancelBubble=!0})),e.on("dragmove",(t=>{t.cancelBubble=!0})),e.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(),n=e.width,i=e.height,r=Math.sqrt(Math.pow(n,2)+Math.pow(i,2));this.sin=Math.abs(i/r),this.cos=Math.abs(n/r),"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 s=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-s.x,y:a.y-s.y},v++,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,n,i;const r=this.findOne("."+this._movingAnchorName),s=r.getStage();s.setPointersPositions(t);const o=s.getPointerPosition();let l={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const h=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(l=this.anchorDragBoundFunc()(h,l,t)),r.setAbsolutePosition(l);const c=r.getAbsolutePosition();if(h.x===c.x&&h.y===c.y)return;if("rotater"===this._movingAnchorName){const i=this._getNodeRect();e=r.x()-i.width/2,n=-r.y()+i.height/2;let s=Math.atan2(-n,e)+Math.PI/2;i.height<0&&(s-=Math.PI);const o=a.Konva.getAngle(this.rotation())+s,l=a.Konva.getAngle(this.rotationSnapTolerance()),h=function(t,e,n){let i=e;for(let r=0;r<t.length;r++){const s=a.Konva.getAngle(t[r]),o=Math.abs(s-e)%(2*Math.PI);Math.min(o,2*Math.PI-o)<n&&(i=s)}return i}(this.rotationSnaps(),o,l),c=_(i,h-i.rotation);return void this._fitNodesInto(c,t)}const d=this.shiftBehavior();let u;u="inverted"===d?this.keepRatio()&&!t.shiftKey:"none"===d?this.keepRatio():this.keepRatio()||t.shiftKey;var p=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(u){var f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};i=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(f.y-r.y(),2));var m=this.findOne(".top-left").x()>f.x?-1:1,g=this.findOne(".top-left").y()>f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,this.findOne(".top-left").x(f.x-e),this.findOne(".top-left").y(f.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(u){f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};i=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(f.y-r.y(),2));m=this.findOne(".top-right").x()<f.x?-1:1,g=this.findOne(".top-right").y()>f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,this.findOne(".top-right").x(f.x+e),this.findOne(".top-right").y(f.y-n)}var v=r.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(u){f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};i=Math.sqrt(Math.pow(f.x-r.x(),2)+Math.pow(r.y()-f.y,2));m=f.x<r.x()?-1:1,g=r.y()<f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,r.x(f.x-e),r.y(f.y+n)}v=r.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(r.y());else if("bottom-right"===this._movingAnchorName){if(u){f=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};i=Math.sqrt(Math.pow(r.x()-f.x,2)+Math.pow(r.y()-f.y,2));m=this.findOne(".bottom-right").x()<f.x?-1:1,g=this.findOne(".bottom-right").y()<f.y?-1:1;e=i*this.cos*m,n=i*this.sin*g,this.findOne(".bottom-right").x(f.x+e),this.findOne(".bottom-right").y(f.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(p=this.centeredScaling()||t.altKey){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),n=t.x(),i=t.y(),r=this.getWidth()-e.x(),s=this.getHeight()-e.y();e.move({x:-n,y:-i}),t.move({x:r,y:s})}const y=this.findOne(".top-left").getAbsolutePosition();e=y.x,n=y.y;const x=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),S=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:n,width:x,height:S,rotation:a.Konva.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 n=this.getNode();v--,this._fire("transformend",{evt:t,target:n}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),n&&this._nodes.forEach((e=>{var n;e._fire("transformend",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(e,n){const i=this._getNodeRect();if(t.Util._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(t.Util._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=new t.Transform;if(r.rotate(a.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding()}if(this.boundBoxFunc()){const n=this.boundBoxFunc()(i,e);n?e=n:t.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const s=1e7,o=new t.Transform;o.translate(i.x,i.y),o.rotate(i.rotation),o.scale(i.width/s,i.height/s);const l=new t.Transform,h=e.width/s,c=e.height/s;!1===this.flipEnabled()?(l.translate(e.x,e.y),l.rotate(e.rotation),l.translate(e.width<0?e.width:0,e.height<0?e.height:0),l.scale(Math.abs(h),Math.abs(c))):(l.translate(e.x,e.y),l.rotate(e.rotation),l.scale(h,c));const d=l.multiply(o.invert());this._nodes.forEach((e=>{var n;const i=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const s=new t.Transform;s.multiply(i.copy().invert()).multiply(d).multiply(i).multiply(r);const a=s.decompose();e.setAttrs(a),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this.rotation(t.Util._getRotation(e.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:n,target:t}),t._fire("transform",{evt:n,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var e;const n=this._getNodeRect();this.rotation(t.Util._getRotation(n.rotation));const i=n.width,r=n.height,s=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),l=this.anchorSize(),h=this.find("._anchor");h.forEach((t=>{t.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+o,offsetY:l/2+o,visible:a&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:l/2+o,visible:a&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:l/2-o,offsetY:l/2+o,visible:a&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:l/2+o,visible:a&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:r/2,offsetX:l/2-o,visible:a&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:l/2+o,offsetY:l/2-o,visible:a&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:r,offsetY:l/2-o,visible:a&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:r,offsetX:l/2-o,offsetY:l/2-o,visible:a&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*t.Util._sign(r)-o,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const c=this.anchorStyleFunc();c&&h.forEach((t=>{c(t)})),null===(e=this.getLayer())||void 0===e||e.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=""),s.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return n.Node.prototype.toObject.call(this)}clone(t){return n.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};return sp.Transformer=y,y.isTransforming=()=>v>0,y.prototype.className="Transformer",(0,l._registerNode)(y),e.Factory.addGetterSetter(y,"enabledAnchors",m,(function(e){return e instanceof Array||t.Util.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===m.indexOf(e)&&t.Util.warn("Unknown anchor name: "+e+". Available names are: "+m.join(", "))})),e||[]})),e.Factory.addGetterSetter(y,"flipEnabled",!0,(0,o.getBooleanValidator)()),e.Factory.addGetterSetter(y,"resizeEnabled",!0),e.Factory.addGetterSetter(y,"anchorSize",10,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateEnabled",!0),e.Factory.addGetterSetter(y,"rotateLineVisible",!0),e.Factory.addGetterSetter(y,"rotationSnaps",[]),e.Factory.addGetterSetter(y,"rotateAnchorOffset",50,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"rotateAnchorCursor","crosshair"),e.Factory.addGetterSetter(y,"rotationSnapTolerance",5,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderEnabled",!0),e.Factory.addGetterSetter(y,"anchorStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"anchorStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"anchorFill","white"),e.Factory.addGetterSetter(y,"anchorCornerRadius",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderStroke","rgb(0, 161, 255)"),e.Factory.addGetterSetter(y,"borderStrokeWidth",1,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"borderDash"),e.Factory.addGetterSetter(y,"keepRatio",!0),e.Factory.addGetterSetter(y,"shiftBehavior","default"),e.Factory.addGetterSetter(y,"centeredScaling",!1),e.Factory.addGetterSetter(y,"ignoreStroke",!1),e.Factory.addGetterSetter(y,"padding",0,(0,o.getNumberValidator)()),e.Factory.addGetterSetter(y,"node"),e.Factory.addGetterSetter(y,"nodes"),e.Factory.addGetterSetter(y,"boundBoxFunc"),e.Factory.addGetterSetter(y,"anchorDragBoundFunc"),e.Factory.addGetterSetter(y,"anchorStyleFunc"),e.Factory.addGetterSetter(y,"shouldOverdrawWholeArea",!1),e.Factory.addGetterSetter(y,"useSingleNodeRotation",!0),e.Factory.backCompat(y,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"}),sp}var op,lp={};var hp,cp={};function dp(){if(hp)return cp;hp=1,Object.defineProperty(cp,"__esModule",{value:!0}),cp.Blur=void 0;const t=kd(),e=Kd(),n=Fd();function i(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const r=[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],s=[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];return cp.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const n=t.data,a=t.width,o=t.height;let l,h,c,d,u,p,f,m,g,_,v,y,x,S,b,M,w,E,T,A,C,R,P,L,I=e+e+1,D=a-1,N=o-1,U=e+1,O=U*(U+1)/2,F=new i,k=null,B=F,z=null,G=null,H=r[e],V=s[e];for(c=1;c<I;c++)B=B.next=new i,c===U&&(k=B);for(B.next=F,f=p=0,h=0;h<o;h++){for(M=w=E=T=m=g=_=v=0,y=U*(A=n[p]),x=U*(C=n[p+1]),S=U*(R=n[p+2]),b=U*(P=n[p+3]),m+=O*A,g+=O*C,_+=O*R,v+=O*P,B=F,c=0;c<U;c++)B.r=A,B.g=C,B.b=R,B.a=P,B=B.next;for(c=1;c<U;c++)d=p+((D<c?D:c)<<2),m+=(B.r=A=n[d])*(L=U-c),g+=(B.g=C=n[d+1])*L,_+=(B.b=R=n[d+2])*L,v+=(B.a=P=n[d+3])*L,M+=A,w+=C,E+=R,T+=P,B=B.next;for(z=F,G=k,l=0;l<a;l++)n[p+3]=P=v*H>>V,0!==P?(P=255/P,n[p]=(m*H>>V)*P,n[p+1]=(g*H>>V)*P,n[p+2]=(_*H>>V)*P):n[p]=n[p+1]=n[p+2]=0,m-=y,g-=x,_-=S,v-=b,y-=z.r,x-=z.g,S-=z.b,b-=z.a,d=f+((d=l+e+1)<D?d:D)<<2,M+=z.r=n[d],w+=z.g=n[d+1],E+=z.b=n[d+2],T+=z.a=n[d+3],m+=M,g+=w,_+=E,v+=T,z=z.next,y+=A=G.r,x+=C=G.g,S+=R=G.b,b+=P=G.a,M-=A,w-=C,E-=R,T-=P,G=G.next,p+=4;f+=a}for(l=0;l<a;l++){for(w=E=T=M=g=_=v=m=0,p=l<<2,y=U*(A=n[p]),x=U*(C=n[p+1]),S=U*(R=n[p+2]),b=U*(P=n[p+3]),m+=O*A,g+=O*C,_+=O*R,v+=O*P,B=F,c=0;c<U;c++)B.r=A,B.g=C,B.b=R,B.a=P,B=B.next;for(u=a,c=1;c<=e;c++)p=u+l<<2,m+=(B.r=A=n[p])*(L=U-c),g+=(B.g=C=n[p+1])*L,_+=(B.b=R=n[p+2])*L,v+=(B.a=P=n[p+3])*L,M+=A,w+=C,E+=R,T+=P,B=B.next,c<N&&(u+=a);for(p=l,z=F,G=k,h=0;h<o;h++)d=p<<2,n[d+3]=P=v*H>>V,P>0?(P=255/P,n[d]=(m*H>>V)*P,n[d+1]=(g*H>>V)*P,n[d+2]=(_*H>>V)*P):n[d]=n[d+1]=n[d+2]=0,m-=y,g-=x,_-=S,v-=b,y-=z.r,x-=z.g,S-=z.b,b-=z.a,d=l+((d=h+U)<N?d:N)*a<<2,m+=M+=z.r=n[d],g+=w+=z.g=n[d+1],_+=E+=z.b=n[d+2],v+=T+=z.a=n[d+3],z=z.next,y+=A=G.r,x+=C=G.g,S+=R=G.b,b+=P=G.a,M-=A,w-=C,E-=R,T-=P,G=G.next,p+=a}}(t,e)},t.Factory.addGetterSetter(e.Node,"blurRadius",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),cp}var up,pp={};var fp,mp={};var gp,_p={};var vp,yp={};var xp,Sp={};var bp,Mp={};var wp,Ep={};var Tp,Ap={};var Cp,Rp={};function Pp(){if(Cp)return Rp;Cp=1,Object.defineProperty(Rp,"__esModule",{value:!0}),Rp.Kaleidoscope=void 0;const t=kd(),e=Kd(),n=Ld(),i=Fd();return Rp.Kaleidoscope=function(t){const e=t.width,i=t.height;let r,s,a,o,l,h,c,d,u,p,f=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(m%360)/360);if(f<1)return;const _=n.Util.createCanvasElement();_.width=e,_.height=i;const v=_.getContext("2d").getImageData(0,0,e,i);n.Util.releaseCanvas(_),function(t,e,n){let i,r,s,a,o=t.data,l=e.data,h=t.width,c=t.height,d=n.polarCenterX||h/2,u=n.polarCenterY||c/2,p=0,f=0,m=0,g=0,_=Math.sqrt(d*d+u*u);r=h-d,s=c-u,a=Math.sqrt(r*r+s*s),_=a>_?a:_;let v,y,x,S,b=c,M=h,w=360/M*Math.PI/180;for(y=0;y<M;y+=1)for(x=Math.sin(y*w),S=Math.cos(y*w),v=0;v<b;v+=1)r=Math.floor(d+_*v/b*S),s=Math.floor(u+_*v/b*x),i=4*(s*h+r),p=o[i+0],f=o[i+1],m=o[i+2],g=o[i+3],i=4*(y+v*h),l[i+0]=p,l[i+1]=f,l[i+2]=m,l[i+3]=g}(t,v,{polarCenterX:e/2,polarCenterY:i/2});let y=e/Math.pow(2,f);for(;y<=8;)y*=2,f-=1;y=Math.ceil(y);let x=y,S=0,b=x,M=1;for(g+y>e&&(S=x,b=0,M=-1),s=0;s<i;s+=1)for(r=S;r!==b;r+=M)a=Math.round(r+g)%e,u=4*(e*s+a),l=v.data[u+0],h=v.data[u+1],c=v.data[u+2],d=v.data[u+3],p=4*(e*s+r),v.data[p+0]=l,v.data[p+1]=h,v.data[p+2]=c,v.data[p+3]=d;for(s=0;s<i;s+=1)for(x=Math.floor(y),o=0;o<f;o+=1){for(r=0;r<x+1;r+=1)u=4*(e*s+r),l=v.data[u+0],h=v.data[u+1],c=v.data[u+2],d=v.data[u+3],p=4*(e*s+2*x-r-1),v.data[p+0]=l,v.data[p+1]=h,v.data[p+2]=c,v.data[p+3]=d;x*=2}!function(t,e,n){let i,r,s,a,o,l,h=t.data,c=e.data,d=t.width,u=t.height,p=n.polarCenterX||d/2,f=n.polarCenterY||u/2,m=0,g=0,_=0,v=0,y=Math.sqrt(p*p+f*f);r=d-p,s=u-f,l=Math.sqrt(r*r+s*s),y=l>y?l:y;let x,S,b,M,w=u,E=d;for(r=0;r<d;r+=1)for(s=0;s<u;s+=1)a=r-p,o=s-f,x=Math.sqrt(a*a+o*o)*w/y,S=(180*Math.atan2(o,a)/Math.PI+360+0)%360,S=S*E/360,b=Math.floor(S),M=Math.floor(x),i=4*(M*d+b),m=h[i+0],g=h[i+1],_=h[i+2],v=h[i+3],i=4*(s*d+r),c[i+0]=m,c[i+1]=g,c[i+2]=_,c[i+3]=v}(v,t,{polarRotation:0})},t.Factory.addGetterSetter(e.Node,"kaleidoscopePower",2,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"kaleidoscopeAngle",0,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Rp}var Lp,Ip={};function Dp(){if(Lp)return Ip;Lp=1,Object.defineProperty(Ip,"__esModule",{value:!0}),Ip.Mask=void 0;const t=kd(),e=Kd(),n=Fd();function i(t,e,n){let i=4*(n*t.width+e);const r=[];return r.push(t.data[i++],t.data[i++],t.data[i++],t.data[i++]),r}function r(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))}return Ip.Mask=function(t){let e=function(t,e){const n=i(t,0,0),s=i(t,t.width-1,0),a=i(t,0,t.height-1),o=i(t,t.width-1,t.height-1),l=e||10;if(r(n,s)<l&&r(s,o)<l&&r(o,a)<l&&r(a,n)<l){const e=function(t){const e=[0,0,0];for(let n=0;n<t.length;n++)e[0]+=t[n][0],e[1]+=t[n][1],e[2]+=t[n][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([s,n,o,a]),i=[];for(let n=0;n<t.width*t.height;n++){const s=r(e,[t.data[4*n],t.data[4*n+1],t.data[4*n+2]]);i[n]=s<l?0:255}return i}}(t,this.threshold());return e&&(e=function(t,e,n){const i=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(i.length)),s=Math.floor(r/2),a=[];for(let o=0;o<n;o++)for(let l=0;l<e;l++){const h=o*e+l;let c=0;for(let a=0;a<r;a++)for(let h=0;h<r;h++){const d=o+a-s,u=l+h-s;if(d>=0&&d<n&&u>=0&&u<e){const n=i[a*r+h];c+=t[d*e+u]*n}}a[h]=2040===c?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const i=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(i.length)),s=Math.floor(r/2),a=[];for(let o=0;o<n;o++)for(let l=0;l<e;l++){const h=o*e+l;let c=0;for(let a=0;a<r;a++)for(let h=0;h<r;h++){const d=o+a-s,u=l+h-s;if(d>=0&&d<n&&u>=0&&u<e){const n=i[a*r+h];c+=t[d*e+u]*n}}a[h]=c>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const i=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(i.length)),s=Math.floor(r/2),a=[];for(let o=0;o<n;o++)for(let l=0;l<e;l++){const h=o*e+l;let c=0;for(let a=0;a<r;a++)for(let h=0;h<r;h++){const d=o+a-s,u=l+h-s;if(d>=0&&d<n&&u>=0&&u<e){const n=i[a*r+h];c+=t[d*e+u]*n}}a[h]=c}return a}(e,t.width,t.height),function(t,e){for(let n=0;n<t.width*t.height;n++)t.data[4*n+3]=e[n]}(t,e)),t},t.Factory.addGetterSetter(e.Node,"threshold",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Ip}var Np,Up={};var Op,Fp={};var kp,Bp={};var zp,Gp={};var Hp,Vp={};var Wp,Xp={};var jp,Yp={};var qp,Kp,Zp={};function Jp(){if(Kp)return Ed;Kp=1,Object.defineProperty(Ed,"__esModule",{value:!0}),Ed.Konva=void 0;const t=Su(),e=function(){if(bu)return Mu;bu=1,Object.defineProperty(Mu,"__esModule",{value:!0}),Mu.Arc=void 0;const t=kd(),e=lu(),n=Cd(),i=Fd(),r=Cd();let s=class extends e.Shape{_sceneFunc(t){const e=n.Konva.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(),r=n.Konva.getAngle(i?360-this.angle():this.angle()),s=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),o=Math.sin(Math.min(r,Math.PI/2)),l=s*(s>0?t:e),h=a*(a>0?t:e),c=o*(o>0?e:t);return{x:l,y:i?-1*c:h,width:1*e-l,height:c-h}}};return Mu.Arc=s,s.prototype._centroid=!0,s.prototype.className="Arc",s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1,(0,i.getBooleanValidator)()),Mu}(),n=function(){if(Pu)return Eu;Pu=1,Object.defineProperty(Eu,"__esModule",{value:!0}),Eu.Arrow=void 0;const t=kd(),e=Au(),n=Fd(),i=Cd(),r=Du();let s=class extends e.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,n=this.points();let i=n;const s=0!==this.tension()&&n.length>4;s&&(i=this.getTensionPoints());const a=this.pointerLength(),o=n.length;let l,h;if(s){const t=[i[i.length-4],i[i.length-3],i[i.length-2],i[i.length-1],n[o-2],n[o-1]],e=r.Path.calcLength(i[i.length-4],i[i.length-3],"C",t),s=r.Path.getPointOnQuadraticBezier(Math.min(1,1-a/e),t[0],t[1],t[2],t[3],t[4],t[5]);l=n[o-2]-s.x,h=n[o-1]-s.y}else l=n[o-2]-n[o-4],h=n[o-1]-n[o-3];const c=(Math.atan2(h,l)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(n[o-2],n[o-1]),t.rotate(c),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(n[0],n[1]),s?(l=(i[0]+i[2])/2-n[0],h=(i[1]+i[3])/2-n[1]):(l=n[2]-n[0],h=n[3]-n[1]),t.rotate((Math.atan2(-h,-l)+e)%e),t.moveTo(0,0),t.lineTo(-a,d/2),t.lineTo(-a,-d/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-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}};return Eu.Arrow=s,s.prototype.className="Arrow",(0,i._registerNode)(s),t.Factory.addGetterSetter(s,"pointerLength",10,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerWidth",10,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"pointerAtBeginning",!1),t.Factory.addGetterSetter(s,"pointerAtEnding",!0),Eu}(),i=function(){if(Nu)return Uu;Nu=1,Object.defineProperty(Uu,"__esModule",{value:!0}),Uu.Circle=void 0;const t=kd(),e=lu(),n=Fd(),i=Cd();let r=class extends e.Shape{_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)}};return Uu.Circle=r,r.prototype._centroid=!0,r.prototype.className="Circle",r.prototype._attrsAffectingSize=["radius"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,n.getNumberValidator)()),Uu}(),r=function(){if(Ou)return Fu;Ou=1,Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.Ellipse=void 0;const t=kd(),e=lu(),n=Fd(),i=Cd();let r=class extends e.Shape{_sceneFunc(t){const e=this.radiusX(),n=this.radiusY();t.beginPath(),t.save(),e!==n&&t.scale(1,n/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)}};return Fu.Ellipse=r,r.prototype.className="Ellipse",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,i._registerNode)(r),t.Factory.addComponentsGetterSetter(r,"radius",["x","y"]),t.Factory.addGetterSetter(r,"radiusX",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"radiusY",0,(0,n.getNumberValidator)()),Fu}(),s=function(){if(ku)return Bu;ku=1,Object.defineProperty(Bu,"__esModule",{value:!0}),Bu.Image=void 0;const t=Ld(),e=kd(),n=lu(),i=Cd(),r=Fd();class s extends n.Shape{constructor(t){super(t),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(e){const n=this.getWidth(),i=this.getHeight(),r=this.cornerRadius(),s=this.attrs.image;let a;if(s){const t=this.attrs.cropWidth,e=this.attrs.cropHeight;a=t&&e?[s,this.cropX(),this.cropY(),t,e,0,0,n,i]:[s,0,0,n,i]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?t.Util.drawRoundedRectPath(e,n,i,r):e.rect(0,0,n,i),e.closePath(),e.fillStrokeShape(this)),s&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){const n=this.width(),i=this.height(),r=this.cornerRadius();e.beginPath(),r?t.Util.drawRoundedRectPath(e,n,i,r):e.rect(0,0,n,i),e.closePath(),e.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(e,n,i=null){const r=t.Util.createImageElement();r.onload=function(){const t=new s({image:r});n(t)},r.onerror=i,r.crossOrigin="Anonymous",r.src=e}}return Bu.Image=s,s.prototype.className="Image",(0,i._registerNode)(s),e.Factory.addGetterSetter(s,"cornerRadius",0,(0,r.getNumberOrArrayOfNumbersValidator)(4)),e.Factory.addGetterSetter(s,"image"),e.Factory.addComponentsGetterSetter(s,"crop",["x","y","width","height"]),e.Factory.addGetterSetter(s,"cropX",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropY",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropWidth",0,(0,r.getNumberValidator)()),e.Factory.addGetterSetter(s,"cropHeight",0,(0,r.getNumberValidator)()),Bu}(),a=function(){if(zu)return Gu;zu=1,Object.defineProperty(Gu,"__esModule",{value:!0}),Gu.Tag=Gu.Label=void 0;const t=kd(),e=lu(),n=fu(),i=Fd(),r=Cd(),s=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],a="up",o="right",l="down",h="left",c=s.length;let d=class extends n.Group{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,n=this;const i=function(){n._sync()};for(e=0;e<c;e++)t.on(s[e]+"Change.konva",i)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,n,i,r,s,c,d=this.getText(),u=this.getTag();if(d&&u){switch(t=d.width(),e=d.height(),n=u.pointerDirection(),i=u.pointerWidth(),c=u.pointerHeight(),r=0,s=0,n){case a:r=t/2,s=-1*c;break;case o:r=t+i,s=e/2;break;case l:r=t/2,s=e+c;break;case h:r=-1*i,s=e/2}u.setAttrs({x:-1*r,y:-1*s,width:t,height:e}),d.setAttrs({x:-1*r,y:-1*s})}}};Gu.Label=d,d.prototype.className="Label",(0,r._registerNode)(d);class u extends e.Shape{_sceneFunc(t){const e=this.width(),n=this.height(),i=this.pointerDirection(),r=this.pointerWidth(),s=this.pointerHeight(),c=this.cornerRadius();let d=0,u=0,p=0,f=0;"number"==typeof c?d=u=p=f=Math.min(c,e/2,n/2):(d=Math.min(c[0]||0,e/2,n/2),u=Math.min(c[1]||0,e/2,n/2),f=Math.min(c[2]||0,e/2,n/2),p=Math.min(c[3]||0,e/2,n/2)),t.beginPath(),t.moveTo(d,0),i===a&&(t.lineTo((e-r)/2,0),t.lineTo(e/2,-1*s),t.lineTo((e+r)/2,0)),t.lineTo(e-u,0),t.arc(e-u,u,u,3*Math.PI/2,0,!1),i===o&&(t.lineTo(e,(n-s)/2),t.lineTo(e+r,n/2),t.lineTo(e,(n+s)/2)),t.lineTo(e,n-f),t.arc(e-f,n-f,f,0,Math.PI/2,!1),i===l&&(t.lineTo((e+r)/2,n),t.lineTo(e/2,n+s),t.lineTo((e-r)/2,n)),t.lineTo(p,n),t.arc(p,n-p,p,Math.PI/2,Math.PI,!1),i===h&&(t.lineTo(0,(n+s)/2),t.lineTo(-1*r,n/2),t.lineTo(0,(n-s)/2)),t.lineTo(0,d),t.arc(d,d,d,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,n=this.pointerWidth(),i=this.pointerHeight(),r=this.pointerDirection(),s=this.width(),c=this.height();return r===a?(e-=i,c+=i):r===l?c+=i:r===h?(t-=1.5*n,s+=n):r===o&&(s+=1.5*n),{x:t,y:e,width:s,height:c}}}return Gu.Tag=u,u.prototype.className="Tag",(0,r._registerNode)(u),t.Factory.addGetterSetter(u,"pointerDirection","none"),t.Factory.addGetterSetter(u,"pointerWidth",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(u,"pointerHeight",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(u,"cornerRadius",0,(0,i.getNumberOrArrayOfNumbersValidator)(4)),Gu}(),o=Au(),l=Du(),h=Wu(),c=function(){if(Xu)return ju;Xu=1,Object.defineProperty(ju,"__esModule",{value:!0}),ju.RegularPolygon=void 0;const t=kd(),e=lu(),n=Fd(),i=Cd();let r=class extends e.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,n=[];for(let i=0;i<t;i++)n.push({x:e*Math.sin(2*i*Math.PI/t),y:-1*e*Math.cos(2*i*Math.PI/t)});return n}getSelfRect(){const t=this._getPoints();let e=t[0].x,n=t[0].y,i=t[0].x,r=t[0].y;return t.forEach((t=>{e=Math.min(e,t.x),n=Math.max(n,t.x),i=Math.min(i,t.y),r=Math.max(r,t.y)})),{x:e,y:i,width:n-e,height:r-i}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}};return ju.RegularPolygon=r,r.prototype.className="RegularPolygon",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["radius"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"radius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"sides",0,(0,n.getNumberValidator)()),ju}(),d=function(){if(Yu)return qu;Yu=1,Object.defineProperty(qu,"__esModule",{value:!0}),qu.Ring=void 0;const t=kd(),e=lu(),n=Fd(),i=Cd(),r=2*Math.PI;let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,r,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),r,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)}};return qu.Ring=s,s.prototype.className="Ring",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,i._registerNode)(s),t.Factory.addGetterSetter(s,"innerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(s,"outerRadius",0,(0,n.getNumberValidator)()),qu}(),u=function(){if(Ku)return Zu;Ku=1,Object.defineProperty(Zu,"__esModule",{value:!0}),Zu.Sprite=void 0;const t=kd(),e=lu(),n=_u(),i=Fd(),r=Cd();let s=class extends e.Shape{constructor(t){super(t),this._updated=!0,this.anim=new n.Animation((()=>{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(),n=this.frameIndex(),i=4*n,r=this.animations()[e],s=this.frameOffsets(),a=r[i+0],o=r[i+1],l=r[i+2],h=r[i+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,l,h),t.closePath(),t.fillStrokeShape(this)),c)if(s){const i=s[e],r=2*n;t.drawImage(c,a,o,l,h,i[r+0],i[r+1],l,h)}else t.drawImage(c,a,o,l,h,0,0,l,h)}_hitFunc(t){const e=this.animation(),n=this.frameIndex(),i=4*n,r=this.animations()[e],s=this.frameOffsets(),a=r[i+2],o=r[i+3];if(t.beginPath(),s){const i=s[e],r=2*n;t.rect(i[r+0],i[r+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)}};return Zu.Sprite=s,s.prototype.className="Sprite",(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"animation"),t.Factory.addGetterSetter(s,"animations"),t.Factory.addGetterSetter(s,"frameOffsets"),t.Factory.addGetterSetter(s,"image"),t.Factory.addGetterSetter(s,"frameIndex",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"frameRate",17,(0,i.getNumberValidator)()),t.Factory.backCompat(s,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Zu}(),p=function(){if(Ju)return Qu;Ju=1,Object.defineProperty(Qu,"__esModule",{value:!0}),Qu.Star=void 0;const t=kd(),e=lu(),n=Fd(),i=Cd();let r=class extends e.Shape{_sceneFunc(t){const e=this.innerRadius(),n=this.outerRadius(),i=this.numPoints();t.beginPath(),t.moveTo(0,0-n);for(let r=1;r<2*i;r++){const s=r%2==0?n:e,a=s*Math.sin(r*Math.PI/i),o=-1*s*Math.cos(r*Math.PI/i);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)}};return Qu.Star=r,r.prototype.className="Star",r.prototype._centroid=!0,r.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,i._registerNode)(r),t.Factory.addGetterSetter(r,"numPoints",5,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"innerRadius",0,(0,n.getNumberValidator)()),t.Factory.addGetterSetter(r,"outerRadius",0,(0,n.getNumberValidator)()),Qu}(),f=ep(),m=function(){if(np)return ip;np=1,Object.defineProperty(ip,"__esModule",{value:!0}),ip.TextPath=void 0;const t=Ld(),e=kd(),n=lu(),i=Du(),r=ep(),s=Fd(),a=Cd(),o="normal";function l(t){t.fillText(this.partialText,0,0)}function h(t){t.strokeText(this.partialText,0,0)}let c=class extends n.Shape{constructor(e){super(e),this.dummyCanvas=t.Util.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 i.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:i.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=i.Path.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(),n=this.fill(),i=this.fontSize(),r=this.glyphInfo;"underline"===e&&t.beginPath();for(let n=0;n<r.length;n++){t.save();const s=r[n].p0;t.translate(s.x,s.y),t.rotate(r[n].rotation),this.partialText=r[n].text,t.fillStrokeShape(this),"underline"===e&&(0===n&&t.moveTo(0,i/2+1),t.lineTo(i,i/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=n,t.lineWidth=i/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const n=e[0].p0;t.moveTo(n.x,n.y)}for(let n=0;n<e.length;n++){const i=e[n].p1;t.lineTo(i.x,i.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return t.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return r.Text.prototype.setText.call(this,t)}_getContextFont(){return r.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const n=e.measureText(t);return e.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const n=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);let l=0;"center"===s&&(l=Math.max(0,this.pathLength/2-o/2)),"right"===s&&(l=Math.max(0,this.pathLength-o));const h=(0,r.stringToArray)(this.text());let c=l;for(let t=0;t<h.length;t++){const e=this._getPointAtLength(c);if(!e)return;let r=this._getTextSize(h[t]).width+n;if(" "===h[t]&&"justify"===s){const t=this.text().split(" ").length-1;r+=(this.pathLength-o)/t}const l=this._getPointAtLength(c+r);if(!l)return;const d=i.Path.getLineLength(e.x,e.y,l.x,l.y);let u=0;if(a)try{u=a(h[t-1],h[t])*this.fontSize()}catch(t){u=0}e.x+=u,l.x+=u,this.textWidth+=u;const p=i.Path.getPointOnLine(u+d/2,e.x,e.y,l.x,l.y),f=Math.atan2(l.y-e.y,l.x-e.x);this.glyphInfo.push({transposeX:p.x,transposeY:p.y,text:h[t],rotation:f,p0:e,p1:l}),c+=r}}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,n,i=t[0]||0,r=t[0]||0,s=t[1]||0,a=t[1]||0;for(let o=0;o<t.length/2;o++)e=t[2*o],n=t[2*o+1],i=Math.min(i,e),r=Math.max(r,e),s=Math.min(s,n),a=Math.max(a,n);const o=this.fontSize();return{x:i-o/2,y:s-o/2,width:r-i+o,height:a-s+o}}destroy(){return t.Util.releaseCanvas(this.dummyCanvas),super.destroy()}};return ip.TextPath=c,c.prototype._fillFunc=l,c.prototype._strokeFunc=h,c.prototype._fillFuncHit=l,c.prototype._strokeFuncHit=h,c.prototype.className="TextPath",c.prototype._attrsAffectingSize=["text","fontSize","data"],(0,a._registerNode)(c),e.Factory.addGetterSetter(c,"data"),e.Factory.addGetterSetter(c,"fontFamily","Arial"),e.Factory.addGetterSetter(c,"fontSize",12,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"fontStyle",o),e.Factory.addGetterSetter(c,"align","left"),e.Factory.addGetterSetter(c,"letterSpacing",0,(0,s.getNumberValidator)()),e.Factory.addGetterSetter(c,"textBaseline","middle"),e.Factory.addGetterSetter(c,"fontVariant",o),e.Factory.addGetterSetter(c,"text",""),e.Factory.addGetterSetter(c,"textDecoration",null),e.Factory.addGetterSetter(c,"kerningFunc",null),ip}(),g=ap(),_=function(){if(op)return lp;op=1,Object.defineProperty(lp,"__esModule",{value:!0}),lp.Wedge=void 0;const t=kd(),e=lu(),n=Cd(),i=Fd(),r=Cd();let s=class extends e.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,n.Konva.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)}};return lp.Wedge=s,s.prototype.className="Wedge",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,r._registerNode)(s),t.Factory.addGetterSetter(s,"radius",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"angle",0,(0,i.getNumberValidator)()),t.Factory.addGetterSetter(s,"clockwise",!1),t.Factory.backCompat(s,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),lp}(),v=dp(),y=function(){if(up)return pp;up=1,Object.defineProperty(pp,"__esModule",{value:!0}),pp.Brighten=void 0;const t=kd(),e=Kd(),n=Fd();return pp.Brighten=function(t){let e,n=255*this.brightness(),i=t.data,r=i.length;for(e=0;e<r;e+=4)i[e]+=n,i[e+1]+=n,i[e+2]+=n},t.Factory.addGetterSetter(e.Node,"brightness",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),pp}(),x=function(){if(fp)return mp;fp=1,Object.defineProperty(mp,"__esModule",{value:!0}),mp.Contrast=void 0;const t=kd(),e=Kd(),n=Fd();return mp.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2);let n,i=t.data,r=i.length,s=150,a=150,o=150;for(n=0;n<r;n+=4)s=i[n],a=i[n+1],o=i[n+2],s/=255,s-=.5,s*=e,s+=.5,s*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,s=s<0?0:s>255?255:s,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,i[n]=s,i[n+1]=a,i[n+2]=o},t.Factory.addGetterSetter(e.Node,"contrast",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),mp}(),S=function(){if(gp)return _p;gp=1,Object.defineProperty(_p,"__esModule",{value:!0}),_p.Emboss=void 0;const t=kd(),e=Kd(),n=Ld(),i=Fd();return _p.Emboss=function(t){let e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),r=this.embossDirection(),s=this.embossBlend(),a=0,o=0,l=t.data,h=t.width,c=t.height,d=4*h,u=c;switch(r){case"top-left":a=-1,o=-1;break;case"top":a=-1,o=0;break;case"top-right":a=-1,o=1;break;case"right":a=0,o=1;break;case"bottom-right":a=1,o=1;break;case"bottom":a=1,o=0;break;case"bottom-left":a=1,o=-1;break;case"left":a=0,o=-1;break;default:n.Util.error("Unknown emboss direction: "+r)}do{const t=(u-1)*d;let n=a;u+n<1&&(n=0),u+n>c&&(n=0);const r=(u-1+n)*h*4;let p=h;do{const n=t+4*(p-1);let a=o;p+a<1&&(a=0),p+a>h&&(a=0);const c=r+4*(p-1+a),d=l[n]-l[c],u=l[n+1]-l[c+1],f=l[n+2]-l[c+2];let m=d;const g=m>0?m:-m;if((u>0?u:-u)>g&&(m=u),(f>0?f:-f)>g&&(m=f),m*=e,s){const t=l[n]+m,e=l[n+1]+m,i=l[n+2]+m;l[n]=t>255?255:t<0?0:t,l[n+1]=e>255?255:e<0?0:e,l[n+2]=i>255?255:i<0?0:i}else{let t=i-m;t<0?t=0:t>255&&(t=255),l[n]=l[n+1]=l[n+2]=t}}while(--p)}while(--u)},t.Factory.addGetterSetter(e.Node,"embossStrength",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossWhiteLevel",.5,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossDirection","top-left",null,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"embossBlend",!1,null,t.Factory.afterSetFilter),_p}(),b=function(){if(vp)return yp;vp=1,Object.defineProperty(yp,"__esModule",{value:!0}),yp.Enhance=void 0;const t=kd(),e=Kd(),n=Fd();function i(t,e,n,i,r){let s,a=n-e,o=r-i;return 0===a?i+o/2:0===o?i:(s=(t-e)/a,s=o*s+i,s)}return yp.Enhance=function(t){let e,n,r,s,a=t.data,o=a.length,l=a[0],h=l,c=a[1],d=c,u=a[2],p=u;const f=this.enhance();if(0===f)return;for(s=0;s<o;s+=4)e=a[s+0],e<l?l=e:e>h&&(h=e),n=a[s+1],n<c?c=n:n>d&&(d=n),r=a[s+2],r<u?u=r:r>p&&(p=r);let m,g,_,v,y,x,S,b,M;for(h===l&&(h=255,l=0),d===c&&(d=255,c=0),p===u&&(p=255,u=0),f>0?(g=h+f*(255-h),_=l-f*(l-0),y=d+f*(255-d),x=c-f*(c-0),b=p+f*(255-p),M=u-f*(u-0)):(m=.5*(h+l),g=h+f*(h-m),_=l+f*(l-m),v=.5*(d+c),y=d+f*(d-v),x=c+f*(c-v),S=.5*(p+u),b=p+f*(p-S),M=u+f*(u-S)),s=0;s<o;s+=4)a[s+0]=i(a[s+0],l,h,_,g),a[s+1]=i(a[s+1],c,d,x,y),a[s+2]=i(a[s+2],u,p,M,b)},t.Factory.addGetterSetter(e.Node,"enhance",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),yp}(),M=(xp||(xp=1,Object.defineProperty(Sp,"__esModule",{value:!0}),Sp.Grayscale=void 0,Sp.Grayscale=function(t){let e,n,i=t.data,r=i.length;for(e=0;e<r;e+=4)n=.34*i[e]+.5*i[e+1]+.16*i[e+2],i[e]=n,i[e+1]=n,i[e+2]=n}),Sp),w=function(){if(bp)return Mp;bp=1,Object.defineProperty(Mp,"__esModule",{value:!0}),Mp.HSL=void 0;const t=kd(),e=Kd(),n=Fd();return t.Factory.addGetterSetter(e.Node,"hue",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"luminance",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Mp.HSL=function(t){let e,n=t.data,i=n.length,r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=127*this.luminance();const o=1*r*Math.cos(s*Math.PI/180),l=1*r*Math.sin(s*Math.PI/180),h=.299+.701*o+.167*l,c=.587-.587*o+.33*l,d=.114-.114*o-.497*l,u=.299-.299*o-.328*l,p=.587+.413*o+.035*l,f=.114-.114*o+.293*l,m=.299-.3*o+1.25*l,g=.587-.586*o-1.05*l,_=.114+.886*o-.2*l;let v,y,x,S;for(e=0;e<i;e+=4)v=n[e+0],y=n[e+1],x=n[e+2],S=n[e+3],n[e+0]=h*v+c*y+d*x+a,n[e+1]=u*v+p*y+f*x+a,n[e+2]=m*v+g*y+_*x+a,n[e+3]=S},Mp}(),E=function(){if(wp)return Ep;wp=1,Object.defineProperty(Ep,"__esModule",{value:!0}),Ep.HSV=void 0;const t=kd(),e=Kd(),n=Fd();return Ep.HSV=function(t){const e=t.data,n=e.length,i=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,a=i*r*Math.cos(s*Math.PI/180),o=i*r*Math.sin(s*Math.PI/180),l=.299*i+.701*a+.167*o,h=.587*i-.587*a+.33*o,c=.114*i-.114*a-.497*o,d=.299*i-.299*a-.328*o,u=.587*i+.413*a+.035*o,p=.114*i-.114*a+.293*o,f=.299*i-.3*a+1.25*o,m=.587*i-.586*a-1.05*o,g=.114*i+.886*a-.2*o;let _,v,y,x;for(let t=0;t<n;t+=4)_=e[t+0],v=e[t+1],y=e[t+2],x=e[t+3],e[t+0]=l*_+h*v+c*y,e[t+1]=d*_+u*v+p*y,e[t+2]=f*_+m*v+g*y,e[t+3]=x},t.Factory.addGetterSetter(e.Node,"hue",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"saturation",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"value",0,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Ep}(),T=(Tp||(Tp=1,Object.defineProperty(Ap,"__esModule",{value:!0}),Ap.Invert=void 0,Ap.Invert=function(t){let e,n=t.data,i=n.length;for(e=0;e<i;e+=4)n[e]=255-n[e],n[e+1]=255-n[e+1],n[e+2]=255-n[e+2]}),Ap),A=Pp(),C=Dp(),R=function(){if(Np)return Up;Np=1,Object.defineProperty(Up,"__esModule",{value:!0}),Up.Noise=void 0;const t=kd(),e=Kd(),n=Fd();return Up.Noise=function(t){const e=255*this.noise(),n=t.data,i=n.length,r=e/2;for(let t=0;t<i;t+=4)n[t+0]+=r-2*r*Math.random(),n[t+1]+=r-2*r*Math.random(),n[t+2]+=r-2*r*Math.random()},t.Factory.addGetterSetter(e.Node,"noise",.2,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Up}(),P=function(){if(Op)return Fp;Op=1,Object.defineProperty(Fp,"__esModule",{value:!0}),Fp.Pixelate=void 0;const t=kd(),e=Ld(),n=Kd(),i=Fd();return Fp.Pixelate=function(t){let n,i,r,s,a,o,l,h,c,d,u,p,f,m,g=Math.ceil(this.pixelSize()),_=t.width,v=t.height,y=Math.ceil(_/g),x=Math.ceil(v/g),S=t.data;if(g<=0)e.Util.error("pixelSize value can not be <= 0");else for(p=0;p<y;p+=1)for(f=0;f<x;f+=1){for(s=0,a=0,o=0,l=0,h=p*g,c=h+g,d=f*g,u=d+g,m=0,n=h;n<c;n+=1)if(!(n>=_))for(i=d;i<u;i+=1)i>=v||(r=4*(_*i+n),s+=S[r+0],a+=S[r+1],o+=S[r+2],l+=S[r+3],m+=1);for(s/=m,a/=m,o/=m,l/=m,n=h;n<c;n+=1)if(!(n>=_))for(i=d;i<u;i+=1)i>=v||(r=4*(_*i+n),S[r+0]=s,S[r+1]=a,S[r+2]=o,S[r+3]=l)}},t.Factory.addGetterSetter(n.Node,"pixelSize",8,(0,i.getNumberValidator)(),t.Factory.afterSetFilter),Fp}(),L=function(){if(kp)return Bp;kp=1,Object.defineProperty(Bp,"__esModule",{value:!0}),Bp.Posterize=void 0;const t=kd(),e=Kd(),n=Fd();return Bp.Posterize=function(t){let e,n=Math.round(254*this.levels())+1,i=t.data,r=i.length,s=255/n;for(e=0;e<r;e+=1)i[e]=Math.floor(i[e]/s)*s},t.Factory.addGetterSetter(e.Node,"levels",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Bp}(),I=function(){if(zp)return Gp;zp=1,Object.defineProperty(Gp,"__esModule",{value:!0}),Gp.RGB=void 0;const t=kd(),e=Kd(),n=Fd();return Gp.RGB=function(t){let e,n,i=t.data,r=i.length,s=this.red(),a=this.green(),o=this.blue();for(e=0;e<r;e+=4)n=(.34*i[e]+.5*i[e+1]+.16*i[e+2])/255,i[e]=n*s,i[e+1]=n*a,i[e+2]=n*o,i[e+3]=i[e+3]},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,n.RGBComponent,t.Factory.afterSetFilter),Gp}(),D=function(){if(Hp)return Vp;Hp=1,Object.defineProperty(Vp,"__esModule",{value:!0}),Vp.RGBA=void 0;const t=kd(),e=Kd(),n=Fd();return Vp.RGBA=function(t){const e=t.data,n=e.length,i=this.red(),r=this.green(),s=this.blue(),a=this.alpha();for(let t=0;t<n;t+=4){const n=1-a;e[t]=i*a+e[t]*n,e[t+1]=r*a+e[t+1]*n,e[t+2]=s*a+e[t+2]*n}},t.Factory.addGetterSetter(e.Node,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),t.Factory.addGetterSetter(e.Node,"blue",0,n.RGBComponent,t.Factory.afterSetFilter),t.Factory.addGetterSetter(e.Node,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})),Vp}(),N=(Wp||(Wp=1,Object.defineProperty(Xp,"__esModule",{value:!0}),Xp.Sepia=void 0,Xp.Sepia=function(t){let e,n,i,r,s=t.data,a=s.length;for(e=0;e<a;e+=4)n=s[e+0],i=s[e+1],r=s[e+2],s[e+0]=Math.min(255,.393*n+.769*i+.189*r),s[e+1]=Math.min(255,.349*n+.686*i+.168*r),s[e+2]=Math.min(255,.272*n+.534*i+.131*r)}),Xp),U=(jp||(jp=1,Object.defineProperty(Yp,"__esModule",{value:!0}),Yp.Solarize=void 0,Yp.Solarize=function(t){const e=t.data,n=t.width,i=4*n;let r=t.height;do{const t=(r-1)*i;let s=n;do{const n=t+4*(s-1);let i=e[n],r=e[n+1],a=e[n+2];i>127&&(i=255-i),r>127&&(r=255-r),a>127&&(a=255-a),e[n]=i,e[n+1]=r,e[n+2]=a}while(--s)}while(--r)}),Yp),O=function(){if(qp)return Zp;qp=1,Object.defineProperty(Zp,"__esModule",{value:!0}),Zp.Threshold=void 0;const t=kd(),e=Kd(),n=Fd();return Zp.Threshold=function(t){const e=255*this.threshold(),n=t.data,i=n.length;for(let t=0;t<i;t+=1)n[t]=n[t]<e?0:255},t.Factory.addGetterSetter(e.Node,"threshold",.5,(0,n.getNumberValidator)(),t.Factory.afterSetFilter),Zp}();return Ed.Konva=t.Konva.Util._assign(t.Konva,{Arc:e.Arc,Arrow:n.Arrow,Circle:i.Circle,Ellipse:r.Ellipse,Image:s.Image,Label:a.Label,Tag:a.Tag,Line:o.Line,Path:l.Path,Rect:h.Rect,RegularPolygon:c.RegularPolygon,Ring:d.Ring,Sprite:u.Sprite,Star:p.Star,Text:f.Text,TextPath:m.TextPath,Transformer:g.Transformer,Wedge:_.Wedge,Filters:{Blur:v.Blur,Brighten:y.Brighten,Contrast:x.Contrast,Emboss:S.Emboss,Enhance:b.Enhance,Grayscale:M.Grayscale,HSL:w.HSL,HSV:E.HSV,Invert:T.Invert,Kaleidoscope:A.Kaleidoscope,Mask:C.Mask,Noise:R.Noise,Pixelate:P.Pixelate,Posterize:L.Posterize,RGB:I.RGB,RGBA:D.RGBA,Sepia:N.Sepia,Solarize:U.Solarize,Threshold:O.Threshold}}),Ed}var Qp,$p=wd.exports;var tf=bd(function(){if(Qp)return wd.exports;Qp=1,Object.defineProperty($p,"__esModule",{value:!0});const t=Jp();return wd.exports=t.Konva,wd.exports}());class ef{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 nf{constructor(t,e,n){this.setColor(t,e,n)}asHex(){return"#"+this.HEX}asRGB(){return{r:this.R,g:this.G,b:this.B}}setColor(t,e,n){this.R=t,this.G=e,this.B=n,this.HEX=this.rgbToHex(t,e,n)}rgbToHex(t,e,n){const i=t=>{const e=t.toString(16);return"0"===e?"00":e};return i(t)+i(e)+i(n)}}const rf=new Map([["solid",[]],["dot",[30,30,.001,30]],["dash",[30,30]]]);class sf{constructor(t,e=null){var n,i;if(e)return void(this._ref=e);t||(t={}),t.points||(t.points=[{x:50,y:50},{x:100,y:100}]);const r=[];t.points.forEach((t=>r.push(t.x,t.y))),this._ref=new tf.Line({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(i=t.width)&&void 0!==i?i:4,globalCompositeOperation:"source-over",lineCap:"round",lineJoin:"round",points:r,draggable:!0,strokeScaleEnabled:!1,dash:rf.get(t.type)||[]}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),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 rf.get("dot"):t="dot";break;case rf.get("dash"):t="dash";break;default:t="solid"}return t}setLineType(t){const e=rf.get(t);e&&this._ref.dash(e)}addPoints(t){let e=this._ref.points();t.forEach((t=>{e=e.concat([t.x,t.y])})),this._ref.points(e)}}class af{constructor(t,e=null){var n,i,r;this.TEXT_FONT_FAMILY="Calibri",e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.text||(t.text="default"),this._ref=new tf.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!==(i=t.color)&&void 0!==i?i:"#ff0000",align:"left",draggable:!0,rotation:null!==(r=t.rotation)&&void 0!==r?r:0}),this._ref.width(this._ref.getTextWidth()),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY);r<50&&(r=50),s<Math.round(this.getFontSize())&&(s=Math.round(this.getFontSize())),n&&this._ref.width(r),i&&this._ref.height(s),this._ref.scale({x:1,y:1})})),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})}getFontSize(){return this._ref.fontSize()}setFontSize(t){this._ref.fontSize(t)}}class of{constructor(t,e=null){var n,i,r,s;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),this._ref=new tf.Rect({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(i=t.lineWidth)&&void 0!==i?i: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!==(s=t.height)&&void 0!==s?s:200,draggable:!0,strokeScaleEnabled:!1}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY);r<50&&(r=50),s<50&&(s=50),n&&this._ref.width(r),i&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}getWidth(){return this._ref.width()}getHeigth(){return this._ref.height()}setWidth(t){this._ref.width(t)}setHeight(t){this._ref.height(t)}setPosition(t,e){this._ref.setPosition({x:t,y:e})}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()}}class lf{constructor(t,e=null){var n,i;e?this._ref=e:(t||(t={}),t.position||(t.position={x:100,y:100}),t.radius||(t.radius={x:25,y:25}),this._ref=new tf.Ellipse({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",strokeWidth:null!==(i=t.lineWidth)&&void 0!==i?i: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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.radiusX();n&&(r*=e.scaleX);let s=this._ref.radiusY();i&&(s*=e.scaleY);r<25&&(r=25),s<25&&(s=25),t.evt.ctrlKey||t.evt.shiftKey?n?this._ref.radius({x:r,y:r}):this._ref.radius({x:s,y:s}):this._ref.radius({x:r,y:s}),this._ref.scale({x:1,y:1})})),this._ref.id(this._ref._id.toString()))}getPosition(){return this._ref.position()}setPosition(t,e){this._ref.setPosition({x:t,y:e})}getRadiusX(){return this._ref.radiusX()}setRadiusX(t){this._ref.radiusX(t)}getRadiusY(){return this._ref.radiusY()}setRadiusY(t){this._ref.radiusY(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}}class hf{constructor(t,e=null){var n,i;e?this._ref=e:(t||(t={}),t.start||(t.start={x:50,y:50}),t.end||(t.end={x:100,y:100}),this._ref=new tf.Arrow({stroke:null!==(n=t.color)&&void 0!==n?n:"#ff0000",fill:null!==(i=t.color)&&void 0!==i?i:"#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.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation)})),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.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 n=this._ref.points();this._ref.points([t,e,n[2],n[3]])}getEndPoint(){const t=this._ref.points();return{x:t[2],y:t[3]}}setEndPoint(t,e){const n=this._ref.points();this._ref.points([n[0],n[1],t,e])}}class cf{constructor(t,e=null){var n,i;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=",e)return 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(),void(this._ratio=this._ref.height()<=this.EPSILON||this._ref.width()<=this.EPSILON?1:this._ref.height()/this._ref.width());t||(t={}),t.position||(t.position={x:50,y:50}),t.src&&t.src.startsWith(this.BASE64_HEADER_START)||(t.src=this.BASE64_NOT_FOUND),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,n=t.maxWidth-this._canvasImage.width;(e<=this.EPSILON||n<=this.EPSILON)&&(n<=this.EPSILON&&n<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)))}},this._canvasImage.onerror=()=>{this._canvasImage.onerror=function(){},this._canvasImage.src=this.BASE64_NOT_FOUND},this._canvasImage.src=t.src,this._ref=new tf.Image({x:t.position.x,y:t.position.y,image:this._canvasImage,width:null!==(n=t.width)&&void 0!==n?n:0,height:null!==(i=t.height)&&void 0!==i?i:0,draggable:!0}),this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY),t.evt.ctrlKey||t.evt.shiftKey?n?(this._ref.width(r),this._ref.height(r*this._ratio)):(this._ref.width(s/this._ratio),this._ref.height(s)):(n&&this._ref.width(r),i&&this._ref.height(s)),this._ref.scale({x:1,y:1})})),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)}getHeight(){return this._ref.height()}setHeight(t){this._ref.height(t),this._ref.width(t/this._ratio)}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})}}class df{constructor(t,e=null){var n,i,r,s;if(e)return void(this._ref=e);t||(t={}),t.position||(t.position={x:100,y:100});const a=16;this._ref=new tf.Shape({x:t.position.x,y:t.position.y,width:null!==(n=t.width)&&void 0!==n?n:200,height:null!==(i=t.height)&&void 0!==i?i:200,stroke:null!==(r=t.color)&&void 0!==r?r:"#ff0000",strokeWidth:null!==(s=t.lineWidth)&&void 0!==s?s:4,draggable:!0,strokeScaleEnabled:!1,globalCompositeOperation:"source-over",sceneFunc:(t,e)=>{const n=[{x:0,y:0},{x:0+this._ref.width(),y:0},{x:0+this._ref.width(),y:0+this._ref.height()},{x:0,y:0+this._ref.height()},{x:0,y:0}],i=(r={x:0,y:0},s=this._ref.width(),o=this._ref.height(),{x:r.x+s/2,y:r.y+o/2});var r,s,o;t.beginPath();for(let e=0;e<n.length-1;e++){let r=30;const s=n[e+1].x-n[e].x,o=n[e+1].y-n[e].y,l=Math.sqrt(s*s+o*o),h=Math.floor(l/r);r=30+h/(l%r);let c=n[e].x+s/h/2,d=n[e].y+o/h/2;const u=n[e+1].x,p=n[e+1].y,f=Math.atan((p-d)/(u-c)),m=f+Math.PI,g=c>i.x&&d>i.y;for(let e=0;e<h;e++)g?t.arc(c,d,a,f,m):t.arc(c,d,a,m,f),c+=s/h,d+=o/h}t.closePath(),t.fillStrokeShape(e)}}),this._ref.className="Cloud",this._ref.on("transform",(t=>{const e=t.target.attrs;e.rotation!==this._ref.rotation()&&this._ref.rotation(e.rotation);const n=Math.abs(e.scaleX-1)>1e-5,i=Math.abs(e.scaleY-1)>1e-5;let r=this._ref.width();n&&(r*=e.scaleX);let s=this._ref.height();i&&(s*=e.scaleY);r<100&&(r=100),s<100&&(s=100),n&&this._ref.width(r),i&&this._ref.height(s),this._ref.scale({x:1,y:1})})),this._ref.getSelfRect=()=>({x:-16,y:-16,width:this._ref.width()+32,height:this._ref.height()+32}),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})}getWidth(){return this._ref.width()}setWidth(t){this._ref.width(t)}getHeigth(){return this._ref.height()}setHeight(t){this._ref.height(t)}getLineWidth(){return this._ref.strokeWidth()}setLineWidth(t){this._ref.strokeWidth(t)}}const uf={SelectMarkup:{name:"SelectMarkup",initializer:null},Line:{name:"Line",initializer:(t,e=null)=>new sf(e,t)},Text:{name:"Text",initializer:(t,e=null)=>new af(e,t)},Rectangle:{name:"Rect",initializer:(t,e=null)=>new of(e,t)},Ellipse:{name:"Ellipse",initializer:(t,e=null)=>new lf(e,t)},Arrow:{name:"Arrow",initializer:(t,e=null)=>new hf(e,t)},Image:{name:"Image",initializer:(t,e=null)=>new cf(e,t)},Cloud:{name:"Cloud",initializer:(t,e=null)=>new df(e,t)}};class pf{constructor(){this._containerEvents=[],this._markupIsActive=!1,this._markupColor=new nf(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=t=>{const{width:e,height:n}=t[0].contentRect;e&&n&&this._konvaStage&&(this._konvaStage.width(e),this._konvaStage.height(n))},this.pan=t=>{const e={x:this._konvaStage.x()+t.dX,y:this._konvaStage.y()+t.dY};this._konvaStage.position(e)},this.zoomAt=t=>{const e=this._konvaStage.scaleX()*t.data;this._konvaStage.scale({x:e,y:e});const n={x:t.x-(t.x-this._konvaStage.x())*t.data,y:t.y-(t.y-this._konvaStage.y())*t.data};this._konvaStage.position(n)},this.redirectToViewer=t=>{this._viewer&&this._viewer.emit(t)},this.getRelativePointPosition=(t,e)=>{const n=e.getAbsoluteTransform().copy();return n.invert(),n.point(t)},this.getRelativePointerPosition=t=>this.getRelativePointPosition(t.getStage().getPointerPosition(),t)}initialize(t,e,n,i){if(!tf)throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');this._viewer=n,this._worldTransformer=null!=i?i:new ef,this._container=t,this._containerEvents=null!=e?e:[],this._markupContainer=document.createElement("div"),this._markupContainer.id="markup-container",this._markupContainer.style.position="absolute",this._markupContainer.style.top="0px",this._markupContainer.style.left="0px",this._markupContainer.style.outline="0px",this._markupContainer.style.pointerEvents="none";const r=this._container.parentElement;r.appendChild(this._markupContainer),this._resizeObserver=new ResizeObserver(this.resizeContainer),this._resizeObserver.observe(r),this._markupColor.setColor(255,0,0),this.initializeKonva(),this._viewer&&(this._viewer.addEventListener("changeactivedragger",this.changeActiveDragger),this._viewer.addEventListener("pan",this.pan),this._viewer.addEventListener("zoomat",this.zoomAt))}dispose(){var t,e;this._viewer&&(this._viewer.removeEventListener("zoomat",this.zoomAt),this._viewer.removeEventListener("pan",this.pan),this._viewer.removeEventListener("changeactivedragger",this.changeActiveDragger)),this.destroyKonva(),null===(t=this._resizeObserver)||void 0===t||t.disconnect(),this._resizeObserver=void 0,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,n){this._markupColor.setColor(t,e,n),this._viewer.emit({type:"changemarkupcolor",data:{r:t,g:e,b:n}})}colorizeAllMarkup(t,e,n){const i=new nf(t,e,n).asHex();this.getObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,i)}))}colorizeSelectedMarkups(t,e,n){const i=new nf(t,e,n).asHex();this.getSelectedObjects().filter((t=>{var e;return null===(e=t.setColor)||void 0===e?void 0:e.call(t,i)}))}setViewpoint(t){var e,n,i,r,s,a,o,l;this.clearSelected(),this.removeTextInput(),this.removeImageInput(),this._konvaStage.scale({x:1,y:1}),this._konvaStage.position({x:0,y:0});const h=(null===(e=t.custom_fields)||void 0===e?void 0:e.markup_color)||{r:255,g:0,b:0};this.setMarkupColor(h.r,h.g,h.b),null===(n=t.lines)||void 0===n||n.forEach((t=>{const e=[];t.points.forEach((t=>{const n=this._worldTransformer.worldToScreen(t);e.push(n.x),e.push(n.y)})),this.addLine(e,t.color,t.type,t.width,t.id)})),null===(i=t.texts)||void 0===i||i.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===(r=t.rectangles)||void 0===r||r.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addRectangle(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(s=t.ellipses)||void 0===s||s.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addEllipse(e,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),n=this._worldTransformer.worldToScreen(t.end);this.addArrow(e,n,t.color,t.id)})),null===(o=t.clouds)||void 0===o||o.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addCloud(e,t.width,t.height,t.line_width,t.color,t.id)})),null===(l=t.images)||void 0===l||l.forEach((t=>{const e=this._worldTransformer.worldToScreen(t.position);this.addImage(e,t.src,t.width,t.height,t.id)}))}getViewpoint(t){return t||(t={}),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.snapshot={data:this.combineMarkupWithDrawing()},t}enableEditMode(t){return t&&uf[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 n=uf[t];if(!n||!n.initializer)throw new Error(`Markup CreateObject - unsupported markup type ${t}`);const i=n.initializer(null,e);return this.addObject(i),i}getObjects(){const t=[];return Object.keys(uf).forEach((e=>{const n=uf[e];this.konvaLayerFind(e).forEach((e=>t.push(n.initializer(e))))})),t}getSelectedObjects(){return this._konvaTransformer?this._konvaTransformer.nodes().map((t=>{const e=t.className,n=Object.values(uf).find((t=>t.name===e));return n?n.initializer(t):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=uf[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)):[]}initializeKonva(){const t=new tf.Stage({container:this._markupContainer,width:this._container.clientWidth,height:this._container.clientHeight});this._konvaStage=t;const e=new tf.Layer({pixelRation:window.devicePixelRatio});t.add(e),this._groupImages=new tf.Group,e.add(this._groupImages),this._groupGeometry=new tf.Group,e.add(this._groupGeometry),this._groupTexts=new tf.Group,e.add(this._groupTexts),this._konvaLayer=e;const n=new tf.Transformer({shouldOverdrawWholeArea:!1,keepRatio:!1,flipEnabled:!1});e.add(n),this._konvaTransformer=n;let i,r,s,a=!1;t.on("mousedown touchstart",(e=>{if(!this._markupIsActive||e.target!==t||"Text"===this._markupMode||"Image"===this._markupMode)return;if(e.target===t&&n.nodes().length>0)return void n.nodes([]);const s=this.getRelativePointerPosition(t);r=s,a=["Arrow","Cloud","Ellipse","Line","Rectangle"].some((t=>t===this._markupMode)),"Line"===this._markupMode&&(i=this.addLine([s.x,s.y,s.x,s.y]))})),t.on("mouseup touchend",(e=>{if(this._markupIsActive){if(a){const e=this.getRelativePointerPosition(t),n=r&&e.x===r.x&&e.y===r.y,i=n?r.x:Math.min(r.x,e.x),s=n?r.y:Math.min(r.y,e.y),a=n?200:Math.abs(r.x-e.x),o=n?200:Math.abs(r.y-e.y);n&&("Rectangle"===this._markupMode?this.addRectangle({x:i,y:s},a,o):"Ellipse"===this._markupMode?this.addEllipse({x:i,y:s},{x:a/2,y:o/2}):"Arrow"===this._markupMode?this.addArrow({x:r.x,y:r.y},{x:n?r.x+200:e.x,y:n?s:e.y}):"Cloud"===this._markupMode&&this.addCloud({x:i,y:s},Math.max(100,a),Math.max(100,o)))}s=void 0,a=!1}})),t.on("mousemove touchmove",(e=>{if(!this._markupIsActive)return;if(!a)return;const n=this.getRelativePointerPosition(t),o=r&&n.x===r.x&&n.y===r.y,l=o?r.x:Math.min(r.x,n.x),h=o?r.y:Math.min(r.y,n.y),c=o?200:Math.abs(r.x-n.x),d=o?200:Math.abs(r.y-n.y);"Line"===this._markupMode?i.addPoints([{x:n.x,y:n.y}]):"Arrow"===this._markupMode?s?s.setEndPoint(n.x,n.y):s=this.addArrow({x:r.x,y:r.y},{x:n.x,y:n.y}):"Rectangle"===this._markupMode?s?(s.setPosition(l,h),s.setWidth(c),s.setHeight(d)):s=this.addRectangle({x:l,y:h},c,d):"Ellipse"===this._markupMode?s?(s.setPosition(l,h),s.setRadiusX(c),s.setRadiusY(d)):s=this.addEllipse({x:l,y:h},{x:c,y:d}):"Cloud"===this._markupMode&&(s?(s.setPosition(l,h),s.setWidth(Math.max(100,c)),s.setHeight(Math.max(100,d))):s=this.addCloud({x:l,y:h},c,d))})),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===n.nodes().length){const n=this.getRelativePointerPosition(t);this.createTextInput(n,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},this._imageInputRef.value,0,0,this._imageInputRef.value);else if(0===n.nodes().length){const e=this.getRelativePointerPosition(t);this.createImageInput(e)}return void n.nodes([])}if("Text"===this._markupMode||"SelectMarkup"===this._markupMode){if("Text"===e.target.className&&1===n.nodes().length&&n.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===n.nodes().length&&n.nodes()[0]===e.target)return void(this._imageInputRef&&this._imageInputRef.value?this.addImage(this._imageInputPos,this._imageInputRef.value,0,0):this.createImageInput({x:e.target.attrs.x,y:e.target.attrs.y}));this.removeImageInput()}n.nodes().filter((t=>"Cloud"===t.className||"Image"===t.className)).length>0||"Cloud"===e.target.className||"Image"===e.target.className?n.rotateEnabled(!1):n.rotateEnabled(!0);const i=e.evt.shiftKey||e.evt.ctrlKey||e.evt.metaKey,r=n.nodes().indexOf(e.target)>=0;if(i||r){if(i&&r){const t=n.nodes().slice();t.splice(t.indexOf(e.target),1),n.nodes(t)}else if(i&&!r){const t=n.nodes().concat([e.target]);n.nodes(t)}}else n.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 n=e.points();if(!n)return;const i=[],r=e.getAbsoluteTransform();for(let t=0;t<n.length;t+=2){const e=r.point({x:n[t],y:n[t+1]}),s=this._worldTransformer.screenToWorld(e);i.push(s)}const s=new sf(null,e),a={id:s.id(),points:i,color:s.getColor()||"#ff0000",type:s.getLineType()||this.lineType,width:s.getLineWidth()||this.lineWidth};t.push(a)})),t}getMarkupTexts(){const t=[];return this.konvaLayerFind("Text").forEach((e=>{const n=this._worldTransformer.getScale(),i=e.position(),r=this._konvaStage.getAbsoluteTransform(),s=r.point({x:i.x,y:i.y}),a=this._worldTransformer.screenToWorld(s),o=new af(null,e),l={id:o.id(),position:a,text:o.getText(),text_size:.02*n.y,angle:o.getRotation(),color:o.getColor(),font_size:o.getFontSize()*r.getMatrix()[0]};t.push(l)})),t}getMarkupRectangles(){const t=[];return this.konvaLayerFind("Rectangle").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new of(null,e),l={id:o.id(),position:s,width:o.getWidth()*a,height:o.getHeigth()*a,line_width:o.getLineWidth(),color:o.getColor()};t.push(l)})),t}getMarkupEllipses(){const t=[];return this.konvaLayerFind("Ellipse").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new lf(null,e),l={id:o.id(),position:s,radius:{x:e.getRadiusX()*a,y:e.getRadiusY()*a},line_width:o.getLineWidth(),color:o.getColor()};t.push(l)})),t}getMarkupArrows(){const t=[];return this.konvaLayerFind("Arrow").forEach((e=>{const n=e.getAbsoluteTransform(),i=n.point({x:e.points()[0],y:e.points()[1]}),r=this._worldTransformer.screenToWorld(i),s=n.point({x:e.points()[2],y:e.points()[3]}),a=this._worldTransformer.screenToWorld(s),o=new hf(null,e),l={id:o.id(),start:r,end:a,color:o.getColor()};t.push(l)})),t}getMarkupImages(){const t=[];return this.konvaLayerFind("Image").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new cf(null,e),l={id:o.id(),position:s,src:o.getSrc(),width:o.getWidth()*a,height:o.getHeight()*a};t.push(l)})),t}getMarkupClouds(){const t=[];return this.konvaLayerFind("Cloud").forEach((e=>{const n=e.position(),i=this._konvaStage.getAbsoluteTransform(),r=i.point({x:n.x,y:n.y}),s=this._worldTransformer.screenToWorld(r),a=i.getMatrix()[0],o=new df(null,e),l={id:o.id(),position:s,width:o.getWidth()*a,height:o.getHeigth()*a,line_width:o.getLineWidth(),color:o.getColor()};t.push(l)})),t}combineMarkupWithDrawing(){this.clearSelected();const t=document.createElement("canvas");if(this._konvaStage){t.width=this._konvaStage.width(),t.height=this._konvaStage.height();const e=t.getContext("2d");this._container instanceof HTMLCanvasElement&&e.drawImage(this._container,0,0),e.drawImage(this._konvaStage.toCanvas({pixelRatio:window.devicePixelRatio}),0,0)}return t.toDataURL("image/jpeg",.25)}addLine(t,e,n,i,r){if(!t||0===t.length)return;const s=[];for(let e=0;e<t.length;e+=2)s.push({x:t[e],y:t[e+1]});const a=new sf({points:s,type:n||this.lineType,width:i||this.lineWidth,color:e||this._markupColor.asHex(),id:r});return this.addObject(a),a}createTextInput(t,e,n,i,r){this._textInputRef?this.removeTextInput():(this._textInputPos=t,this._textInputAngle=i,this._textInputRef=document.createElement("textarea"),this._textInputRef.style.zIndex="9999",this._textInputRef.style.position="absolute",this._textInputRef.style.display="block",this._textInputRef.style.top=n+"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())},r&&(this._textInputRef.value=r),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,n)=>{const i=new FileReader;i.readAsDataURL(t),i.onload=()=>{e(i.result)},i.onerror=t=>{n(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 n=t.target.files[0],i=await e(n);this.addImage({x:this._imageInputPos.x,y:this._imageInputPos.y},i.toString(),0,0)},this._imageInputRef.oncancel=t=>{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,n,i,r,s,a){var o;if(!t)return;null===(o=this.getSelectedObjects().at(0))||void 0===o||o.delete(),this.clearSelected(),this.removeTextInput();const l=1e-6;if(r&&r>l&&(!s||s<l)){const t=.02;s=r/(this._worldTransformer.getScale().y/t)/34}const h=new af({position:{x:e.x,y:e.y},text:t,rotation:n,fontSize:s||this.fontSize,color:i||this._markupColor.asHex(),id:a});return this.addObject(h),h}addRectangle(t,e,n,i,r,s){if(!t)return;const a=new of({position:t,width:e,height:n,lineWidth:i||this.lineWidth,color:r||this._markupColor.asHex(),id:s});return this.addObject(a),a}addEllipse(t,e,n,i,r){if(!t)return;const s=new lf({position:t,radius:e,lineWidth:n,color:i||this._markupColor.asHex(),id:r});return this.addObject(s),s}addArrow(t,e,n,i){if(!t||!e)return;const r=new hf({start:t,end:e,color:n||this._markupColor.asHex(),id:i});return this.addObject(r),r}addCloud(t,e,n,i,r,s){if(!t||!e||!n)return;const a=new df({position:t,width:e,height:n,color:r||this._markupColor.asHex(),lineWidth:i||this.lineWidth,id:s});return this.addObject(a),a}addImage(t,e,n,i,r){var s;if(!t||!e)return;null===(s=this.getSelectedObjects().at(0))||void 0===s||s.delete(),this.clearSelected(),this.removeImageInput();const a=new cf({position:t,src:e,width:n,height:i,maxWidth:this._konvaStage.width()-t.x,maxHeight:this._konvaStage.height()-t.y,id:r});return this.addObject(a),a}}const ff={type:"change"},mf={type:"start"},gf={type:"end"},_f=-1,vf=0,yf=1,xf=2,Sf=3,bf=4,Mf=5,wf=6;class Ef extends Ge{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Rn,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:h,MIDDLE:c,RIGHT:d},this.touches={ONE:u,TWO:f},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",D),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",D),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(ff),n.update(),n.state=_f},this.update=function(){const e=new Rn,a=(new Cn).setFromUnitVectors(t.up,new Rn(0,1,0)),l=a.clone().invert(),h=new Rn,c=new Cn,d=new Rn,u=2*Math.PI;return function(){const t=n.object.position;e.copy(t).sub(n.target),e.applyQuaternion(a),r.setFromVector3(e),n.autoRotate&&n.state===_f&&o(2*Math.PI/60/60*n.autoRotateSpeed),n.enableDamping?(r.theta+=s.theta*n.dampingFactor,r.phi+=s.phi*n.dampingFactor):(r.theta+=s.theta,r.phi+=s.phi);let p=n.minAzimuthAngle,f=n.maxAzimuthAngle;return isFinite(p)&&isFinite(f)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),f<-Math.PI?f+=u:f>Math.PI&&(f-=u),r.theta=p<=f?Math.max(p,Math.min(f,r.theta)):r.theta>(p+f)/2?Math.max(p,r.theta):Math.min(f,r.theta)),r.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=n.scale,r.radius=Math.max(n.minDistance,Math.min(n.maxDistance,r.radius)),!0===n.enableDamping?n.target.addScaledVector(n.panOffset,n.dampingFactor):n.target.add(n.panOffset),e.setFromSpherical(r),e.applyQuaternion(l),t.copy(n.target).add(e),n.object.lookAt(n.target),!0===n.enableDamping?(s.theta*=1-n.dampingFactor,s.phi*=1-n.dampingFactor,n.panOffset.multiplyScalar(1-n.dampingFactor)):(s.set(0,0,0),n.panOffset.set(0,0,0)),n.scale=1,!!(n.zoomChanged||h.distanceToSquared(n.object.position)>i||8*(1-c.dot(n.object.quaternion))>i||d.distanceToSquared(n.target)>0)&&(n.dispatchEvent(ff),h.copy(n.object.position),c.copy(n.object.quaternion),d.copy(n.target),n.zoomChanged=!1,!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",N),n.domElement.removeEventListener("pointerdown",R),n.domElement.removeEventListener("pointercancel",L),n.domElement.removeEventListener("wheel",I),n.domElement.removeEventListener("pointermove",P),n.domElement.removeEventListener("pointerup",L),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",D),n._domElementKeyEvents=null)};const n=this;n.state=_f;const i=1e-6,r=new pc,s=new pc;function a(){return Math.pow(.95,n.zoomSpeed)}function o(t){s.theta-=t}function l(t){s.phi-=t}n.scale=1,n.panOffset=new Rn,n.zoomChanged=!1,n.rotateStart=new $e,n.rotateEnd=new $e,n.rotateDelta=new $e,n.panStart=new $e,n.panEnd=new $e,n.panDelta=new $e,n.dollyStart=new $e,n.dollyEnd=new $e,n.dollyDelta=new $e,n.dollyScale=0,n.pointers=[],n.pointerPositions={};const g=function(){const t=new Rn;return function(e,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-e),n.panOffset.add(t)}}(),_=function(){const t=new Rn;return function(e,i){!0===n.screenSpacePanning?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(n.object.up,t)),t.multiplyScalar(e),n.panOffset.add(t)}}(),v=function(){const t=new Rn;return function(e,i){const r=n.domElement;if(n.object.isPerspectiveCamera){const s=n.object.position;t.copy(s).sub(n.target);let a=t.length();a*=Math.tan(n.object.fov/2*Math.PI/180),g(2*e*a/r.clientHeight,n.object.matrix),_(2*i*a/r.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(g(e*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),_(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function y(t){n.object.isPerspectiveCamera?n.scale/=t:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*t)),n.object.updateProjectionMatrix(),n.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function x(t){n.object.isPerspectiveCamera?n.scale*=t:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/t)),n.object.updateProjectionMatrix(),n.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function S(t){n.rotateStart.set(t.clientX,t.clientY)}function b(t){n.panStart.set(t.clientX,t.clientY)}function M(){if(1===n.pointers.length)n.rotateStart.set(n.pointers[0].pageX,n.pointers[0].pageY);else{const t=.5*(n.pointers[0].pageX+n.pointers[1].pageX),e=.5*(n.pointers[0].pageY+n.pointers[1].pageY);n.rotateStart.set(t,e)}}function w(){if(1===n.pointers.length)n.panStart.set(n.pointers[0].pageX,n.pointers[0].pageY);else{const t=.5*(n.pointers[0].pageX+n.pointers[1].pageX),e=.5*(n.pointers[0].pageY+n.pointers[1].pageY);n.panStart.set(t,e)}}function E(){const t=n.pointers[0].pageX-n.pointers[1].pageX,e=n.pointers[0].pageY-n.pointers[1].pageY,i=Math.sqrt(t*t+e*e);n.dollyStart.set(0,i)}function T(t){if(1==n.pointers.length)n.rotateEnd.set(t.pageX,t.pageY);else{const e=O(t),i=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);n.rotateEnd.set(i,r)}n.rotateDelta.subVectors(n.rotateEnd,n.rotateStart).multiplyScalar(n.rotateSpeed);const e=n.domElement;o(2*Math.PI*n.rotateDelta.x/e.clientHeight),l(2*Math.PI*n.rotateDelta.y/e.clientHeight),n.rotateStart.copy(n.rotateEnd)}function A(t){if(1===n.pointers.length)n.panEnd.set(t.pageX,t.pageY);else{const e=O(t),i=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);n.panEnd.set(i,r)}n.panDelta.subVectors(n.panEnd,n.panStart).multiplyScalar(n.panSpeed),v(n.panDelta.x,n.panDelta.y),n.panStart.copy(n.panEnd)}function C(t){const e=O(t),i=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(i*i+r*r);n.dollyEnd.set(0,s),n.dollyDelta.set(0,Math.pow(n.dollyEnd.y/n.dollyStart.y,n.zoomSpeed)),y(n.dollyDelta.y),n.dollyStart.copy(n.dollyEnd)}function R(t){!1!==n.enabled&&(0===n.pointers.length&&(n.domElement.setPointerCapture(t.pointerId),n.domElement.addEventListener("pointermove",P),n.domElement.addEventListener("pointerup",L)),function(t){n.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(U(t),n.pointers.length){case 1:switch(n.touches.ONE){case u:if(!1===n.enableRotate)return;M(),n.state=Sf;break;case p:if(!1===n.enablePan)return;w(),n.state=bf;break;default:n.state=_f}break;case 2:switch(n.touches.TWO){case f:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&E(),n.enablePan&&w(),n.state=Mf;break;case m:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&E(),n.enableRotate&&M(),n.state=wf;break;default:n.state=_f}break;default:n.state=_f}n.state!==_f&&n.dispatchEvent(mf)}(t):function(t){let e;switch(t.button){case 0:e=n.mouseButtons.LEFT;break;case 1:e=n.mouseButtons.MIDDLE;break;case 2:e=n.mouseButtons.RIGHT;break;default:e=-1}switch(e){case c:if(!1===n.enableZoom)return;!function(t){n.dollyStart.set(t.clientX,t.clientY)}(t),n.state=yf;break;case h:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===n.enablePan)return;b(t),n.state=xf}else{if(!1===n.enableRotate)return;S(t),n.state=vf}break;case d:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===n.enableRotate)return;S(t),n.state=vf}else{if(!1===n.enablePan)return;b(t),n.state=xf}break;default:n.state=_f}n.state!==_f&&n.dispatchEvent(mf)}(t))}function P(t){!1!==n.enabled&&("touch"===t.pointerType?function(t){switch(U(t),n.state){case Sf:if(!1===n.enableRotate)return;T(t),n.update();break;case bf:if(!1===n.enablePan)return;A(t),n.update();break;case Mf:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(t){n.enableZoom&&C(t),n.enablePan&&A(t)}(t),n.update();break;case wf:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(t){n.enableZoom&&C(t),n.enableRotate&&T(t)}(t),n.update();break;default:n.state=_f}}(t):function(t){switch(n.state){case vf:if(!1===n.enableRotate)return;!function(t){n.rotateEnd.set(t.clientX,t.clientY),n.rotateDelta.subVectors(n.rotateEnd,n.rotateStart).multiplyScalar(n.rotateSpeed);const e=n.domElement;o(2*Math.PI*n.rotateDelta.x/e.clientHeight),l(2*Math.PI*n.rotateDelta.y/e.clientHeight),n.rotateStart.copy(n.rotateEnd),n.update()}(t);break;case yf:if(!1===n.enableZoom)return;!function(t){n.dollyEnd.set(t.clientX,t.clientY),n.dollyDelta.subVectors(n.dollyEnd,n.dollyStart),n.dollyDelta.y<0?(n.dollyScale=1/a(),y(a())):n.dollyDelta.y>0&&(n.dollyScale=a(),x(a())),n.dollyStart.copy(n.dollyEnd),n.update()}(t);break;case xf:if(!1===n.enablePan)return;!function(t){n.panEnd.set(t.clientX,t.clientY),n.panDelta.subVectors(n.panEnd,n.panStart).multiplyScalar(n.panSpeed),v(n.panDelta.x,n.panDelta.y),n.panStart.copy(n.panEnd),n.update()}(t)}}(t))}function L(t){!function(t){delete n.pointerPositions[t.pointerId];for(let e=0;e<n.pointers.length;e++)if(n.pointers[e].pointerId==t.pointerId)return void n.pointers.splice(e,1)}(t),0===n.pointers.length&&(n.domElement.releasePointerCapture(t.pointerId),n.domElement.removeEventListener("pointermove",P),n.domElement.removeEventListener("pointerup",L)),n.dispatchEvent(gf),n.state=_f}function I(t){!1!==n.enabled&&!1!==n.enableZoom&&n.state===_f&&(t.preventDefault(),n.dispatchEvent(mf),function(t){n.dollyEnd.set(n.domElement.clientWidth/2,n.domElement.clientHeight/2),n.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(n.dollyScale=1/a(),x(a())):t.deltaY>0&&(n.dollyScale=a(),y(a())),n.dollyStart.copy(n.dollyEnd),n.update(),0!==t.deltaY&&(n.state=yf,n.dispatchEvent(ff),n.state=_f)}(t),n.dispatchEvent(gf))}function D(t){!1!==n.enabled&&!1!==n.enablePan&&function(t){let e=!1;switch(t.code){case n.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?l(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(0,n.keyPanSpeed),e=!0;break;case n.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?l(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(0,-n.keyPanSpeed),e=!0;break;case n.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(n.keyPanSpeed,0),e=!0;break;case n.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):v(-n.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),n.update())}(t)}function N(t){!1!==n.enabled&&t.preventDefault()}function U(t){let e=n.pointerPositions[t.pointerId];void 0===e&&(e=new $e,n.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function O(t){const e=t.pointerId===n.pointers[0].pointerId?n.pointers[1]:n.pointers[0];return n.pointerPositions[e.pointerId]}n.domElement.addEventListener("contextmenu",N),n.domElement.addEventListener("pointerdown",R),n.domElement.addEventListener("pointercancel",L),n.domElement.addEventListener("wheel",I,{passive:!1}),this.update()}}class Tf{constructor(t){this.updateControls=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case xf:case bf: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 yf:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new Ef(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:h,MIDDLE:d,RIGHT:d},this.orbit.touches={ONE:u,TWO:f},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.on("geometryend",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.on("zoom",this.updateControls),this.viewer.on("drawviewpoint",this.updateControls),this.viewer.on("contextmenu",this.stopContextMenu),this.updateControls()}dispose(){this.viewer.off("geometryend",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.off("zoom",this.updateControls),this.viewer.off("drawviewpoint",this.updateControls),this.viewer.off("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class Af extends Tf{constructor(t){super(t),this.orbit.mouseButtons={LEFT:d,MIDDLE:d,RIGHT:d}}}class Cf extends Tf{constructor(t){super(t),this.orbit.mouseButtons={LEFT:c,MIDDLE:d,RIGHT:d}}}class Rf extends fc{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 $e(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.moveKeys=new Set,this.moveClock=new tc,this.quaternion=t.quaternion.clone(),this.downPosition=new $e(0,0),this.rotateDelta=new $e(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 $e(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new $e(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new $e(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new $e(-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,n=Math.PI*t.y/this.domElement.clientHeight,i=new Cn;i.setFromAxisAngle(this.object.up,e);const r=new Cn;r.setFromAxisAngle(new Rn(1,0,0),n);const s=this.quaternion.clone();s.premultiply(i).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class Pf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new Rn);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2},this.controlsChange=()=>{this.viewer.update()},this.walkspeedChange=t=>{this.viewer.emitEvent(t)},this.viewerRender=()=>{this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new Rf(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.viewer=t,this.viewer.on("render",this.viewerRender),this.viewer.on("zoom",this.viewerZoom),this.updateControls()}dispose(){this.viewer.off("render",this.viewerRender),this.viewer.off("zoom",this.viewerZoom),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose()}}const Lf=new cc,If=new Rn,Df=new Rn,Nf=new Cn,Uf={X:new Rn(1,0,0),Y:new Rn(0,1,0),Z:new Rn(0,0,1)},Of={type:"change"},Ff={type:"mouseDown",mode:null},kf={type:"mouseUp",mode:null},Bf={type:"objectChange"};class zf extends fc{constructor(t,e=null){super(void 0,e);const n=new om(this);this._root=n;const i=new lm;this._gizmo=i,n.add(i);const r=new hm;this._plane=r,n.add(r);const s=this;function a(t,e){let n=e;Object.defineProperty(s,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,r[t]=e,i[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(Of))}}),s[t]=e,r[t]=e,i[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 Rn,l=new Rn,h=new Cn,c=new Cn,d=new Rn,u=new Cn,p=new Rn,f=new Rn,m=new Rn,g=new Rn;a("worldPosition",o),a("worldPositionStart",l),a("worldQuaternion",h),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",f),a("rotationAxis",m),a("rotationAngle",0),a("eye",g),this._offset=new Rn,this._startNorm=new Rn,this._endNorm=new Rn,this._cameraScale=new Rn,this._parentPosition=new Rn,this._parentQuaternion=new Cn,this._parentQuaternionInv=new Cn,this._parentScale=new Rn,this._worldScaleStart=new Rn,this._worldQuaternionInv=new Cn,this._worldScale=new Rn,this._positionStart=new Rn,this._quaternionStart=new Cn,this._scaleStart=new Rn,this._getPointer=Gf.bind(this),this._onPointerDown=Vf.bind(this),this._onPointerHover=Hf.bind(this),this._onPointerMove=Wf.bind(this),this._onPointerUp=Xf.bind(this),null!==e&&this.connect()}connect(){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&&Lf.setFromCamera(t,this.camera);const e=jf(this._gizmo.picker[this.mode],Lf);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&&Lf.setFromCamera(t,this.camera);const e=jf(this._plane,Lf,!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,Ff.mode=this.mode,this.dispatchEvent(Ff)}}pointerMove(t){const e=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===i||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&Lf.setFromCamera(t,this.camera);const s=jf(this._plane,Lf,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"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"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(Nf.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(If.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(If.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if("scale"===n){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),Df.set(t,t,t)}else If.copy(this.pointStart),Df.copy(this.pointEnd),If.applyQuaternion(this._worldQuaternionInv),Df.applyQuaternion(this._worldQuaternionInv),Df.divide(If),-1===e.search("X")&&(Df.x=1),-1===e.search("Y")&&(Df.y=1),-1===e.search("Z")&&(Df.z=1);i.scale.copy(this._scaleStart).multiply(Df),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(If.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(If.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(Uf[e]),If.copy(Uf[e]),"local"===r&&If.applyQuaternion(this.worldQuaternion),If.cross(this.eye),0===If.length()?n=!0:this.rotationAngle=this._offset.dot(If.normalize())*t),("E"===e||n)&&(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"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Nf.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Nf.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Of),this.dispatchEvent(Bf)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(kf.mode=this.mode,this.dispatchEvent(kf)),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(Of),this.dispatchEvent(Bf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Lf}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}}function Gf(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 Hf(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Vf(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 Wf(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Xf(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function jf(t,e,n){const i=e.intersectObject(t,!0);for(let t=0;t<i.length;t++)if(i[t].object.visible||n)return i[t];return!1}const Yf=new mi,qf=new Rn(0,1,0),Kf=new Rn(0,0,0),Zf=new si,Jf=new Cn,Qf=new Cn,$f=new Rn,tm=new si,em=new Rn(1,0,0),nm=new Rn(0,1,0),im=new Rn(0,0,1),rm=new Rn,sm=new Rn,am=new Rn;class om extends Ii{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 lm extends Ii{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new er({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Ul({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=t.clone();n.opacity=.15;const i=e.clone();i.opacity=.5;const r=t.clone();r.color.setHex(16711680);const s=t.clone();s.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const l=t.clone();l.color.setHex(65280),l.opacity=.5;const h=t.clone();h.color.setHex(255),h.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;t.clone().color.setHex(16776960);const u=t.clone();u.color.setHex(7895160);const p=new ih(0,.04,.1,12);p.translate(0,.05,0);const f=new Rr(.08,.08,.08);f.translate(0,.04,0);const m=new mr;m.setAttribute("position",new or([0,0,0,1,0,0],3));const g=new ih(.0075,.0075,.5,3);function _(t,e){const n=new oh(t,.0075,3,64,e*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}g.translate(0,.25,0);const v={X:[[new Ar(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new Ar(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new Ar(g,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Ar(p,s),[0,.5,0]],[new Ar(p,s),[0,-.5,0],[Math.PI,0,0]],[new Ar(g,s)]],Z:[[new Ar(p,a),[0,0,.5],[Math.PI/2,0,0]],[new Ar(p,a),[0,0,-.5],[-Math.PI/2,0,0]],[new Ar(g,a),null,[Math.PI/2,0,0]]],XYZ:[[new Ar(new sh(.1,0),c.clone()),[0,0,0]]],XY:[[new Ar(new Rr(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new Ar(new Rr(.15,.15,.01),o.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ar(new Rr(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},y={X:[[new Ar(new ih(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ar(new ih(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ar(new ih(.2,0,.6,4),n),[0,.3,0]],[new Ar(new ih(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ar(new ih(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ar(new ih(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Ar(new sh(.2,0),n)]],XY:[[new Ar(new Rr(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ar(new Rr(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ar(new Rr(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},x={START:[[new Ar(new sh(.01,2),i),null,null,null,"helper"]],END:[[new Ar(new sh(.01,2),i),null,null,null,"helper"]],DELTA:[[new Vl(function(){const t=new mr;return t.setAttribute("position",new or([0,0,0,1,1,1],3)),t}(),i),null,null,null,"helper"]],X:[[new Vl(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Vl(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Vl(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},S={XYZE:[[new Ar(_(.5,1),u),null,[0,Math.PI/2,0]]],X:[[new Ar(_(.5,.5),r)]],Y:[[new Ar(_(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new Ar(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new Ar(_(.75,1),d),null,[0,Math.PI/2,0]]]},b={AXIS:[[new Vl(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new Ar(new ah(.25,10,8),n)]],X:[[new Ar(new oh(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ar(new oh(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ar(new oh(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ar(new oh(.75,.1,2,24),n)]]},w={X:[[new Ar(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new Ar(g,r),[0,0,0],[0,0,-Math.PI/2]],[new Ar(f,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Ar(f,s),[0,.5,0]],[new Ar(g,s)],[new Ar(f,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Ar(f,a),[0,0,.5],[Math.PI/2,0,0]],[new Ar(g,a),[0,0,0],[Math.PI/2,0,0]],[new Ar(f,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Ar(new Rr(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new Ar(new Rr(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ar(new Rr(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ar(new Rr(.1,.1,.1),c.clone())]]},E={X:[[new Ar(new ih(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ar(new ih(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ar(new ih(.2,0,.6,4),n),[0,.3,0]],[new Ar(new ih(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ar(new ih(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ar(new ih(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Ar(new Rr(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ar(new Rr(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ar(new Rr(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ar(new Rr(.2,.2,.2),n),[0,0,0]]]},T={X:[[new Vl(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Vl(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Vl(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function A(t){const e=new Ii;for(const n in t)for(let i=t[n].length;i--;){const r=t[n][i][0].clone(),s=t[n][i][1],a=t[n][i][2],o=t[n][i][3],l=t[n][i][4];r.name=n,r.tag=l,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const h=r.geometry.clone();h.applyMatrix4(r.matrix),r.geometry=h,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=A(v)),this.add(this.gizmo.rotate=A(S)),this.add(this.gizmo.scale=A(w)),this.add(this.picker.translate=A(y)),this.add(this.picker.rotate=A(M)),this.add(this.picker.scale=A(E)),this.add(this.helper.translate=A(x)),this.add(this.helper.rotate=A(b)),this.add(this.helper.scale=A(T)),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:Qf;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 n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let t=0;t<n.length;t++){const i=n[t];let r;if(i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition),r=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),i.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==i.tag){if(i.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,n=.2;"X"===i.name&&Math.abs(qf.copy(em).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(qf.copy(nm).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(qf.copy(im).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(qf.copy(im).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"YZ"===i.name&&Math.abs(qf.copy(em).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XZ"===i.name&&Math.abs(qf.copy(nm).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)}else"rotate"===this.mode&&(Jf.copy(e),qf.copy(this.eye).applyQuaternion(Nf.copy(e).invert()),-1!==i.name.search("E")&&i.quaternion.setFromRotationMatrix(Zf.lookAt(this.eye,Kf,nm)),"X"===i.name&&(Nf.setFromAxisAngle(em,Math.atan2(-qf.y,qf.z)),Nf.multiplyQuaternions(Jf,Nf),i.quaternion.copy(Nf)),"Y"===i.name&&(Nf.setFromAxisAngle(nm,Math.atan2(qf.x,qf.z)),Nf.multiplyQuaternions(Jf,Nf),i.quaternion.copy(Nf)),"Z"===i.name&&(Nf.setFromAxisAngle(im,Math.atan2(qf.y,qf.x)),Nf.multiplyQuaternions(Jf,Nf),i.quaternion.copy(Nf)));i.visible=i.visible&&(-1===i.name.indexOf("X")||this.showX),i.visible=i.visible&&(-1===i.name.indexOf("Y")||this.showY),i.visible=i.visible&&(-1===i.name.indexOf("Z")||this.showZ),i.visible=i.visible&&(-1===i.name.indexOf("E")||this.showX&&this.showY&&this.showZ),i.material._color=i.material._color||i.material.color.clone(),i.material._opacity=i.material._opacity||i.material.opacity,i.material.color.copy(i.material._color),i.material.opacity=i.material._opacity,this.enabled&&this.axis&&(i.name===this.axis||this.axis.split("").some((function(t){return i.name===t})))&&(i.material.color.setHex(16776960),i.material.opacity=1)}else i.visible=!1,"AXIS"===i.name?(i.visible=!!this.axis,"X"===this.axis&&(Nf.setFromEuler(Yf.set(0,0,0)),i.quaternion.copy(e).multiply(Nf),Math.abs(qf.copy(em).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Y"===this.axis&&(Nf.setFromEuler(Yf.set(0,0,Math.PI/2)),i.quaternion.copy(e).multiply(Nf),Math.abs(qf.copy(nm).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(Nf.setFromEuler(Yf.set(0,Math.PI/2,0)),i.quaternion.copy(e).multiply(Nf),Math.abs(qf.copy(im).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(Nf.setFromEuler(Yf.set(0,Math.PI/2,0)),qf.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Zf.lookAt(Kf,qf,nm)),i.quaternion.multiply(Nf),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),If.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),If.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(If),i.visible=this.dragging):(i.quaternion.copy(e),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class hm extends Ar{constructor(){super(new $r(1e5,1e5,2,2),new er({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"),rm.copy(em).applyQuaternion("local"===e?this.worldQuaternion:Qf),sm.copy(nm).applyQuaternion("local"===e?this.worldQuaternion:Qf),am.copy(im).applyQuaternion("local"===e?this.worldQuaternion:Qf),qf.copy(sm),this.mode){case"translate":case"scale":switch(this.axis){case"X":qf.copy(this.eye).cross(rm),$f.copy(rm).cross(qf);break;case"Y":qf.copy(this.eye).cross(sm),$f.copy(sm).cross(qf);break;case"Z":qf.copy(this.eye).cross(am),$f.copy(am).cross(qf);break;case"XY":$f.copy(am);break;case"YZ":$f.copy(rm);break;case"XZ":qf.copy(am),$f.copy(sm);break;case"XYZ":case"E":$f.set(0,0,0)}break;default:$f.set(0,0,0)}0===$f.length()?this.quaternion.copy(this.cameraQuaternion):(tm.lookAt(If.set(0,0,0),$f,qf),this.quaternion.setFromRotationMatrix(tm)),super.updateMatrixWorld(t)}}class cm extends Vl{constructor(t,e=1,n=16776960,i=new Rn){const r=new mr;r.setAttribute("position",new or([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new Ul({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=i;const s=new mr;s.setAttribute("position",new or([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.helper=new Ar(s,new er({color:n,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)}}class dm extends Tf{constructor(t,e,n){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.viewerExplode=()=>{this.planeHelper.size=this.viewer.extents.getSize(new Rn).length(),this.viewer.update()},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const i=t.extents.getSize(new Rn).length(),r=t.extents.getCenter(new Rn),s=-r.dot(e);this.plane=new Yr(e,s),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new cm(this.plane,i,n,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new Ii,this.planeCenter.position.copy(t.extents.getCenter(new Rn)),this.viewer.helpers.add(this.planeCenter),this.transform=new zf(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.on("explode",this.viewerExplode),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.off("explode",this.viewerExplode),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 um extends dm{constructor(t){super(t,new Rn(1,0,0),16711680)}}class pm extends dm{constructor(t){super(t,new Rn(0,1,0),65280)}}class fm extends dm{constructor(t){super(t,new Rn(0,0,1),255)}}class mm extends Tf{constructor(t){super(t),this.onPointerDown=t=>{0===t.button&&(this.line.startPoint=this.snapper.getSnapPoint(t),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint)},this.onPointerMove=t=>{this.orbit.enabled&&-1!==this.orbit.state||(this.line.endPoint=this.snapper.getSnapPoint(t),this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>=.01?(this.line=new ym(this.overlay),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.renderOverlay=()=>{this.overlay.render()},this.updateSnapper=()=>{this.snapper.update(this.viewer.scene)},this.overlay=new _m(t.camera,t.canvas),this.overlay.attach(),this.line=new ym(this.overlay),this.overlay.addLine(this.line),this.snapper=new gm(t.camera,t.canvas),this.snapper.update(t.scene),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.updateSnapper),this.viewer.addEventListener("isolate",this.updateSnapper),this.viewer.addEventListener("showall",this.updateSnapper)}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.updateSnapper),this.viewer.removeEventListener("isolate",this.updateSnapper),this.viewer.removeEventListener("showall",this.updateSnapper),this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class gm{constructor(t,e){this.objects=[],this.camera=t,this.canvas=e,this.raycaster=new cc}getSnapPoint(t){const e=new $e(t.clientX,t.clientY),n=this.canvas.getBoundingClientRect(),i=(e.x-n.left)/n.width*2-1,r=-(e.y-n.top)/n.height*2+1,s=new $e(i,r);this.raycaster.setFromCamera(s,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}};const a=this.raycaster.intersectObjects(this.objects,!1);if(0!==a.length)return a[0].point}update(t){this.objects=[],t.traverseVisible((t=>this.objects.push(t)))}}class _m{constructor(t,e){this.lines=[],this.camera=t,this.canvas=e,this.projector=new Pm(t,e)}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.background="rgba(0,0,0,0)",this.container.style.position="absolute",this.container.style.top="0px",this.container.style.left="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement.appendChild(this.container)}dispose(){this.clear()}detach(){this.container.remove(),this.container=void 0}clear(){this.lines.forEach((t=>t.dispose())),this.lines=[]}render(){this.projector.updateProjectionMatrix(),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))}}const vm=new Rn;class ym{constructor(t){this.id=Date.now(),this.unit="",this.scale=1,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.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()}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:n}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=n?"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:n}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=n?"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:n,visible:i}=t.projectLine(this.startPoint,this.endPoint);n.sub(e);const r=n.angle(),s=n.length();this.elementLine.style.display=i?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${s}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${r}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){vm.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:n}=t.projectPoint(vm),i=this.getDistance();this.elementLabel.style.display=n&&i>=.01?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=`${i.toFixed(2)} ${this.unit}`}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 xm,Sm;const bm=new si,Mm=new si,wm=new Rn,Em=new Mn,Tm=new Mn,Am=new $e,Cm=new $e,Rm=new $e;class Pm{constructor(t,e){this.camera=t,this.canvas=e}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();xm=t.width/2,Sm=t.height/2,bm.copy(this.camera.matrixWorldInverse),Mm.multiplyMatrices(this.camera.projectionMatrix,bm)}projectPoint(t){wm.copy(t).applyMatrix4(Mm);const e=wm.z>=-1&&wm.z<=1;return Am.x=(wm.x+1)*xm,Am.y=(1-wm.y)*Sm,{point:Am,visible:e}}projectLine(t,e){let n;Em.copy(t).applyMatrix4(Mm),Tm.copy(e).applyMatrix4(Mm);const i=Em.z+Em.w,r=Tm.z+Tm.w,s=-Em.z+Em.w,a=-Tm.z+Tm.w;if(i>=0&&r>=0&&s>=0&&a>=0)n=!0;else if(i<0&&r<0||s<0&&a<0)n=!1;else{let t=0,e=1;i<0?t=Math.max(t,i/(i-r)):r<0&&(e=Math.min(e,i/(i-r))),s<0?t=Math.max(t,s/(s-a)):a<0&&(e=Math.min(e,s/(s-a))),n=e>=t,n&&(Em.lerp(Tm,t),Tm.lerp(Em,1-e))}return Em.multiplyScalar(1/Em.w),Tm.multiplyScalar(1/Tm.w),Cm.x=(Em.x+1)*xm,Cm.y=(1-Em.y)*Sm,Rm.x=(Tm.x+1)*xm,Rm.y=(1-Tm.y)*Sm,{point1:Cm,point2:Rm,visible:n}}}class Lm{constructor(t){this.syncExtents=()=>{const t=this.viewer.models.reduce(((t,e)=>t.expandByObject(e.scene)),new In);this.viewer.extents.copy(t),this.viewer.target.copy(t.getCenter(new Rn))},this.viewer=t,this.viewer.addEventListener("geometryend",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents)}dispose(){this.viewer.removeEventListener("geometryend",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents)}}class Im{constructor(t){this.viewer=t,this.ambientLight=new Jh(16777215,0),this.viewer.camera.add(this.ambientLight),this.directionalLight=new Zh(16777215,1),this.directionalLight.position.set(.5,0,.866),this.viewer.camera.add(this.directionalLight)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight=void 0,this.directionalLight.removeFromParent(),this.directionalLight=void 0}}class Dm extends Xo{constructor(){super();const t=new Rr;t.deleteAttribute("uv");const e=new lh({side:x}),n=new lh,i=new qh(16777215,900,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new Ar(t,e);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new Ar(t,n);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);const a=new Ar(t,n);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);const o=new Ar(t,n);o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),this.add(o);const l=new Ar(t,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const h=new Ar(t,n);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const c=new Ar(t,n);c.position.set(-2.193,-.369,-5.547),c.rotation.set(0,.516,0),c.scale.set(3.875,3.487,2.986),this.add(c);const d=new Ar(t,Nm(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);const u=new Ar(t,Nm(50));u.position.set(-16.109,18.021,-8.207),u.scale.set(.1,2.425,2.751),this.add(u);const p=new Ar(t,Nm(17));p.position.set(14.904,12.198,-1.832),p.scale.set(.15,4.265,6.331),this.add(p);const f=new Ar(t,Nm(43));f.position.set(-.462,8.89,14.52),f.scale.set(4.38,5.441,.088),this.add(f);const m=new Ar(t,Nm(20));m.position.set(3.235,11.486,-12.541),m.scale.set(2.5,2,.1),this.add(m);const g=new Ar(t,Nm(100));g.position.set(0,20,0),g.scale.set(1,.1,1),this.add(g)}dispose(){const t=new Set;this.traverse((e=>{e.isMesh&&(t.add(e.geometry),t.add(e.material))}));for(const e of t)e.dispose()}}function Nm(t){const e=new er;return e.color.setScalar(t),e}class Um{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215)},this.viewer=t,this.backgroundColor=new Ji(16777215);const e=new Dm,n=new ws(this.viewer.renderer);this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.scene.environment=n.fromScene(e).texture,this.viewer.addEventListener("optionschange",this.syncOptions),e.dispose()}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.environment=void 0,this.viewer.scene.background=void 0}}class Om{constructor(t){this.geometryEnd=t=>{const e=this.viewer.extents.getSize(new Rn).length();this.viewer.camera.near=e/100,this.viewer.camera.far=100*e,this.viewer.camera.updateMatrixWorld(),this.viewer.camera.updateProjectionMatrix(),this.viewer.executeCommand("setDefaultViewPosition","sw"),this.viewer.executeCommand("zoomToExtents")},this.viewer=t,this.viewer.addEventListener("geometryend",this.geometryEnd)}dispose(){this.viewer.removeEventListener("geometryend",this.geometryEnd)}}class Fm{constructor(t){this.resizeViewer=t=>{const{width:e,height:n}=t[0].contentRect;e&&n&&(this.viewer.camera.aspect=e/n,this.viewer.camera.updateProjectionMatrix(),this.viewer.renderer.setSize(e,n,!0),this.viewer.update(!0),this.viewer.emitEvent({type:"resize",width:e,height:n}))},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class km{constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t)},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class Bm extends Ii{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new us(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new er({toneMapped:!1,color:"#aa0000"}),n=new er({toneMapped:!1,color:"#00aa00"}),i=new er({toneMapped:!1,color:"#0000aa"}),r=this.getSpriteMaterial(e.color,"X"),s=this.getSpriteMaterial(n.color,"Y"),a=this.getSpriteMaterial(i.color,"Z"),o=new ih(.01,.01,1,3);o.translate(0,.5,0);const l=new ih(0,.1,.25,12);l.translate(0,.625,0);const h={X:[[new Ar(l,e),[.5,0,0],[0,0,-Math.PI/2]],[new Ar(o,e),[0,0,0],[0,0,-Math.PI/2]],[new hl(r),[1.55,0,0]]],Y:[[new Ar(l,n),[0,.5,0],null],[new Ar(o,n),null,null],[new hl(s),[0,1.55,0]]],Z:[[new Ar(l,i),[0,0,.5],[Math.PI/2,0,0]],[new Ar(o,i),null,[Math.PI/2,0,0]],[new hl(a),[0,0,1.55]]]};Object.keys(h).forEach((t=>{h[t].forEach((e=>{const n=e[0],i=e[1],r=e[2];n.name=t,i&&n.position.set(i[0],i[1],i[2]),r&&n.rotation.set(r[0],r[1],r[2]),n.updateMatrixWorld(),this.add(n)}))}))}dispose(){this.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}getSpriteMaterial(t,e){const n=document.createElement("canvas");n.width=64,n.height=64;const i=n.getContext("2d");i.clearRect(0,0,64,64),i.font="24px Arial",i.textAlign="center",i.fillStyle=t.getStyle(),i.fillText(e,32,41);const r=new nh(n);return r.colorSpace=we,new Ko({map:r,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.clippingPlanes,n=t.getViewport(new Mn);t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clippingPlanes=[],t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(n),t.clippingPlanes=e}}class zm{constructor(t){this.viewerRender=()=>{this.viewer.options.showWCS&&(this.viewer.extents.isEmpty()||this.wcsHelper.render(this.viewer.renderer))},this.wcsHelper=new Bm(t.camera),this.viewer=t,this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}t.CANVAS_EVENTS=o,t.CanvasEvents=a,t.Dragger=class{constructor(t){this.name=""}initialize(){}dispose(){}updatePreview(){}},t.Options=s,t.Viewer=class extends xd{constructor(t){super(),this._options=new s(this),this.client=t,this.canvasEvents=o,this.canvaseventlistener=t=>this.emit(t),this.extents=new In,this.target=new Rn,this.draggerFactory={Pan:Af,Zoom:Cf,Orbit:Tf,Walk:Pf,CuttingPlaneXAxis:um,CuttingPlaneYAxis:pm,CuttingPlaneZAxis:fm,MeasureLine:mm},this._activeDragger=null,this.models=[],this.components=[],this.selected=[],this.renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new pf}get options(){return this._options}get draggers(){return Object.keys(this.draggerFactory)}get markup(){return this._markup}initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),this.scene=new Xo,this.helpers=new Xo;const n=t.parentElement.getBoundingClientRect(),i=n.width||1,r=n.height||1;return this.camera=new Br(45,i/r,.01,1e3),this.camera.up.set(0,0,1),this.renderer=new Wo({canvas:t,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(i,r),this.renderer.toneMapping=Q,this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this),this.components.push(new Lm(this)),this.components.push(new Im(this)),this.components.push(new Um(this)),this.components.push(new Om(this)),this.components.push(new Fm(this)),this.components.push(new km(this)),this.components.push(new mc(this)),this.components.push(new zm(this)),this.syncOptions(),this.syncOverlay(),this.renderTime=performance.now(),this.render(this.renderTime),"function"==typeof e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.emitEvent({type:"dispose"}),this.components.forEach((t=>t.dispose())),this.components=[],this.setActiveDragger(),this.removeAllListeners(),this.clear(),this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this.renderer&&this.renderer.dispose(),this.renderer=void 0,this.camera=void 0,this.scene=void 0,this.helpers=void 0,this}isInitialized(){return!!this.renderer}render(t){if(!this.renderNeeded)return;if(!this.renderer)return;this.renderNeeded=!1,this.renderer.setViewport(0,0,this.canvas.offsetWidth,this.canvas.offsetHeight),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);const e=this.renderer.clippingPlanes;this.renderer.clippingPlanes=[],this.renderer.autoClear=!1,this.renderer.render(this.helpers,this.camera),this.renderer.clippingPlanes=e;const n=(t-this.renderTime)/1e3;this.renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:n})}update(t=!1){this.renderNeeded=!0,t&&this.render(performance.now()),this.emitEvent({type:"update",data:t})}syncOptions(t=this.options){}loadReferences(t){return Promise.resolve(this)}async open(t){if(!this.renderer)return this;let e;if(this.cancel(),this.clear(),this.emitEvent({type:"open",file:t,model:t}),t){const n=await t.getModels()||[];e=n.find((t=>t.default))||n[0]}if(!e)throw new Error("No default model found");const n=e.database.split(".").pop();if("gltf"!==n)throw new Error(`Unknown geometry type: ${n}`);const i=`${e.httpClient.serverUrl}${e.path}/${e.database}`,r={requestHeader:e.httpClient.headers};return await this.loadReferences(e),await this.loadGltfFile(i,void 0,r),this}cancel(){return this.emitEvent({type:"cancel"}),this}openGltfFile(t,e=new Map,n={}){return this.renderer?(this.cancel(),this.clear(),this.emitEvent({type:"open"}),this.loadGltfFile(t,e,n)):Promise.resolve(this)}async loadGltfFile(t,e=new Map,n={}){const i=new yd(t,e,n);try{this.emitEvent({type:"geometrystart"});const t=new bc(i);t.setPath(i.path),t.setRequestHeader(n.requestHeader),t.setCrossOrigin(n.crossOrigin||t.crossOrigin),t.setWithCredentials(n.withCredentials||t.withCredentials);const e=await t.loadAsync(i.fileURL,(t=>{const{lengthComputable:e,loaded:n,total:i}=t,r=e?n/i:1;this.emitEvent({type:"geometryprogress",data:r})}));if(!this.scene)return this;if(!e.scene)throw new Error("No glTF scene found");this.models.push(e),this.scene.add(e.scene),this.syncOptions(),this.syncOverlay(),this.update(),this.emitEvent({type:"databasechunk"}),this.emitEvent({type:"geometryend",data:e.scene})}catch(t){throw this.emitEvent({type:"geometryerror",data:t}),t}finally{i.dispose()}return this}clear(){if(!this.renderer)return this;function t(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach((t=>{t.dispose()})))}return this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.helpers.traverse(t),this.helpers.clear(),this.models.forEach((e=>e.scene.traverse(t))),this.models.forEach((t=>t.scene.removeFromParent())),this.models=[],this.scene.clear(),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this}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")}setSelected(t){this.executeCommand("setSelected",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){if(this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()){const e=this.draggerFactory[t];e&&(this._activeDragger=new e(this),this._activeDragger.name=t)}const e=this.canvas;e&&(e.className=e.className.split(" ").filter((t=>!t.startsWith("oda-cursor-"))).filter((t=>t)).concat(`oda-cursor-${t.toLowerCase()}`).join(" ")),this.emitEvent({type:"changeactivedragger",data:t}),this.update()}return this._activeDragger}resetActiveDragger(){const t=this._activeDragger;t&&(this.setActiveDragger(),this.setActiveDragger(t.name))}is3D(){return!0}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),n=t.x/(e.width/2)-1,i=-t.y/(e.height/2)+1,r=new Rn(n,i,-1);return r.unproject(this.camera),{x:r.x,y:r.y,z:r.z}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new Rn(t.x,t.y,t.z);e.project(this.camera);const n=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(n.width/2),y:(1-e.y)*(n.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return i("ThreeJS").executeCommand(t,this,...e)}getComponent(t){return this.components.find((e=>e instanceof t))}drawViewpoint(t){var e,n,i;if(!this.renderer)return;const r=({x:t,y:e,z:n})=>new Rn(t,e,n),s=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{t&&(this.camera.up.copy(r(t.up_vector)),this.camera.fov=t.field_of_view,this.camera.position.copy(r(t.view_point)),this.camera.lookAt(r(t.direction).add(this.camera.position)),this.camera.updateMatrixWorld(),this.camera.updateProjectionMatrix())})(t.perspective_camera),(t=>{null==t||t.forEach((t=>{const e=new Yr;e.setFromNormalAndCoplanarPoint(r(t.direction),r(t.location)),this.renderer.clippingPlanes.push(e)}))})(t.clipping_planes),(t=>{this.setSelected(null==t?void 0:t.map((t=>t.handle)))})(t.selection),this._markup.setViewpoint(t),this.target=r(null!==(i=null===(n=t.custom_fields)||void 0===n?void 0:n.camera_target)&&void 0!==i?i:this.target),this.setActiveDragger(s),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:n})=>({x:t,y:e,z:n}),e={custom_fields:{}};return e.perspective_camera=(()=>({view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new Rn)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}))(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach((n=>{const i={location:t(n.coplanarPoint(new Rn)),direction:t(n.normal)};e.push(i)})),e})(),e.selection=(()=>this.getSelected().map((t=>({handle:t}))))(),e.description=(new Date).toDateString(),this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),this.emitEvent({type:"createviewpoint",data:e}),e}},t.commands=i,t.defaultOptions=r}));
|
|
6
|
+
*/const on="170",ln=0,hn=1,cn=2,dn=0,un=1,pn=2,fn=3,mn=1,gn=2,_n=3,vn=0,yn=1,xn=2,Sn=100,bn=101,Mn=102,wn=200,En=201,Tn=202,An=203,Cn=204,Rn=205,Pn=206,Ln=207,In=208,Dn=209,Nn=210,Un=211,On=212,Fn=213,kn=214,Bn=0,zn=1,Gn=2,Hn=3,Vn=4,Wn=5,Xn=6,jn=7,Yn=0,qn=1,Kn=2,Zn=0,Qn=1,Jn=2,$n=3,ti=4,ei=5,ni=6,ii=7,ri="attached",si=301,ai=302,oi=306,li=1e3,hi=1001,ci=1002,di=1003,ui=1004,pi=1005,fi=1006,mi=1007,gi=1008,_i=1009,vi=1010,yi=1011,xi=1012,Si=1013,bi=1014,Mi=1015,wi=1016,Ei=1017,Ti=1018,Ai=1020,Ci=35902,Ri=1021,Pi=1022,Li=1023,Ii=1024,Di=1025,Ni=1026,Ui=1027,Oi=1028,Fi=1029,ki=1030,Bi=1031,zi=1033,Gi=33776,Hi=33777,Vi=33778,Wi=33779,Xi=35840,ji=35841,Yi=35842,qi=35843,Ki=36196,Zi=37492,Qi=37496,Ji=37808,$i=37809,tr=37810,er=37811,nr=37812,ir=37813,rr=37814,sr=37815,ar=37816,or=37817,lr=37818,hr=37819,cr=37820,dr=37821,ur=36492,pr=36494,fr=36495,mr=36283,gr=36284,_r=36285,vr=36286,yr=2300,xr=2301,Sr=2302,br="",Mr="srgb",wr="srgb-linear",Er="linear",Tr="srgb",Ar=7680,Cr=512,Rr=513,Pr=514,Lr=515,Ir=516,Dr=517,Nr=518,Ur=519,Or=35044,Fr="300 es",kr=2e3,Br=2001;class zr{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}}const Gr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Hr=1234567;const Vr=Math.PI/180,Wr=180/Math.PI;function Xr(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(Gr[255&t]+Gr[t>>8&255]+Gr[t>>16&255]+Gr[t>>24&255]+"-"+Gr[255&e]+Gr[e>>8&255]+"-"+Gr[e>>16&15|64]+Gr[e>>24&255]+"-"+Gr[63&n|128]+Gr[n>>8&255]+"-"+Gr[n>>16&255]+Gr[n>>24&255]+Gr[255&i]+Gr[i>>8&255]+Gr[i>>16&255]+Gr[i>>24&255]).toLowerCase()}function jr(t,e,n){return Math.max(e,Math.min(n,t))}function Yr(t,e){return(t%e+e)%e}function qr(t,e,n){return(1-n)*t+n*e}function Kr(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Zr(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Qr={DEG2RAD:Vr,RAD2DEG:Wr,generateUUID:Xr,clamp:jr,euclideanModulo:Yr,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:qr,damp:function(t,e,n,i){return qr(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(Yr(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(Hr=t);let e=Hr+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Vr},radToDeg:function(t){return t*Wr},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),h=s((e+i)/2),c=a((e+i)/2),d=s((e-i)/2),u=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*c,l*d,l*u,o*h);break;case"YZY":t.set(l*u,o*c,l*d,o*h);break;case"ZXZ":t.set(l*d,l*u,o*c,o*h);break;case"XZX":t.set(o*c,l*f,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*f,o*h);break;case"ZYZ":t.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Zr,denormalize:Kr};class Jr{constructor(t=0,e=0){Jr.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(jr(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class $r{constructor(t,e,n,i,r,s,a,o,l){$r.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=r,h[5]=o,h[6]=n,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],h=n[4],c=n[7],d=n[2],u=n[5],p=n[8],f=i[0],m=i[3],g=i[6],_=i[1],v=i[4],y=i[7],x=i[2],S=i[5],b=i[8];return r[0]=s*f+a*_+o*x,r[3]=s*m+a*v+o*S,r[6]=s*g+a*y+o*b,r[1]=l*f+h*_+c*x,r[4]=l*m+h*v+c*S,r[7]=l*g+h*y+c*b,r[2]=d*f+u*_+p*x,r[5]=d*m+u*v+p*S,r[8]=d*g+u*y+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*s*h-e*a*l-n*r*h+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=h*s-a*l,d=a*o-h*r,u=l*r-s*o,p=e*c+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=c*f,t[1]=(i*l-h*n)*f,t[2]=(a*n-i*s)*f,t[3]=d*f,t[4]=(h*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=u*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ts.makeScale(t,e)),this}rotate(t){return this.premultiply(ts.makeRotation(-t)),this}translate(t,e){return this.premultiply(ts.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ts=new $r;function es(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function ns(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function is(){const t=ns("canvas");return t.style.display="block",t}const rs={};function ss(t){t in rs||(rs[t]=!0,console.warn(t))}const as={enabled:!0,workingColorSpace:wr,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===Tr&&(t.r=os(t.r),t.g=os(t.g),t.b=os(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Tr&&(t.r=ls(t.r),t.g=ls(t.g),t.b=ls(t.b)),t):t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===br?Er:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}};function os(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function ls(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const hs=[.64,.33,.3,.6,.15,.06],cs=[.2126,.7152,.0722],ds=[.3127,.329],us=(new $r).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ps=(new $r).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);let fs;as.define({[wr]:{primaries:hs,whitePoint:ds,transfer:Er,toXYZ:us,fromXYZ:ps,luminanceCoefficients:cs,workingColorSpaceConfig:{unpackColorSpace:Mr},outputColorSpaceConfig:{drawingBufferColorSpace:Mr}},[Mr]:{primaries:hs,whitePoint:ds,transfer:Tr,toXYZ:us,fromXYZ:ps,luminanceCoefficients:cs,outputColorSpaceConfig:{drawingBufferColorSpace:Mr}}});class ms{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===fs&&(fs=ns("canvas")),fs.width=t.width,fs.height=t.height;const n=fs.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=fs}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ns("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*os(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*os(e[t]/255)):e[t]=os(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let gs=0;class _s{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:gs++}),this.uuid=Xr(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(vs(i[e].image)):t.push(vs(i[e]))}else t=vs(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function vs(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?ms.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ys=0;class xs extends zr{constructor(t=xs.DEFAULT_IMAGE,e=xs.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=Li,o=_i,l=xs.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ys++}),this.uuid=Xr(),this.name="",this.source=new _s(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Jr(0,0),this.repeat=new Jr(1,1),this.center=new Jr(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new $r,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case li:t.x=t.x-Math.floor(t.x);break;case hi:t.x=t.x<0?0:1;break;case ci:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case li:t.y=t.y-Math.floor(t.y);break;case hi:t.y=t.y<0?0:1;break;case ci:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}xs.DEFAULT_IMAGE=null,xs.DEFAULT_MAPPING=300,xs.DEFAULT_ANISOTROPY=1;class Ss{constructor(t=0,e=0,n=0,i=1){Ss.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],h=o[4],c=o[8],d=o[1],u=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(h-d)<s&&Math.abs(c-f)<s&&Math.abs(p-m)<s){if(Math.abs(h+d)<a&&Math.abs(c+f)<a&&Math.abs(p+m)<a&&Math.abs(l+u+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(u+1)/2,_=(g+1)/2,v=(h+d)/4,y=(c+f)/4,x=(p+m)/4;return t>o&&t>_?t<s?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=v/n,r=y/n):o>_?o<s?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=v/i,r=x/i):_<s?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(_),n=y/r,i=x/r),this.set(n,i,r,e),this}let _=Math.sqrt((m-p)*(m-p)+(c-f)*(c-f)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(c-f)/_,this.z=(d-h)/_,this.w=Math.acos((l+u+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class bs extends zr{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Ss(0,0,t,e),this.scissorTest=!1,this.viewport=new Ss(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:fi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new xs(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const s=n.count;for(let t=0;t<s;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++)this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new _s(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ms extends bs{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class ws extends xs{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=di,this.minFilter=di,this.wrapR=hi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Es extends xs{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=di,this.minFilter=di,this.wrapR=hi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ts{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,s,a){let o=n[i+0],l=n[i+1],h=n[i+2],c=n[i+3];const d=r[s+0],u=r[s+1],p=r[s+2],f=r[s+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=h,void(t[e+3]=c);if(1===a)return t[e+0]=d,t[e+1]=u,t[e+2]=p,void(t[e+3]=f);if(c!==f||o!==d||l!==u||h!==p){let t=1-a;const e=o*d+l*u+h*p+c*f,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+d*r,l=l*t+u*r,h=h*t+p*r,c=c*t+f*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=t,l*=t,h*=t,c*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],h=n[i+3],c=r[s],d=r[s+1],u=r[s+2],p=r[s+3];return t[e]=a*p+h*c+o*u-l*d,t[e+1]=o*p+h*d+l*c-a*u,t[e+2]=l*p+h*u+a*d-o*c,t[e+3]=h*p-a*c-o*d-l*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),h=a(i/2),c=a(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"YXZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"ZXY":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"ZYX":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"YZX":this._x=d*h*c+l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c-d*u*p;break;case"XZY":this._x=d*h*c-l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],d=n+a+c;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(h-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>c){const t=2*Math.sqrt(1+n-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-n-c);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(jr(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=n*h+s*a+i*l-r*o,this._y=i*h+s*o+r*a-n*l,this._z=r*h+s*l+n*o-i*a,this._w=s*h-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(o),h=Math.atan2(l,a),c=Math.sin((1-e)*h)/l,d=Math.sin(e*h)/l;return this._w=s*c+this._w*d,this._x=n*c+this._x*d,this._y=i*c+this._y*d,this._z=r*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class As{constructor(t=0,e=0,n=0){As.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Rs.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Rs.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),h=2*(a*e-r*i),c=2*(r*n-s*e);return this.x=e+o*l+s*c-a*h,this.y=n+o*h+a*l-r*c,this.z=i+o*c+r*h-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Cs.copy(this).projectOnVector(t),this.sub(Cs)}reflect(t){return this.sub(Cs.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(jr(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Cs=new As,Rs=new Ts;class Ps{constructor(t=new As(1/0,1/0,1/0),e=new As(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Is.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Is.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Is.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}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=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,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}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,Is):Is.fromBufferAttribute(i,e),Is.applyMatrix4(t.matrixWorld),this.expandByPoint(Is);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Ds.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),Ds.copy(n.boundingBox)),Ds.applyMatrix4(t.matrixWorld),this.union(Ds)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}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&&this.min.z<=t.min.z&&t.max.z<=this.max.z}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),(t.z-this.min.z)/(this.max.z-this.min.z))}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&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Is),Is.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(zs),Gs.subVectors(this.max,zs),Ns.subVectors(t.a,zs),Us.subVectors(t.b,zs),Os.subVectors(t.c,zs),Fs.subVectors(Us,Ns),ks.subVectors(Os,Us),Bs.subVectors(Ns,Os);let e=[0,-Fs.z,Fs.y,0,-ks.z,ks.y,0,-Bs.z,Bs.y,Fs.z,0,-Fs.x,ks.z,0,-ks.x,Bs.z,0,-Bs.x,-Fs.y,Fs.x,0,-ks.y,ks.x,0,-Bs.y,Bs.x,0];return!!Ws(e,Ns,Us,Os,Gs)&&(e=[1,0,0,0,1,0,0,0,1],!!Ws(e,Ns,Us,Os,Gs)&&(Hs.crossVectors(Fs,ks),e=[Hs.x,Hs.y,Hs.z],Ws(e,Ns,Us,Os,Gs)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Is).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Is).length()),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}applyMatrix4(t){return this.isEmpty()||(Ls[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ls[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ls[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ls[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ls[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ls[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ls[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ls[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ls)),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)}}const Ls=[new As,new As,new As,new As,new As,new As,new As,new As],Is=new As,Ds=new Ps,Ns=new As,Us=new As,Os=new As,Fs=new As,ks=new As,Bs=new As,zs=new As,Gs=new As,Hs=new As,Vs=new As;function Ws(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){Vs.fromArray(t,s);const a=r.x*Math.abs(Vs.x)+r.y*Math.abs(Vs.y)+r.z*Math.abs(Vs.z),o=e.dot(Vs),l=n.dot(Vs),h=i.dot(Vs);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Xs=new Ps,js=new As,Ys=new As;class qs{constructor(t=new As,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Xs.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;js.subVectors(t,this.center);const e=js.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(js,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Ys.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(js.copy(t.center).add(Ys)),this.expandByPoint(js.copy(t.center).sub(Ys))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Ks=new As,Zs=new As,Qs=new As,Js=new As,$s=new As,ta=new As,ea=new As;class na{constructor(t=new As,e=new As(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Ks)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ks.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ks.copy(this.origin).addScaledVector(this.direction,e),Ks.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Zs.copy(t).add(e).multiplyScalar(.5),Qs.copy(e).sub(t).normalize(),Js.copy(this.origin).sub(Zs);const r=.5*t.distanceTo(e),s=-this.direction.dot(Qs),a=Js.dot(this.direction),o=-Js.dot(Qs),l=Js.lengthSq(),h=Math.abs(1-s*s);let c,d,u,p;if(h>0)if(c=s*o-a,d=s*a-o,p=r*h,c>=0)if(d>=-p)if(d<=p){const t=1/h;c*=t,d*=t,u=c*(c+s*d+2*a)+d*(s*c+d+2*o)+l}else d=r,c=Math.max(0,-(s*d+a)),u=-c*c+d*(d+2*o)+l;else d=-r,c=Math.max(0,-(s*d+a)),u=-c*c+d*(d+2*o)+l;else d<=-p?(c=Math.max(0,-(-s*r+a)),d=c>0?-r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l):d<=p?(c=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(c=Math.max(0,-(s*r+a)),d=c>0?r:Math.min(Math.max(-r,-o),r),u=-c*c+d*(d+2*o)+l);else d=s>0?-r:r,c=Math.max(0,-(s*d+a)),u=-c*c+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,c),i&&i.copy(Zs).addScaledVector(Qs,d),u}intersectSphere(t,e){Ks.subVectors(t.center,this.origin);const n=Ks.dot(this.direction),i=Ks.dot(Ks)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,s=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,s=(t.min.y-d.y)*h),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s<i||isNaN(i))&&(i=s),c>=0?(a=(t.min.z-d.z)*c,o=(t.max.z-d.z)*c):(a=(t.max.z-d.z)*c,o=(t.min.z-d.z)*c),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,Ks)}intersectTriangle(t,e,n,i,r){$s.subVectors(e,t),ta.subVectors(n,t),ea.crossVectors($s,ta);let s,a=this.direction.dot(ea);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Js.subVectors(this.origin,t);const o=s*this.direction.dot(ta.crossVectors(Js,ta));if(o<0)return null;const l=s*this.direction.dot($s.cross(Js));if(l<0)return null;if(o+l>a)return null;const h=-s*Js.dot(ea);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ia{constructor(t,e,n,i,r,s,a,o,l,h,c,d,u,p,f,m){ia.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,h,c,d,u,p,f,m)}set(t,e,n,i,r,s,a,o,l,h,c,d,u,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=d,g[3]=u,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new ia).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/ra.setFromMatrixColumn(t,0).length(),r=1/ra.setFromMatrixColumn(t,1).length(),s=1/ra.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),h=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=s*h,n=s*c,i=a*h,r=a*c;e[0]=o*h,e[4]=-o*c,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*h,n=o*c,i=l*h,r=l*c;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*c,e[5]=s*h,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*h,n=o*c,i=l*h,r=l*c;e[0]=t-r*a,e[4]=-s*c,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*h,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*h,n=s*c,i=a*h,r=a*c;e[0]=o*h,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*c,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*h,e[4]=r-t*c,e[8]=i*c+n,e[1]=c,e[5]=s*h,e[9]=-a*h,e[2]=-l*h,e[6]=n*c+i,e[10]=t-r*c}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*h,e[4]=-c,e[8]=l*h,e[1]=t*c+r,e[5]=s*h,e[9]=n*c-i,e[2]=i*c-n,e[6]=a*h,e[10]=r*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(aa,t,oa)}lookAt(t,e,n){const i=this.elements;return ca.subVectors(t,e),0===ca.lengthSq()&&(ca.z=1),ca.normalize(),la.crossVectors(n,ca),0===la.lengthSq()&&(1===Math.abs(n.z)?ca.x+=1e-4:ca.z+=1e-4,ca.normalize(),la.crossVectors(n,ca)),la.normalize(),ha.crossVectors(ca,la),i[0]=la.x,i[4]=ha.x,i[8]=ca.x,i[1]=la.y,i[5]=ha.y,i[9]=ca.y,i[2]=la.z,i[6]=ha.z,i[10]=ca.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],h=n[1],c=n[5],d=n[9],u=n[13],p=n[2],f=n[6],m=n[10],g=n[14],_=n[3],v=n[7],y=n[11],x=n[15],S=i[0],b=i[4],M=i[8],w=i[12],E=i[1],T=i[5],A=i[9],C=i[13],R=i[2],P=i[6],L=i[10],I=i[14],D=i[3],N=i[7],U=i[11],O=i[15];return r[0]=s*S+a*E+o*R+l*D,r[4]=s*b+a*T+o*P+l*N,r[8]=s*M+a*A+o*L+l*U,r[12]=s*w+a*C+o*I+l*O,r[1]=h*S+c*E+d*R+u*D,r[5]=h*b+c*T+d*P+u*N,r[9]=h*M+c*A+d*L+u*U,r[13]=h*w+c*C+d*I+u*O,r[2]=p*S+f*E+m*R+g*D,r[6]=p*b+f*T+m*P+g*N,r[10]=p*M+f*A+m*L+g*U,r[14]=p*w+f*C+m*I+g*O,r[3]=_*S+v*E+y*R+x*D,r[7]=_*b+v*T+y*P+x*N,r[11]=_*M+v*A+y*L+x*U,r[15]=_*w+v*C+y*I+x*O,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],h=t[2],c=t[6],d=t[10],u=t[14];return t[3]*(+r*o*c-i*l*c-r*a*d+n*l*d+i*a*u-n*o*u)+t[7]*(+e*o*u-e*l*d+r*s*d-i*s*u+i*l*h-r*o*h)+t[11]*(+e*l*c-e*a*u-r*s*c+n*s*u+r*a*h-n*l*h)+t[15]*(-i*a*h-e*o*c+e*a*d+i*s*c-n*s*d+n*o*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=t[9],d=t[10],u=t[11],p=t[12],f=t[13],m=t[14],g=t[15],_=c*m*l-f*d*l+f*o*u-a*m*u-c*o*g+a*d*g,v=p*d*l-h*m*l-p*o*u+s*m*u+h*o*g-s*d*g,y=h*f*l-p*c*l+p*a*u-s*f*u-h*a*g+s*c*g,x=p*c*o-h*f*o-p*a*d+s*f*d+h*a*m-s*c*m,S=e*_+n*v+i*y+r*x;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/S;return t[0]=_*b,t[1]=(f*d*r-c*m*r-f*i*u+n*m*u+c*i*g-n*d*g)*b,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*b,t[3]=(c*o*r-a*d*r-c*i*l+n*d*l+a*i*u-n*o*u)*b,t[4]=v*b,t[5]=(h*m*r-p*d*r+p*i*u-e*m*u-h*i*g+e*d*g)*b,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*b,t[7]=(s*d*r-h*o*r+h*i*l-e*d*l-s*i*u+e*o*u)*b,t[8]=y*b,t[9]=(p*c*r-h*f*r-p*n*u+e*f*u+h*n*g-e*c*g)*b,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*b,t[11]=(h*a*r-s*c*r-h*n*l+e*c*l+s*n*u-e*a*u)*b,t[12]=x*b,t[13]=(h*f*i-p*c*i+p*n*d-e*f*d-h*n*m+e*c*m)*b,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*b,t[15]=(s*c*i-h*a*i+h*n*o-e*c*o-s*n*d+e*a*d)*b,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,h=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,h*a+n,h*o-i*s,0,l*o-i*a,h*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,h=s+s,c=a+a,d=r*l,u=r*h,p=r*c,f=s*h,m=s*c,g=a*c,_=o*l,v=o*h,y=o*c,x=n.x,S=n.y,b=n.z;return i[0]=(1-(f+g))*x,i[1]=(u+y)*x,i[2]=(p-v)*x,i[3]=0,i[4]=(u-y)*S,i[5]=(1-(d+g))*S,i[6]=(m+_)*S,i[7]=0,i[8]=(p+v)*b,i[9]=(m-_)*b,i[10]=(1-(d+f))*b,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=ra.set(i[0],i[1],i[2]).length();const s=ra.set(i[4],i[5],i[6]).length(),a=ra.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],sa.copy(this);const o=1/r,l=1/s,h=1/a;return sa.elements[0]*=o,sa.elements[1]*=o,sa.elements[2]*=o,sa.elements[4]*=l,sa.elements[5]*=l,sa.elements[6]*=l,sa.elements[8]*=h,sa.elements[9]*=h,sa.elements[10]*=h,e.setFromRotationMatrix(sa),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=2e3){const o=this.elements,l=2*r/(e-t),h=2*r/(n-i),c=(e+t)/(e-t),d=(n+i)/(n-i);let u,p;if(a===kr)u=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Br)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);u=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=h,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=2e3){const o=this.elements,l=1/(e-t),h=1/(n-i),c=1/(s-r),d=(e+t)*l,u=(n+i)*h;let p,f;if(a===kr)p=(s+r)*c,f=-2*c;else{if(a!==Br)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*c,f=-1*c}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const ra=new As,sa=new ia,aa=new As(0,0,0),oa=new As(1,1,1),la=new As,ha=new As,ca=new As,da=new ia,ua=new Ts;class pa{constructor(t=0,e=0,n=0,i=pa.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],h=i[9],c=i[2],d=i[6],u=i[10];switch(e){case"XYZ":this._y=Math.asin(jr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-jr(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(jr(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,u),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-jr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(jr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,u));break;case"XZY":this._z=Math.asin(-jr(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return da.makeRotationFromQuaternion(t),this.setFromRotationMatrix(da,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ua.setFromEuler(this),this.setFromQuaternion(ua,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}pa.DEFAULT_ORDER="XYZ";class fa{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return!!(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let ma=0;const ga=new As,_a=new Ts,va=new ia,ya=new As,xa=new As,Sa=new As,ba=new Ts,Ma=new As(1,0,0),wa=new As(0,1,0),Ea=new As(0,0,1),Ta={type:"added"},Aa={type:"removed"},Ca={type:"childadded",child:null},Ra={type:"childremoved",child:null};class Pa extends zr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ma++}),this.uuid=Xr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pa.DEFAULT_UP.clone();const t=new As,e=new pa,n=new Ts,i=new As(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ia},normalMatrix:{value:new $r}}),this.matrix=new ia,this.matrixWorld=new ia,this.matrixAutoUpdate=Pa.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return _a.setFromAxisAngle(t,e),this.quaternion.multiply(_a),this}rotateOnWorldAxis(t,e){return _a.setFromAxisAngle(t,e),this.quaternion.premultiply(_a),this}rotateX(t){return this.rotateOnAxis(Ma,t)}rotateY(t){return this.rotateOnAxis(wa,t)}rotateZ(t){return this.rotateOnAxis(Ea,t)}translateOnAxis(t,e){return ga.copy(t).applyQuaternion(this.quaternion),this.position.add(ga.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ma,t)}translateY(t){return this.translateOnAxis(wa,t)}translateZ(t){return this.translateOnAxis(Ea,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(va.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?ya.copy(t):ya.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),xa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?va.lookAt(xa,ya,this.up):va.lookAt(ya,xa,this.up),this.quaternion.setFromRotationMatrix(va),i&&(va.extractRotation(i.matrixWorld),_a.setFromRotationMatrix(va),this.quaternion.premultiply(_a.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Ta),Ca.child=t,this.dispatchEvent(Ca),Ca.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Aa),Ra.child=t,this.dispatchEvent(Ra),Ra.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),va.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),va.multiply(t.parent.matrixWorld)),t.applyMatrix4(va),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Ta),Ca.child=t,this.dispatchEvent(Ca),Ca.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xa,t,Sa),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xa,ba,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=s(t.geometries),i=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),h=s(t.animations),c=s(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h),c.length>0&&(n.nodes=c)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}Pa.DEFAULT_UP=new As(0,1,0),Pa.DEFAULT_MATRIX_AUTO_UPDATE=!0,Pa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const La=new As,Ia=new As,Da=new As,Na=new As,Ua=new As,Oa=new As,Fa=new As,ka=new As,Ba=new As,za=new As,Ga=new Ss,Ha=new Ss,Va=new Ss;class Wa{constructor(t=new As,e=new As,n=new As){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),La.subVectors(t,e),i.cross(La);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){La.subVectors(i,e),Ia.subVectors(n,e),Da.subVectors(t,e);const s=La.dot(La),a=La.dot(Ia),o=La.dot(Da),l=Ia.dot(Ia),h=Ia.dot(Da),c=s*l-a*a;if(0===c)return r.set(0,0,0),null;const d=1/c,u=(l*o-a*h)*d,p=(s*h-a*o)*d;return r.set(1-u-p,p,u)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Na)&&(Na.x>=0&&Na.y>=0&&Na.x+Na.y<=1)}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,Na)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Na.x),o.addScaledVector(s,Na.y),o.addScaledVector(a,Na.z),o)}static getInterpolatedAttribute(t,e,n,i,r,s){return Ga.setScalar(0),Ha.setScalar(0),Va.setScalar(0),Ga.fromBufferAttribute(t,e),Ha.fromBufferAttribute(t,n),Va.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(Ga,r.x),s.addScaledVector(Ha,r.y),s.addScaledVector(Va,r.z),s}static isFrontFacing(t,e,n,i){return La.subVectors(n,e),Ia.subVectors(t,e),La.cross(Ia).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return La.subVectors(this.c,this.b),Ia.subVectors(this.a,this.b),.5*La.cross(Ia).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Wa.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Wa.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Wa.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Wa.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Wa.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Ua.subVectors(i,n),Oa.subVectors(r,n),ka.subVectors(t,n);const o=Ua.dot(ka),l=Oa.dot(ka);if(o<=0&&l<=0)return e.copy(n);Ba.subVectors(t,i);const h=Ua.dot(Ba),c=Oa.dot(Ba);if(h>=0&&c<=h)return e.copy(i);const d=o*c-h*l;if(d<=0&&o>=0&&h<=0)return s=o/(o-h),e.copy(n).addScaledVector(Ua,s);za.subVectors(t,r);const u=Ua.dot(za),p=Oa.dot(za);if(p>=0&&u<=p)return e.copy(r);const f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Oa,a);const m=h*p-u*c;if(m<=0&&c-h>=0&&u-p>=0)return Fa.subVectors(r,i),a=(c-h)/(c-h+(u-p)),e.copy(i).addScaledVector(Fa,a);const g=1/(m+f+d);return s=f*g,a=d*g,e.copy(n).addScaledVector(Ua,s).addScaledVector(Oa,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Xa={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ja={h:0,s:0,l:0},Ya={h:0,s:0,l:0};function qa(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Ka{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Mr){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,as.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=as.workingColorSpace){return this.r=t,this.g=e,this.b=n,as.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=as.workingColorSpace){if(t=Yr(t,1),e=jr(e,0,1),n=jr(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=qa(r,i,t+1/3),this.g=qa(r,i,t),this.b=qa(r,i,t-1/3)}return as.toWorkingColorSpace(this,i),this}setStyle(t,e=Mr){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Mr){const n=Xa[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=os(t.r),this.g=os(t.g),this.b=os(t.b),this}copyLinearToSRGB(t){return this.r=ls(t.r),this.g=ls(t.g),this.b=ls(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Mr){return as.fromWorkingColorSpace(Za.copy(this),t),65536*Math.round(jr(255*Za.r,0,255))+256*Math.round(jr(255*Za.g,0,255))+Math.round(jr(255*Za.b,0,255))}getHexString(t=Mr){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=as.workingColorSpace){as.fromWorkingColorSpace(Za.copy(this),e);const n=Za.r,i=Za.g,r=Za.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const h=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=h<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i<r?6:0);break;case i:o=(r-n)/t+2;break;case r:o=(n-i)/t+4}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=as.workingColorSpace){return as.fromWorkingColorSpace(Za.copy(this),e),t.r=Za.r,t.g=Za.g,t.b=Za.b,t}getStyle(t=Mr){as.fromWorkingColorSpace(Za.copy(this),t);const e=Za.r,n=Za.g,i=Za.b;return t!==Mr?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(ja),this.setHSL(ja.h+t,ja.s+e,ja.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(ja),t.getHSL(Ya);const n=qr(ja.h,Ya.h,e),i=qr(ja.s,Ya.s,e),r=qr(ja.l,Ya.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Za=new Ka;Ka.NAMES=Xa;let Qa=0;class Ja extends zr{static get type(){return"Material"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Qa++}),this.uuid=Xr(),this.name="",this.blending=1,this.side=vn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=Sn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ka(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ar,this.stencilZFail=Ar,this.stencilZPass=Ar,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==vn&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==Sn&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ar&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ar&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ar&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class $a extends Ja{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new Ka(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pa,this.combine=Yn,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const to=new As,eo=new Jr;class no{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=Or,this.updateRanges=[],this.gpuType=Mi,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)eo.fromBufferAttribute(this,e),eo.applyMatrix3(t),this.setXY(e,eo.x,eo.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)to.fromBufferAttribute(this,e),to.applyMatrix3(t),this.setXYZ(e,to.x,to.y,to.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)to.fromBufferAttribute(this,e),to.applyMatrix4(t),this.setXYZ(e,to.x,to.y,to.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)to.fromBufferAttribute(this,e),to.applyNormalMatrix(t),this.setXYZ(e,to.x,to.y,to.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)to.fromBufferAttribute(this,e),to.transformDirection(t),this.setXYZ(e,to.x,to.y,to.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Kr(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Zr(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Kr(e,this.array)),e}setX(t,e){return this.normalized&&(e=Zr(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Kr(e,this.array)),e}setY(t,e){return this.normalized&&(e=Zr(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Kr(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Zr(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Kr(e,this.array)),e}setW(t,e){return this.normalized&&(e=Zr(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Zr(e,this.array),n=Zr(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Zr(e,this.array),n=Zr(n,this.array),i=Zr(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Zr(e,this.array),n=Zr(n,this.array),i=Zr(i,this.array),r=Zr(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Or&&(t.usage=this.usage),t}}class io extends no{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ro extends no{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class so extends no{constructor(t,e,n){super(new Float32Array(t),e,n)}}let ao=0;const oo=new ia,lo=new Pa,ho=new As,co=new Ps,uo=new Ps,po=new As;class fo extends zr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ao++}),this.uuid=Xr(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(es(t)?ro:io)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new $r).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return oo.makeRotationFromQuaternion(t),this.applyMatrix4(oo),this}rotateX(t){return oo.makeRotationX(t),this.applyMatrix4(oo),this}rotateY(t){return oo.makeRotationY(t),this.applyMatrix4(oo),this}rotateZ(t){return oo.makeRotationZ(t),this.applyMatrix4(oo),this}translate(t,e,n){return oo.makeTranslation(t,e,n),this.applyMatrix4(oo),this}scale(t,e,n){return oo.makeScale(t,e,n),this.applyMatrix4(oo),this}lookAt(t){return lo.lookAt(t),lo.updateMatrix(),this.applyMatrix4(lo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ho).negate(),this.translate(ho.x,ho.y,ho.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new so(e,3))}else{for(let n=0,i=e.count;n<i;n++){const i=t[n];e.setXYZ(n,i.x,i.y,i.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Ps);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new As(-1/0,-1/0,-1/0),new As(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];co.setFromBufferAttribute(n),this.morphTargetsRelative?(po.addVectors(this.boundingBox.min,co.min),this.boundingBox.expandByPoint(po),po.addVectors(this.boundingBox.max,co.max),this.boundingBox.expandByPoint(po)):(this.boundingBox.expandByPoint(co.min),this.boundingBox.expandByPoint(co.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new qs);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new As,1/0);if(t){const n=this.boundingSphere.center;if(co.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];uo.setFromBufferAttribute(n),this.morphTargetsRelative?(po.addVectors(co.min,uo.min),co.expandByPoint(po),po.addVectors(co.max,uo.max),co.expandByPoint(po)):(co.expandByPoint(uo.min),co.expandByPoint(uo.max))}co.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)po.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(po));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],a=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)po.fromBufferAttribute(s,e),a&&(ho.fromBufferAttribute(t,e),po.add(ho)),i=Math.max(i,n.distanceToSquared(po))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new no(new Float32Array(4*n.count),4));const s=this.getAttribute("tangent"),a=[],o=[];for(let t=0;t<n.count;t++)a[t]=new As,o[t]=new As;const l=new As,h=new As,c=new As,d=new Jr,u=new Jr,p=new Jr,f=new As,m=new As;function g(t,e,i){l.fromBufferAttribute(n,t),h.fromBufferAttribute(n,e),c.fromBufferAttribute(n,i),d.fromBufferAttribute(r,t),u.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),h.sub(l),c.sub(l),u.sub(d),p.sub(d);const s=1/(u.x*p.y-p.x*u.y);isFinite(s)&&(f.copy(h).multiplyScalar(p.y).addScaledVector(c,-u.y).multiplyScalar(s),m.copy(c).multiplyScalar(u.x).addScaledVector(h,-p.x).multiplyScalar(s),a[t].add(f),a[e].add(f),a[i].add(f),o[t].add(m),o[e].add(m),o[i].add(m))}let _=this.groups;0===_.length&&(_=[{start:0,count:t.count}]);for(let e=0,n=_.length;e<n;++e){const n=_[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const v=new As,y=new As,x=new As,S=new As;function b(t){x.fromBufferAttribute(i,t),S.copy(x);const e=a[t];v.copy(e),v.sub(x.multiplyScalar(x.dot(e))).normalize(),y.crossVectors(S,e);const n=y.dot(o[t])<0?-1:1;s.setXYZW(t,v.x,v.y,v.z,n)}for(let e=0,n=_.length;e<n;++e){const n=_[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)b(t.getX(e+0)),b(t.getX(e+1)),b(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new no(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new As,r=new As,s=new As,a=new As,o=new As,l=new As,h=new As,c=new As;if(t)for(let d=0,u=t.count;d<u;d+=3){const u=t.getX(d+0),p=t.getX(d+1),f=t.getX(d+2);i.fromBufferAttribute(e,u),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),c.subVectors(i,r),h.cross(c),a.fromBufferAttribute(n,u),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),a.add(h),o.add(h),l.add(h),n.setXYZ(u,a.x,a.y,a.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),c.subVectors(i,r),h.cross(c),n.setXYZ(t+0,h.x,h.y,h.z),n.setXYZ(t+1,h.x,h.y,h.z),n.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)po.fromBufferAttribute(t,e),po.normalize(),t.setXYZ(e,po.x,po.y,po.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,s=new n.constructor(e.length*i);let a=0,o=0;for(let r=0,l=e.length;r<l;r++){a=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)s[o++]=n[a++]}return new no(s,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new fo,n=this.index.array,i=this.attributes;for(const r in i){const s=t(i[r],n);e.setAttribute(r,s)}const r=this.morphAttributes;for(const i in r){const s=[],a=r[i];for(let e=0,i=a.length;e<i;e++){const i=t(a[e],n);s.push(i)}e.morphAttributes[i]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,n=s.length;t<n;t++){const n=s[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];s.push(i.toJSON(t.data))}s.length>0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const mo=new ia,go=new na,_o=new qs,vo=new As,yo=new As,xo=new As,So=new As,bo=new As,Mo=new As,wo=new As,Eo=new As;class To extends Pa{constructor(t=new fo,e=new $a){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(r&&a){Mo.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=a[n],o=r[n];0!==i&&(bo.fromBufferAttribute(o,t),s?Mo.addScaledVector(bo,i):Mo.addScaledVector(bo.sub(e),i))}e.add(Mo)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),_o.copy(n.boundingSphere),_o.applyMatrix4(r),go.copy(t.ray).recast(t.near),!1===_o.containsPoint(go.origin)){if(null===go.intersectSphere(_o,vo))return;if(go.origin.distanceToSquared(vo)>(t.far-t.near)**2)return}mo.copy(r).invert(),go.copy(t.ray).applyMatrix4(mo),null!==n.boundingBox&&!1===go.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,go)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=d.length;r<o;r++){const o=d[r],p=s[o.materialIndex];for(let r=Math.max(o.start,u.start),s=Math.min(a.count,Math.min(o.start+o.count,u.start+u.count));r<s;r+=3){i=Ao(this,p,t,n,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let r=Math.max(0,u.start),o=Math.min(a.count,u.start+u.count);r<o;r+=3){i=Ao(this,s,t,n,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==o)if(Array.isArray(s))for(let r=0,a=d.length;r<a;r++){const a=d[r],p=s[a.materialIndex];for(let r=Math.max(a.start,u.start),s=Math.min(o.count,Math.min(a.start+a.count,u.start+u.count));r<s;r+=3){i=Ao(this,p,t,n,l,h,c,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let r=Math.max(0,u.start),a=Math.min(o.count,u.start+u.count);r<a;r+=3){i=Ao(this,s,t,n,l,h,c,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function Ao(t,e,n,i,r,s,a,o,l,h){t.getVertexPosition(o,yo),t.getVertexPosition(l,xo),t.getVertexPosition(h,So);const c=function(t,e,n,i,r,s,a,o){let l;if(l=e.side===yn?i.intersectTriangle(a,s,r,!0,o):i.intersectTriangle(r,s,a,e.side===vn,o),null===l)return null;Eo.copy(o),Eo.applyMatrix4(t.matrixWorld);const h=n.ray.origin.distanceTo(Eo);return h<n.near||h>n.far?null:{distance:h,point:Eo.clone(),object:t}}(t,e,n,i,yo,xo,So,wo);if(c){const t=new As;Wa.getBarycoord(wo,yo,xo,So,t),r&&(c.uv=Wa.getInterpolatedAttribute(r,o,l,h,t,new Jr)),s&&(c.uv1=Wa.getInterpolatedAttribute(s,o,l,h,t,new Jr)),a&&(c.normal=Wa.getInterpolatedAttribute(a,o,l,h,t,new As),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:l,c:h,normal:new As,materialIndex:0};Wa.getNormal(yo,xo,So,e.normal),c.face=e,c.barycoord=t}return c}class Co extends fo{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],h=[],c=[];let d=0,u=0;function p(t,e,n,i,r,s,p,f,m,g,_){const v=s/m,y=p/g,x=s/2,S=p/2,b=f/2,M=m+1,w=g+1;let E=0,T=0;const A=new As;for(let s=0;s<w;s++){const a=s*y-S;for(let o=0;o<M;o++){const d=o*v-x;A[t]=d*i,A[e]=a*r,A[n]=b,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[n]=f>0?1:-1,h.push(A.x,A.y,A.z),c.push(o/m),c.push(1-s/g),E+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const n=d+e+M*t,i=d+e+M*(t+1),r=d+(e+1)+M*(t+1),s=d+(e+1)+M*t;o.push(n,i,s),o.push(i,r,s),T+=6}a.addGroup(u,T,_),u+=T,d+=E}p("z","y","x",-1,-1,n,e,t,s,r,0),p("z","y","x",1,-1,n,e,-t,s,r,1),p("x","z","y",1,1,t,n,e,i,s,2),p("x","z","y",1,-1,t,n,-e,i,s,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new so(l,3)),this.setAttribute("normal",new so(h,3)),this.setAttribute("uv",new so(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Co(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Ro(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function Po(t){const e={};for(let n=0;n<t.length;n++){const i=Ro(t[n]);for(const t in i)e[t]=i[t]}return e}function Lo(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:as.workingColorSpace}const Io={clone:Ro,merge:Po};class Do extends Ja{static get type(){return"ShaderMaterial"}constructor(t){super(),this.isShaderMaterial=!0,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ro(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class No extends Pa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ia,this.projectionMatrix=new ia,this.projectionMatrixInverse=new ia,this.coordinateSystem=kr}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const Uo=new As,Oo=new Jr,Fo=new Jr;class ko extends No{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Wr*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Vr*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Wr*Math.atan(Math.tan(.5*Vr*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Uo.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Uo.x,Uo.y).multiplyScalar(-t/Uo.z),Uo.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Uo.x,Uo.y).multiplyScalar(-t/Uo.z)}getViewSize(t,e){return this.getViewBounds(t,Oo,Fo),e.subVectors(Fo,Oo)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Vr*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Bo=-90;class zo extends Pa{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ko(Bo,1,t,e);i.layers=this.layers,this.add(i);const r=new ko(Bo,1,t,e);r.layers=this.layers,this.add(r);const s=new ko(Bo,1,t,e);s.layers=this.layers,this.add(s);const a=new ko(Bo,1,t,e);a.layers=this.layers,this.add(a);const o=new ko(Bo,1,t,e);o.layers=this.layers,this.add(o);const l=new ko(Bo,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===kr)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Br)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,h]=this.children,c=t.getRenderTarget(),d=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(c,d,u),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Go extends xs{constructor(t,e,n,i,r,s,a,o,l,h){super(t=void 0!==t?t:[],e=void 0!==e?e:si,n,i,r,s,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Ho extends Ms{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Go(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:fi}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Co(5,5,5),r=new Do({name:"CubemapFromEquirect",uniforms:Ro(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:yn,blending:0});r.uniforms.tEquirect.value=e;const s=new To(i,r),a=e.minFilter;e.minFilter===gi&&(e.minFilter=fi);return new zo(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}const Vo=new As,Wo=new As,Xo=new $r;class jo{constructor(t=new As(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Vo.subVectors(n,e).cross(Wo.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Vo),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Xo.getNormalMatrix(t),i=this.coplanarPoint(Vo).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Yo=new qs,qo=new As;class Ko{constructor(t=new jo,e=new jo,n=new jo,i=new jo,r=new jo,s=new jo){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3){const n=this.planes,i=t.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],h=i[5],c=i[6],d=i[7],u=i[8],p=i[9],f=i[10],m=i[11],g=i[12],_=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,d-l,m-u,y-g).normalize(),n[1].setComponents(o+r,d+l,m+u,y+g).normalize(),n[2].setComponents(o+s,d+h,m+p,y+_).normalize(),n[3].setComponents(o-s,d-h,m-p,y-_).normalize(),n[4].setComponents(o-a,d-c,m-f,y-v).normalize(),e===kr)n[5].setComponents(o+a,d+c,m+f,y+v).normalize();else{if(e!==Br)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,c,f,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),Yo.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),Yo.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Yo)}intersectsSprite(t){return Yo.center.set(0,0,0),Yo.radius=.7071067811865476,Yo.applyMatrix4(t.matrixWorld),this.intersectsSphere(Yo)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(qo.x=i.normal.x>0?t.max.x:t.min.x,qo.y=i.normal.y>0?t.max.y:t.min.y,qo.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(qo)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Zo(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Qo(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.version<n.version)&&e.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=e.get(n);if(void 0===r)e.set(n,function(e,n){const i=e.array,r=e.usage,s=i.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(n,a),t.bufferData(n,i,r),e.onUploadCallback(),i instanceof Float32Array)o=t.FLOAT;else if(i instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=t.SHORT;else if(i instanceof Uint32Array)o=t.UNSIGNED_INT;else if(i instanceof Int32Array)o=t.INT;else if(i instanceof Int8Array)o=t.BYTE;else if(i instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,size:s}}(n,i));else if(r.version<n.version){if(r.size!==n.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,n,i){const r=n.array,s=n.updateRanges;if(t.bindBuffer(i,e),0===s.length)t.bufferSubData(i,0,r);else{s.sort(((t,e)=>t.start-e.start));let e=0;for(let t=1;t<s.length;t++){const n=s[e],i=s[t];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++e,s[e]=i)}s.length=e+1;for(let e=0,n=s.length;e<n;e++){const n=s[e];t.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}class Jo extends fo{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,s=e/2,a=Math.floor(n),o=Math.floor(i),l=a+1,h=o+1,c=t/a,d=e/o,u=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*d-s;for(let n=0;n<l;n++){const i=n*c-r;p.push(i,-e,0),f.push(0,0,1),m.push(n/a),m.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const n=e+l*t,i=e+l*(t+1),r=e+1+l*(t+1),s=e+1+l*t;u.push(n,i,s),u.push(i,r,s)}this.setIndex(u),this.setAttribute("position",new so(p,3)),this.setAttribute("normal",new so(f,3)),this.setAttribute("uv",new so(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jo(t.width,t.height,t.widthSegments,t.heightSegments)}}const $o={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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\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\t\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, roughness * 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 * ( 1.0 - 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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), 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.07, 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:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\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#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 saturate(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.specularColor;\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 * transposeMat3( 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\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}\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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * 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\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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 );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\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 )\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_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\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\tuniform sampler2D directionalShadowMap[ 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\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\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 sampler2D pointShadowMap[ 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\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D 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\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\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\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.diffuseColor, material.specularColor, 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\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\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\n\t\t#else\n\t\t\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\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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\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}",distanceRGBA_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}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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 <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 = packDepthToRGBA( dist );\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 <packing>\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 <packing>\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( packNormalToRGB( normal ), 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 <packing>\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 <packing>\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\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\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 <packing>\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 <packing>\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}"},tl={common:{diffuse:{value:new Ka(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new $r},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $r}},envmap:{envMap:{value:null},envMapRotation:{value:new $r},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new $r}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $r}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $r},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $r},normalScale:{value:new Jr(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $r},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $r}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $r}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $r}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ka(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 Ka(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0},uvTransform:{value:new $r}},sprite:{diffuse:{value:new Ka(16777215)},opacity:{value:1},center:{value:new Jr(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $r},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0}}},el={basic:{uniforms:Po([tl.common,tl.specularmap,tl.envmap,tl.aomap,tl.lightmap,tl.fog]),vertexShader:$o.meshbasic_vert,fragmentShader:$o.meshbasic_frag},lambert:{uniforms:Po([tl.common,tl.specularmap,tl.envmap,tl.aomap,tl.lightmap,tl.emissivemap,tl.bumpmap,tl.normalmap,tl.displacementmap,tl.fog,tl.lights,{emissive:{value:new Ka(0)}}]),vertexShader:$o.meshlambert_vert,fragmentShader:$o.meshlambert_frag},phong:{uniforms:Po([tl.common,tl.specularmap,tl.envmap,tl.aomap,tl.lightmap,tl.emissivemap,tl.bumpmap,tl.normalmap,tl.displacementmap,tl.fog,tl.lights,{emissive:{value:new Ka(0)},specular:{value:new Ka(1118481)},shininess:{value:30}}]),vertexShader:$o.meshphong_vert,fragmentShader:$o.meshphong_frag},standard:{uniforms:Po([tl.common,tl.envmap,tl.aomap,tl.lightmap,tl.emissivemap,tl.bumpmap,tl.normalmap,tl.displacementmap,tl.roughnessmap,tl.metalnessmap,tl.fog,tl.lights,{emissive:{value:new Ka(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$o.meshphysical_vert,fragmentShader:$o.meshphysical_frag},toon:{uniforms:Po([tl.common,tl.aomap,tl.lightmap,tl.emissivemap,tl.bumpmap,tl.normalmap,tl.displacementmap,tl.gradientmap,tl.fog,tl.lights,{emissive:{value:new Ka(0)}}]),vertexShader:$o.meshtoon_vert,fragmentShader:$o.meshtoon_frag},matcap:{uniforms:Po([tl.common,tl.bumpmap,tl.normalmap,tl.displacementmap,tl.fog,{matcap:{value:null}}]),vertexShader:$o.meshmatcap_vert,fragmentShader:$o.meshmatcap_frag},points:{uniforms:Po([tl.points,tl.fog]),vertexShader:$o.points_vert,fragmentShader:$o.points_frag},dashed:{uniforms:Po([tl.common,tl.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$o.linedashed_vert,fragmentShader:$o.linedashed_frag},depth:{uniforms:Po([tl.common,tl.displacementmap]),vertexShader:$o.depth_vert,fragmentShader:$o.depth_frag},normal:{uniforms:Po([tl.common,tl.bumpmap,tl.normalmap,tl.displacementmap,{opacity:{value:1}}]),vertexShader:$o.meshnormal_vert,fragmentShader:$o.meshnormal_frag},sprite:{uniforms:Po([tl.sprite,tl.fog]),vertexShader:$o.sprite_vert,fragmentShader:$o.sprite_frag},background:{uniforms:{uvTransform:{value:new $r},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$o.background_vert,fragmentShader:$o.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $r}},vertexShader:$o.backgroundCube_vert,fragmentShader:$o.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$o.cube_vert,fragmentShader:$o.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$o.equirect_vert,fragmentShader:$o.equirect_frag},distanceRGBA:{uniforms:Po([tl.common,tl.displacementmap,{referencePosition:{value:new As},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$o.distanceRGBA_vert,fragmentShader:$o.distanceRGBA_frag},shadow:{uniforms:Po([tl.lights,tl.fog,{color:{value:new Ka(0)},opacity:{value:1}}]),vertexShader:$o.shadow_vert,fragmentShader:$o.shadow_frag}};el.physical={uniforms:Po([el.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $r},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $r},clearcoatNormalScale:{value:new Jr(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $r},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $r},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $r},sheen:{value:0},sheenColor:{value:new Ka(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $r},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $r},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $r},transmissionSamplerSize:{value:new Jr},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $r},attenuationDistance:{value:0},attenuationColor:{value:new Ka(0)},specularColor:{value:new Ka(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $r},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $r},anisotropyVector:{value:new Jr},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $r}}]),vertexShader:$o.meshphysical_vert,fragmentShader:$o.meshphysical_frag};const nl={r:0,b:0,g:0},il=new pa,rl=new ia;function sl(t,e,n,i,r,s,a){const o=new Ka(0);let l,h,c=!0===s?0:1,d=null,u=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;if(i&&i.isTexture){i=(t.backgroundBlurriness>0?n:e).get(i)}return i}function m(e,n){e.getRGB(nl,Lo(t)),i.buffers.color.setClear(nl.r,nl.g,nl.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,m(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,m(o,c)},render:function(e){let n=!1;const r=f(e);null===r?m(o,c):r&&r.isColor&&(m(r,1),n=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===oi)?(void 0===h&&(h=new To(new Co(1,1,1),new Do({name:"BackgroundCubeMaterial",uniforms:Ro(el.backgroundCube.uniforms),vertexShader:el.backgroundCube.vertexShader,fragmentShader:el.backgroundCube.fragmentShader,side:yn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),il.copy(n.backgroundRotation),il.x*=-1,il.y*=-1,il.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(il.y*=-1,il.z*=-1),h.material.uniforms.envMap.value=i,h.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(rl.makeRotationFromEuler(il)),h.material.toneMapped=as.getTransfer(i.colorSpace)!==Tr,d===i&&u===i.version&&p===t.toneMapping||(h.material.needsUpdate=!0,d=i,u=i.version,p=t.toneMapping),h.layers.enableAll(),e.unshift(h,h.geometry,h.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new To(new Jo(2,2),new Do({name:"BackgroundMaterial",uniforms:Ro(el.background.uniforms),vertexShader:el.background.vertexShader,fragmentShader:el.background.fragmentShader,side:vn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=as.getTransfer(i.colorSpace)!==Tr,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),d===i&&u===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,d=i,u=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))}}}function al(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=h(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function h(t){const e=[],i=[],r=[];for(let t=0;t<n;t++)e[t]=0,i[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function d(t){u(t,0)}function u(e,n){const i=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;i[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==n&&(t.vertexAttribDivisor(e,n),a[e]=n)}function p(){const e=s.newAttributes,n=s.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==e[i]&&(t.disableVertexAttribArray(i),n[i]=0)}function f(e,n,i,r,s,a,o){!0===o?t.vertexAttribIPointer(e,n,i,s,a):t.vertexAttribPointer(e,n,i,r,s,a)}function m(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let _=!1;const v=function(e,n,r){const s=!0===r.wireframe;let a=i[e.id];void 0===a&&(a={},i[e.id]=a);let o=a[n.id];void 0===o&&(o={},a[n.id]=o);let l=o[s];void 0===l&&(l=h(t.createVertexArray()),o[s]=l);return l}(m,l,r);s!==v&&(s=v,o(s.object)),_=function(t,e,n,i){const r=s.attributes,a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){const n=r[e];let i=a[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}}return s.attributesNum!==o||s.index!==i}(n,m,l,g),_&&function(t,e,n,i){const r={},a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l){if(l[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(_||a)&&(a=!1,function(n,i,r,s){c();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const h=l.buffer,c=l.type,p=l.bytesPerElement,m=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===Si;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)u(r.location+t,e.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)f(r.location+t,a/r.locationSize,c,i,l*p,(g+a/r.locationSize*t)*p,m)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)u(r.location+t,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)d(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)f(r.location+t,a/r.locationSize,c,i,a*p,a/r.locationSize*t*p,m)}}else if(void 0!==l){const e=l[i];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(n,r,l,m),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const t in i){const e=i[t];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t]}},releaseStatesOfGeometry:function(t){if(void 0===i[t.id])return;const e=i[t.id];for(const t in e){const n=e[t];for(const t in n)l(n[t].object),delete n[t];delete e[t]}delete i[t.id]},releaseStatesOfProgram:function(t){for(const e in i){const n=i[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)l(r[t].object),delete r[t];delete n[t.id]}},initAttributes:c,enableAttribute:d,disableUnusedAttributes:p}}function ol(t,e,n){let i;function r(e,r,s){0!==s&&(t.drawArraysInstanced(i,e,r,s),n.update(r,i,s))}this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];n.update(a,i,1)},this.renderMultiDrawInstances=function(t,s,a,o){if(0===a)return;const l=e.get("WEBGL_multi_draw");if(null===l)for(let e=0;e<t.length;e++)r(t[e],s[e],o[e]);else{l.multiDrawArraysInstancedWEBGL(i,t,0,s,0,o,0,a);let e=0;for(let t=0;t<a;t++)e+=s[t]*o[t];n.update(e,i,1)}}}function ll(t,e,n,i){let r;function s(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!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,h=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===Li||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===wi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==_i&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Mi&&!r)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:h,maxTextures:c,maxVertexTextures:d,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),vertexTextures:d>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function hl(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new jo,o=new $r,l={value:null,needsUpdate:!1};function h(t,n,i,r){const s=null!==t?t.length:0;let h=null;if(0!==s){if(h=l.value,!0!==r||null===h){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length<e)&&(h=new Float32Array(e));for(let e=0,n=i;e!==s;++e,n+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(h,n),h[n+3]=a.constant}l.value=h,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const n=0!==t.length||e||0!==i||r;return r=e,i=t.length,n},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){n=h(t,e,0)},this.setState=function(a,o,c){const d=a.clippingPlanes,u=a.clipIntersection,p=a.clipShadows,f=t.get(a);if(!r||null===d||0===d.length||s&&!p)s?h(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);e.numPlanes=i,e.numIntersection=0}();else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=h(d,o,e,c);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=t}}}function cl(t){let e=new WeakMap;function n(t,e){return 303===e?t.mapping=si:304===e&&(t.mapping=ai),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(303===s||304===s){if(e.has(r)){return n(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new Ho(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class dl extends No{constructor(t=-1,e=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,s=n+t,a=i+e,o=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const ul=[.125,.215,.35,.446,.526,.582],pl=20,fl=new dl,ml=new Ka;let gl=null,_l=0,vl=0,yl=!1;const xl=(1+Math.sqrt(5))/2,Sl=1/xl,bl=[new As(-xl,Sl,0),new As(xl,Sl,0),new As(-Sl,0,xl),new As(Sl,0,xl),new As(0,xl,-Sl),new As(0,xl,Sl),new As(-1,1,-1),new As(1,1,-1),new As(-1,1,1),new As(1,1,1)];class Ml{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){gl=this._renderer.getRenderTarget(),_l=this._renderer.getActiveCubeFace(),vl=this._renderer.getActiveMipmapLevel(),yl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Al(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Tl(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.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._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(gl,_l,vl),this._renderer.xr.enabled=yl,t.scissorTest=!1,El(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===si||t.mapping===ai?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),gl=this._renderer.getRenderTarget(),_l=this._renderer.getActiveCubeFace(),vl=this._renderer.getActiveMipmapLevel(),yl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:fi,minFilter:fi,generateMipmaps:!1,type:wi,format:Li,colorSpace:wr,depthBuffer:!1},i=wl(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=wl(t,e,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],n=[],i=[];let r=t;const s=t-4+1+ul.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);n.push(s);let o=1/s;a>t-4?o=ul[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),h=-l,c=1+l,d=[h,h,c,h,c,c,h,h,c,c,h,c],u=6,p=6,f=3,m=2,g=1,_=new Float32Array(f*p*u),v=new Float32Array(m*p*u),y=new Float32Array(g*p*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,n=t>2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];_.set(i,f*p*t),v.set(d,m*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const x=new fo;x.setAttribute("position",new no(_,f)),x.setAttribute("uv",new no(v,m)),x.setAttribute("faceIndex",new no(y,g)),e.push(x),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(pl),r=new As(0,1,0),s=new Do({name:"SphericalGaussianBlur",defines:{n:pl,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Cl(),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 s}(i,t,e)}return i}_compileMaterial(t){const e=new To(this._lodPlanes[0],t);this._renderer.compile(e,fl)}_sceneToCubeUV(t,e,n,i){const r=new ko(90,1,e,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(ml),o.toneMapping=Zn,o.autoClear=!1;const c=new $a({name:"PMREM.Background",side:yn,depthWrite:!1,depthTest:!1}),d=new To(new Co,c);let u=!1;const p=t.background;p?p.isColor&&(c.color.copy(p),t.background=null,u=!0):(c.color.copy(ml),u=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===n?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;El(i,n*l,e>2?l:0,l,l),o.setRenderTarget(i),u&&o.render(d,r),o.render(t,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=h,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===si||t.mapping===ai;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Al()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Tl());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new To(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;El(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,fl)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e<i;e++){const n=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),r=bl[(i-e-1)%bl.length];this._blur(t,e-1,e,n,r)}e.autoClear=n}_blur(t,e,n,i,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,n,i,"latitudinal",r),this._halfBlur(s,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const h=new To(this._lodPlanes[i],l),c=l.uniforms,d=this._sizeLods[n]-1,u=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/u,f=isFinite(r)?1+Math.floor(3*p):pl;f>pl&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<pl;++t){const e=t/p,n=Math.exp(-e*e/2);m.push(n),0===t?g+=n:t<f&&(g+=2*n)}for(let t=0;t<m.length;t++)m[t]=m[t]/g;c.envMap.value=t.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:_}=this;c.dTheta.value=u,c.mipInt.value=_-n;const v=this._sizeLods[i];El(e,3*v*(i>_-4?i-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(h,fl)}}function wl(t,e,n){const i=new Ms(t,e,n);return i.texture.mapping=oi,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function El(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function Tl(){return new Do({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cl(),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 Al(){return new Do({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cl(),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 Cl(){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 Rl(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=303===s||304===s,o=s===si||s===ai;if(a||o){let s=e.get(r);const l=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new Ml(t)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const l=r.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;const n=6;for(let i=0;i<n;i++)void 0!==t[i]&&e++;return e===n}(l)?(null===n&&(n=new Ml(t)),s=a?n.fromEquirectangular(r):n.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",i),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Pl(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&ss("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Ll(t,e,n,i){const r={},s=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]);for(const t in o.morphAttributes){const n=o.morphAttributes[t];for(let t=0,i=n.length;t<i;t++)e.remove(n[t])}o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let a=0;if(null!==i){const t=i.array;a=i.version;for(let e=0,i=t.length;e<i;e+=3){const i=t[e+0],r=t[e+1],s=t[e+2];n.push(i,r,r,s,s,i)}}else{if(void 0===r)return;{const t=r.array;a=r.version;for(let e=0,i=t.length/3-1;e<i;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}}const o=new(es(n)?ro:io)(n,1);o.version=a;const l=s.get(t);l&&e.remove(l),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,n.memory.geometries++),e},update:function(n){const i=n.attributes;for(const n in i)e.update(i[n],t.ARRAY_BUFFER);const r=n.morphAttributes;for(const n in r){const i=r[n];for(let n=0,r=i.length;n<r;n++)e.update(i[n],t.ARRAY_BUFFER)}},getWireframeAttribute:function(t){const e=s.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&o(t)}else o(t);return s.get(t)}}}function Il(t,e,n){let i,r,s;function a(e,a,o){0!==o&&(t.drawElementsInstanced(i,a,r,e*s,o),n.update(a,i,o))}this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(i,a,r,e*s),n.update(a,i,1)},this.renderInstances=a,this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];n.update(o,i,1)},this.renderMultiDrawInstances=function(t,o,l,h){if(0===l)return;const c=e.get("WEBGL_multi_draw");if(null===c)for(let e=0;e<t.length;e++)a(t[e]/s,o[e],h[e]);else{c.multiDrawElementsInstancedWEBGL(i,o,0,r,t,0,h,0,l);let e=0;for(let t=0;t<l;t++)e+=o[t]*h[t];n.update(e,i,1)}}}function Dl(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(n,i,r){switch(e.calls++,i){case t.TRIANGLES:e.triangles+=r*(n/3);break;case t.LINES:e.lines+=r*(n/2);break;case t.LINE_STRIP:e.lines+=r*(n-1);break;case t.LINE_LOOP:e.lines+=r*n;break;case t.POINTS:e.points+=r*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Nl(t,e,n){const i=new WeakMap,r=new Ss;return{update:function(s,a,o){const l=s.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==h?h.length:0;let d=i.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,f=void 0!==a.morphAttributes.color,m=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],_=a.morphAttributes.color||[];let v=0;!0===u&&(v=1),!0===p&&(v=2),!0===f&&(v=3);let y=a.attributes.position.count*v,x=1;y>e.maxTextureSize&&(x=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const S=new Float32Array(y*x*4*c),b=new ws(S,y,x,c);b.type=Mi,b.needsUpdate=!0;const M=4*v;for(let E=0;E<c;E++){const T=m[E],A=g[E],C=_[E],R=y*x*4*E;for(let P=0;P<T.count;P++){const L=P*M;!0===u&&(r.fromBufferAttribute(T,P),S[R+L+0]=r.x,S[R+L+1]=r.y,S[R+L+2]=r.z,S[R+L+3]=0),!0===p&&(r.fromBufferAttribute(A,P),S[R+L+4]=r.x,S[R+L+5]=r.y,S[R+L+6]=r.z,S[R+L+7]=0),!0===f&&(r.fromBufferAttribute(C,P),S[R+L+8]=r.x,S[R+L+9]=r.y,S[R+L+10]=r.z,S[R+L+11]=4===C.itemSize?r.w:1)}}function w(){b.dispose(),i.delete(a),a.removeEventListener("dispose",w)}d={count:c,texture:b,size:new Jr(y,x)},i.set(a,d),a.addEventListener("dispose",w)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let I=0;for(let N=0;N<l.length;N++)I+=l[N];const D=a.morphTargetsRelative?1:1-I;o.getUniforms().setValue(t,"morphTargetBaseInfluence",D),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",d.texture,n),o.getUniforms().setValue(t,"morphTargetsTextureSize",d.size)}}}function Ul(t,e,n,i){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(a){const o=i.render.frame,l=a.geometry,h=e.get(a,l);if(r.get(h)!==o&&(e.update(h),r.set(h,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",s)&&a.addEventListener("dispose",s),r.get(a)!==o&&(n.update(a.instanceMatrix,t.ARRAY_BUFFER),null!==a.instanceColor&&n.update(a.instanceColor,t.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const t=a.skeleton;r.get(t)!==o&&(t.update(),r.set(t,o))}return h},dispose:function(){r=new WeakMap}}}class Ol extends xs{constructor(t,e,n,i,r,s,a,o,l,h=1026){if(h!==Ni&&h!==Ui)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===Ni&&(n=bi),void 0===n&&h===Ui&&(n=Ai),super(null,i,r,s,a,o,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:di,this.minFilter=void 0!==o?o:di,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}const Fl=new xs,kl=new Ol(1,1),Bl=new ws,zl=new Es,Gl=new Go,Hl=[],Vl=[],Wl=new Float32Array(16),Xl=new Float32Array(9),jl=new Float32Array(4);function Yl(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let s=Hl[r];if(void 0===s&&(s=new Float32Array(r),Hl[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function ql(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function Kl(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function Zl(t,e){let n=Vl[e];void 0===n&&(n=new Int32Array(e),Vl[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function Ql(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Jl(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ql(n,e))return;t.uniform2fv(this.addr,e),Kl(n,e)}}function $l(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ql(n,e))return;t.uniform3fv(this.addr,e),Kl(n,e)}}function th(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ql(n,e))return;t.uniform4fv(this.addr,e),Kl(n,e)}}function eh(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ql(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Kl(n,e)}else{if(ql(n,i))return;jl.set(i),t.uniformMatrix2fv(this.addr,!1,jl),Kl(n,i)}}function nh(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ql(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Kl(n,e)}else{if(ql(n,i))return;Xl.set(i),t.uniformMatrix3fv(this.addr,!1,Xl),Kl(n,i)}}function ih(t,e){const n=this.cache,i=e.elements;if(void 0===i){if(ql(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Kl(n,e)}else{if(ql(n,i))return;Wl.set(i),t.uniformMatrix4fv(this.addr,!1,Wl),Kl(n,i)}}function rh(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function sh(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ql(n,e))return;t.uniform2iv(this.addr,e),Kl(n,e)}}function ah(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ql(n,e))return;t.uniform3iv(this.addr,e),Kl(n,e)}}function oh(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ql(n,e))return;t.uniform4iv(this.addr,e),Kl(n,e)}}function lh(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function hh(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ql(n,e))return;t.uniform2uiv(this.addr,e),Kl(n,e)}}function ch(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ql(n,e))return;t.uniform3uiv(this.addr,e),Kl(n,e)}}function dh(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ql(n,e))return;t.uniform4uiv(this.addr,e),Kl(n,e)}}function uh(t,e,n){const i=this.cache,r=n.allocateTextureUnit();let s;i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),this.type===t.SAMPLER_2D_SHADOW?(kl.compareFunction=Lr,s=kl):s=Fl,n.setTexture2D(e||s,r)}function ph(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||zl,r)}function fh(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||Gl,r)}function mh(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||Bl,r)}function gh(t,e){t.uniform1fv(this.addr,e)}function _h(t,e){const n=Yl(e,this.size,2);t.uniform2fv(this.addr,n)}function vh(t,e){const n=Yl(e,this.size,3);t.uniform3fv(this.addr,n)}function yh(t,e){const n=Yl(e,this.size,4);t.uniform4fv(this.addr,n)}function xh(t,e){const n=Yl(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Sh(t,e){const n=Yl(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function bh(t,e){const n=Yl(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Mh(t,e){t.uniform1iv(this.addr,e)}function wh(t,e){t.uniform2iv(this.addr,e)}function Eh(t,e){t.uniform3iv(this.addr,e)}function Th(t,e){t.uniform4iv(this.addr,e)}function Ah(t,e){t.uniform1uiv(this.addr,e)}function Ch(t,e){t.uniform2uiv(this.addr,e)}function Rh(t,e){t.uniform3uiv(this.addr,e)}function Ph(t,e){t.uniform4uiv(this.addr,e)}function Lh(t,e,n){const i=this.cache,r=e.length,s=Zl(n,r);ql(i,s)||(t.uniform1iv(this.addr,s),Kl(i,s));for(let t=0;t!==r;++t)n.setTexture2D(e[t]||Fl,s[t])}function Ih(t,e,n){const i=this.cache,r=e.length,s=Zl(n,r);ql(i,s)||(t.uniform1iv(this.addr,s),Kl(i,s));for(let t=0;t!==r;++t)n.setTexture3D(e[t]||zl,s[t])}function Dh(t,e,n){const i=this.cache,r=e.length,s=Zl(n,r);ql(i,s)||(t.uniform1iv(this.addr,s),Kl(i,s));for(let t=0;t!==r;++t)n.setTextureCube(e[t]||Gl,s[t])}function Nh(t,e,n){const i=this.cache,r=e.length,s=Zl(n,r);ql(i,s)||(t.uniform1iv(this.addr,s),Kl(i,s));for(let t=0;t!==r;++t)n.setTexture2DArray(e[t]||Bl,s[t])}class Uh{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Ql;case 35664:return Jl;case 35665:return $l;case 35666:return th;case 35674:return eh;case 35675:return nh;case 35676:return ih;case 5124:case 35670:return rh;case 35667:case 35671:return sh;case 35668:case 35672:return ah;case 35669:case 35673:return oh;case 5125:return lh;case 36294:return hh;case 36295:return ch;case 36296:return dh;case 35678:case 36198:case 36298:case 36306:case 35682:return uh;case 35679:case 36299:case 36307:return ph;case 35680:case 36300:case 36308:case 36293:return fh;case 36289:case 36303:case 36311:case 36292:return mh}}(e.type)}}class Oh{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return gh;case 35664:return _h;case 35665:return vh;case 35666:return yh;case 35674:return xh;case 35675:return Sh;case 35676:return bh;case 5124:case 35670:return Mh;case 35667:case 35671:return wh;case 35668:case 35672:return Eh;case 35669:case 35673:return Th;case 5125:return Ah;case 36294:return Ch;case 36295:return Rh;case 36296:return Ph;case 35678:case 36198:case 36298:case 36306:case 35682:return Lh;case 35679:case 36299:case 36307:return Ih;case 35680:case 36300:case 36308:case 36293:return Dh;case 36289:case 36303:case 36311:case 36292:return Nh}}(e.type)}}class Fh{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,s=i.length;r!==s;++r){const s=i[r];s.setValue(t,e[s.id],n)}}}const kh=/(\w+)(\])?(\[|\.)?/g;function Bh(t,e){t.seq.push(e),t.map[e.id]=e}function zh(t,e,n){const i=t.name,r=i.length;for(kh.lastIndex=0;;){const s=kh.exec(i),a=kh.lastIndex;let o=s[1];const l="]"===s[2],h=s[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===r){Bh(n,void 0===h?new Uh(o,t,e):new Oh(o,t,e));break}{let t=n.map[o];void 0===t&&(t=new Fh(o),Bh(n,t)),n=t}}}class Gh{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=t.getActiveUniform(e,i);zh(n,t.getUniformLocation(e,n.name),this)}}setValue(t,e,n,i){const r=this.map[e];void 0!==r&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];void 0!==i&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=n[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const r=t[i];r.id in e&&n.push(r)}return n}}function Hh(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const Vh=37297;let Wh=0;const Xh=new $r;function jh(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(i&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const i=parseInt(s[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const n=t.split("\n"),i=[],r=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let t=r;t<s;t++){const r=t+1;i.push(`${r===e?">":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function Yh(t,e){const n=function(t){as._getMatrix(Xh,as.workingColorSpace,t);const e=`mat3( ${Xh.elements.map((t=>t.toFixed(4)))} )`;switch(as.getTransfer(t)){case Er:return[e,"LinearTransferOETF"];case Tr:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function qh(t,e){let n;switch(e){case Qn:n="Linear";break;case Jn:n="Reinhard";break;case $n:n="Cineon";break;case ti:n="ACESFilmic";break;case ni:n="AgX";break;case ii:n="Neutral";break;case ei:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Kh=new As;function Zh(){as.getLuminanceCoefficients(Kh);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Kh.x.toFixed(4)}, ${Kh.y.toFixed(4)}, ${Kh.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Qh(t){return""!==t}function Jh(t,e){const n=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,n).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 $h(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const tc=/^[ \t]*#include +<([\w\d./]+)>/gm;function ec(t){return t.replace(tc,ic)}const nc=new Map;function ic(t,e){let n=$o[e];if(void 0===n){const t=nc.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=$o[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return ec(n)}const rc=/#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 sc(t){return t.replace(rc,ac)}function ac(t,e,n,i){let r="";for(let t=parseInt(e);t<parseInt(n);t++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function oc(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}function lc(t,e,n,i){const r=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=function(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===mn?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===gn?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===_n&&(e="SHADOWMAP_TYPE_VSM"),e}(n),h=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case si:case ai:e="ENVMAP_TYPE_CUBE";break;case oi:e="ENVMAP_TYPE_CUBE_UV"}return e}(n),c=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===ai&&(e="ENVMAP_MODE_REFRACTION");return e}(n),d=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case Yn:e="ENVMAP_BLENDING_MULTIPLY";break;case qn:e="ENVMAP_BLENDING_MIX";break;case Kn:e="ENVMAP_BLENDING_ADD"}return e}(n),u=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Qh).join("\n")}(n),f=function(t){const e=[];for(const n in t){const i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(s),m=r.createProgram();let g,_,v=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Qh).join("\n"),g.length>0&&(g+="\n"),_=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Qh).join("\n"),_.length>0&&(_+="\n")):(g=[oc(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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(Qh).join("\n"),_=[oc(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+c:"",n.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":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Zn?"#define TONE_MAPPING":"",n.toneMapping!==Zn?$o.tonemapping_pars_fragment:"",n.toneMapping!==Zn?qh("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",$o.colorspace_pars_fragment,Yh("linearToOutputTexel",n.outputColorSpace),Zh(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Qh).join("\n")),a=ec(a),a=Jh(a,n),a=$h(a,n),o=ec(o),o=Jh(o,n),o=$h(o,n),a=sc(a),o=sc(o),!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",n.glslVersion===Fr?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Fr?"":"#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"+_);const y=v+g+a,x=v+_+o,S=Hh(r,r.VERTEX_SHADER,y),b=Hh(r,r.FRAGMENT_SHADER,x);function M(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(S).trim(),s=r.getShaderInfoLog(b).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,S,b);else{const t=jh(r,S,"vertex"),i=jh(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:s,prefix:_}})}r.deleteShader(S),r.deleteShader(b),w=new Gh(r,m),E=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=t.getActiveAttrib(e,r),s=i.name;let a=1;i.type===t.FLOAT_MAT2&&(a=2),i.type===t.FLOAT_MAT3&&(a=3),i.type===t.FLOAT_MAT4&&(a=4),n[s]={type:i.type,location:t.getAttribLocation(e,s),locationSize:a}}return n}(r,m)}let w,E;r.attachShader(m,S),r.attachShader(m,b),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===w&&M(this),w},this.getAttributes=function(){return void 0===E&&M(this),E};let T=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===T&&(T=r.getProgramParameter(m,Vh)),T},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Wh++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=S,this.fragmentShader=b,this}let hc=0;class cc{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),s=this._getShaderCacheForMaterial(t);return!1===s.has(i)&&(s.add(i),i.usedTimes++),!1===s.has(r)&&(s.add(r),r.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 n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new dc(t),e.set(t,n)),n}}class dc{constructor(t){this.id=hc++,this.code=t,this.usedTimes=0}}function uc(t,e,n,i,r,s,a){const o=new fa,l=new cc,h=new Set,c=[],d=r.logarithmicDepthBuffer,u=r.vertexTextures;let p=r.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 m(t){return h.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(s,o,c,g,_){const v=g.fog,y=_.geometry,x=s.isMeshStandardMaterial?g.environment:null,S=(s.isMeshStandardMaterial?n:e).get(s.envMap||x),b=S&&S.mapping===oi?S.image.height:null,M=f[s.type];null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead."));const w=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,E=void 0!==w?w.length:0;let T,A,C,R,P=0;if(void 0!==y.morphAttributes.position&&(P=1),void 0!==y.morphAttributes.normal&&(P=2),void 0!==y.morphAttributes.color&&(P=3),M){const t=el[M];T=t.vertexShader,A=t.fragmentShader}else T=s.vertexShader,A=s.fragmentShader,l.update(s),C=l.getVertexShaderID(s),R=l.getFragmentShaderID(s);const L=t.getRenderTarget(),I=t.state.buffers.depth.getReversed(),D=!0===_.isInstancedMesh,N=!0===_.isBatchedMesh,U=!!s.map,O=!!s.matcap,F=!!S,k=!!s.aoMap,B=!!s.lightMap,z=!!s.bumpMap,G=!!s.normalMap,H=!!s.displacementMap,V=!!s.emissiveMap,W=!!s.metalnessMap,X=!!s.roughnessMap,j=s.anisotropy>0,Y=s.clearcoat>0,q=s.dispersion>0,K=s.iridescence>0,Z=s.sheen>0,Q=s.transmission>0,J=j&&!!s.anisotropyMap,$=Y&&!!s.clearcoatMap,tt=Y&&!!s.clearcoatNormalMap,et=Y&&!!s.clearcoatRoughnessMap,nt=K&&!!s.iridescenceMap,it=K&&!!s.iridescenceThicknessMap,rt=Z&&!!s.sheenColorMap,st=Z&&!!s.sheenRoughnessMap,at=!!s.specularMap,ot=!!s.specularColorMap,lt=!!s.specularIntensityMap,ht=Q&&!!s.transmissionMap,ct=Q&&!!s.thicknessMap,dt=!!s.gradientMap,ut=!!s.alphaMap,pt=s.alphaTest>0,ft=!!s.alphaHash,mt=!!s.extensions;let gt=Zn;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(gt=t.toneMapping));const _t={shaderID:M,shaderType:s.type,shaderName:s.name,vertexShader:T,fragmentShader:A,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:N,batchingColor:N&&null!==_._colorsTexture,instancing:D,instancingColor:D&&null!==_.instanceColor,instancingMorph:D&&null!==_.morphTexture,supportsVertexTextures:u,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:wr,alphaToCoverage:!!s.alphaToCoverage,map:U,matcap:O,envMap:F,envMapMode:F&&S.mapping,envMapCubeUVHeight:b,aoMap:k,lightMap:B,bumpMap:z,normalMap:G,displacementMap:u&&H,emissiveMap:V,normalMapObjectSpace:G&&1===s.normalMapType,normalMapTangentSpace:G&&0===s.normalMapType,metalnessMap:W,roughnessMap:X,anisotropy:j,anisotropyMap:J,clearcoat:Y,clearcoatMap:$,clearcoatNormalMap:tt,clearcoatRoughnessMap:et,dispersion:q,iridescence:K,iridescenceMap:nt,iridescenceThicknessMap:it,sheen:Z,sheenColorMap:rt,sheenRoughnessMap:st,specularMap:at,specularColorMap:ot,specularIntensityMap:lt,transmission:Q,transmissionMap:ht,thicknessMap:ct,gradientMap:dt,opaque:!1===s.transparent&&1===s.blending&&!1===s.alphaToCoverage,alphaMap:ut,alphaTest:pt,alphaHash:ft,combine:s.combine,mapUv:U&&m(s.map.channel),aoMapUv:k&&m(s.aoMap.channel),lightMapUv:B&&m(s.lightMap.channel),bumpMapUv:z&&m(s.bumpMap.channel),normalMapUv:G&&m(s.normalMap.channel),displacementMapUv:H&&m(s.displacementMap.channel),emissiveMapUv:V&&m(s.emissiveMap.channel),metalnessMapUv:W&&m(s.metalnessMap.channel),roughnessMapUv:X&&m(s.roughnessMap.channel),anisotropyMapUv:J&&m(s.anisotropyMap.channel),clearcoatMapUv:$&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:tt&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:it&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:st&&m(s.sheenRoughnessMap.channel),specularMapUv:at&&m(s.specularMap.channel),specularColorMapUv:ot&&m(s.specularColorMap.channel),specularIntensityMapUv:lt&&m(s.specularIntensityMap.channel),transmissionMapUv:ht&&m(s.transmissionMap.channel),thicknessMapUv:ct&&m(s.thicknessMap.channel),alphaMapUv:ut&&m(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(G||j),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===_.isPoints&&!!y.attributes.uv&&(U||ut),fog:!!v,useFog:!0===s.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:d,reverseDepthBuffer:I,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:E,morphTextureStride:P,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:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&c.length>0,shadowMapType:t.shadowMap.type,toneMapping:gt,decodeVideoTexture:U&&!0===s.map.isVideoTexture&&as.getTransfer(s.map.colorSpace)===Tr,decodeVideoTextureEmissive:V&&!0===s.emissiveMap.isVideoTexture&&as.getTransfer(s.emissiveMap.colorSpace)===Tr,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:s.side===yn,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:mt&&!0===s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(mt&&!0===s.extensions.multiDraw||N)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return _t.vertexUv1s=h.has(1),_t.vertexUv2s=h.has(2),_t.vertexUv3s=h.has(3),h.clear(),_t},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.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)}(n,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0);e.instancing&&o.enable(1);e.instancingColor&&o.enable(2);e.instancingMorph&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);e.alphaHash&&o.enable(18);e.batching&&o.enable(19);e.dispersion&&o.enable(20);e.batchingColor&&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.reverseDepthBuffer&&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)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=el[e];n=Io.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=c.length;t<e;t++){const e=c[t];if(e.cacheKey===n){i=e,++i.usedTimes;break}}return void 0===i&&(i=new lc(t,n,e,s),c.push(i)),i},releaseProgram:function(t){if(0==--t.usedTimes){const e=c.indexOf(t);c[e]=c[c.length-1],c.pop(),t.destroy()}},releaseShaderCache:function(t){l.remove(t)},programs:c,dispose:function(){l.dispose()}}}function pc(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,i){t.get(e)[n]=i},dispose:function(){t=new WeakMap}}}function fc(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 mc(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 gc(){const t=[];let e=0;const n=[],i=[],r=[];function s(n,i,r,s,a,o){let l=t[e];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:s,renderOrder:n.renderOrder,z:a,group:o},t[e]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=s,l.renderOrder=n.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){e=0,n.length=0,i.length=0,r.length=0},push:function(t,e,a,o,l,h){const c=s(t,e,a,o,l,h);a.transmission>0?i.push(c):!0===a.transparent?r.push(c):n.push(c)},unshift:function(t,e,a,o,l,h){const c=s(t,e,a,o,l,h);a.transmission>0?i.unshift(c):!0===a.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=e,i=t.length;n<i;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||fc),i.length>1&&i.sort(e||mc),r.length>1&&r.sort(e||mc)}}}function _c(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new gc,t.set(e,[r])):n>=i.length?(r=new gc,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function vc(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new As,color:new Ka};break;case"SpotLight":n={position:new As,direction:new As,color:new Ka,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new As,color:new Ka,distance:0,decay:0};break;case"HemisphereLight":n={direction:new As,skyColor:new Ka,groundColor:new Ka};break;case"RectAreaLight":n={color:new Ka,position:new As,halfWidth:new As,halfHeight:new As}}return t[e.id]=n,n}}}let yc=0;function xc(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Sc(t){const e=new vc,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Jr};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Jr,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={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++)i.probe.push(new As);const r=new As,s=new ia,a=new ia;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,h=0,c=0,d=0,u=0,p=0,f=0,m=0,g=0,_=0,v=0;r.sort(xc);for(let t=0,y=r.length;t<y;t++){const y=r[t],x=y.color,S=y.intensity,b=y.distance,M=y.shadow&&y.shadow.map?y.shadow.map.texture:null;if(y.isAmbientLight)s+=x.r*S,a+=x.g*S,o+=x.b*S;else if(y.isLightProbe){for(let t=0;t<9;t++)i.probe[t].addScaledVector(y.sh.coefficients[t],S);v++}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=n.get(y);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,i.directionalShadow[l]=e,i.directionalShadowMap[l]=M,i.directionalShadowMatrix[l]=y.shadow.matrix,p++}i.directional[l]=t,l++}else if(y.isSpotLight){const t=e.get(y);t.position.setFromMatrixPosition(y.matrixWorld),t.color.copy(x).multiplyScalar(S),t.distance=b,t.coneCos=Math.cos(y.angle),t.penumbraCos=Math.cos(y.angle*(1-y.penumbra)),t.decay=y.decay,i.spot[c]=t;const r=y.shadow;if(y.map&&(i.spotLightMap[g]=y.map,g++,r.updateMatrices(y),y.castShadow&&_++),i.spotLightMatrix[c]=r.matrix,y.castShadow){const t=n.get(y);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,i.spotShadow[c]=t,i.spotShadowMap[c]=M,m++}c++}else if(y.isRectAreaLight){const t=e.get(y);t.color.copy(x).multiplyScalar(S),t.halfWidth.set(.5*y.width,0,0),t.halfHeight.set(0,.5*y.height,0),i.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=n.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,i.pointShadow[h]=e,i.pointShadowMap[h]=M,i.pointShadowMatrix[h]=y.shadow.matrix,f++}i.point[h]=t,h++}else if(y.isHemisphereLight){const t=e.get(y);t.skyColor.copy(y.color).multiplyScalar(S),t.groundColor.copy(y.groundColor).multiplyScalar(S),i.hemi[u]=t,u++}}d>0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=tl.LTC_FLOAT_1,i.rectAreaLTC2=tl.LTC_FLOAT_2):(i.rectAreaLTC1=tl.LTC_HALF_1,i.rectAreaLTC2=tl.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===h&&y.spotLength===c&&y.rectAreaLength===d&&y.hemiLength===u&&y.numDirectionalShadows===p&&y.numPointShadows===f&&y.numSpotShadows===m&&y.numSpotMaps===g&&y.numLightProbes===v||(i.directional.length=l,i.spot.length=c,i.rectArea.length=d,i.point.length=h,i.hemi.length=u,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-_,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=_,i.numLightProbes=v,y.directionalLength=l,y.pointLength=h,y.spotLength=c,y.rectAreaLength=d,y.hemiLength=u,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=v,i.version=yc++)},setupView:function(t,e){let n=0,o=0,l=0,h=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=i.directional[n];t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),n++}else if(u.isSpotLight){const t=i.spot[l];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),t.direction.setFromMatrixPosition(u.matrixWorld),r.setFromMatrixPosition(u.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(d),l++}else if(u.isRectAreaLight){const t=i.rectArea[h];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),a.identity(),s.copy(u.matrixWorld),s.premultiply(d),a.extractRotation(s),t.halfWidth.set(.5*u.width,0,0),t.halfHeight.set(0,.5*u.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),h++}else if(u.isPointLight){const t=i.point[o];t.position.setFromMatrixPosition(u.matrixWorld),t.position.applyMatrix4(d),o++}else if(u.isHemisphereLight){const t=i.hemi[c];t.direction.setFromMatrixPosition(u.matrixWorld),t.direction.transformDirection(d),c++}}},state:i}}function bc(t){const e=new Sc(t),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:function(t){r.camera=t,n.length=0,i.length=0},state:r,setupLights:function(){e.setup(n)},setupLightsView:function(t){e.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){i.push(t)}}}function Mc(t){let e=new WeakMap;return{get:function(n,i=0){const r=e.get(n);let s;return void 0===r?(s=new bc(t),e.set(n,[s])):i>=r.length?(s=new bc(t),r.push(s)):s=r[i],s},dispose:function(){e=new WeakMap}}}class wc extends Ja{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Ec extends Ja{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Tc(t,e,n){let i=new Ko;const r=new Jr,s=new Jr,a=new Ss,o=new wc({depthPacking:3201}),l=new Ec,h={},c=n.maxTextureSize,d={[vn]:yn,[yn]:vn,[xn]:2},u=new Do({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Jr},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;\n#include <packing>\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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\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 = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\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( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const f=new fo;f.setAttribute("position",new no(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new To(f,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=mn;let _=this.type;function v(n,i){const s=e.update(m);u.defines.VSM_SAMPLES!==n.blurSamples&&(u.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ms(r.x,r.y)),u.uniforms.shadow_pass.value=n.map.texture,u.uniforms.resolution.value=n.mapSize,u.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,s,u,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,s,p,m,null)}function y(e,n,i,r){let s=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=s.uuid,e=n.uuid;let i=h[t];void 0===i&&(i={},h[t]=i);let r=i[e];void 0===r&&(r=s.clone(),i[e]=r,n.addEventListener("dispose",S)),s=r}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===_n?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=i}return s}function x(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===_n)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let h=0,c=e.length;h<c;h++){const c=e[h],d=l[c.materialIndex];if(d&&d.visible){const e=y(n,d,a,o);n.onBeforeShadow(t,n,r,s,i,e,c),t.renderBufferDirect(s,null,i,e,n,c),n.onAfterShadow(t,n,r,s,i,e,c)}}}else if(l.visible){const e=y(n,l,a,o);n.onBeforeShadow(t,n,r,s,i,e,null),t.renderBufferDirect(s,null,i,e,n,null),n.onAfterShadow(t,n,r,s,i,e,null)}}const l=n.children;for(let t=0,e=l.length;t<e;t++)x(l[t],r,s,a,o)}function S(t){t.target.removeEventListener("dispose",S);for(const e in h){const n=h[e],i=t.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(e,n,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),h=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),u=t.state;u.setBlending(0),u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const p=_!==_n&&this.type===_n,f=_===_n&&this.type!==_n;for(let l=0,h=e.length;l<h;l++){const h=e[l],d=h.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",h,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();if(r.multiply(m),s.copy(d.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/m.x),r.x=s.x*m.x,d.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/m.y),r.y=s.y*m.y,d.mapSize.y=s.y)),null===d.map||!0===p||!0===f){const t=this.type!==_n?{minFilter:di,magFilter:di}:{};null!==d.map&&d.map.dispose(),d.map=new Ms(r.x,r.y,t),d.map.texture.name=h.name+".shadowMap",d.camera.updateProjectionMatrix()}t.setRenderTarget(d.map),t.clear();const g=d.getViewportCount();for(let t=0;t<g;t++){const e=d.getViewport(t);a.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),u.viewport(a),d.updateMatrices(h,t),i=d.getFrustum(),x(n,o,d.camera,h,this.type)}!0!==d.isPointLightShadow&&this.type===_n&&v(d,o),d.needsUpdate=!1}_=this.type,g.needsUpdate=!1,t.setRenderTarget(l,h,d)}}const Ac={[Bn]:1,[Gn]:6,[Vn]:7,[Hn]:5,[zn]:0,[Xn]:2,[jn]:4,[Wn]:3};function Cc(t,e){const n=new function(){let e=!1;const n=new Ss;let i=null;const r=new Ss(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,s,a,o){!0===o&&(e*=a,i*=a,s*=a),n.set(e,i,s,a),!1===r.equals(n)&&(t.clearColor(e,i,s,a),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,s=null,a=null;return{setReversed:function(t){if(i!==t){const t=e.get("EXT_clip_control");i?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT);const n=a;a=null,this.setClear(n)}i=t},getReversed:function(){return i},setTest:function(e){e?z(t.DEPTH_TEST):G(t.DEPTH_TEST)},setMask:function(e){r===e||n||(t.depthMask(e),r=e)},setFunc:function(e){if(i&&(e=Ac[e]),s!==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)}s=e}},setLocked:function(t){n=t},setClear:function(e){a!==e&&(i&&(e=1-e),t.clearDepth(e),a=e)},reset:function(){n=!1,r=null,s=null,a=null,i=!1}}},r=new function(){let e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,h=null;return{setTest:function(n){e||(n?z(t.STENCIL_TEST):G(t.STENCIL_TEST))},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,a){i===e&&r===n&&s===a||(t.stencilFunc(e,n,a),i=e,r=n,s=a)},setOp:function(e,n,i){a===e&&o===n&&l===i||(t.stencilOp(e,n,i),a=e,o=n,l=i)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,n=null,i=null,r=null,s=null,a=null,o=null,l=null,h=null}}},s=new WeakMap,a=new WeakMap;let o={},l={},h=new WeakMap,c=[],d=null,u=!1,p=null,f=null,m=null,g=null,_=null,v=null,y=null,x=new Ka(0,0,0),S=0,b=!1,M=null,w=null,E=null,T=null,A=null;const C=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let R=!1,P=0;const L=t.getParameter(t.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),R=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),R=P>=2);let I=null,D={};const N=t.getParameter(t.SCISSOR_BOX),U=t.getParameter(t.VIEWPORT),O=(new Ss).fromArray(N),F=(new Ss).fromArray(U);function k(e,n,i,r){const s=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<i;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(n,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(n+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const B={};function z(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function G(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}B[t.TEXTURE_2D]=k(t.TEXTURE_2D,t.TEXTURE_2D,1),B[t.TEXTURE_CUBE_MAP]=k(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),B[t.TEXTURE_2D_ARRAY]=k(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),B[t.TEXTURE_3D]=k(t.TEXTURE_3D,t.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),z(t.DEPTH_TEST),i.setFunc(3),X(!1),j(1),z(t.CULL_FACE),W(0);const H={[Sn]:t.FUNC_ADD,[bn]:t.FUNC_SUBTRACT,[Mn]:t.FUNC_REVERSE_SUBTRACT};H[103]=t.MIN,H[104]=t.MAX;const V={[wn]:t.ZERO,[En]:t.ONE,[Tn]:t.SRC_COLOR,[Cn]:t.SRC_ALPHA,[Nn]:t.SRC_ALPHA_SATURATE,[In]:t.DST_COLOR,[Pn]:t.DST_ALPHA,[An]:t.ONE_MINUS_SRC_COLOR,[Rn]:t.ONE_MINUS_SRC_ALPHA,[Dn]:t.ONE_MINUS_DST_COLOR,[Ln]:t.ONE_MINUS_DST_ALPHA,[Un]:t.CONSTANT_COLOR,[On]:t.ONE_MINUS_CONSTANT_COLOR,[Fn]:t.CONSTANT_ALPHA,[kn]:t.ONE_MINUS_CONSTANT_ALPHA};function W(e,n,i,r,s,a,o,l,h,c){if(0!==e){if(!1===u&&(z(t.BLEND),u=!0),5===e)s=s||n,a=a||i,o=o||r,n===f&&s===_||(t.blendEquationSeparate(H[n],H[s]),f=n,_=s),i===m&&r===g&&a===v&&o===y||(t.blendFuncSeparate(V[i],V[r],V[a],V[o]),m=i,g=r,v=a,y=o),!1!==l.equals(x)&&h===S||(t.blendColor(l.r,l.g,l.b,h),x.copy(l),S=h),p=e,b=!1;else if(e!==p||c!==b){if(f===Sn&&_===Sn||(t.blendEquation(t.FUNC_ADD),f=Sn,_=Sn),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.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.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.blendFunc(t.SRC_ALPHA,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}m=null,g=null,v=null,y=null,x.set(0,0,0),S=0,p=e,b=c}}else!0===u&&(G(t.BLEND),u=!1)}function X(e){M!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),M=e)}function j(e){0!==e?(z(t.CULL_FACE),e!==w&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):G(t.CULL_FACE),w=e}function Y(e,n,i){e?(z(t.POLYGON_OFFSET_FILL),T===n&&A===i||(t.polygonOffset(n,i),T=n,A=i)):G(t.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:z,disable:G,bindFramebuffer:function(e,n){return l[e]!==n&&(t.bindFramebuffer(e,n),l[e]=n,e===t.DRAW_FRAMEBUFFER&&(l[t.FRAMEBUFFER]=n),e===t.FRAMEBUFFER&&(l[t.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(e,n){let i=c,r=!1;if(e){i=h.get(n),void 0===i&&(i=[],h.set(n,i));const s=e.textures;if(i.length!==s.length||i[0]!==t.COLOR_ATTACHMENT0){for(let e=0,n=s.length;e<n;e++)i[e]=t.COLOR_ATTACHMENT0+e;i.length=s.length,r=!0}}else i[0]!==t.BACK&&(i[0]=t.BACK,r=!0);r&&t.drawBuffers(i)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:W,setMaterial:function(e,s){2===e.side?G(t.CULL_FACE):z(t.CULL_FACE);let a=e.side===yn;s&&(a=!a),X(a),1===e.blending&&!1===e.transparent?W(0):W(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),i.setFunc(e.depthFunc),i.setTest(e.depthTest),i.setMask(e.depthWrite),n.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),Y(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?z(t.SAMPLE_ALPHA_TO_COVERAGE):G(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:X,setCullFace:j,setLineWidth:function(e){e!==E&&(R&&t.lineWidth(e),E=e)},setPolygonOffset:Y,setScissorTest:function(e){e?z(t.SCISSOR_TEST):G(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+C-1),I!==e&&(t.activeTexture(e),I=e)},bindTexture:function(e,n,i){void 0===i&&(i=null===I?t.TEXTURE0+C-1:I);let r=D[i];void 0===r&&(r={type:void 0,texture:void 0},D[i]=r),r.type===e&&r.texture===n||(I!==i&&(t.activeTexture(i),I=i),t.bindTexture(e,n||B[e]),r.type=e,r.texture=n)},unbindTexture:function(){const e=D[I];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.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,n){let i=a.get(n);void 0===i&&(i=new WeakMap,a.set(n,i));let r=i.get(e);void 0===r&&(r=t.getUniformBlockIndex(n,e.name),i.set(e,r))},uniformBlockBinding:function(e,n){const i=a.get(n).get(e);s.get(n)!==i&&(t.uniformBlockBinding(n,i,e.__bindingPointIndex),s.set(n,i))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===O.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),O.copy(e))},viewport:function(e){!1===F.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),F.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),i.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={},I=null,D={},l={},h=new WeakMap,c=[],d=null,u=!1,p=null,f=null,m=null,g=null,_=null,v=null,y=null,x=new Ka(0,0,0),S=0,b=!1,M=null,w=null,E=null,T=null,A=null,O.set(0,0,t.canvas.width,t.canvas.height),F.set(0,0,t.canvas.width,t.canvas.height),n.reset(),i.reset(),r.reset()}}}function Rc(t,e,n,i){const r=function(t){switch(t){case _i:case vi:return{byteLength:1,components:1};case xi:case yi:case wi:return{byteLength:2,components:1};case Ei:case Ti:return{byteLength:2,components:4};case bi:case Si:case Mi:return{byteLength:4,components:1};case Ci:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(i);switch(n){case Ri:case Ii:return t*e;case Di:return t*e*2;case Oi:case Fi:return t*e/r.components*r.byteLength;case ki:case Bi:return t*e*2/r.components*r.byteLength;case Pi:return t*e*3/r.components*r.byteLength;case Li:case zi:return t*e*4/r.components*r.byteLength;case Gi:case Hi:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Vi:case Wi:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case ji:case qi:return Math.max(t,16)*Math.max(e,8)/4;case Xi:case Yi:return Math.max(t,8)*Math.max(e,8)/2;case Ki:case Zi:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Qi:case Ji:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case $i:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case tr:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case er:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case nr:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case ir:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case rr:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case sr:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case ar:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case or:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case lr:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case hr:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case cr:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case dr:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case ur:case pr:case fr:return Math.ceil(t/4)*Math.ceil(e/4)*16;case mr:case gr:return Math.ceil(t/4)*Math.ceil(e/4)*8;case _r:case vr:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Pc(t,e,n,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),h=new Jr,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 f(t,e){return p?new OffscreenCanvas(t,e):ns("canvas")}function m(t,e,n){let i=1;const r=G(t);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<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 n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===d&&(d=f(n,s));const a=e?f(n,s):d;a.width=n,a.height=s;return a.getContext("2d").drawImage(t,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function _(e){t.generateMipmap(e)}function v(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(n,i,r,s,a=!1){if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),i===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),i===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),i===t.RGBA){const e=a?Er:as.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===Tr?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===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,n){let i;return e?null===n||n===bi||n===Ai?i=t.DEPTH24_STENCIL8:n===Mi?i=t.DEPTH32F_STENCIL8:n===xi&&(i=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===bi||n===Ai?i=t.DEPTH_COMPONENT24:n===Mi?i=t.DEPTH_COMPONENT32F:n===xi&&(i=t.DEPTH_COMPONENT16),i}function S(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==di&&t.minFilter!==fi?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 b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=u.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&w(t),0===Object.keys(r).length&&u.delete(n)}i.remove(t)}(e),e.isVideoTexture&&c.delete(e)}function M(e){const n=e.target;n.removeEventListener("dispose",M),function(e){const n=i.get(e);e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i<n.__webglFramebuffer[e].length;i++)t.deleteFramebuffer(n.__webglFramebuffer[e][i]);else t.deleteFramebuffer(n.__webglFramebuffer[e]);n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[e])}else{if(Array.isArray(n.__webglFramebuffer))for(let e=0;e<n.__webglFramebuffer.length;e++)t.deleteFramebuffer(n.__webglFramebuffer[e]);else t.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&t.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let e=0;e<n.__webglColorRenderbuffer.length;e++)n.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(n.__webglColorRenderbuffer[e]);n.__webglDepthRenderbuffer&&t.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,n=r.length;e<n;e++){const n=i.get(r[e]);n.__webglTexture&&(t.deleteTexture(n.__webglTexture),a.memory.textures--),i.remove(r[e])}i.remove(e)}(n)}function w(e){const n=i.get(e);t.deleteTexture(n.__webglTexture);const r=e.source;delete u.get(r)[n.__cacheKey],a.memory.textures--}let E=0;function T(e,r){const s=i.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&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void I(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const A={[li]:t.REPEAT,[hi]:t.CLAMP_TO_EDGE,[ci]:t.MIRRORED_REPEAT},C={[di]:t.NEAREST,[ui]:t.NEAREST_MIPMAP_NEAREST,[pi]:t.NEAREST_MIPMAP_LINEAR,[fi]:t.LINEAR,[mi]:t.LINEAR_MIPMAP_NEAREST,[gi]:t.LINEAR_MIPMAP_LINEAR},R={[Cr]:t.NEVER,[Ur]:t.ALWAYS,[Rr]:t.LESS,[Lr]:t.LEQUAL,[Pr]:t.EQUAL,[Nr]:t.GEQUAL,[Ir]:t.GREATER,[Dr]:t.NOTEQUAL};function P(n,s){if(s.type!==Mi||!1!==e.has("OES_texture_float_linear")||s.magFilter!==fi&&s.magFilter!==mi&&s.magFilter!==pi&&s.magFilter!==gi&&s.minFilter!==fi&&s.minFilter!==mi&&s.minFilter!==pi&&s.minFilter!==gi||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,A[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,A[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,A[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,R[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===di)return;if(s.minFilter!==pi&&s.minFilter!==gi)return;if(s.type===Mi&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function L(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",b));const r=n.source;let s=u.get(r);void 0===s&&(s={},u.set(r,s));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()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&w(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function I(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const h=L(e,a),c=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const d=i.get(c);if(c.version!==d.__version||!0===h){n.activeTexture(t.TEXTURE0+o);const e=as.getPrimaries(as.workingColorSpace),i=a.colorSpace===br?null:as.getPrimaries(a.colorSpace),u=a.colorSpace===br||e===i?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=m(a.image,!1,r.maxTextureSize);p=z(a,p);const f=s.convert(a.format,a.colorSpace),v=s.convert(a.type);let b,M=y(a.internalFormat,f,v,a.colorSpace,a.isVideoTexture);P(l,a);const w=a.mipmaps,E=!0!==a.isVideoTexture,T=void 0===d.__version||!0===h,A=c.dataReady,C=S(a,p);if(a.isDepthTexture)M=x(a.format===Ui,a.type),T&&(E?n.texStorage2D(t.TEXTURE_2D,1,M,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,M,p.width,p.height,0,f,v,null));else if(a.isDataTexture)if(w.length>0){E&&T&&n.texStorage2D(t.TEXTURE_2D,C,M,w[0].width,w[0].height);for(let e=0,i=w.length;e<i;e++)b=w[e],E?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,v,b.data):n.texImage2D(t.TEXTURE_2D,e,M,b.width,b.height,0,f,v,b.data);a.generateMipmaps=!1}else E?(T&&n.texStorage2D(t.TEXTURE_2D,C,M,p.width,p.height),A&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,p.width,p.height,f,v,p.data)):n.texImage2D(t.TEXTURE_2D,0,M,p.width,p.height,0,f,v,p.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){E&&T&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,M,w[0].width,w[0].height,p.depth);for(let e=0,i=w.length;e<i;e++)if(b=w[e],a.format!==Li)if(null!==f)if(E){if(A)if(a.layerUpdates.size>0){const i=Rc(b.width,b.height,a.format,a.type);for(const r of a.layerUpdates){const s=b.data.subarray(r*i/b.data.BYTES_PER_ELEMENT,(r+1)*i/b.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,b.width,b.height,1,f,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,f,b.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,M,b.width,b.height,p.depth,0,b.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else E?A&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,b.width,b.height,p.depth,f,v,b.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,M,b.width,b.height,p.depth,0,f,v,b.data)}else{E&&T&&n.texStorage2D(t.TEXTURE_2D,C,M,w[0].width,w[0].height);for(let e=0,i=w.length;e<i;e++)b=w[e],a.format!==Li?null!==f?E?A&&n.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,b.data):n.compressedTexImage2D(t.TEXTURE_2D,e,M,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,b.width,b.height,f,v,b.data):n.texImage2D(t.TEXTURE_2D,e,M,b.width,b.height,0,f,v,b.data)}else if(a.isDataArrayTexture)if(E){if(T&&n.texStorage3D(t.TEXTURE_2D_ARRAY,C,M,p.width,p.height,p.depth),A)if(a.layerUpdates.size>0){const e=Rc(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,v,r)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,M,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isData3DTexture)E?(T&&n.texStorage3D(t.TEXTURE_3D,C,M,p.width,p.height,p.depth),A&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)):n.texImage3D(t.TEXTURE_3D,0,M,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isFramebufferTexture){if(T)if(E)n.texStorage2D(t.TEXTURE_2D,C,M,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r<C;r++)n.texImage2D(t.TEXTURE_2D,r,M,e,i,0,f,v,null),e>>=1,i>>=1}}else if(w.length>0){if(E&&T){const e=G(w[0]);n.texStorage2D(t.TEXTURE_2D,C,M,e.width,e.height)}for(let e=0,i=w.length;e<i;e++)b=w[e],E?A&&n.texSubImage2D(t.TEXTURE_2D,e,0,0,f,v,b):n.texImage2D(t.TEXTURE_2D,e,M,f,v,b);a.generateMipmaps=!1}else if(E){if(T){const e=G(p);n.texStorage2D(t.TEXTURE_2D,C,M,e.width,e.height)}A&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,f,v,p)}else n.texImage2D(t.TEXTURE_2D,0,M,f,v,p);g(a)&&_(l),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function D(e,r,a,l,h,c){const d=s.convert(a.format,a.colorSpace),u=s.convert(a.type),p=y(a.internalFormat,d,u,a.colorSpace),f=i.get(r),m=i.get(a);if(m.__renderTarget=r,!f.__hasExternalTextures){const e=Math.max(1,r.width>>c),i=Math.max(1,r.height>>c);h===t.TEXTURE_3D||h===t.TEXTURE_2D_ARRAY?n.texImage3D(h,c,p,e,i,r.depth,0,d,u,null):n.texImage2D(h,c,p,e,i,0,d,u,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,h,m.__webglTexture,0,k(r)):(h===t.TEXTURE_2D||h>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&h<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,h,m.__webglTexture,c),n.bindFramebuffer(t.FRAMEBUFFER,null)}function N(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=x(n.stencilBuffer,s),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=k(n);B(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,h,a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,h,a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r<e.length;r++){const a=e[r],l=s.convert(a.format,a.colorSpace),h=s.convert(a.type),c=y(a.internalFormat,l,h,a.colorSpace),d=k(n);i&&!1===B(n)?t.renderbufferStorageMultisample(t.RENDERBUFFER,d,c,n.width,n.height):B(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,d,c,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,c,n.width,n.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function U(e){const r=i.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=i.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),T(r.depthTexture,0);const a=s.__webglTexture,l=k(r);if(r.depthTexture.format===Ni)B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Ui)throw new Error("Unknown depthTexture format");B(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),N(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,s)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),N(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const O=[],F=[];function k(t){return Math.min(r.maxSamples,t.samples)}function B(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function z(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==wr&&n!==br&&(as.getTransfer(n)===Tr?i===Li&&r===_i||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),e}function G(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(h.width=t.naturalWidth||t.width,h.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(h.width=t.displayWidth,h.height=t.displayHeight):(h.width=t.width,h.height=t.height),h}this.allocateTextureUnit=function(){const t=E;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),E+=1,t},this.resetTextureUnits=function(){E=0},this.setTexture2D=T,this.setTexture2DArray=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?I(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=L(e,a),h=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=i.get(h);if(h.version!==c.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=as.getPrimaries(as.workingColorSpace),i=a.colorSpace===br?null:as.getPrimaries(a.colorSpace),d=a.colorSpace===br||e===i?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,f=[];for(let t=0;t<6;t++)f[t]=u||p?p?a.image[t].image:a.image[t]:m(a.image[t],!0,r.maxCubemapSize),f[t]=z(a,f[t]);const v=f[0],x=s.convert(a.format,a.colorSpace),b=s.convert(a.type),M=y(a.internalFormat,x,b,a.colorSpace),w=!0!==a.isVideoTexture,E=void 0===c.__version||!0===l,T=h.dataReady;let A,C=S(a,v);if(P(t.TEXTURE_CUBE_MAP,a),u){w&&E&&n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,v.width,v.height);for(let e=0;e<6;e++){A=f[e].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];a.format!==Li?null!==x?w?T&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,x,r.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,0,0,r.width,r.height,x,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i,M,r.width,r.height,0,x,b,r.data)}}}else{if(A=a.mipmaps,w&&E){A.length>0&&C++;const e=G(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,C,M,e.width,e.height)}for(let e=0;e<6;e++)if(p){w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,x,b,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,f[e].width,f[e].height,0,x,b,f[e].data);for(let i=0;i<A.length;i++){const r=A[i].image[e].image;w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,r.width,r.height,x,b,r.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,r.width,r.height,0,x,b,r.data)}}else{w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,b,f[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,M,x,b,f[e]);for(let i=0;i<A.length;i++){const r=A[i];w?T&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,0,0,x,b,r.image[e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,i+1,M,x,b,r.image[e])}}}g(a)&&_(t.TEXTURE_CUBE_MAP),c.__version=h.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,n,r){const s=i.get(e);void 0!==n&&D(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&U(e)},this.setupRenderTarget=function(e){const r=e.texture,o=i.get(e),l=i.get(r);e.addEventListener("dispose",M);const h=e.textures,c=!0===e.isWebGLCubeRenderTarget,d=h.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[e][n]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(d)for(let e=0,n=h.length;e<n;e++){const n=i.get(h[e]);void 0===n.__webglTexture&&(n.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===B(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<h.length;n++){const i=h[n];o.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=s.convert(i.format,i.colorSpace),a=s.convert(i.type),l=y(i.internalFormat,r,a,i.colorSpace,!0===e.isXRRenderTarget),c=k(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,o.__webglColorRenderbuffer[n])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),N(o.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){n.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),P(t.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)D(o.__webglFramebuffer[n][i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else D(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);g(r)&&_(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let r=0,s=h.length;r<s;r++){const s=h[r],a=i.get(s);n.bindTexture(t.TEXTURE_2D,a.__webglTexture),P(t.TEXTURE_2D,s),D(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,t.TEXTURE_2D,0),g(s)&&_(t.TEXTURE_2D)}n.unbindTexture()}else{let i=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(i=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),P(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)D(o.__webglFramebuffer[n],e,r,t.COLOR_ATTACHMENT0,i,n);else D(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,i,0);g(r)&&_(i),n.unbindTexture()}e.depthBuffer&&U(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(g(s)){const e=v(t),r=i.get(s).__webglTexture;n.bindTexture(e,r),_(e),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===B(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const h=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=i.get(e),d=r.length>1;if(d)for(let e=0;e<r.length;e++)n.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let n=0;n<r.length;n++){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[n]);const e=i.get(r[n]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===l&&(O.length=0,F.length=0,O.push(t.COLOR_ATTACHMENT0+n),e.depthBuffer&&!1===e.resolveDepthBuffer&&(O.push(h),F.push(h),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,F)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,O))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),d)for(let e=0;e<r.length;e++){n.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=i.get(r[e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=D,this.useMultisampledRTT=B}function Lc(t,e){return{convert:function(n,i=""){let r;const s=as.getTransfer(i);if(n===_i)return t.UNSIGNED_BYTE;if(n===Ei)return t.UNSIGNED_SHORT_4_4_4_4;if(n===Ti)return t.UNSIGNED_SHORT_5_5_5_1;if(n===Ci)return t.UNSIGNED_INT_5_9_9_9_REV;if(n===vi)return t.BYTE;if(n===yi)return t.SHORT;if(n===xi)return t.UNSIGNED_SHORT;if(n===Si)return t.INT;if(n===bi)return t.UNSIGNED_INT;if(n===Mi)return t.FLOAT;if(n===wi)return t.HALF_FLOAT;if(n===Ri)return t.ALPHA;if(n===Pi)return t.RGB;if(n===Li)return t.RGBA;if(n===Ii)return t.LUMINANCE;if(n===Di)return t.LUMINANCE_ALPHA;if(n===Ni)return t.DEPTH_COMPONENT;if(n===Ui)return t.DEPTH_STENCIL;if(n===Oi)return t.RED;if(n===Fi)return t.RED_INTEGER;if(n===ki)return t.RG;if(n===Bi)return t.RG_INTEGER;if(n===zi)return t.RGBA_INTEGER;if(n===Gi||n===Hi||n===Vi||n===Wi)if(s===Tr){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Gi)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Hi)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Vi)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Wi)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Gi)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Hi)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Vi)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Wi)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Xi||n===ji||n===Yi||n===qi){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Xi)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ji)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Yi)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===qi)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Ki||n===Zi||n===Qi){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===Ki||n===Zi)return s===Tr?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Qi)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===Ji||n===$i||n===tr||n===er||n===nr||n===ir||n===rr||n===sr||n===ar||n===or||n===lr||n===hr||n===cr||n===dr){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===Ji)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===$i)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===tr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===er)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===nr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ir)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===rr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ar)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===or)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===lr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===hr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===cr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===dr)return s===Tr?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===ur||n===pr||n===fr){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(n===ur)return s===Tr?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===pr)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===fr)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===mr||n===gr||n===_r||n===vr){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===ur)return r.COMPRESSED_RED_RGTC1_EXT;if(n===gr)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===_r)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===vr)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Ai?t.UNSIGNED_INT_24_8:void 0!==t[n]?t[n]:null}}}class Ic extends ko{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Dc extends Pa{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Nc={type:"move"};class Uc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Dc,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Dc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new As,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new As),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Dc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new As,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new As),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),r=this._getHandJoint(l,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,h=.005;l.inputState.pinching&&a>o+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Nc)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new Dc;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class Oc{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(null===this.texture){const i=new xs;t.properties.get(i).__webglTexture=e.texture,e.depthNear==n.depthNear&&e.depthFar==n.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new Do({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 To(new Jo(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Fc extends zr{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,h=null,c=null,d=null,u=null,p=null;const f=new Oc,m=e.getContextAttributes();let g=null,_=null;const v=[],y=[],x=new Jr;let S=null;const b=new ko;b.viewport=new Ss;const M=new ko;M.viewport=new Ss;const w=[b,M],E=new Ic;let T=null,A=null;function C(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const n=v[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function R(){i.removeEventListener("select",C),i.removeEventListener("selectstart",C),i.removeEventListener("selectend",C),i.removeEventListener("squeeze",C),i.removeEventListener("squeezestart",C),i.removeEventListener("squeezeend",C),i.removeEventListener("end",R),i.removeEventListener("inputsourceschange",P);for(let t=0;t<v.length;t++){const e=y[t];null!==e&&(y[t]=null,v[t].disconnect(e))}T=null,A=null,f.reset(),t.setRenderTarget(g),u=null,d=null,c=null,i=null,_=null,U.stop(),n.isPresenting=!1,t.setPixelRatio(S),t.setSize(x.width,x.height,!1),n.dispatchEvent({type:"sessionend"})}function P(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],i=y.indexOf(n);i>=0&&(y[i]=null,v[i].disconnect(n))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let i=y.indexOf(n);if(-1===i){for(let t=0;t<v.length;t++){if(t>=y.length){y.push(n),i=t;break}if(null===y[t]){y[t]=n,i=t;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=v[t];return void 0===e&&(e=new Uc,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new Uc,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new Uc,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(h){if(i=h,null!==i){if(g=t.getRenderTarget(),i.addEventListener("select",C),i.addEventListener("selectstart",C),i.addEventListener("selectend",C),i.addEventListener("squeeze",C),i.addEventListener("squeezestart",C),i.addEventListener("squeezeend",C),i.addEventListener("end",R),i.addEventListener("inputsourceschange",P),!0!==m.xrCompatible&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(x),void 0===i.renderState.layers){const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t.setSize(u.framebufferWidth,u.framebufferHeight,!1),_=new Ms(u.framebufferWidth,u.framebufferHeight,{format:Li,type:_i,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?Ui:Ni,s=m.stencil?Ai:bi);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=new XRWebGLBinding(i,e),d=c.createProjectionLayer(o),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new Ms(d.textureWidth,d.textureHeight,{format:Li,type:_i,depthTexture:new Ol(d.textureWidth,d.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues})}_.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const L=new As,I=new As;function D(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===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),E.near=M.near=b.near=e,E.far=M.far=b.far=n,T===E.near&&A===E.far||(i.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,A=E.far),b.layers.mask=2|t.layers.mask,M.layers.mask=4|t.layers.mask,E.layers.mask=b.layers.mask|M.layers.mask;const r=t.parent,s=E.cameras;D(E,r);for(let t=0;t<s.length;t++)D(s[t],r);2===s.length?function(t,e,n){L.setFromMatrixPosition(e.matrixWorld),I.setFromMatrixPosition(n.matrixWorld);const i=L.distanceTo(I),r=e.projectionMatrix.elements,s=n.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],h=(r[9]-1)/r[5],c=(r[8]-1)/r[0],d=(s[8]+1)/s[0],u=a*c,p=a*d,f=i/(-c+d),m=f*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+f,n=o+f,r=u-m,s=p+(i-m),c=l*o/n*e,d=h*o/n*e;t.projectionMatrix.makePerspective(r,s,c,d,e,n),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(E,b,M):E.projectionMatrix.copy(b.projectionMatrix),function(t,e,n){null===n?t.matrix.copy(e.matrixWorld):(t.matrix.copy(n.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*Wr*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,E,r)},this.getCamera=function(){return E},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(E)};let N=null;const U=new Zo;U.setAnimationLoop((function(e,r){if(h=r.getViewerPose(l||s),p=r,null!==h){const e=h.views;null!==u&&(t.setRenderTargetFramebuffer(_,u.framebuffer),t.setRenderTarget(_));let n=!1;e.length!==E.cameras.length&&(E.cameras.length=0,n=!0);for(let i=0;i<e.length;i++){const r=e[i];let s=null;if(null!==u)s=u.getViewport(r);else{const e=c.getViewSubImage(d,r);s=e.viewport,0===i&&(t.setRenderTargetTextures(_,e.colorTexture,d.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(_))}let a=w[i];void 0===a&&(a=new ko,a.layers.enable(i),a.viewport=new Ss,w[i]=a),a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(r.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(E.matrix.copy(a.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),!0===n&&E.cameras.push(a)}const r=i.enabledFeatures;if(r&&r.includes("depth-sensing")){const n=c.getDepthInformation(e[0]);n&&n.isValid&&n.texture&&f.init(t,n,i.renderState)}}for(let t=0;t<v.length;t++){const e=y[t],n=v[t];null!==e&&void 0!==n&&n.update(e,r,l||s)}N&&N(e,r),r.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:r}),p=null})),this.setAnimationLoop=function(t){N=t},this.dispose=function(){}}}const kc=new pa,Bc=new ia;function zc(t,e){function n(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function i(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map,n(i.map,t.mapTransform)),i.alphaMap&&(t.alphaMap.value=i.alphaMap,n(i.alphaMap,t.alphaMapTransform)),i.bumpMap&&(t.bumpMap.value=i.bumpMap,n(i.bumpMap,t.bumpMapTransform),t.bumpScale.value=i.bumpScale,i.side===yn&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,n(i.normalMap,t.normalMapTransform),t.normalScale.value.copy(i.normalScale),i.side===yn&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,n(i.displacementMap,t.displacementMapTransform),t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,t.emissiveMapTransform)),i.specularMap&&(t.specularMap.value=i.specularMap,n(i.specularMap,t.specularMapTransform)),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,kc.copy(a),kc.x*=-1,kc.y*=-1,kc.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(kc.y*=-1,kc.z*=-1),t.envMapRotation.value.setFromMatrix4(Bc.makeRotationFromEuler(kc)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,Lo(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){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,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===yn&&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,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(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,n(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.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,n(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Gc(t,e,n,i){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function h(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?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function c(e){const n=e.target;n.removeEventListener("dispose",c);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,d){let u=r[n.id];void 0===u&&(!function(t){const e=t.uniforms;let n=0;const i=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=h(s[t]),a=n%i,o=a%r.boundary,l=a+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);t.__size=n,t.__cache={}}(n),u=function(e){const n=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const i=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=u,n.addEventListener("dispose",c));const p=d.program;i.updateUBOMapping(n,p);const f=e.render.frame;s[n.id]!==f&&(!function(e){const n=r[e.id],i=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,n);for(let e=0,n=i.length;e<n;e++){const n=Array.isArray(i[e])?i[e]:[i[e]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,e,i,s)){const e=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let s=0;s<n.length;s++){const a=n[s],o=h(a);"number"==typeof a||"boolean"==typeof a?(r.__data[0]=a,t.bufferSubData(t.UNIFORM_BUFFER,e+i,r.__data)):a.isMatrix3?(r.__data[0]=a.elements[0],r.__data[1]=a.elements[1],r.__data[2]=a.elements[2],r.__data[3]=0,r.__data[4]=a.elements[3],r.__data[5]=a.elements[4],r.__data[6]=a.elements[5],r.__data[7]=0,r.__data[8]=a.elements[6],r.__data[9]=a.elements[7],r.__data[10]=a.elements[8],r.__data[11]=0):(a.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,e,r.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}(n),s[n.id]=f)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}class Hc{constructor(t={}){const{canvas:e=is(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:c=!1,reverseDepthBuffer:d=!1}=t;let u;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=n.getContextAttributes().alpha}else u=s;const p=new Uint32Array(4),f=new Int32Array(4);let m=null,g=null;const _=[],v=[];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._outputColorSpace=Mr,this.toneMapping=Zn,this.toneMappingExposure=1;const y=this;let x=!1,S=0,b=0,M=null,w=-1,E=null;const T=new Ss,A=new Ss;let C=null;const R=new Ka(0);let P=0,L=e.width,I=e.height,D=1,N=null,U=null;const O=new Ss(0,0,L,I),F=new Ss(0,0,L,I);let k=!1;const B=new Ko;let z=!1,G=!1;const H=new ia,V=new ia,W=new As,X=new Ss,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Y=!1;function q(){return null===M?D:1}let K,Z,Q,J,$,tt,et,nt,it,rt,st,at,ot,lt,ht,ct,dt,ut,pt,ft,mt,gt,_t,vt,yt=n;function xt(t,n){return e.getContext(t,n)}try{const t={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${on}`),e.addEventListener("webglcontextlost",Mt,!1),e.addEventListener("webglcontextrestored",wt,!1),e.addEventListener("webglcontextcreationerror",Et,!1),null===yt){const e="webgl2";if(yt=xt(e,t),null===yt)throw xt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function St(){K=new Pl(yt),K.init(),gt=new Lc(yt,K),Z=new ll(yt,K,t,gt),Q=new Cc(yt,K),Z.reverseDepthBuffer&&d&&Q.buffers.depth.setReversed(!0),J=new Dl(yt),$=new pc,tt=new Pc(yt,K,Q,$,Z,gt,J),et=new cl(y),nt=new Rl(y),it=new Qo(yt),_t=new al(yt,it),rt=new Ll(yt,it,J,_t),st=new Ul(yt,rt,it,J),pt=new Nl(yt,Z,tt),ct=new hl($),at=new uc(y,et,nt,K,Z,_t,ct),ot=new zc(y,$),lt=new _c,ht=new Mc(K),ut=new sl(y,et,nt,Q,st,u,o),dt=new Tc(y,st,Z),vt=new Gc(yt,J,Z,Q),ft=new ol(yt,K,J),mt=new Il(yt,K,J),J.programs=at.programs,y.capabilities=Z,y.extensions=K,y.properties=$,y.renderLists=lt,y.shadowMap=dt,y.state=Q,y.info=J}St();const bt=new Fc(y,yt);function Mt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function wt(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const t=J.autoReset,e=dt.enabled,n=dt.autoUpdate,i=dt.needsUpdate,r=dt.type;St(),J.autoReset=t,dt.enabled=e,dt.autoUpdate=n,dt.needsUpdate=i,dt.type=r}function Et(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Tt(t){const e=t.target;e.removeEventListener("dispose",Tt),function(t){(function(t){const e=$.get(t).programs;void 0!==e&&(e.forEach((function(t){at.releaseProgram(t)})),t.isShaderMaterial&&at.releaseShaderCache(t))})(t),$.remove(t)}(e)}function At(t,e,n){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=yn,t.needsUpdate=!0,Ft(t,e,n),t.side=vn,t.needsUpdate=!0,Ft(t,e,n),t.side=2):Ft(t,e,n)}this.xr=bt,this.getContext=function(){return yt},this.getContextAttributes=function(){return yt.getContextAttributes()},this.forceContextLoss=function(){const t=K.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=K.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return D},this.setPixelRatio=function(t){void 0!==t&&(D=t,this.setSize(L,I,!1))},this.getSize=function(t){return t.set(L,I)},this.setSize=function(t,n,i=!0){bt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(L=t,I=n,e.width=Math.floor(t*D),e.height=Math.floor(n*D),!0===i&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(L*D,I*D).floor()},this.setDrawingBufferSize=function(t,n,i){L=t,I=n,D=i,e.width=Math.floor(t*i),e.height=Math.floor(n*i),this.setViewport(0,0,t,n)},this.getCurrentViewport=function(t){return t.copy(T)},this.getViewport=function(t){return t.copy(O)},this.setViewport=function(t,e,n,i){t.isVector4?O.set(t.x,t.y,t.z,t.w):O.set(t,e,n,i),Q.viewport(T.copy(O).multiplyScalar(D).round())},this.getScissor=function(t){return t.copy(F)},this.setScissor=function(t,e,n,i){t.isVector4?F.set(t.x,t.y,t.z,t.w):F.set(t,e,n,i),Q.scissor(A.copy(F).multiplyScalar(D).round())},this.getScissorTest=function(){return k},this.setScissorTest=function(t){Q.setScissorTest(k=t)},this.setOpaqueSort=function(t){N=t},this.setTransparentSort=function(t){U=t},this.getClearColor=function(t){return t.copy(ut.getClearColor())},this.setClearColor=function(){ut.setClearColor.apply(ut,arguments)},this.getClearAlpha=function(){return ut.getClearAlpha()},this.setClearAlpha=function(){ut.setClearAlpha.apply(ut,arguments)},this.clear=function(t=!0,e=!0,n=!0){let i=0;if(t){let t=!1;if(null!==M){const e=M.texture.format;t=e===zi||e===Bi||e===Fi}if(t){const t=M.texture.type,e=t===_i||t===bi||t===xi||t===Ai||t===Ei||t===Ti,n=ut.getClearColor(),i=ut.getClearAlpha(),r=n.r,s=n.g,a=n.b;e?(p[0]=r,p[1]=s,p[2]=a,p[3]=i,yt.clearBufferuiv(yt.COLOR,0,p)):(f[0]=r,f[1]=s,f[2]=a,f[3]=i,yt.clearBufferiv(yt.COLOR,0,f))}else i|=yt.COLOR_BUFFER_BIT}e&&(i|=yt.DEPTH_BUFFER_BIT),n&&(i|=yt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),yt.clear(i)},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",Mt,!1),e.removeEventListener("webglcontextrestored",wt,!1),e.removeEventListener("webglcontextcreationerror",Et,!1),lt.dispose(),ht.dispose(),$.dispose(),et.dispose(),nt.dispose(),st.dispose(),_t.dispose(),vt.dispose(),at.dispose(),bt.dispose(),bt.removeEventListener("sessionstart",Rt),bt.removeEventListener("sessionend",Pt),Lt.stop()},this.renderBufferDirect=function(t,e,n,i,r,s){null===e&&(e=j);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,n,i,r){!0!==e.isScene&&(e=j);tt.resetTextureUnits();const s=e.fog,a=i.isMeshStandardMaterial?e.environment:null,o=null===M?y.outputColorSpace:!0===M.isXRRenderTarget?M.texture.colorSpace:wr,l=(i.isMeshStandardMaterial?nt:et).get(i.envMap||a),h=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,c=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,u=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=Zn;i.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(f=y.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=void 0!==m?m.length:0,v=$.get(i),x=g.state.lights;if(!0===z&&(!0===G||t!==E)){const e=t===E&&i.id===w;ct.setState(i,t,e)}let S=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==x.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?S=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?S=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?S=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==l||!0===i.fog&&v.fog!==s?S=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===ct.numPlanes&&v.numIntersection===ct.numIntersection?(v.vertexAlphas!==h||v.vertexTangents!==c||v.morphTargets!==d||v.morphNormals!==u||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==_)&&(S=!0):S=!0:S=!0:S=!0:S=!0:(S=!0,v.__version=i.version);let b=v.currentProgram;!0===S&&(b=Ft(i,e,r));let T=!1,A=!1,C=!1;const R=b.getUniforms(),P=v.uniforms;Q.useProgram(b.program)&&(T=!0,A=!0,C=!0);i.id!==w&&(w=i.id,A=!0);if(T||E!==t){Q.buffers.depth.getReversed()?(H.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(H),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(H),R.setValue(yt,"projectionMatrix",H)):R.setValue(yt,"projectionMatrix",t.projectionMatrix),R.setValue(yt,"viewMatrix",t.matrixWorldInverse);const e=R.map.cameraPosition;void 0!==e&&e.setValue(yt,W.setFromMatrixPosition(t.matrixWorld)),Z.logarithmicDepthBuffer&&R.setValue(yt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(yt,"isOrthographic",!0===t.isOrthographicCamera),E!==t&&(E=t,A=!0,C=!0)}if(r.isSkinnedMesh){R.setOptional(yt,r,"bindMatrix"),R.setOptional(yt,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),R.setValue(yt,"boneTexture",t.boneTexture,tt))}r.isBatchedMesh&&(R.setOptional(yt,r,"batchingTexture"),R.setValue(yt,"batchingTexture",r._matricesTexture,tt),R.setOptional(yt,r,"batchingIdTexture"),R.setValue(yt,"batchingIdTexture",r._indirectTexture,tt),R.setOptional(yt,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(yt,"batchingColorTexture",r._colorsTexture,tt));const L=n.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||pt.update(r,n,b);(A||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,R.setValue(yt,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);A&&(R.setValue(yt,"toneMappingExposure",y.toneMappingExposure),v.needsLights&&(U=C,(N=P).ambientLightColor.needsUpdate=U,N.lightProbe.needsUpdate=U,N.directionalLights.needsUpdate=U,N.directionalLightShadows.needsUpdate=U,N.pointLights.needsUpdate=U,N.pointLightShadows.needsUpdate=U,N.spotLights.needsUpdate=U,N.spotLightShadows.needsUpdate=U,N.rectAreaLights.needsUpdate=U,N.hemisphereLights.needsUpdate=U),s&&!0===i.fog&&ot.refreshFogUniforms(P,s),ot.refreshMaterialUniforms(P,i,D,I,g.state.transmissionRenderTarget[t.id]),Gh.upload(yt,kt(v),P,tt));var N,U;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Gh.upload(yt,kt(v),P,tt),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&R.setValue(yt,"center",r.center);if(R.setValue(yt,"modelViewMatrix",r.modelViewMatrix),R.setValue(yt,"normalMatrix",r.normalMatrix),R.setValue(yt,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e<n;e++){const n=t[e];vt.update(n,b),vt.bind(n,b)}}return b}(t,e,n,i,r);Q.setMaterial(i,a);let l=n.index,h=1;if(!0===i.wireframe){if(l=rt.getWireframeAttribute(n),void 0===l)return;h=2}const c=n.drawRange,d=n.attributes.position;let u=c.start*h,p=(c.start+c.count)*h;null!==s&&(u=Math.max(u,s.start*h),p=Math.min(p,(s.start+s.count)*h)),null!==l?(u=Math.max(u,0),p=Math.min(p,l.count)):null!=d&&(u=Math.max(u,0),p=Math.min(p,d.count));const f=p-u;if(f<0||f===1/0)return;let m;_t.setup(r,i,o,n,l);let _=ft;if(null!==l&&(m=it.get(l),_=mt,_.setIndex(m)),r.isMesh)!0===i.wireframe?(Q.setLineWidth(i.wireframeLinewidth*q()),_.setMode(yt.LINES)):_.setMode(yt.TRIANGLES);else if(r.isLine){let t=i.linewidth;void 0===t&&(t=1),Q.setLineWidth(t*q()),r.isLineSegments?_.setMode(yt.LINES):r.isLineLoop?_.setMode(yt.LINE_LOOP):_.setMode(yt.LINE_STRIP)}else r.isPoints?_.setMode(yt.POINTS):r.isSprite&&_.setMode(yt.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)_.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(K.get("WEBGL_multi_draw"))_.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,n=r._multiDrawCount,s=l?it.get(l).bytesPerElement:1,a=$.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)a.setValue(yt,"_gl_DrawID",i),_.render(t[i]/s,e[i])}else if(r.isInstancedMesh)_.renderInstances(u,f,r.count);else if(n.isInstancedBufferGeometry){const t=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,e=Math.min(n.instanceCount,t);_.renderInstances(u,f,e)}else _.render(u,f)},this.compile=function(t,e,n=null){null===n&&(n=t),g=ht.get(n),g.init(e),v.push(g),n.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),t!==n&&t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(g.pushLight(t),t.castShadow&&g.pushShadow(t))})),g.setupLights();const i=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 r=0;r<e.length;r++){const s=e[r];At(s,n,t),i.add(s)}else At(e,n,t),i.add(e)})),v.pop(),g=null,i},this.compileAsync=function(t,e,n=null){const i=this.compile(t,e,n);return new Promise((e=>{function n(){i.forEach((function(t){$.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==K.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Ct=null;function Rt(){Lt.stop()}function Pt(){Lt.start()}const Lt=new Zo;function It(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)g.pushLight(t),t.castShadow&&g.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||B.intersectsSprite(t)){i&&X.setFromMatrixPosition(t.matrixWorld).applyMatrix4(V);const e=st.update(t),r=t.material;r.visible&&m.push(t,e,r,n,X.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||B.intersectsObject(t))){const e=st.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),X.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),X.copy(e.boundingSphere.center)),X.applyMatrix4(t.matrixWorld).applyMatrix4(V)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s<a;s++){const a=i[s],o=r[a.materialIndex];o&&o.visible&&m.push(t,e,o,n,X.z,a)}}else r.visible&&m.push(t,e,r,n,X.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)It(r[t],e,n,i)}function Dt(t,e,n,i){const r=t.opaque,s=t.transmissive,a=t.transparent;g.setupLightsView(n),!0===z&&ct.setGlobalState(y.clippingPlanes,n),i&&Q.viewport(T.copy(i)),r.length>0&&Ut(r,e,n),s.length>0&&Ut(s,e,n),a.length>0&&Ut(a,e,n),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function Nt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===g.state.transmissionRenderTarget[i.id]&&(g.state.transmissionRenderTarget[i.id]=new Ms(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")||K.has("EXT_color_buffer_float")?wi:_i,minFilter:gi,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:as.workingColorSpace}));const s=g.state.transmissionRenderTarget[i.id],a=i.viewport||T;s.setSize(a.z,a.w);const o=y.getRenderTarget();y.setRenderTarget(s),y.getClearColor(R),P=y.getClearAlpha(),P<1&&y.setClearColor(16777215,.5),y.clear(),Y&&ut.render(n);const l=y.toneMapping;y.toneMapping=Zn;const h=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),g.setupLightsView(i),!0===z&&ct.setGlobalState(y.clippingPlanes,i),Ut(t,n,i),tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s),!1===K.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,l=s.material,h=s.group;if(2===l.side&&a.layers.test(i.layers)){const e=l.side;l.side=yn,l.needsUpdate=!0,Ot(a,n,i,o,l,h),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(tt.updateMultisampleRenderTarget(s),tt.updateRenderTargetMipmap(s))}y.setRenderTarget(o),y.setClearColor(R,P),void 0!==h&&(i.viewport=h),y.toneMapping=l}function Ut(t,e,n){const i=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=s.object,o=s.geometry,l=null===i?s.material:i,h=s.group;a.layers.test(n.layers)&&Ot(a,e,n,o,l,h)}}function Ot(t,e,n,i,r,s){t.onBeforeRender(y,e,n,i,r,s),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(y,e,n,i,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=yn,r.needsUpdate=!0,y.renderBufferDirect(n,e,i,r,t,s),r.side=vn,r.needsUpdate=!0,y.renderBufferDirect(n,e,i,r,t,s),r.side=2):y.renderBufferDirect(n,e,i,r,t,s),t.onAfterRender(y,e,n,i,r,s)}function Ft(t,e,n){!0!==e.isScene&&(e=j);const i=$.get(t),r=g.state.lights,s=g.state.shadowsArray,a=r.state.version,o=at.getParameters(t,r.state,s,e,n),l=at.getProgramCacheKey(o);let h=i.programs;i.environment=t.isMeshStandardMaterial?e.environment:null,i.fog=e.fog,i.envMap=(t.isMeshStandardMaterial?nt:et).get(t.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===h&&(t.addEventListener("dispose",Tt),h=new Map,i.programs=h);let c=h.get(l);if(void 0!==c){if(i.currentProgram===c&&i.lightsStateVersion===a)return Bt(t,o),c}else o.uniforms=at.getUniforms(t),t.onBeforeCompile(o,y),c=at.acquireProgram(o,l),h.set(l,c),i.uniforms=o.uniforms;const d=i.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=ct.uniform),Bt(t,o),i.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),i.lightsStateVersion=a,i.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=c,i.uniformsList=null,c}function kt(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Gh.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function Bt(t,e){const n=$.get(t);n.outputColorSpace=e.outputColorSpace,n.batching=e.batching,n.batchingColor=e.batchingColor,n.instancing=e.instancing,n.instancingColor=e.instancingColor,n.instancingMorph=e.instancingMorph,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Lt.setAnimationLoop((function(t){Ct&&Ct(t)})),"undefined"!=typeof self&&Lt.setContext(self),this.setAnimationLoop=function(t){Ct=t,bt.setAnimationLoop(t),null===t?Lt.stop():Lt.start()},bt.addEventListener("sessionstart",Rt),bt.addEventListener("sessionend",Pt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===x)return;if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===bt.enabled&&!0===bt.isPresenting&&(!0===bt.cameraAutoUpdate&&bt.updateCamera(e),e=bt.getCamera()),!0===t.isScene&&t.onBeforeRender(y,t,e,M),g=ht.get(t,v.length),g.init(e),v.push(g),V.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),B.setFromProjectionMatrix(V),G=this.localClippingEnabled,z=ct.init(this.clippingPlanes,G),m=lt.get(t,_.length),m.init(),_.push(m),!0===bt.enabled&&!0===bt.isPresenting){const t=y.xr.getDepthSensingMesh();null!==t&&It(t,e,-1/0,y.sortObjects)}It(t,e,0,y.sortObjects),m.finish(),!0===y.sortObjects&&m.sort(N,U),Y=!1===bt.enabled||!1===bt.isPresenting||!1===bt.hasDepthSensing(),Y&&ut.addToRenderList(m,t),this.info.render.frame++,!0===z&&ct.beginShadows();const n=g.state.shadowsArray;dt.render(n,t,e),!0===z&&ct.endShadows(),!0===this.info.autoReset&&this.info.reset();const i=m.opaque,r=m.transmissive;if(g.setupLights(),e.isArrayCamera){const n=e.cameras;if(r.length>0)for(let e=0,s=n.length;e<s;e++){Nt(i,r,t,n[e])}Y&&ut.render(t);for(let e=0,i=n.length;e<i;e++){const i=n[e];Dt(m,t,i,i.viewport)}}else r.length>0&&Nt(i,r,t,e),Y&&ut.render(t),Dt(m,t,e);null!==M&&(tt.updateMultisampleRenderTarget(M),tt.updateRenderTargetMipmap(M)),!0===t.isScene&&t.onAfterRender(y,t,e),_t.resetDefaultState(),w=-1,E=null,v.pop(),v.length>0?(g=v[v.length-1],!0===z&&ct.setGlobalState(y.clippingPlanes,g.state.camera)):g=null,_.pop(),m=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,n){$.get(t.texture).__webglTexture=e,$.get(t.depthTexture).__webglTexture=n;const i=$.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===K.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=$.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){M=t,S=e,b=n;let i=!0,r=null,s=!1,a=!1;if(t){const o=$.get(t);if(void 0!==o.__useDefaultFramebuffer)Q.bindFramebuffer(yt.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)tt.setupRenderTarget(t);else if(o.__hasExternalTextures)tt.rebindTextures(t,$.get(t.texture).__webglTexture,$.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&$.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(t)}}const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const h=$.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(h[e])?h[e][n]:h[e],s=!0):r=t.samples>0&&!1===tt.useMultisampledRTT(t)?$.get(t).__webglMultisampledFramebuffer:Array.isArray(h)?h[n]:h,T.copy(t.viewport),A.copy(t.scissor),C=t.scissorTest}else T.copy(O).multiplyScalar(D).floor(),A.copy(F).multiplyScalar(D).floor(),C=k;if(Q.bindFramebuffer(yt.FRAMEBUFFER,r)&&i&&Q.drawBuffers(t,r),Q.viewport(T),Q.scissor(A),Q.setScissorTest(C),s){const i=$.get(t.texture);yt.framebufferTexture2D(yt.FRAMEBUFFER,yt.COLOR_ATTACHMENT0,yt.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=$.get(t.texture),r=e||0;yt.framebufferTextureLayer(yt.FRAMEBUFFER,yt.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}w=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){Q.bindFramebuffer(yt.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(!Z.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&yt.readPixels(e,n,i,r,gt.convert(o),gt.convert(l),s)}finally{const t=null!==M?$.get(M).__webglFramebuffer:null;Q.bindFramebuffer(yt.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=$.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,l=a.format,h=a.type;if(!Z.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){Q.bindFramebuffer(yt.FRAMEBUFFER,o);const t=yt.createBuffer();yt.bindBuffer(yt.PIXEL_PACK_BUFFER,t),yt.bufferData(yt.PIXEL_PACK_BUFFER,s.byteLength,yt.STREAM_READ),yt.readPixels(e,n,i,r,gt.convert(l),gt.convert(h),0);const a=null!==M?$.get(M).__webglFramebuffer:null;Q.bindFramebuffer(yt.FRAMEBUFFER,a);const c=yt.fenceSync(yt.SYNC_GPU_COMMANDS_COMPLETE,0);return yt.flush(),await function(t,e,n){return new Promise((function(i,r){setTimeout((function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}),n)}))}(yt,c,4),yt.bindBuffer(yt.PIXEL_PACK_BUFFER,t),yt.getBufferSubData(yt.PIXEL_PACK_BUFFER,0,s),yt.deleteBuffer(t),yt.deleteSync(c),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(ss("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;tt.setTexture2D(t,0),yt.copyTexSubImage2D(yt.TEXTURE_2D,n,0,0,a,o,r,s),Q.unbindTexture()},this.copyTextureToTexture=function(t,e,n=null,i=null,r=0){let s,a,o,l,h,c,d,u,p;!0!==t.isTexture&&(ss("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],r=arguments[3]||0,n=null);const f=t.isCompressedTexture?t.mipmaps[r]:t.image;null!==n?(s=n.max.x-n.min.x,a=n.max.y-n.min.y,o=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,h=n.min.y,c=n.isBox3?n.min.z:0):(s=f.width,a=f.height,o=f.depth||1,l=0,h=0,c=0),null!==i?(d=i.x,u=i.y,p=i.z):(d=0,u=0,p=0);const m=gt.convert(e.format),g=gt.convert(e.type);let _;e.isData3DTexture?(tt.setTexture3D(e,0),_=yt.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(tt.setTexture2DArray(e,0),_=yt.TEXTURE_2D_ARRAY):(tt.setTexture2D(e,0),_=yt.TEXTURE_2D),yt.pixelStorei(yt.UNPACK_FLIP_Y_WEBGL,e.flipY),yt.pixelStorei(yt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),yt.pixelStorei(yt.UNPACK_ALIGNMENT,e.unpackAlignment);const v=yt.getParameter(yt.UNPACK_ROW_LENGTH),y=yt.getParameter(yt.UNPACK_IMAGE_HEIGHT),x=yt.getParameter(yt.UNPACK_SKIP_PIXELS),S=yt.getParameter(yt.UNPACK_SKIP_ROWS),b=yt.getParameter(yt.UNPACK_SKIP_IMAGES);yt.pixelStorei(yt.UNPACK_ROW_LENGTH,f.width),yt.pixelStorei(yt.UNPACK_IMAGE_HEIGHT,f.height),yt.pixelStorei(yt.UNPACK_SKIP_PIXELS,l),yt.pixelStorei(yt.UNPACK_SKIP_ROWS,h),yt.pixelStorei(yt.UNPACK_SKIP_IMAGES,c);const M=t.isDataArrayTexture||t.isData3DTexture,w=e.isDataArrayTexture||e.isData3DTexture;if(t.isRenderTargetTexture||t.isDepthTexture){const n=$.get(t),i=$.get(e),f=$.get(n.__renderTarget),m=$.get(i.__renderTarget);Q.bindFramebuffer(yt.READ_FRAMEBUFFER,f.__webglFramebuffer),Q.bindFramebuffer(yt.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let n=0;n<o;n++)M&&yt.framebufferTextureLayer(yt.READ_FRAMEBUFFER,yt.COLOR_ATTACHMENT0,$.get(t).__webglTexture,r,c+n),t.isDepthTexture?(w&&yt.framebufferTextureLayer(yt.DRAW_FRAMEBUFFER,yt.COLOR_ATTACHMENT0,$.get(e).__webglTexture,r,p+n),yt.blitFramebuffer(l,h,s,a,d,u,s,a,yt.DEPTH_BUFFER_BIT,yt.NEAREST)):w?yt.copyTexSubImage3D(_,r,d,u,p+n,l,h,s,a):yt.copyTexSubImage2D(_,r,d,u,p+n,l,h,s,a);Q.bindFramebuffer(yt.READ_FRAMEBUFFER,null),Q.bindFramebuffer(yt.DRAW_FRAMEBUFFER,null)}else w?t.isDataTexture||t.isData3DTexture?yt.texSubImage3D(_,r,d,u,p,s,a,o,m,g,f.data):e.isCompressedArrayTexture?yt.compressedTexSubImage3D(_,r,d,u,p,s,a,o,m,f.data):yt.texSubImage3D(_,r,d,u,p,s,a,o,m,g,f):t.isDataTexture?yt.texSubImage2D(yt.TEXTURE_2D,r,d,u,s,a,m,g,f.data):t.isCompressedTexture?yt.compressedTexSubImage2D(yt.TEXTURE_2D,r,d,u,f.width,f.height,m,f.data):yt.texSubImage2D(yt.TEXTURE_2D,r,d,u,s,a,m,g,f);yt.pixelStorei(yt.UNPACK_ROW_LENGTH,v),yt.pixelStorei(yt.UNPACK_IMAGE_HEIGHT,y),yt.pixelStorei(yt.UNPACK_SKIP_PIXELS,x),yt.pixelStorei(yt.UNPACK_SKIP_ROWS,S),yt.pixelStorei(yt.UNPACK_SKIP_IMAGES,b),0===r&&e.generateMipmaps&&yt.generateMipmap(_),Q.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n=null,i=null,r=0){return!0!==t.isTexture&&(ss("WebGLRenderer: copyTextureToTexture3D function signature has changed."),n=arguments[0]||null,i=arguments[1]||null,t=arguments[2],e=arguments[3],r=arguments[4]||0),ss('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(t,e,n,i,r)},this.initRenderTarget=function(t){void 0===$.get(t).__webglFramebuffer&&tt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?tt.setTextureCube(t,0):t.isData3DTexture?tt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?tt.setTexture2DArray(t,0):tt.setTexture2D(t,0),Q.unbindTexture()},this.resetState=function(){S=0,b=0,M=null,Q.reset(),_t.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return kr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=as._getDrawingBufferColorSpace(t),e.unpackColorSpace=as._getUnpackColorSpace()}}class Vc extends Pa{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new pa,this.environmentIntensity=1,this.environmentRotation=new pa,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class Wc{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Or,this.updateRanges=[],this.version=0,this.uuid=Xr()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Xr()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Xr()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Xc=new As;class jc{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Xc.fromBufferAttribute(this,e),Xc.applyMatrix4(t),this.setXYZ(e,Xc.x,Xc.y,Xc.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Xc.fromBufferAttribute(this,e),Xc.applyNormalMatrix(t),this.setXYZ(e,Xc.x,Xc.y,Xc.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Xc.fromBufferAttribute(this,e),Xc.transformDirection(t),this.setXYZ(e,Xc.x,Xc.y,Xc.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Kr(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Zr(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Zr(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Zr(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Zr(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Zr(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Kr(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Kr(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Kr(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Kr(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zr(e,this.array),n=Zr(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zr(e,this.array),n=Zr(n,this.array),i=Zr(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zr(e,this.array),n=Zr(n,this.array),i=Zr(i,this.array),r=Zr(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new no(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new jc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Yc extends Ja{static get type(){return"SpriteMaterial"}constructor(t){super(),this.isSpriteMaterial=!0,this.color=new Ka(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let qc;const Kc=new As,Zc=new As,Qc=new As,Jc=new Jr,$c=new Jr,td=new ia,ed=new As,nd=new As,id=new As,rd=new Jr,sd=new Jr,ad=new Jr;class od extends Pa{constructor(t=new Yc){if(super(),this.isSprite=!0,this.type="Sprite",void 0===qc){qc=new fo;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Wc(t,5);qc.setIndex([0,1,2,0,2,3]),qc.setAttribute("position",new jc(e,3,0,!1)),qc.setAttribute("uv",new jc(e,2,3,!1))}this.geometry=qc,this.material=t,this.center=new Jr(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Zc.setFromMatrixScale(this.matrixWorld),td.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Qc.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Zc.multiplyScalar(-Qc.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const s=this.center;ld(ed.set(-.5,-.5,0),Qc,s,Zc,i,r),ld(nd.set(.5,-.5,0),Qc,s,Zc,i,r),ld(id.set(.5,.5,0),Qc,s,Zc,i,r),rd.set(0,0),sd.set(1,0),ad.set(1,1);let a=t.ray.intersectTriangle(ed,nd,id,!1,Kc);if(null===a&&(ld(nd.set(-.5,.5,0),Qc,s,Zc,i,r),sd.set(0,1),a=t.ray.intersectTriangle(ed,id,nd,!1,Kc),null===a))return;const o=t.ray.origin.distanceTo(Kc);o<t.near||o>t.far||e.push({distance:o,point:Kc.clone(),uv:Wa.getInterpolation(Kc,ed,nd,id,rd,sd,ad,new Jr),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function ld(t,e,n,i,r,s){Jc.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?($c.x=s*Jc.x-r*Jc.y,$c.y=r*Jc.x+s*Jc.y):$c.copy(Jc),t.copy(e),t.x+=$c.x,t.y+=$c.y,t.applyMatrix4(td)}const hd=new As,cd=new Ss,dd=new Ss,ud=new As,pd=new ia,fd=new As,md=new qs,gd=new ia,_d=new na;class vd extends To{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ri,this.bindMatrix=new ia,this.bindMatrixInverse=new ia,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Ps),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,fd),this.boundingBox.expandByPoint(fd)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new qs),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,fd),this.boundingSphere.expandByPoint(fd)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),md.copy(this.boundingSphere),md.applyMatrix4(i),!1!==t.ray.intersectsSphere(md)&&(gd.copy(i).invert(),_d.copy(t.ray).applyMatrix4(gd),null!==this.boundingBox&&!1===_d.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,_d)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Ss,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===ri?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;cd.fromBufferAttribute(i.attributes.skinIndex,t),dd.fromBufferAttribute(i.attributes.skinWeight,t),hd.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=dd.getComponent(t);if(0!==i){const r=cd.getComponent(t);pd.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(ud.copy(hd).applyMatrix4(pd),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}class yd extends Pa{constructor(){super(),this.isBone=!0,this.type="Bone"}}class xd extends xs{constructor(t=null,e=1,n=1,i,r,s,a,o,l=1003,h=1003,c,d){super(null,s,a,o,l,h,i,r,c,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Sd=new ia,bd=new ia;class Md{constructor(t=[],e=[]){this.uuid=Xr(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new ia)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new ia;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){const r=t[i]?t[i].matrixWorld:bd;Sd.multiplyMatrices(r,e[i]),Sd.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new Md(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new xd(e,t,t,Li,Mi);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const i=t.bones[n];let r=e[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new yd),this.bones.push(r),this.boneInverses.push((new ia).fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const s=n[i];t.boneInverses.push(s.toArray())}return t}}class wd extends no{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Ed=new ia,Td=new ia,Ad=[],Cd=new Ps,Rd=new ia,Pd=new To,Ld=new qs;class Id extends To{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new wd(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,Rd)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Ps),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ed),Cd.copy(t.boundingBox).applyMatrix4(Ed),this.boundingBox.union(Cd)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new qs),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ed),Ld.copy(t.boundingSphere).applyMatrix4(Ed),this.boundingSphere.union(Ld)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(n.length+1)+1;for(let t=0;t<n.length;t++)n[t]=i[r+t]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Pd.geometry=this.geometry,Pd.material=this.material,void 0!==Pd.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Ld.copy(this.boundingSphere),Ld.applyMatrix4(n),!1!==t.ray.intersectsSphere(Ld)))for(let r=0;r<i;r++){this.getMatrixAt(r,Ed),Td.multiplyMatrices(n,Ed),Pd.matrixWorld=Td,Pd.raycast(t,Ad);for(let t=0,n=Ad.length;t<n;t++){const n=Ad[t];n.instanceId=r,n.object=this,e.push(n)}Ad.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new wd(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new xd(new Float32Array(i*this.count),i,this.count,Oi,Mi));const r=this.morphTexture.source.data.data;let s=0;for(let t=0;t<n.length;t++)s+=n[t];const a=this.geometry.morphTargetsRelative?1:1-s,o=i*t;r[o]=a,r.set(n,o+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class Dd extends Ja{static get type(){return"LineBasicMaterial"}constructor(t){super(),this.isLineBasicMaterial=!0,this.color=new Ka(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Nd=new As,Ud=new As,Od=new ia,Fd=new na,kd=new qs,Bd=new As,zd=new As;class Gd extends Pa{constructor(t=new fo,e=new Dd){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)Nd.fromBufferAttribute(e,t-1),Ud.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=Nd.distanceTo(Ud);t.setAttribute("lineDistance",new so(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),kd.copy(n.boundingSphere),kd.applyMatrix4(i),kd.radius+=r,!1===t.ray.intersectsSphere(kd))return;Od.copy(i).invert(),Fd.copy(t.ray).applyMatrix4(Od);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,h=n.index,c=n.attributes.position;if(null!==h){const n=Math.max(0,s.start),i=Math.min(h.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=h.getX(r),i=h.getX(r+1),s=Hd(this,t,Fd,o,n,i);s&&e.push(s)}if(this.isLineLoop){const r=h.getX(i-1),s=h.getX(n),a=Hd(this,t,Fd,o,r,s);a&&e.push(a)}}else{const n=Math.max(0,s.start),i=Math.min(c.count,s.start+s.count);for(let r=n,s=i-1;r<s;r+=l){const n=Hd(this,t,Fd,o,r,r+1);n&&e.push(n)}if(this.isLineLoop){const r=Hd(this,t,Fd,o,i-1,n);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Hd(t,e,n,i,r,s){const a=t.geometry.attributes.position;Nd.fromBufferAttribute(a,r),Ud.fromBufferAttribute(a,s);if(n.distanceSqToSegment(Nd,Ud,Bd,zd)>i)return;Bd.applyMatrix4(t.matrixWorld);const o=e.ray.origin.distanceTo(Bd);return o<e.near||o>e.far?void 0:{distance:o,point:zd.clone().applyMatrix4(t.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:t}}const Vd=new As,Wd=new As;class Xd extends Gd{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)Vd.fromBufferAttribute(e,t),Wd.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Vd.distanceTo(Wd);t.setAttribute("lineDistance",new so(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class jd extends Gd{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Yd extends Ja{static get type(){return"PointsMaterial"}constructor(t){super(),this.isPointsMaterial=!0,this.color=new Ka(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const qd=new ia,Kd=new na,Zd=new qs,Qd=new As;class Jd extends Pa{constructor(t=new fo,e=new Yd){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,s=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Zd.copy(n.boundingSphere),Zd.applyMatrix4(i),Zd.radius+=r,!1===t.ray.intersectsSphere(Zd))return;qd.copy(i).invert(),Kd.copy(t.ray).applyMatrix4(qd);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=n.index,h=n.attributes.position;if(null!==l){for(let n=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);n<r;n++){const r=l.getX(n);Qd.fromBufferAttribute(h,r),$d(Qd,r,o,i,t,e,this)}}else{for(let n=Math.max(0,s.start),r=Math.min(h.count,s.start+s.count);n<r;n++)Qd.fromBufferAttribute(h,n),$d(Qd,n,o,i,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function $d(t,e,n,i,r,s,a){const o=Kd.distanceSqToPoint(t);if(o<n){const n=new As;Kd.closestPointToPoint(t,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class tu extends xs{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class eu extends fo{constructor(t=1,e=1,n=1,i=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],c=[],d=[],u=[];let p=0;const f=[],m=n/2;let g=0;function _(n){const r=p,s=new Jr,f=new As;let _=0;const v=!0===n?t:e,y=!0===n?1:-1;for(let t=1;t<=i;t++)c.push(0,m*y,0),d.push(0,y,0),u.push(.5,.5),p++;const x=p;for(let t=0;t<=i;t++){const e=t/i*o+a,n=Math.cos(e),r=Math.sin(e);f.x=v*r,f.y=m*y,f.z=v*n,c.push(f.x,f.y,f.z),d.push(0,y,0),s.x=.5*n+.5,s.y=.5*r*y+.5,u.push(s.x,s.y),p++}for(let t=0;t<i;t++){const e=r+t,i=x+t;!0===n?h.push(i,i+1,e):h.push(i+1,i,e),_+=3}l.addGroup(g,_,!0===n?1:2),g+=_}!function(){const s=new As,_=new As;let v=0;const y=(e-t)/n;for(let l=0;l<=r;l++){const h=[],g=l/r,v=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*o+a,l=Math.sin(r),f=Math.cos(r);_.x=v*l,_.y=-g*n+m,_.z=v*f,c.push(_.x,_.y,_.z),s.set(l,y,f).normalize(),d.push(s.x,s.y,s.z),u.push(e,1-g),h.push(p++)}f.push(h)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const s=f[i][n],a=f[i+1][n],o=f[i+1][n+1],l=f[i][n+1];(t>0||0!==i)&&(h.push(s,a,l),v+=3),(e>0||i!==r-1)&&(h.push(a,o,l),v+=3)}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&_(!0),e>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new so(c,3)),this.setAttribute("normal",new so(d,3)),this.setAttribute("uv",new so(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new eu(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class nu extends fo{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)s[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/l)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const n=Math.floor(e/2);e%2==0?(o(s[t][n+1]),o(s[t+1][n]),o(s[t][n])):(o(s[t][n+1]),o(s[t+1][n+1]),o(s[t+1][n]))}}function o(t){r.push(t.x,t.y,t.z)}function l(e,n){const i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function h(t,e,n,i){i<0&&1===t.x&&(s[e]=t.x-1),0===n.x&&0===n.z&&(s[e]=i/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}!function(t){const n=new As,i=new As,r=new As;for(let s=0;s<e.length;s+=3)l(e[s+0],n),l(e[s+1],i),l(e[s+2],r),a(n,i,r,t)}(i),function(t){const e=new As;for(let n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){const t=new As;for(let n=0;n<r.length;n+=3){t.x=r[n+0],t.y=r[n+1],t.z=r[n+2];const i=c(t)/2/Math.PI+.5,a=(e=t,Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5);s.push(i,1-a)}var e;(function(){const t=new As,e=new As,n=new As,i=new As,a=new Jr,o=new Jr,l=new Jr;for(let d=0,u=0;d<r.length;d+=9,u+=6){t.set(r[d+0],r[d+1],r[d+2]),e.set(r[d+3],r[d+4],r[d+5]),n.set(r[d+6],r[d+7],r[d+8]),a.set(s[u+0],s[u+1]),o.set(s[u+2],s[u+3]),l.set(s[u+4],s[u+5]),i.copy(t).add(e).add(n).divideScalar(3);const p=c(i);h(a,u+0,t,p),h(o,u+2,e,p),h(l,u+4,n,p)}})(),function(){for(let t=0;t<s.length;t+=6){const e=s[t+0],n=s[t+2],i=s[t+4],r=Math.max(e,n,i),a=Math.min(e,n,i);r>.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new so(r,3)),this.setAttribute("normal",new so(r.slice(),3)),this.setAttribute("uv",new so(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new nu(t.vertices,t.indices,t.radius,t.details)}}class iu extends nu{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new iu(t.radius,t.detail)}}class ru extends fo{constructor(t=1,e=32,n=16,i=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:s,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const o=Math.min(s+a,Math.PI);let l=0;const h=[],c=new As,d=new As,u=[],p=[],f=[],m=[];for(let u=0;u<=n;u++){const g=[],_=u/n;let v=0;0===u&&0===s?v=.5/e:u===n&&o===Math.PI&&(v=-.5/e);for(let n=0;n<=e;n++){const o=n/e;c.x=-t*Math.cos(i+o*r)*Math.sin(s+_*a),c.y=t*Math.cos(s+_*a),c.z=t*Math.sin(i+o*r)*Math.sin(s+_*a),p.push(c.x,c.y,c.z),d.copy(c).normalize(),f.push(d.x,d.y,d.z),m.push(o+v,1-_),g.push(l++)}h.push(g)}for(let t=0;t<n;t++)for(let i=0;i<e;i++){const e=h[t][i+1],r=h[t][i],a=h[t+1][i],l=h[t+1][i+1];(0!==t||s>0)&&u.push(e,r,l),(t!==n-1||o<Math.PI)&&u.push(r,a,l)}this.setIndex(u),this.setAttribute("position",new so(p,3)),this.setAttribute("normal",new so(f,3)),this.setAttribute("uv",new so(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ru(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class su extends fo{constructor(t=1,e=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const s=[],a=[],o=[],l=[],h=new As,c=new As,d=new As;for(let s=0;s<=n;s++)for(let u=0;u<=i;u++){const p=u/i*r,f=s/n*Math.PI*2;c.x=(t+e*Math.cos(f))*Math.cos(p),c.y=(t+e*Math.cos(f))*Math.sin(p),c.z=e*Math.sin(f),a.push(c.x,c.y,c.z),h.x=t*Math.cos(p),h.y=t*Math.sin(p),d.subVectors(c,h).normalize(),o.push(d.x,d.y,d.z),l.push(u/i),l.push(s/n)}for(let t=1;t<=n;t++)for(let e=1;e<=i;e++){const n=(i+1)*t+e-1,r=(i+1)*(t-1)+e-1,a=(i+1)*(t-1)+e,o=(i+1)*t+e;s.push(n,r,o),s.push(r,a,o)}this.setIndex(s),this.setAttribute("position",new so(a,3)),this.setAttribute("normal",new so(o,3)),this.setAttribute("uv",new so(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new su(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class au extends Ja{static get type(){return"MeshStandardMaterial"}constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.color=new Ka(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ka(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Jr(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pa,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class ou extends au{static get type(){return"MeshPhysicalMaterial"}constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Jr(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return jr(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ka(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ka(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ka(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}function lu(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function hu(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function cu(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function du(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push.apply(n,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}class uu{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let s;n:{i:if(!(t<i)){for(let s=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(r=i,i=e[++n],t<i)break e}s=e.length;break n}if(t>=r)break t;{const a=e[1];t<a&&(n=2,r=a);for(let s=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===s)break;if(i=r,r=e[--n-1],t>=r)break e}s=n,n=0}}for(;n<s;){const i=n+s>>>1;t<e[i]?s=i:n=i+1}if(i=e[n],r=e[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=n[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class pu extends uu{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,s=t+1,a=i[r],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case 2401:r=t,a=2*e-n;break;case 2402:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(void 0===o)switch(this.getSettings_().endingEnd){case 2401:s=t,o=2*n-e;break;case 2402:s=1,o=n+i[1]-i[0];break;default:s=t-1,o=e}const l=.5*(n-e),h=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(o-n),this._offsetPrev=r*h,this._offsetNext=s*h}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=this._offsetPrev,c=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(n-e)/(i-e),f=p*p,m=f*p,g=-d*m+2*d*f-d*p,_=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,v=(-1-u)*m+(1.5+u)*f+.5*p,y=u*m-u*f;for(let t=0;t!==a;++t)r[t]=g*s[h+t]+_*s[l+t]+v*s[o+t]+y*s[c+t];return r}}class fu extends uu{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=t*a,l=o-a,h=(n-e)/(i-e),c=1-h;for(let t=0;t!==a;++t)r[t]=s[l+t]*c+s[o+t]*h;return r}}class mu extends uu{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class gu{constructor(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=lu(e,this.TimeBufferType),this.values=lu(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:lu(t.times,Array),values:lu(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(n.interpolation=e)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new mu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new fu(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new pu(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case yr:e=this.InterpolantFactoryMethodDiscrete;break;case xr:e=this.InterpolantFactoryMethodLinear;break;case Sr:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yr;case this.InterpolantFactoryMethodLinear:return xr;case this.InterpolantFactoryMethodSmooth:return Sr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,s=i-1;for(;r!==i&&n[r]<t;)++r;for(;-1!==s&&n[s]>e;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&(a=i,ArrayBuffer.isView(a)&&!(a instanceof DataView)))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}var a;return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Sr,r=t.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(i)r=!0;else{const t=a*n,i=t-n,s=t+n;for(let a=0;a!==n;++a){const n=e[t+a];if(n!==e[i+a]||n!==e[s+a]){r=!0;break}}}if(r){if(a!==s){t[s]=t[a];const i=a*n,r=s*n;for(let t=0;t!==n;++t)e[r+t]=e[i+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}gu.prototype.TimeBufferType=Float32Array,gu.prototype.ValueBufferType=Float32Array,gu.prototype.DefaultInterpolation=xr;class _u extends gu{constructor(t,e,n){super(t,e,n)}}_u.prototype.ValueTypeName="bool",_u.prototype.ValueBufferType=Array,_u.prototype.DefaultInterpolation=yr,_u.prototype.InterpolantFactoryMethodLinear=void 0,_u.prototype.InterpolantFactoryMethodSmooth=void 0;class vu extends gu{}vu.prototype.ValueTypeName="color";class yu extends gu{}yu.prototype.ValueTypeName="number";class xu extends uu{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)Ts.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Su extends gu{InterpolantFactoryMethodLinear(t){return new xu(this.times,this.values,this.getValueSize(),t)}}Su.prototype.ValueTypeName="quaternion",Su.prototype.InterpolantFactoryMethodSmooth=void 0;class bu extends gu{constructor(t,e,n){super(t,e,n)}}bu.prototype.ValueTypeName="string",bu.prototype.ValueBufferType=Array,bu.prototype.DefaultInterpolation=yr,bu.prototype.InterpolantFactoryMethodLinear=void 0,bu.prototype.InterpolantFactoryMethodSmooth=void 0;class Mu extends gu{}Mu.prototype.ValueTypeName="vector";class wu{constructor(t="",e=-1,n=[],i=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Xr(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(Eu(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(gu.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t<r;t++){let a=[],o=[];a.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const l=hu(a);a=cu(a,1,l),o=cu(o,1,l),i||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new yu(".morphTargetInfluences["+e[t].name+"]",a,o).scale(1/n))}return new this(t,-1,s)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const e=t;n=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<n.length;t++)if(n[t].name===e)return n[t];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,n=t.length;e<n;e++){const n=t[e],s=n.name.match(r);if(s&&s.length>1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];du(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t<l.length;t++){const r=l[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let n=0;n<r[e].morphTargets.length;n++)t[r[e].morphTargets[n]]=-1;for(const n in t){const t=[],s=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),s.push(i.morphTarget===n?1:0)}i.push(new yu(".morphTargetInfluence["+n+"]",t,s))}o=t.length*s}else{const s=".bones["+e[t].name+"]";n(Mu,s+".position",r,"pos",i),n(Su,s+".quaternion",r,"rot",i),n(Mu,s+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,o,i,a)}resetDuration(){let t=0;for(let e=0,n=this.tracks.length;e!==n;++e){const n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Eu(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yu;case"vector":case"vector2":case"vector3":case"vector4":return Mu;case"color":return vu;case"quaternion":return Su;case"bool":case"boolean":return _u;case"string":return bu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],n=[];du(t.keys,e,n,"value"),t.times=e,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const Tu={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class Au{constructor(t,e,n){const i=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===s&&void 0!==i.onStart&&i.onStart(t,a,o),s=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(s=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}}}const Cu=new Au;class Ru{constructor(t){this.manager=void 0!==t?t:Cu,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Ru.DEFAULT_MATERIAL_NAME="__DEFAULT";const Pu={};class Lu extends Error{constructor(t,e){super(t),this.response=e}}class Iu extends Ru{constructor(t){super(t)}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Tu.get(t);if(void 0!==r)return this.manager.itemStart(t),setTimeout((()=>{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==Pu[t])return void Pu[t].push({onLoad:e,onProgress:n,onError:i});Pu[t]=[],Pu[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=Pu[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}}),(e=>{t.error(e)}))}()}});return new Response(l)}throw new Lu(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{Tu.add(t,e);const n=Pu[t];delete Pu[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onLoad&&i.onLoad(e)}})).catch((e=>{const n=Pu[t];if(void 0===n)throw this.manager.itemError(t),e;delete Pu[t];for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}this.manager.itemError(t)})).finally((()=>{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Du extends Ru{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Tu.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const a=ns("img");function o(){h(),Tu.add(t,this),e&&e(this),r.manager.itemEnd(t)}function l(e){h(),i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(t),a.src=t,a}}class Nu extends Ru{constructor(t){super(t)}load(t,e,n,i){const r=new xs,s=new Du(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)}),n,i),r}}class Uu extends Pa{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ka(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(e.object.target=this.target.uuid),e}}const Ou=new ia,Fu=new As,ku=new As;class Bu{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Jr(512,512),this.map=null,this.mapPass=null,this.matrix=new ia,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ko,this._frameExtents=new Jr(1,1),this._viewportCount=1,this._viewports=[new Ss(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Fu.setFromMatrixPosition(t.matrixWorld),e.position.copy(Fu),ku.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(ku),e.updateMatrixWorld(),Ou.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ou),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ou)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class zu extends Bu{constructor(){super(new ko(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=2*Wr*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Gu extends Uu{constructor(t,e,n=0,i=Math.PI/3,r=0,s=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pa.DEFAULT_UP),this.updateMatrix(),this.target=new Pa,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new zu}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Hu=new ia,Vu=new As,Wu=new As;class Xu extends Bu{constructor(){super(new ko(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Jr(4,2),this._viewportCount=6,this._viewports=[new Ss(2,1,1,1),new Ss(0,1,1,1),new Ss(3,1,1,1),new Ss(1,1,1,1),new Ss(3,0,1,1),new Ss(1,0,1,1)],this._cubeDirections=[new As(1,0,0),new As(-1,0,0),new As(0,0,1),new As(0,0,-1),new As(0,1,0),new As(0,-1,0)],this._cubeUps=[new As(0,1,0),new As(0,1,0),new As(0,1,0),new As(0,1,0),new As(0,0,1),new As(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Vu.setFromMatrixPosition(t.matrixWorld),n.position.copy(Vu),Wu.copy(n.position),Wu.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Wu),n.updateMatrixWorld(),i.makeTranslation(-Vu.x,-Vu.y,-Vu.z),Hu.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Hu)}}class ju extends Uu{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Xu}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Yu extends Bu{constructor(){super(new dl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class qu extends Uu{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pa.DEFAULT_UP),this.updateMatrix(),this.target=new Pa,this.shadow=new Yu}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Ku extends Uu{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Zu{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(t){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Qu extends Ru{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Tu.get(t);if(void 0!==s)return r.manager.itemStart(t),s.then?void s.then((n=>{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return Tu.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),Tu.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));Tu.add(t,o),r.manager.itemStart(t)}}class Ju{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=$u(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=$u();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function $u(){return performance.now()}const tp="\\[\\]\\.:\\/",ep=new RegExp("["+tp+"]","g"),np="[^"+tp+"]",ip="[^"+tp.replace("\\.","")+"]",rp=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",np)+/(WCOD+)?/.source.replace("WCOD",ip)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",np)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",np)+"$"),sp=["material","materials","bones","map"];class ap{constructor(t,e,n){this.path=e,this.parsedPath=n||ap.parseTrackName(e),this.node=ap.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new ap.Composite(t,e,n):new ap(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ep,"")}static parseTrackName(t){const e=rp.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==sp.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const s=n(r.children);if(s)return s}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=ap.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(n){let i=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==i){if(void 0===t[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const s=t[i];if(void 0===s){const n=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ap.Composite=class{constructor(t,e,n){const i=n||ap.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},ap.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},ap.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},ap.prototype.GetterByBindingType=[ap.prototype._getValue_direct,ap.prototype._getValue_array,ap.prototype._getValue_arrayElement,ap.prototype._getValue_toArray],ap.prototype.SetterByBindingTypeAndVersioning=[[ap.prototype._setValue_direct,ap.prototype._setValue_direct_setNeedsUpdate,ap.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ap.prototype._setValue_array,ap.prototype._setValue_array_setNeedsUpdate,ap.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ap.prototype._setValue_arrayElement,ap.prototype._setValue_arrayElement_setNeedsUpdate,ap.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ap.prototype._setValue_fromArray,ap.prototype._setValue_fromArray_setNeedsUpdate,ap.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const op=new ia;class lp{constructor(t,e,n=0,i=1/0){this.ray=new na(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new fa,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return op.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(op),this}intersectObject(t,e=!0,n=[]){return cp(t,this,n,e),n.sort(hp),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)cp(t[i],this,n,e);return n.sort(hp),n}}function hp(t,e){return t.distance-e.distance}function cp(t,e,n,i){let r=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,n)&&(r=!1)}if(!0===r&&!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)cp(i[t],e,n,!0)}}class dp{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(jr(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class up extends zr{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:on}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=on);const pp=new lp,fp=new As,mp=new As,gp=new Ts,_p={X:new As(1,0,0),Y:new As(0,1,0),Z:new As(0,0,1)},vp={type:"change"},yp={type:"mouseDown",mode:null},xp={type:"mouseUp",mode:null},Sp={type:"objectChange"};class bp extends up{constructor(t,e=null){super(void 0,e);const n=new Vp(this);this._root=n;const i=new Wp;this._gizmo=i,n.add(i);const r=new Xp;this._plane=r,n.add(r);const s=this;function a(t,e){let n=e;Object.defineProperty(s,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,r[t]=e,i[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(vp))}}),s[t]=e,r[t]=e,i[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 As,l=new As,h=new Ts,c=new Ts,d=new As,u=new Ts,p=new As,f=new As,m=new As,g=new As;a("worldPosition",o),a("worldPositionStart",l),a("worldQuaternion",h),a("worldQuaternionStart",c),a("cameraPosition",d),a("cameraQuaternion",u),a("pointStart",p),a("pointEnd",f),a("rotationAxis",m),a("rotationAngle",0),a("eye",g),this._offset=new As,this._startNorm=new As,this._endNorm=new As,this._cameraScale=new As,this._parentPosition=new As,this._parentQuaternion=new Ts,this._parentQuaternionInv=new Ts,this._parentScale=new As,this._worldScaleStart=new As,this._worldQuaternionInv=new Ts,this._worldScale=new As,this._positionStart=new As,this._quaternionStart=new Ts,this._scaleStart=new As,this._getPointer=Mp.bind(this),this._onPointerDown=Ep.bind(this),this._onPointerHover=wp.bind(this),this._onPointerMove=Tp.bind(this),this._onPointerUp=Ap.bind(this),null!==e&&this.connect()}connect(){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&&pp.setFromCamera(t,this.camera);const e=Cp(this._gizmo.picker[this.mode],pp);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&&pp.setFromCamera(t,this.camera);const e=Cp(this._plane,pp,!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,yp.mode=this.mode,this.dispatchEvent(yp)}}pointerMove(t){const e=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===i||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&pp.setFromCamera(t,this.camera);const s=Cp(this._plane,pp,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"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"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(gp.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(fp.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(fp.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if("scale"===n){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),mp.set(t,t,t)}else fp.copy(this.pointStart),mp.copy(this.pointEnd),fp.applyQuaternion(this._worldQuaternionInv),mp.applyQuaternion(this._worldQuaternionInv),mp.divide(fp),-1===e.search("X")&&(mp.x=1),-1===e.search("Y")&&(mp.y=1),-1===e.search("Z")&&(mp.z=1);i.scale.copy(this._scaleStart).multiply(mp),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(fp.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(fp.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(_p[e]),fp.copy(_p[e]),"local"===r&&fp.applyQuaternion(this.worldQuaternion),fp.cross(this.eye),0===fp.length()?n=!0:this.rotationAngle=this._offset.dot(fp.normalize())*t),("E"===e||n)&&(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"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(gp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(gp.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(vp),this.dispatchEvent(Sp)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(xp.mode=this.mode,this.dispatchEvent(xp)),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(vp),this.dispatchEvent(Sp),this.pointStart.copy(this.pointEnd))}getRaycaster(){return pp}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}}function Mp(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 wp(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Ep(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 Tp(t){this.enabled&&this.pointerMove(this._getPointer(t))}function Ap(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function Cp(t,e,n){const i=e.intersectObject(t,!0);for(let t=0;t<i.length;t++)if(i[t].object.visible||n)return i[t];return!1}const Rp=new pa,Pp=new As(0,1,0),Lp=new As(0,0,0),Ip=new ia,Dp=new Ts,Np=new Ts,Up=new As,Op=new ia,Fp=new As(1,0,0),kp=new As(0,1,0),Bp=new As(0,0,1),zp=new As,Gp=new As,Hp=new As;class Vp extends Pa{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 Wp extends Pa{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new $a({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Dd({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=t.clone();n.opacity=.15;const i=e.clone();i.opacity=.5;const r=t.clone();r.color.setHex(16711680);const s=t.clone();s.color.setHex(65280);const a=t.clone();a.color.setHex(255);const o=t.clone();o.color.setHex(16711680),o.opacity=.5;const l=t.clone();l.color.setHex(65280),l.opacity=.5;const h=t.clone();h.color.setHex(255),h.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;t.clone().color.setHex(16776960);const u=t.clone();u.color.setHex(7895160);const p=new eu(0,.04,.1,12);p.translate(0,.05,0);const f=new Co(.08,.08,.08);f.translate(0,.04,0);const m=new fo;m.setAttribute("position",new so([0,0,0,1,0,0],3));const g=new eu(.0075,.0075,.5,3);function _(t,e){const n=new su(t,.0075,3,64,e*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}g.translate(0,.25,0);const v={X:[[new To(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new To(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new To(g,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new To(p,s),[0,.5,0]],[new To(p,s),[0,-.5,0],[Math.PI,0,0]],[new To(g,s)]],Z:[[new To(p,a),[0,0,.5],[Math.PI/2,0,0]],[new To(p,a),[0,0,-.5],[-Math.PI/2,0,0]],[new To(g,a),null,[Math.PI/2,0,0]]],XYZ:[[new To(new iu(.1,0),c.clone()),[0,0,0]]],XY:[[new To(new Co(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new To(new Co(.15,.15,.01),o.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new To(new Co(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},y={X:[[new To(new eu(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new To(new eu(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new To(new eu(.2,0,.6,4),n),[0,.3,0]],[new To(new eu(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new To(new eu(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new To(new eu(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new To(new iu(.2,0),n)]],XY:[[new To(new Co(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new To(new Co(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new To(new Co(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},x={START:[[new To(new iu(.01,2),i),null,null,null,"helper"]],END:[[new To(new iu(.01,2),i),null,null,null,"helper"]],DELTA:[[new Gd(function(){const t=new fo;return t.setAttribute("position",new so([0,0,0,1,1,1],3)),t}(),i),null,null,null,"helper"]],X:[[new Gd(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Gd(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Gd(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},S={XYZE:[[new To(_(.5,1),u),null,[0,Math.PI/2,0]]],X:[[new To(_(.5,.5),r)]],Y:[[new To(_(.5,.5),s),null,[0,0,-Math.PI/2]]],Z:[[new To(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new To(_(.75,1),d),null,[0,Math.PI/2,0]]]},b={AXIS:[[new Gd(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},M={XYZE:[[new To(new ru(.25,10,8),n)]],X:[[new To(new su(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new To(new su(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new To(new su(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new To(new su(.75,.1,2,24),n)]]},w={X:[[new To(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new To(g,r),[0,0,0],[0,0,-Math.PI/2]],[new To(f,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new To(f,s),[0,.5,0]],[new To(g,s)],[new To(f,s),[0,-.5,0],[0,0,Math.PI]]],Z:[[new To(f,a),[0,0,.5],[Math.PI/2,0,0]],[new To(g,a),[0,0,0],[Math.PI/2,0,0]],[new To(f,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new To(new Co(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new To(new Co(.15,.15,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new To(new Co(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new To(new Co(.1,.1,.1),c.clone())]]},E={X:[[new To(new eu(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new To(new eu(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new To(new eu(.2,0,.6,4),n),[0,.3,0]],[new To(new eu(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new To(new eu(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new To(new eu(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new To(new Co(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new To(new Co(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new To(new Co(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new To(new Co(.2,.2,.2),n),[0,0,0]]]},T={X:[[new Gd(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Gd(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Gd(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function A(t){const e=new Pa;for(const n in t)for(let i=t[n].length;i--;){const r=t[n][i][0].clone(),s=t[n][i][1],a=t[n][i][2],o=t[n][i][3],l=t[n][i][4];r.name=n,r.tag=l,s&&r.position.set(s[0],s[1],s[2]),a&&r.rotation.set(a[0],a[1],a[2]),o&&r.scale.set(o[0],o[1],o[2]),r.updateMatrix();const h=r.geometry.clone();h.applyMatrix4(r.matrix),r.geometry=h,r.renderOrder=1/0,r.position.set(0,0,0),r.rotation.set(0,0,0),r.scale.set(1,1,1),e.add(r)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=A(v)),this.add(this.gizmo.rotate=A(S)),this.add(this.gizmo.scale=A(w)),this.add(this.picker.translate=A(y)),this.add(this.picker.rotate=A(M)),this.add(this.picker.scale=A(E)),this.add(this.helper.translate=A(x)),this.add(this.helper.rotate=A(b)),this.add(this.helper.scale=A(T)),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:Np;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 n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let t=0;t<n.length;t++){const i=n[t];let r;if(i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition),r=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),i.scale.set(1,1,1).multiplyScalar(r*this.size/4),"helper"!==i.tag){if(i.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,n=.2;"X"===i.name&&Math.abs(Pp.copy(Fp).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(Pp.copy(kp).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(Pp.copy(Bp).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(Pp.copy(Bp).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"YZ"===i.name&&Math.abs(Pp.copy(Fp).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XZ"===i.name&&Math.abs(Pp.copy(kp).applyQuaternion(e).dot(this.eye))<n&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)}else"rotate"===this.mode&&(Dp.copy(e),Pp.copy(this.eye).applyQuaternion(gp.copy(e).invert()),-1!==i.name.search("E")&&i.quaternion.setFromRotationMatrix(Ip.lookAt(this.eye,Lp,kp)),"X"===i.name&&(gp.setFromAxisAngle(Fp,Math.atan2(-Pp.y,Pp.z)),gp.multiplyQuaternions(Dp,gp),i.quaternion.copy(gp)),"Y"===i.name&&(gp.setFromAxisAngle(kp,Math.atan2(Pp.x,Pp.z)),gp.multiplyQuaternions(Dp,gp),i.quaternion.copy(gp)),"Z"===i.name&&(gp.setFromAxisAngle(Bp,Math.atan2(Pp.y,Pp.x)),gp.multiplyQuaternions(Dp,gp),i.quaternion.copy(gp)));i.visible=i.visible&&(-1===i.name.indexOf("X")||this.showX),i.visible=i.visible&&(-1===i.name.indexOf("Y")||this.showY),i.visible=i.visible&&(-1===i.name.indexOf("Z")||this.showZ),i.visible=i.visible&&(-1===i.name.indexOf("E")||this.showX&&this.showY&&this.showZ),i.material._color=i.material._color||i.material.color.clone(),i.material._opacity=i.material._opacity||i.material.opacity,i.material.color.copy(i.material._color),i.material.opacity=i.material._opacity,this.enabled&&this.axis&&(i.name===this.axis||this.axis.split("").some((function(t){return i.name===t})))&&(i.material.color.setHex(16776960),i.material.opacity=1)}else i.visible=!1,"AXIS"===i.name?(i.visible=!!this.axis,"X"===this.axis&&(gp.setFromEuler(Rp.set(0,0,0)),i.quaternion.copy(e).multiply(gp),Math.abs(Pp.copy(Fp).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Y"===this.axis&&(gp.setFromEuler(Rp.set(0,0,Math.PI/2)),i.quaternion.copy(e).multiply(gp),Math.abs(Pp.copy(kp).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(gp.setFromEuler(Rp.set(0,Math.PI/2,0)),i.quaternion.copy(e).multiply(gp),Math.abs(Pp.copy(Bp).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(gp.setFromEuler(Rp.set(0,Math.PI/2,0)),Pp.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Ip.lookAt(Lp,Pp,kp)),i.quaternion.multiply(gp),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),fp.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),fp.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(fp),i.visible=this.dragging):(i.quaternion.copy(e),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class Xp extends To{constructor(){super(new Jo(1e5,1e5,2,2),new $a({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"),zp.copy(Fp).applyQuaternion("local"===e?this.worldQuaternion:Np),Gp.copy(kp).applyQuaternion("local"===e?this.worldQuaternion:Np),Hp.copy(Bp).applyQuaternion("local"===e?this.worldQuaternion:Np),Pp.copy(Gp),this.mode){case"translate":case"scale":switch(this.axis){case"X":Pp.copy(this.eye).cross(zp),Up.copy(zp).cross(Pp);break;case"Y":Pp.copy(this.eye).cross(Gp),Up.copy(Gp).cross(Pp);break;case"Z":Pp.copy(this.eye).cross(Hp),Up.copy(Hp).cross(Pp);break;case"XY":Up.copy(Hp);break;case"YZ":Up.copy(zp);break;case"XZ":Pp.copy(Hp),Up.copy(Gp);break;case"XYZ":case"E":Up.set(0,0,0)}break;default:Up.set(0,0,0)}0===Up.length()?this.quaternion.copy(this.cameraQuaternion):(Op.lookAt(fp.set(0,0,0),Up,Pp),this.quaternion.setFromRotationMatrix(Op)),super.updateMatrixWorld(t)}}class jp extends Gd{constructor(t,e=1,n=16776960,i=new As){const r=new fo;r.setAttribute("position",new so([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new Dd({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e,this.offset=i;const s=new fo;s.setAttribute("position",new so([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.helper=new To(s,new $a({color:n,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 Yp={type:"change"},qp={type:"start"},Kp={type:"end"},Zp=-1,Qp=0,Jp=1,$p=2,tf=3,ef=4,nf=5,rf=6;class sf extends zr{constructor(t,e){super(),this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new As,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:ln,MIDDLE:hn,RIGHT:cn},this.touches={ONE:dn,TWO:pn},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",T),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",T),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Yp),n.update(),n.state=Zp},this.update=function(){const e=new As,a=(new Ts).setFromUnitVectors(t.up,new As(0,1,0)),l=a.clone().invert(),h=new As,c=new Ts,d=new As,u=2*Math.PI;return function(){const t=n.object.position;e.copy(t).sub(n.target),e.applyQuaternion(a),r.setFromVector3(e),n.autoRotate&&n.state===Zp&&o(2*Math.PI/60/60*n.autoRotateSpeed),n.enableDamping?(r.theta+=s.theta*n.dampingFactor,r.phi+=s.phi*n.dampingFactor):(r.theta+=s.theta,r.phi+=s.phi);let p=n.minAzimuthAngle,f=n.maxAzimuthAngle;return isFinite(p)&&isFinite(f)&&(p<-Math.PI?p+=u:p>Math.PI&&(p-=u),f<-Math.PI?f+=u:f>Math.PI&&(f-=u),r.theta=p<=f?Math.max(p,Math.min(f,r.theta)):r.theta>(p+f)/2?Math.max(p,r.theta):Math.min(f,r.theta)),r.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,r.phi)),r.makeSafe(),r.radius*=n.scale,r.radius=Math.max(n.minDistance,Math.min(n.maxDistance,r.radius)),!0===n.enableDamping?n.target.addScaledVector(n.panOffset,n.dampingFactor):n.target.add(n.panOffset),e.setFromSpherical(r),e.applyQuaternion(l),t.copy(n.target).add(e),n.object.lookAt(n.target),!0===n.enableDamping?(s.theta*=1-n.dampingFactor,s.phi*=1-n.dampingFactor,n.panOffset.multiplyScalar(1-n.dampingFactor)):(s.set(0,0,0),n.panOffset.set(0,0,0)),n.scale=1,!!(n.zoomChanged||h.distanceToSquared(n.object.position)>i||8*(1-c.dot(n.object.quaternion))>i||d.distanceToSquared(n.target)>0)&&(n.dispatchEvent(Yp),h.copy(n.object.position),c.copy(n.object.quaternion),d.copy(n.target),n.zoomChanged=!1,!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",A),n.domElement.removeEventListener("pointerdown",b),n.domElement.removeEventListener("pointercancel",w),n.domElement.removeEventListener("wheel",E),n.domElement.removeEventListener("pointermove",M),n.domElement.removeEventListener("pointerup",w),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",T),n._domElementKeyEvents=null)};const n=this;n.state=Zp;const i=1e-6,r=new dp,s=new dp;function a(){return Math.pow(.95,n.zoomSpeed)}function o(t){s.theta-=t}function l(t){s.phi-=t}n.scale=1,n.panOffset=new As,n.zoomChanged=!1,n.rotateStart=new Jr,n.rotateEnd=new Jr,n.rotateDelta=new Jr,n.panStart=new Jr,n.panEnd=new Jr,n.panDelta=new Jr,n.dollyStart=new Jr,n.dollyEnd=new Jr,n.dollyDelta=new Jr,n.dollyScale=0,n.pointers=[],n.pointerPositions={};const h=function(){const t=new As;return function(e,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-e),n.panOffset.add(t)}}(),c=function(){const t=new As;return function(e,i){!0===n.screenSpacePanning?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(n.object.up,t)),t.multiplyScalar(e),n.panOffset.add(t)}}(),d=function(){const t=new As;return function(e,i){const r=n.domElement;if(n.object.isPerspectiveCamera){const s=n.object.position;t.copy(s).sub(n.target);let a=t.length();a*=Math.tan(n.object.fov/2*Math.PI/180),h(2*e*a/r.clientHeight,n.object.matrix),c(2*i*a/r.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(h(e*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),c(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function u(t){n.object.isPerspectiveCamera?n.scale/=t:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*t)),n.object.updateProjectionMatrix(),n.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function p(t){n.object.isPerspectiveCamera?n.scale*=t:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/t)),n.object.updateProjectionMatrix(),n.zoomChanged=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function f(t){n.rotateStart.set(t.clientX,t.clientY)}function m(t){n.panStart.set(t.clientX,t.clientY)}function g(){if(1===n.pointers.length)n.rotateStart.set(n.pointers[0].pageX,n.pointers[0].pageY);else{const t=.5*(n.pointers[0].pageX+n.pointers[1].pageX),e=.5*(n.pointers[0].pageY+n.pointers[1].pageY);n.rotateStart.set(t,e)}}function _(){if(1===n.pointers.length)n.panStart.set(n.pointers[0].pageX,n.pointers[0].pageY);else{const t=.5*(n.pointers[0].pageX+n.pointers[1].pageX),e=.5*(n.pointers[0].pageY+n.pointers[1].pageY);n.panStart.set(t,e)}}function v(){const t=n.pointers[0].pageX-n.pointers[1].pageX,e=n.pointers[0].pageY-n.pointers[1].pageY,i=Math.sqrt(t*t+e*e);n.dollyStart.set(0,i)}function y(t){if(1==n.pointers.length)n.rotateEnd.set(t.pageX,t.pageY);else{const e=R(t),i=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);n.rotateEnd.set(i,r)}n.rotateDelta.subVectors(n.rotateEnd,n.rotateStart).multiplyScalar(n.rotateSpeed);const e=n.domElement;o(2*Math.PI*n.rotateDelta.x/e.clientHeight),l(2*Math.PI*n.rotateDelta.y/e.clientHeight),n.rotateStart.copy(n.rotateEnd)}function x(t){if(1===n.pointers.length)n.panEnd.set(t.pageX,t.pageY);else{const e=R(t),i=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);n.panEnd.set(i,r)}n.panDelta.subVectors(n.panEnd,n.panStart).multiplyScalar(n.panSpeed),d(n.panDelta.x,n.panDelta.y),n.panStart.copy(n.panEnd)}function S(t){const e=R(t),i=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(i*i+r*r);n.dollyEnd.set(0,s),n.dollyDelta.set(0,Math.pow(n.dollyEnd.y/n.dollyStart.y,n.zoomSpeed)),u(n.dollyDelta.y),n.dollyStart.copy(n.dollyEnd)}function b(t){!1!==n.enabled&&(0===n.pointers.length&&(n.domElement.setPointerCapture(t.pointerId),n.domElement.addEventListener("pointermove",M),n.domElement.addEventListener("pointerup",w)),function(t){n.pointers.push(t)}(t),"touch"===t.pointerType?function(t){switch(C(t),n.pointers.length){case 1:switch(n.touches.ONE){case dn:if(!1===n.enableRotate)return;g(),n.state=tf;break;case un:if(!1===n.enablePan)return;_(),n.state=ef;break;default:n.state=Zp}break;case 2:switch(n.touches.TWO){case pn:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&v(),n.enablePan&&_(),n.state=nf;break;case fn:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&v(),n.enableRotate&&g(),n.state=rf;break;default:n.state=Zp}break;default:n.state=Zp}n.state!==Zp&&n.dispatchEvent(qp)}(t):function(t){let e;switch(t.button){case 0:e=n.mouseButtons.LEFT;break;case 1:e=n.mouseButtons.MIDDLE;break;case 2:e=n.mouseButtons.RIGHT;break;default:e=-1}switch(e){case hn:if(!1===n.enableZoom)return;!function(t){n.dollyStart.set(t.clientX,t.clientY)}(t),n.state=Jp;break;case ln:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===n.enablePan)return;m(t),n.state=$p}else{if(!1===n.enableRotate)return;f(t),n.state=Qp}break;case cn:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===n.enableRotate)return;f(t),n.state=Qp}else{if(!1===n.enablePan)return;m(t),n.state=$p}break;default:n.state=Zp}n.state!==Zp&&n.dispatchEvent(qp)}(t))}function M(t){!1!==n.enabled&&("touch"===t.pointerType?function(t){switch(C(t),n.state){case tf:if(!1===n.enableRotate)return;y(t),n.update();break;case ef:if(!1===n.enablePan)return;x(t),n.update();break;case nf:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(t){n.enableZoom&&S(t),n.enablePan&&x(t)}(t),n.update();break;case rf:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(t){n.enableZoom&&S(t),n.enableRotate&&y(t)}(t),n.update();break;default:n.state=Zp}}(t):function(t){switch(n.state){case Qp:if(!1===n.enableRotate)return;!function(t){n.rotateEnd.set(t.clientX,t.clientY),n.rotateDelta.subVectors(n.rotateEnd,n.rotateStart).multiplyScalar(n.rotateSpeed);const e=n.domElement;o(2*Math.PI*n.rotateDelta.x/e.clientHeight),l(2*Math.PI*n.rotateDelta.y/e.clientHeight),n.rotateStart.copy(n.rotateEnd),n.update()}(t);break;case Jp:if(!1===n.enableZoom)return;!function(t){n.dollyEnd.set(t.clientX,t.clientY),n.dollyDelta.subVectors(n.dollyEnd,n.dollyStart),n.dollyDelta.y<0?(n.dollyScale=1/a(),u(a())):n.dollyDelta.y>0&&(n.dollyScale=a(),p(a())),n.dollyStart.copy(n.dollyEnd),n.update()}(t);break;case $p:if(!1===n.enablePan)return;!function(t){n.panEnd.set(t.clientX,t.clientY),n.panDelta.subVectors(n.panEnd,n.panStart).multiplyScalar(n.panSpeed),d(n.panDelta.x,n.panDelta.y),n.panStart.copy(n.panEnd),n.update()}(t)}}(t))}function w(t){!function(t){delete n.pointerPositions[t.pointerId];for(let e=0;e<n.pointers.length;e++)if(n.pointers[e].pointerId==t.pointerId)return void n.pointers.splice(e,1)}(t),0===n.pointers.length&&(n.domElement.releasePointerCapture(t.pointerId),n.domElement.removeEventListener("pointermove",M),n.domElement.removeEventListener("pointerup",w)),n.dispatchEvent(Kp),n.state=Zp}function E(t){!1!==n.enabled&&!1!==n.enableZoom&&n.state===Zp&&(t.preventDefault(),n.dispatchEvent(qp),function(t){n.dollyEnd.set(n.domElement.clientWidth/2,n.domElement.clientHeight/2),n.dollyDelta.set(t.deltaX,t.deltaY),t.deltaY<0?(n.dollyScale=1/a(),p(a())):t.deltaY>0&&(n.dollyScale=a(),u(a())),n.dollyStart.copy(n.dollyEnd),n.update(),0!==t.deltaY&&(n.state=Jp,n.dispatchEvent(Yp),n.state=Zp)}(t),n.dispatchEvent(Kp))}function T(t){!1!==n.enabled&&!1!==n.enablePan&&function(t){let e=!1;switch(t.code){case n.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?l(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):d(0,n.keyPanSpeed),e=!0;break;case n.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?l(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):d(0,-n.keyPanSpeed),e=!0;break;case n.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?o(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):d(n.keyPanSpeed,0),e=!0;break;case n.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?o(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):d(-n.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),n.update())}(t)}function A(t){!1!==n.enabled&&t.preventDefault()}function C(t){let e=n.pointerPositions[t.pointerId];void 0===e&&(e=new Jr,n.pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}function R(t){const e=t.pointerId===n.pointers[0].pointerId?n.pointers[1]:n.pointers[0];return n.pointerPositions[e.pointerId]}n.domElement.addEventListener("contextmenu",A),n.domElement.addEventListener("pointerdown",b),n.domElement.addEventListener("pointercancel",w),n.domElement.addEventListener("wheel",E,{passive:!1}),this.update()}}class af{constructor(t){this.updateControls=()=>{this.orbit.maxDistance=this.viewer.camera.far,this.orbit.minDistance=this.viewer.camera.near,this.orbit.target.copy(this.viewer.target),this.orbit.update()},this.controlsStart=()=>{this.changed=!1},this.controlsChange=()=>{switch(this.viewer.target.copy(this.orbit.target),this.viewer.update(),this.orbit.state){case $p:case ef: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 Jp:this.viewer.emitEvent({type:"zoomat",data:this.orbit.dollyScale,x:this.orbit.dollyEnd.x,y:this.orbit.dollyEnd.y})}this.changed=!0},this.stopContextMenu=t=>{this.changed&&(t.preventDefault(),t.stopPropagation())},this.orbit=new sf(t.camera,t.canvas),this.orbit.mouseButtons={LEFT:ln,MIDDLE:cn,RIGHT:cn},this.orbit.touches={ONE:dn,TWO:pn},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.on("geometryend",this.updateControls),this.viewer.on("viewposition",this.updateControls),this.viewer.on("zoom",this.updateControls),this.viewer.on("drawviewpoint",this.updateControls),this.viewer.on("contextmenu",this.stopContextMenu),this.updateControls()}dispose(){this.viewer.off("geometryend",this.updateControls),this.viewer.off("viewposition",this.updateControls),this.viewer.off("zoom",this.updateControls),this.viewer.off("drawviewpoint",this.updateControls),this.viewer.off("contextmenu",this.stopContextMenu),this.orbit.removeEventListener("start",this.controlsStart),this.orbit.removeEventListener("change",this.controlsChange),this.orbit.dispose()}}class of extends af{constructor(t,e,n){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.viewerExplode=()=>{this.planeHelper.size=this.viewer.extents.getSize(new As).length(),this.viewer.update()},this.onDoubleClick=t=>{t.stopPropagation(),this.plane.negate(),this.viewer.update()};const i=t.extents.getSize(new As).length(),r=t.extents.getCenter(new As),s=-r.dot(e);this.plane=new jo(e,s),t.renderer.clippingPlanes||(t.renderer.clippingPlanes=[]),t.renderer.clippingPlanes.push(this.plane),this.planeHelper=new jp(this.plane,i,n,r),this.viewer.helpers.add(this.planeHelper),this.planeCenter=new Pa,this.planeCenter.position.copy(t.extents.getCenter(new As)),this.viewer.helpers.add(this.planeCenter),this.transform=new bp(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.on("explode",this.viewerExplode),this.viewer.canvas.addEventListener("dblclick",this.onDoubleClick,!0),this.viewer.update()}dispose(){this.viewer.off("explode",this.viewerExplode),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 lf extends of{constructor(t){super(t,new As(1,0,0),16711680)}}class hf extends of{constructor(t){super(t,new As(0,1,0),65280)}}class cf extends of{constructor(t){super(t,new As(0,0,1),255)}}class df extends af{constructor(t){super(t),this.onPointerDown=t=>{0===t.button&&(this.line.startPoint=this.snapper.getSnapPoint(t),this.line.render(),this.viewer.canvas.setPointerCapture(t.pointerId),this.orbit.enabled=!this.line.startPoint)},this.onPointerMove=t=>{this.orbit.enabled&&-1!==this.orbit.state||(this.line.endPoint=this.snapper.getSnapPoint(t),this.line.render(),this.line.startPoint&&(this.changed=!0))},this.onPointerUp=t=>{this.line.startPoint&&this.line.endPoint&&this.line.getDistance()>=.01?(this.line=new mf(this.overlay),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.renderOverlay=()=>{this.overlay.render()},this.updateSnapper=()=>{this.snapper.update(this.viewer.scene)},this.overlay=new pf(t.camera,t.canvas),this.overlay.attach(),this.line=new mf(this.overlay),this.overlay.addLine(this.line),this.snapper=new uf(t.camera,t.canvas),this.snapper.update(t.scene),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.updateSnapper),this.viewer.addEventListener("isolate",this.updateSnapper),this.viewer.addEventListener("showall",this.updateSnapper)}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.updateSnapper),this.viewer.removeEventListener("isolate",this.updateSnapper),this.viewer.removeEventListener("showall",this.updateSnapper),this.overlay.detach(),this.overlay.dispose(),super.dispose()}}class uf{constructor(t,e){this.objects=[],this.camera=t,this.canvas=e,this.raycaster=new lp}getSnapPoint(t){const e=new Jr(t.clientX,t.clientY),n=this.canvas.getBoundingClientRect(),i=(e.x-n.left)/n.width*2-1,r=-(e.y-n.top)/n.height*2+1,s=new Jr(i,r);this.raycaster.setFromCamera(s,this.camera),this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}};const a=this.raycaster.intersectObjects(this.objects,!1);if(0!==a.length)return a[0].point}update(t){this.objects=[],t.traverseVisible((t=>this.objects.push(t)))}}class pf{constructor(t,e){this.lines=[],this.camera=t,this.canvas=e,this.projector=new Tf(t,e)}attach(){this.container=document.createElement("div"),this.container.id="measure-container",this.container.style.background="rgba(0,0,0,0)",this.container.style.position="absolute",this.container.style.top="0px",this.container.style.left="0px",this.container.style.width="100%",this.container.style.height="100%",this.container.style.outline="none",this.container.style.pointerEvents="none",this.container.style.overflow="hidden",this.canvas.parentElement.appendChild(this.container)}dispose(){this.clear()}detach(){this.container.remove(),this.container=void 0}clear(){this.lines.forEach((t=>t.dispose())),this.lines=[]}render(){this.projector.updateProjectionMatrix(),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))}}const ff=new As;class mf{constructor(t){this.id=Date.now(),this.unit="",this.scale=1,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.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()}render(){const t=this.overlay.projector;if(this.startPoint){const{point:e,visible:n}=t.projectPoint(this.startPoint);this.elementStartPoint.style.display=n?"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:n}=t.projectPoint(this.endPoint);this.elementEndPoint.style.display=n?"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:n,visible:i}=t.projectLine(this.startPoint,this.endPoint);n.sub(e);const r=n.angle(),s=n.length();this.elementLine.style.display=i?"block":"none",this.elementLine.style.left=`${e.x}px`,this.elementLine.style.top=`${e.y}px`,this.elementLine.style.width=`${s}px`,this.elementLine.style.transform=`translate(0px, ${-this.lineWidth/2}px) rotate(${r}rad)`}else this.elementLine.style.display="none";if(this.startPoint&&this.endPoint){ff.lerpVectors(this.startPoint,this.endPoint,.5);const{point:e,visible:n}=t.projectPoint(ff),i=this.getDistance();this.elementLabel.style.display=n&&i>=.01?"block":"none",this.elementLabel.style.left=`${e.x}px`,this.elementLabel.style.top=`${e.y}px`,this.elementLabel.innerHTML=`${i.toFixed(2)} ${this.unit}`}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 gf,_f;const vf=new ia,yf=new ia,xf=new As,Sf=new Ss,bf=new Ss,Mf=new Jr,wf=new Jr,Ef=new Jr;class Tf{constructor(t,e){this.camera=t,this.canvas=e}updateProjectionMatrix(){const t=this.canvas.getBoundingClientRect();gf=t.width/2,_f=t.height/2,vf.copy(this.camera.matrixWorldInverse),yf.multiplyMatrices(this.camera.projectionMatrix,vf)}projectPoint(t){xf.copy(t).applyMatrix4(yf);const e=xf.z>=-1&&xf.z<=1;return Mf.x=(xf.x+1)*gf,Mf.y=(1-xf.y)*_f,{point:Mf,visible:e}}projectLine(t,e){let n;Sf.copy(t).applyMatrix4(yf),bf.copy(e).applyMatrix4(yf);const i=Sf.z+Sf.w,r=bf.z+bf.w,s=-Sf.z+Sf.w,a=-bf.z+bf.w;if(i>=0&&r>=0&&s>=0&&a>=0)n=!0;else if(i<0&&r<0||s<0&&a<0)n=!1;else{let t=0,e=1;i<0?t=Math.max(t,i/(i-r)):r<0&&(e=Math.min(e,i/(i-r))),s<0?t=Math.max(t,s/(s-a)):a<0&&(e=Math.min(e,s/(s-a))),n=e>=t,n&&(Sf.lerp(bf,t),bf.lerp(Sf,1-e))}return Sf.multiplyScalar(1/Sf.w),bf.multiplyScalar(1/bf.w),wf.x=(Sf.x+1)*gf,wf.y=(1-Sf.y)*_f,Ef.x=(bf.x+1)*gf,Ef.y=(1-bf.y)*_f,{point1:wf,point2:Ef,visible:n}}}class Af extends af{constructor(t){super(t),this.orbit.mouseButtons={LEFT:cn,MIDDLE:cn,RIGHT:cn}}}class Cf extends up{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 Jr(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.moveKeys=new Set,this.moveClock=new Ju,this.quaternion=t.quaternion.clone(),this.downPosition=new Jr(0,0),this.rotateDelta=new Jr(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 Jr(0,-e/2))),this.moveKeys.has("ArrowDown")&&this.rotateCamera(this.rotateDelta.add(new Jr(0,e/2))),this.moveKeys.has("ArrowLeft")&&this.rotateCamera(this.rotateDelta.add(new Jr(e,0))),this.moveKeys.has("ArrowRight")&&this.rotateCamera(this.rotateDelta.add(new Jr(-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,n=Math.PI*t.y/this.domElement.clientHeight,i=new Ts;i.setFromAxisAngle(this.object.up,e);const r=new Ts;r.setFromAxisAngle(new As(1,0,0),n);const s=this.quaternion.clone();s.premultiply(i).multiply(r).normalize(),this.object.setRotationFromQuaternion(s)}}class Rf{constructor(t){this.updateControls=()=>{const t=this.viewer.extents.getSize(new As);this.controls.movementSpeed=Math.min(t.x,t.y,t.z)/2},this.controlsChange=()=>{this.viewer.update()},this.walkspeedChange=t=>{this.viewer.emitEvent(t)},this.viewerRender=()=>{this.controls.update()},this.viewerZoom=()=>{this.controls.rotateDelta.set(0,0)},this.controls=new Cf(t.camera,t.canvas),this.controls.addEventListener("change",this.controlsChange),this.controls.addEventListener("walkspeedchange",this.walkspeedChange),this.viewer=t,this.viewer.on("render",this.viewerRender),this.viewer.on("zoom",this.viewerZoom),this.updateControls()}dispose(){this.viewer.off("render",this.viewerRender),this.viewer.off("zoom",this.viewerZoom),this.controls.removeEventListener("walkspeedchange",this.walkspeedChange),this.controls.removeEventListener("change",this.controlsChange),this.controls.dispose()}}class Pf extends af{constructor(t){super(t),this.orbit.mouseButtons={LEFT:hn,MIDDLE:cn,RIGHT:cn}}}const Lf=a("threejs");Lf.registerDragger("Pan",(t=>new Af(t))),Lf.registerDragger("Orbit",(t=>new af(t))),Lf.registerDragger("Zoom",(t=>new Pf(t))),Lf.registerDragger("MeasureLine",(t=>new df(t))),Lf.registerDragger("CuttingPlaneXAxis",(t=>new lf(t))),Lf.registerDragger("CuttingPlaneYAxis",(t=>new hf(t))),Lf.registerDragger("CuttingPlaneZAxis",(t=>new cf(t))),Lf.registerDragger("Walk",(t=>new Rf(t)));class If{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 Jr);if(0!==this.downPosition.distanceTo(e))return;const n=this.getPointerIntersects(e);this.clearSelection(),n.length>0&&this.select(n[0].object),this.viewer.update(),this.viewer.emitEvent({type:"select",data:void 0,handles:this.viewer.getSelected()})},this.onDoubleClick=t=>{0===t.button&&this.viewer.executeCommand("zoomToSelected")},this.optionsChange=()=>{const{facesColor:t,facesTransparancy:e}=this.viewer.options;this.facesMaterial.color.setRGB(t.r/255,t.g/255,t.b/255),this.facesMaterial.opacity=(255-e)/255,this.viewer.update()},this.viewer=t,this.raycaster=new lp,this.downPosition=new Jr;const{facesColor:e,facesTransparancy:n}=this.viewer.options;this.facesMaterial=new $a,this.facesMaterial.color.setRGB(e.r/255,e.g/255,e.b/255),this.facesMaterial.opacity=(255-n)/255,this.facesMaterial.transparent=!0,this.viewer.addEventListener("pointerdown",this.onPointerDown),this.viewer.addEventListener("pointerup",this.onPointerUp),this.viewer.addEventListener("dblclick",this.onDoubleClick),this.viewer.addEventListener("optionschange",this.optionsChange)}dispose(){this.facesMaterial.dispose(),this.viewer.removeEventListener("pointerdown",this.onPointerDown),this.viewer.removeEventListener("pointerup",this.onPointerUp),this.viewer.removeEventListener("dblclick",this.onDoubleClick),this.viewer.removeEventListener("optionschange",this.optionsChange)}getMousePosition(t,e){return e.set(t.clientX,t.clientY)}getPointerIntersects(t){const e=this.viewer.canvas.getBoundingClientRect(),n=(t.x-e.left)/e.width*2-1,i=-(t.y-e.top)/e.height*2+1,r=new Jr(n,i);this.raycaster.setFromCamera(r,this.viewer.camera);const s=[];return this.viewer.scene.traverseVisible((t=>s.push(t))),this.raycaster.params=this.raycaster.params={Mesh:{},Line:{threshold:.25},Line2:{threshold:.25},LOD:{},Points:{threshold:.1},Sprite:{}},this.raycaster.intersectObjects(s,!1)}select(t){t.isSelected||(t.isSelected=!0,t.originalMaterial=t.material,t.material=this.facesMaterial,this.viewer.selected.push(t))}clearSelection(){this.viewer.selected.forEach((t=>{t.isSelected=!1,t.material=t.originalMaterial})),this.viewer.selected.length=0}}function Df(t,e){let n=e;return t.children.forEach((t=>{const i=Df(t,e+1);n<i&&(n=i)})),t.originalPosition=t.position.clone(),n}function Nf(t,e=0){e/=100,t.maxDepth||(t.maxDepth=Df(t,1));const n=t.maxDepth;let i=e*(n-1)+1;1===n&&(i=1);!function t(n,r,s,a){const o=(new Ps).setFromObject(n).getCenter(new As),l=a.clone();if(r>0&&r<=i){const t=o.clone().sub(s).multiplyScalar(e);l.add(t)}n.children.forEach((e=>t(e,r+1,o,l)));const h=n.originalPosition;if(n.position.copy(h),e>0){const t=o.sub(s).normalize();n.position.add(t.add(l))}}(t,0,(new Ps).setFromObject(t).getCenter(new As),new As(0,0,0))}function Uf(t,e=0){t.models.forEach((t=>Nf(t.scene,e))),t.update(),t.emitEvent({type:"explode",data:e})}const Of={top:new As(0,0,1),bottom:new As(0,0,-1),left:new As(-1,0,0),right:new As(1,0,0),front:new As(0,-1,0),back:new As(0,1,0),sw:new As(-.5,-.5,1).normalize(),se:new As(.5,-.5,1).normalize(),ne:new As(.5,.5,1).normalize(),nw:new As(-.5,.5,1).normalize()};function Ff(t,e){const n=Of[e]||Of.sw,i=t.extents.getCenter(new As),r=t.extents.getBoundingSphere(new qs),s=n.clone().multiplyScalar(r.radius),a=t.camera;a.position.copy(i).add(s),a.lookAt(i),a.updateProjectionMatrix(),a.updateMatrixWorld(),t.target.copy(i),t.update(),t.emit({type:"viewposition",data:e}),t.executeCommand("zoomToExtents")}const kf=i("threejs");kf.registerCommand("applyModelTransform",(function(t,e){console.warn("applyModelTransform not implemented")})),kf.registerCommand("clearMarkup",(function(t){t.clearOverlay()})),kf.registerCommand("clearSelected",(function(t){const e=new If(t);e.clearSelection(),e.dispose(),t.update(),t.emitEvent({type:"select",data:void 0,handles:[]})})),kf.registerCommand("clearSlices",(function(t){t.clearSlices()})),kf.registerCommand("createPreview",(function(t,e="image/jpeg",n=.25){return t.update(!0),t.canvas.toDataURL(e,n)})),kf.registerCommand("explode",Uf),kf.registerCommand("collect",(function(t){Uf(t,0)})),kf.registerCommand("getDefaultViewPositions",(function(){return Object.keys(Of)})),kf.registerCommand("getModels",(function(t){return t.models.map((t=>{var e;return(null===(e=t.userData)||void 0===e?void 0:e.handle)||""})).filter((t=>t))})),kf.registerCommand("getSelected",(function(t){return t.selected.map((t=>{var e;return null===(e=t.userData)||void 0===e?void 0:e.handle})).filter((t=>t))})),kf.registerCommand("hideSelected",(function(t){t.selected.forEach((t=>t.visible=!1));const e=new If(t);e.clearSelection(),e.dispose(),t.update(),t.emitEvent({type:"hide"}),t.emitEvent({type:"select",data:void 0,handles:[]})})),kf.registerCommand("isolateSelected",(function(t){const e=new Set(t.selected);!function t(n,i){let r=!0;return n.children.forEach((n=>{e.has(n)?r=!1:t(n,i+1)})),r&&i>0&&(n.visible=!1),r}(t.scene,0),t.update(),t.emitEvent({type:"isolate"})})),kf.registerCommand("regenerateAll",(function(t){t.emit({type:"regenerateall"})})),kf.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.executeCommand("k3DViewSW"),t.emit({type:"resetview"})})),kf.registerCommand("selectModel",(function(t,e){console.warn("selectModel not implemented"),t.emit({type:"select",data:[]})})),kf.registerCommand("setActiveDragger",(function(t,e=""){t.setActiveDragger(e)})),kf.registerCommand("setDefaultViewPosition",Ff),kf.registerCommand("setMarkupColor",(function(t,e=255,n=0,i=0){t.markup.setMarkupColor(e,n,i)})),kf.registerCommand("setSelected",(function(t,e=[]){const n=new Set(e),i=[];t.scene.traverseVisible((t=>{var e;n.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&i.push(t)}));const r=new If(t);r.clearSelection(),i.forEach((t=>r.select(t))),r.dispose(),t.update(),t.emitEvent({type:"select",data:void 0,handles:e})})),kf.registerCommand("showAll",(function(t){t.scene.traverse((t=>t.visible=!0)),t.update(),t.emitEvent({type:"showall"})})),kf.registerCommand("zoomToExtents",(function(t){if(t.extents.isEmpty())return;const e=t.extents.getCenter(new As),n=t.extents.getBoundingSphere(new qs).radius,i=new As(0,0,1);i.applyQuaternion(t.camera.quaternion),i.multiplyScalar(3*n),t.camera.position.copy(e).add(i),t.target.copy(e),t.update(),t.emitEvent({type:"zoom"})})),kf.registerCommand("zoomToObjects",(function(t,e=[]){const n=new Set(e),i=[];t.scene.traverseVisible((t=>{var e;n.has(null===(e=t.userData)||void 0===e?void 0:e.handle)&&i.push(t)}));const r=i.reduce(((t,e)=>t.expandByObject(e)),new Ps),s=r.getCenter(new As),a=r.getBoundingSphere(new qs).radius,o=new As(0,0,1);o.applyQuaternion(t.camera.quaternion),o.multiplyScalar(3*a),t.camera.position.copy(s).add(o),t.target.copy(s),t.update(),t.emitEvent({type:"zoom"})})),kf.registerCommand("zoomToSelected",(function(t){const e=t.selected.reduce(((t,e)=>t.expandByObject(e)),new Ps);e.isEmpty()&&e.copy(t.extents);const n=e.getCenter(new As),i=e.getBoundingSphere(new qs).radius,r=new As(0,0,1);r.applyQuaternion(t.camera.quaternion),r.multiplyScalar(3*i),t.camera.position.copy(n).add(r),t.target.copy(n),t.update(),t.emitEvent({type:"zoom"})})),kf.registerCommand("top",(t=>Ff(t,"top"))),kf.registerCommand("bottom",(t=>Ff(t,"bottom"))),kf.registerCommand("left",(t=>Ff(t,"left"))),kf.registerCommand("right",(t=>Ff(t,"right"))),kf.registerCommand("front",(t=>Ff(t,"front"))),kf.registerCommand("back",(t=>Ff(t,"back"))),kf.registerCommand("sw",(t=>Ff(t,"sw"))),kf.registerCommand("se",(t=>Ff(t,"se"))),kf.registerCommand("ne",(t=>Ff(t,"ne"))),kf.registerCommand("nw",(t=>Ff(t,"nw"))),kf.registerCommandAlias("clearMarkup","clearOverlay"),kf.registerCommandAlias("clearSelected","unselect"),kf.registerCommandAlias("zoomToExtents","zoomExtents"),kf.registerCommandAlias("top","k3DViewTop"),kf.registerCommandAlias("bottom","k3DViewBottom"),kf.registerCommandAlias("left","k3DViewLeft"),kf.registerCommandAlias("right","k3DViewRight"),kf.registerCommandAlias("front","k3DViewFront"),kf.registerCommandAlias("back","k3DViewBack"),kf.registerCommandAlias("se","k3DViewSE"),kf.registerCommandAlias("sw","k3DViewSW"),kf.registerCommandAlias("ne","k3DViewNE"),kf.registerCommandAlias("nw","k3DViewNW");class Bf extends Vc{constructor(){super();const t=new Co;t.deleteAttribute("uv");const e=new au({side:yn}),n=new au,i=new ju(16777215,900,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new To(t,e);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new To(t,n);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);const a=new To(t,n);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);const o=new To(t,n);o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),this.add(o);const l=new To(t,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const h=new To(t,n);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const c=new To(t,n);c.position.set(-2.193,-.369,-5.547),c.rotation.set(0,.516,0),c.scale.set(3.875,3.487,2.986),this.add(c);const d=new To(t,zf(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);const u=new To(t,zf(50));u.position.set(-16.109,18.021,-8.207),u.scale.set(.1,2.425,2.751),this.add(u);const p=new To(t,zf(17));p.position.set(14.904,12.198,-1.832),p.scale.set(.15,4.265,6.331),this.add(p);const f=new To(t,zf(43));f.position.set(-.462,8.89,14.52),f.scale.set(4.38,5.441,.088),this.add(f);const m=new To(t,zf(20));m.position.set(3.235,11.486,-12.541),m.scale.set(2.5,2,.1),this.add(m);const g=new To(t,zf(100));g.position.set(0,20,0),g.scale.set(1,.1,1),this.add(g)}dispose(){const t=new Set;this.traverse((e=>{e.isMesh&&(t.add(e.geometry),t.add(e.material))}));for(const e of t)e.dispose()}}function zf(t){const e=new $a;return e.color.setScalar(t),e}class Gf{constructor(t){this.syncOptions=()=>{this.backgroundColor.setHex(16777215)},this.viewer=t,this.backgroundColor=new Ka(16777215);const e=new Bf,n=new Ml(this.viewer.renderer);this.viewer.renderer.setClearColor(this.backgroundColor),this.viewer.scene.background=this.backgroundColor,this.viewer.scene.environment=n.fromScene(e).texture,this.viewer.addEventListener("optionschange",this.syncOptions),e.dispose()}dispose(){this.viewer.removeEventListener("optionschange",this.syncOptions),this.viewer.scene.environment=void 0,this.viewer.scene.background=void 0}}class Hf{constructor(t){this.geometryEnd=t=>{const e=this.viewer.extents.getSize(new As).length();this.viewer.camera.near=e/100,this.viewer.camera.far=100*e,this.viewer.camera.updateMatrixWorld(),this.viewer.camera.updateProjectionMatrix(),this.viewer.executeCommand("setDefaultViewPosition","sw"),this.viewer.executeCommand("zoomToExtents")},this.viewer=t,this.viewer.addEventListener("geometryend",this.geometryEnd)}dispose(){this.viewer.removeEventListener("geometryend",this.geometryEnd)}}class Vf{constructor(t){this.syncExtents=()=>{const t=this.viewer.models.reduce(((t,e)=>t.expandByObject(e.scene)),new Ps);this.viewer.extents.copy(t),this.viewer.target.copy(t.getCenter(new As))},this.viewer=t,this.viewer.addEventListener("geometryend",this.syncExtents),this.viewer.addEventListener("clear",this.syncExtents),this.viewer.on("explode",this.syncExtents)}dispose(){this.viewer.removeEventListener("geometryend",this.syncExtents),this.viewer.removeEventListener("clear",this.syncExtents),this.viewer.off("explode",this.syncExtents)}}class Wf{constructor(t){this.viewer=t,this.ambientLight=new Ku(16777215,0),this.viewer.camera.add(this.ambientLight),this.directionalLight=new qu(16777215,1),this.directionalLight.position.set(.5,0,.866),this.viewer.camera.add(this.directionalLight)}dispose(){this.ambientLight.removeFromParent(),this.ambientLight=void 0,this.directionalLight.removeFromParent(),this.directionalLight=void 0}}class Xf{constructor(t){this.animate=(t=0)=>{this.requestId=requestAnimationFrame(this.animate),this.viewer.render(t)},this.viewer=t,this.animate()}dispose(){cancelAnimationFrame(this.requestId)}}class jf{constructor(t){this.resizeViewer=t=>{const{width:e,height:n}=t[0].contentRect;e&&n&&(this.viewer.camera.aspect=e/n,this.viewer.camera.updateProjectionMatrix(),this.viewer.renderer.setSize(e,n,!0),this.viewer.update(!0),this.viewer.emitEvent({type:"resize",width:e,height:n}))},this.viewer=t,this.resizeObserver=new ResizeObserver(this.resizeViewer),this.resizeObserver.observe(t.canvas.parentElement)}dispose(){this.resizeObserver.disconnect()}}class Yf extends Pa{constructor(t){super(),this.camera=t,this.size=160,this.orthoCamera=new dl(-2,2,2,-2,0,4),this.orthoCamera.position.set(0,0,2);const e=new $a({toneMapped:!1,color:"#aa0000"}),n=new $a({toneMapped:!1,color:"#00aa00"}),i=new $a({toneMapped:!1,color:"#0000aa"}),r=this.getSpriteMaterial(e.color,"X"),s=this.getSpriteMaterial(n.color,"Y"),a=this.getSpriteMaterial(i.color,"Z"),o=new eu(.01,.01,1,3);o.translate(0,.5,0);const l=new eu(0,.1,.25,12);l.translate(0,.625,0);const h={X:[[new To(l,e),[.5,0,0],[0,0,-Math.PI/2]],[new To(o,e),[0,0,0],[0,0,-Math.PI/2]],[new od(r),[1.55,0,0]]],Y:[[new To(l,n),[0,.5,0],null],[new To(o,n),null,null],[new od(s),[0,1.55,0]]],Z:[[new To(l,i),[0,0,.5],[Math.PI/2,0,0]],[new To(o,i),null,[Math.PI/2,0,0]],[new od(a),[0,0,1.55]]]};Object.keys(h).forEach((t=>{h[t].forEach((e=>{const n=e[0],i=e[1],r=e[2];n.name=t,i&&n.position.set(i[0],i[1],i[2]),r&&n.rotation.set(r[0],r[1],r[2]),n.updateMatrixWorld(),this.add(n)}))}))}dispose(){this.traverse((t=>{t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}getSpriteMaterial(t,e){const n=document.createElement("canvas");n.width=64,n.height=64;const i=n.getContext("2d");i.clearRect(0,0,64,64),i.font="24px Arial",i.textAlign="center",i.fillStyle=t.getStyle(),i.fillText(e,32,41);const r=new tu(n);return r.colorSpace=Mr,new Yc({map:r,toneMapped:!1})}render(t){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld();const e=t.clippingPlanes,n=t.getViewport(new Ss);t.setViewport(this.position.x,this.position.y,this.size,this.size),t.clippingPlanes=[],t.clearDepth(),t.render(this,this.orthoCamera),t.setViewport(n),t.clippingPlanes=e}}class qf{constructor(t){this.viewerRender=()=>{this.viewer.options.showWCS&&(this.viewer.extents.isEmpty()||this.wcsHelper.render(this.viewer.renderer))},this.wcsHelper=new Yf(t.camera),this.viewer=t,this.viewer.addEventListener("render",this.viewerRender)}dispose(){this.viewer.removeEventListener("render",this.viewerRender),this.wcsHelper.dispose()}}const Kf=h("threejs");function Zf(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let n=t.getIndex();if(null===n){const e=[],i=t.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<i.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const i=n.count-2,r=[];if(2===e)for(let t=1;t<=i;t++)r.push(n.getX(0)),r.push(n.getX(t)),r.push(n.getX(t+1));else for(let t=0;t<i;t++)t%2==0?(r.push(n.getX(t)),r.push(n.getX(t+1)),r.push(n.getX(t+2))):(r.push(n.getX(t+2)),r.push(n.getX(t+1)),r.push(n.getX(t)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(r),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}Kf.registerComponent("ExtentsComponent",(t=>new Vf(t))),Kf.registerComponent("LightComponent",(t=>new Wf(t))),Kf.registerComponent("BackgroundComponent",(t=>new Gf(t))),Kf.registerComponent("ResizeCanvasComponent",(t=>new jf(t))),Kf.registerComponent("RenderLoopComponent",(t=>new Xf(t))),Kf.registerComponent("DefaultPositionComponent",(t=>new Hf(t))),Kf.registerComponent("SelectionComponent",(t=>new If(t))),Kf.registerComponent("WCSHelperComponent",(t=>new qf(t)));class Qf extends Ru{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new im(t)})),this.register((function(t){return new rm(t)})),this.register((function(t){return new pm(t)})),this.register((function(t){return new fm(t)})),this.register((function(t){return new mm(t)})),this.register((function(t){return new am(t)})),this.register((function(t){return new om(t)})),this.register((function(t){return new lm(t)})),this.register((function(t){return new hm(t)})),this.register((function(t){return new nm(t)})),this.register((function(t){return new cm(t)})),this.register((function(t){return new sm(t)})),this.register((function(t){return new um(t)})),this.register((function(t){return new dm(t)})),this.register((function(t){return new tm(t)})),this.register((function(t){return new gm(t)})),this.register((function(t){return new _m(t)}))}load(t,e,n,i){const r=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const e=Zu.extractUrlBase(t);s=Zu.resolveURL(e,this.path)}else s=Zu.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){i?i(e):console.error(e),r.manager.itemError(t),r.manager.itemEnd(t)},o=new Iu(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){try{r.parse(n,s,(function(n){e(n),r.manager.itemEnd(t)}),a)}catch(t){a(t)}}),n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const s={},a={},o=new TextDecoder;if("string"==typeof t)r=JSON.parse(t);else if(t instanceof ArrayBuffer){if(o.decode(new Uint8Array(t,0,4))===vm){try{s[$f.KHR_BINARY_GLTF]=new Sm(t)}catch(t){return void(i&&i(t))}r=JSON.parse(s[$f.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t))}else r=t;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new jm(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](l);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[e.name]=e,s[e.name]=!0}if(r.extensionsUsed)for(let t=0;t<r.extensionsUsed.length;++t){const e=r.extensionsUsed[t],n=r.extensionsRequired||[];switch(e){case $f.KHR_MATERIALS_UNLIT:s[e]=new em;break;case $f.KHR_DRACO_MESH_COMPRESSION:s[e]=new bm(r,this.dracoLoader);break;case $f.KHR_TEXTURE_TRANSFORM:s[e]=new Mm;break;case $f.KHR_MESH_QUANTIZATION:s[e]=new wm;break;default:n.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise((function(i,r){n.parse(t,e,i,r)}))}}function Jf(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const $f={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class tm{constructor(t){this.parser=t,this.name=$f.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let i=e.cache.get(n);if(i)return i;const r=e.json,s=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let a;const o=new Ka(16777215);void 0!==s.color&&o.setRGB(s.color[0],s.color[1],s.color[2],wr);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new qu(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new ju(o),a.distance=l;break;case"spot":a=new Gu(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,zm(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),i=Promise.resolve(a),e.cache.add(n,i),i}getDependency(t,e){if("light"===t)return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,i=n.json.nodes[t],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(t){return n._getNodeRef(e.cache,r,t)}))}}class em{constructor(){this.name=$f.KHR_MATERIALS_UNLIT}getMaterialType(){return $a}extendParams(t,e,n){const i=[];t.color=new Ka(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],wr),t.opacity=e[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(t,"map",r.baseColorTexture,Mr))}return Promise.all(i)}}class nm{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(e.emissiveIntensity=i),Promise.resolve()}}class im{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&r.push(n.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(r.push(n.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new Jr(t,t)}return Promise.all(r)}}class rm{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_DISPERSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class sm{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.iridescenceFactor&&(e.iridescence=s.iridescenceFactor),void 0!==s.iridescenceTexture&&r.push(n.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),void 0!==s.iridescenceIor&&(e.iridescenceIOR=s.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==s.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),void 0!==s.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),void 0!==s.iridescenceThicknessTexture&&r.push(n.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class am{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Ka(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=i.extensions[this.name];if(void 0!==s.sheenColorFactor){const t=s.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],wr)}return void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&r.push(n.assignTexture(e,"sheenColorMap",s.sheenColorTexture,Mr)),void 0!==s.sheenRoughnessTexture&&r.push(n.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class om{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&r.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class lm{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&r.push(n.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=(new Ka).setRGB(a[0],a[1],a[2],wr),Promise.all(r)}}class hm{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class cm{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&r.push(n.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=(new Ka).setRGB(a[0],a[1],a[2],wr),void 0!==s.specularColorTexture&&r.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture,Mr)),Promise.all(r)}}class dm{constructor(t){this.parser=t,this.name=$f.EXT_MATERIALS_BUMP}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return e.bumpScale=void 0!==s.bumpFactor?s.bumpFactor:1,void 0!==s.bumpTexture&&r.push(n.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class um{constructor(t){this.parser=t,this.name=$f.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?ou:null}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return void 0!==s.anisotropyStrength&&(e.anisotropy=s.anisotropyStrength),void 0!==s.anisotropyRotation&&(e.anisotropyRotation=s.anisotropyRotation),void 0!==s.anisotropyTexture&&r.push(n.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class pm{constructor(t){this.parser=t,this.name=$f.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class fm{constructor(t){this.parser=t,this.name=$f.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class mm{constructor(t){this.parser=t,this.name=$f.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class gm{constructor(t){this.name=$f.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class _m{constructor(t){this.name=$f.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const t of i.primitives)if(t.mode!==Cm.TRIANGLES&&t.mode!==Cm.TRIANGLE_STRIP&&t.mode!==Cm.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const t of n){const e=new ia,n=new As,s=new Ts,o=new As(1,1,1),l=new Id(t.geometry,t.material,i);for(let t=0;t<i;t++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,t),a.ROTATION&&s.fromBufferAttribute(a.ROTATION,t),a.SCALE&&o.fromBufferAttribute(a.SCALE,t),l.setMatrixAt(t,e.compose(n,s,o));for(const e in a)if("_COLOR_0"===e){const t=a[e];l.instanceColor=new wd(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,a[e]);Pa.prototype.copy.call(l,t),this.parser.assignFinalMaterial(l),r.push(l)}return e.isGroup?(e.clear(),e.add(...r),e):r[0]})))}}const vm="glTF",ym=1313821514,xm=5130562;class Sm{constructor(t){this.name=$f.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==vm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(t,12);let s=0;for(;s<i;){const e=r.getUint32(s,!0);s+=4;const i=r.getUint32(s,!0);if(s+=4,i===ym){const i=new Uint8Array(t,12+s,e);this.content=n.decode(i)}else if(i===xm){const n=12+s;this.body=t.slice(n,n+e)}s+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class bm{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=$f.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},l={};for(const t in s){const e=Dm[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const i=Dm[e]||e.toLowerCase();if(void 0!==s[e]){const r=n.accessors[t.attributes[e]],s=Rm[r.componentType];l[i]=s.name,o[i]=!0===r.normalized}}return e.getDependency("bufferView",r).then((function(t){return new Promise((function(e,n){i.decodeDracoFile(t,(function(t){for(const e in t.attributes){const n=t.attributes[e],i=o[e];void 0!==i&&(n.normalized=i)}e(t)}),a,l,wr,n)}))}))}}class Mm{constructor(){this.name=$f.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class wm{constructor(){this.name=$f.KHR_MESH_QUANTIZATION}}class Em extends uu{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let t=0;t!==i;t++)e[t]=n[r+t];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,h=i-e,c=(n-e)/h,d=c*c,u=d*c,p=t*l,f=p-l,m=-2*u+3*d,g=u-d,_=1-m,v=g-d+c;for(let t=0;t!==a;t++){const e=s[f+t+a],n=s[f+t+o]*h,i=s[p+t+a],l=s[p+t]*h;r[t]=_*e+v*n+m*i+g*l}return r}}const Tm=new Ts;class Am extends Em{interpolate_(t,e,n,i){const r=super.interpolate_(t,e,n,i);return Tm.fromArray(r).normalize().toArray(r),r}}const Cm={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Rm={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pm={9728:di,9729:fi,9984:1004,9985:mi,9986:pi,9987:gi},Lm={33071:hi,33648:ci,10497:li},Im={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Dm={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Nm={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Um={CUBICSPLINE:void 0,LINEAR:xr,STEP:yr},Om="OPAQUE",Fm="MASK",km="BLEND";function Bm(t,e,n){for(const i in n.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function zm(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Gm(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,i=e.weights.length;n<i;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,i=n.length;e<i;e++)t.morphTargetDictionary[n[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Hm(t){let e;const n=t.extensions&&t.extensions[$f.KHR_DRACO_MESH_COMPRESSION];if(e=n?"draco:"+n.bufferView+":"+n.indices+":"+Vm(n.attributes):t.indices+":"+Vm(t.attributes)+":"+t.mode,void 0!==t.targets)for(let n=0,i=t.targets.length;n<i;n++)e+=":"+Vm(t.targets[n]);return e}function Vm(t){let e="";const n=Object.keys(t).sort();for(let i=0,r=n.length;i<r;i++)e+=n[i]+":"+t[n[i]]+";";return e}function Wm(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Xm=new ia;class jm{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Jf,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);i=n&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new Nu(this.options.manager):this.textureLoader=new Qu(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Iu(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return Bm(r,s,i),zm(s,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const i=e[n].joints;for(let e=0,n=i.length;e<n;e++)t[i[e]].isBone=!0}for(let e=0,i=t.length;e<i;e++){const i=t[e];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),r=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne((function(t){return t.loadNode&&t.loadNode(e)}));break;case"mesh":i=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":i=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne((function(t){return t.loadAnimation&&t.loadAnimation(e)}));break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(t,e)})),!i)throw new Error("Unknown type: "+t)}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map((function(e,i){return n.getDependency(t,i)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[$f.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(t,r){n.load(Zu.resolveURL(e.uri,i.path),t,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const n=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+n)}))}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse){const t=Im[i.type],e=Rm[i.componentType],n=!0===i.normalized,r=new e(i.count*t);return Promise.resolve(new no(r,t,n))}const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(t){const r=t[0],s=Im[i.type],a=Rm[i.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,h=i.byteOffset||0,c=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,d=!0===i.normalized;let u,p;if(c&&c!==l){const t=Math.floor(h/c),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+t+":"+i.count;let l=e.cache.get(n);l||(u=new a(r,t*c,i.count*c/o),l=new Wc(u,c/o),e.cache.add(n,l)),p=new jc(l,s,h%c/o,d)}else u=null===r?new a(i.count*s):new a(r,h,i.count*s),p=new no(u,s,d);if(void 0!==i.sparse){const e=Im.SCALAR,n=Rm[i.sparse.indices.componentType],o=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,h=new n(t[1],o,i.sparse.count*e),c=new a(t[2],l,i.sparse.count*s);null!==r&&(p=new no(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let t=0,e=h.length;t<e;t++){const e=h[t];if(p.setX(e,c[t*s]),s>=2&&p.setY(e,c[t*s+1]),s>=3&&p.setZ(e,c[t*s+2]),s>=4&&p.setW(e,c[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p}))}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,n).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return e.magFilter=Pm[n.magFilter]||fi,e.minFilter=Pm[n.minFilter]||gi,e.wrapS=Lm[n.wrapS]||li,e.wrapT=Lm[n.wrapT]||li,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==di&&e.minFilter!==fi,i.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(t,e){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const s=i.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then((function(t){l=!0;const e=new Blob([t],{type:s.mimeType});return o=a.createObjectURL(e),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(o).then((function(t){return new Promise((function(n,i){let s=n;!0===e.isImageBitmapLoader&&(s=function(t){const e=new xs(t);e.needsUpdate=!0,n(e)}),e.load(Zu.resolveURL(t,r.path),s,void 0,i)}))})).then((function(t){var e;return!0===l&&a.revokeObjectURL(o),zm(t,s),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t}));return this.sourceCache[t]=h,h}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[$f.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[$f.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[$f.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Yd,Ja.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Dd,Ja.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||s){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return au}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},o=[];if((r.extensions||{})[$f.KHR_MATERIALS_UNLIT]){const t=i[$f.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new Ka(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],wr),a.opacity=t[3]}void 0!==n.baseColorTexture&&o.push(e.assignTexture(a,"map",n.baseColorTexture,Mr)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=2);const l=r.alphaMode||Om;if(l===km?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===Fm&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==$a&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Jr(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==$a&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==$a){const t=r.emissiveFactor;a.emissive=(new Ka).setRGB(t[0],t[1],t[2],wr)}return void 0!==r.emissiveTexture&&s!==$a&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Mr)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),zm(n,r),e.associations.set(n,{materials:t}),r.extensions&&Bm(i,n,r),n}))}createUniqueName(t){const e=ap.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[$f.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return Ym(n,t,e)}))}const s=[];for(let n=0,a=t.length;n<a;n++){const a=t[n],o=Hm(a),l=i[o];if(l)s.push(l.promise);else{let t;t=a.extensions&&a.extensions[$f.KHR_DRACO_MESH_COMPRESSION]?r(a):Ym(new fo,a,e),i[o]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,i=this.extensions,r=n.meshes[t],s=r.primitives,a=[];for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new au({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:vn})),o.DefaultMaterial):this.getDependency("material",s[t].material);a.push(e)}var o;return a.push(e.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,h=o.length;n<h;n++){const h=o[n],c=s[n];let d;const u=a[n];if(c.mode===Cm.TRIANGLES||c.mode===Cm.TRIANGLE_STRIP||c.mode===Cm.TRIANGLE_FAN||void 0===c.mode)d=!0===r.isSkinnedMesh?new vd(h,u):new To(h,u),!0===d.isSkinnedMesh&&d.normalizeSkinWeights(),c.mode===Cm.TRIANGLE_STRIP?d.geometry=Zf(d.geometry,1):c.mode===Cm.TRIANGLE_FAN&&(d.geometry=Zf(d.geometry,2));else if(c.mode===Cm.LINES)d=new Xd(h,u);else if(c.mode===Cm.LINE_STRIP)d=new Gd(h,u);else if(c.mode===Cm.LINE_LOOP)d=new jd(h,u);else{if(c.mode!==Cm.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);d=new Jd(h,u)}Object.keys(d.geometry.morphAttributes).length>0&&Gm(d,r),d.name=e.createUniqueName(r.name||"mesh_"+t),zm(d,r),c.extensions&&Bm(i,d,c),e.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n<i;n++)e.associations.set(l[n],{meshes:t,primitives:n});if(1===l.length)return r.extensions&&Bm(i,l[0],r),l[0];const h=new Dc;r.extensions&&Bm(i,h,r),e.associations.set(h,{meshes:t});for(let t=0,e=l.length;t<e;t++)h.add(l[t]);return h}))}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type];if(i)return"perspective"===n.type?e=new ko(Qr.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(e=new dl(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),zm(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],n=[];for(let t=0,i=e.joints.length;t<i;t++)n.push(this._loadNodeShallow(e.joints[t]));return void 0!==e.inverseBindMatrices?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(t){const n=t.pop(),i=t,r=[],s=[];for(let t=0,a=i.length;t<a;t++){const a=i[t];if(a){r.push(a);const e=new ia;null!==n&&e.fromArray(n.array,16*t),s.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}return new Md(r,s)}))}loadAnimation(t){const e=this.json,n=this,i=e.animations[t],r=i.name?i.name:"animation_"+t,s=[],a=[],o=[],l=[],h=[];for(let t=0,e=i.channels.length;t<e;t++){const e=i.channels[t],n=i.samplers[e.sampler],r=e.target,c=r.node,d=void 0!==i.parameters?i.parameters[n.input]:n.input,u=void 0!==i.parameters?i.parameters[n.output]:n.output;void 0!==r.node&&(s.push(this.getDependency("node",c)),a.push(this.getDependency("accessor",d)),o.push(this.getDependency("accessor",u)),l.push(n),h.push(r))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(h)]).then((function(t){const e=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=[];for(let t=0,r=e.length;t<r;t++){const r=e[t],h=i[t],c=s[t],d=a[t],u=o[t];if(void 0===r)continue;r.updateMatrix&&r.updateMatrix();const p=n._createAnimationTracks(r,h,c,d,u);if(p)for(let t=0;t<p.length;t++)l.push(p[t])}return new wu(r,void 0,l)}))}createNodeMesh(t){const e=this.json,n=this,i=e.nodes[t];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(t){const e=n._getNodeRef(n.meshCache,i.mesh,t);return void 0!==i.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,n=i.weights.length;e<n;e++)t.morphTargetInfluences[e]=i.weights[e]})),e}))}loadNode(t){const e=this,n=this.json.nodes[t],i=e._loadNodeShallow(t),r=[],s=n.children||[];for(let t=0,n=s.length;t<n;t++)r.push(e.getDependency("node",s[t]));const a=void 0===n.skin?Promise.resolve(null):e.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),a]).then((function(t){const e=t[0],n=t[1],i=t[2];null!==i&&e.traverse((function(t){t.isSkinnedMesh&&t.bind(i,Xm)}));for(let t=0,i=n.length;t<i;t++)e.add(n[t]);return e}))}_loadNodeShallow(t){const e=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const r=e.nodes[t],s=r.name?i.createUniqueName(r.name):"",a=[],o=i._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return o&&a.push(o),void 0!==r.camera&&a.push(i.getDependency("camera",r.camera).then((function(t){return i._getNodeRef(i.cameraCache,r.camera,t)}))),i._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){a.push(t)})),this.nodeCache[t]=Promise.all(a).then((function(e){let a;if(a=!0===r.isBone?new yd:e.length>1?new Dc:1===e.length?e[0]:new Pa,a!==e[0])for(let t=0,n=e.length;t<n;t++)a.add(e[t]);if(r.name&&(a.userData.name=r.name,a.name=s),zm(a,r),r.extensions&&Bm(n,a,r),void 0!==r.matrix){const t=new ia;t.fromArray(r.matrix),a.applyMatrix4(t)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=t,a})),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],i=this,r=new Dc;n.name&&(r.name=i.createUniqueName(n.name)),zm(r,n),n.extensions&&Bm(e,r,n);const s=n.nodes||[],a=[];for(let t=0,e=s.length;t<e;t++)a.push(i.getDependency("node",s[t]));return Promise.all(a).then((function(t){for(let e=0,n=t.length;e<n;e++)r.add(t[e]);return i.associations=(t=>{const e=new Map;for(const[t,n]of i.associations)(t instanceof Ja||t instanceof xs)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(r),r}))}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(Nm[r.path]===Nm.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),Nm[r.path]){case Nm.weights:l=yu;break;case Nm.rotation:l=Su;break;case Nm.position:case Nm.scale:l=Mu;break;default:if(1===n.itemSize)l=yu;else l=Mu}const h=void 0!==i.interpolation?Um[i.interpolation]:xr,c=this._getArrayFromAccessor(n);for(let t=0,n=o.length;t<n;t++){const n=new l(o[t]+"."+Nm[r.path],e.array,c,h);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(n),s.push(n)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const t=Wm(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*t;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof Su?Am:Em)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ym(t,e,n){const i=e.attributes,r=[];function s(e,i){return n.getDependency("accessor",e).then((function(e){t.setAttribute(i,e)}))}for(const e in i){const n=Dm[e]||e.toLowerCase();n in t.attributes||r.push(s(i[e],n))}if(void 0!==e.indices&&!t.index){const i=n.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));r.push(i)}return as.workingColorSpace!==wr&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${as.workingColorSpace}" not supported.`),zm(t,e),function(t,e,n){const i=e.attributes,r=new Ps;if(void 0===i.POSITION)return;{const t=n.json.accessors[i.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new As(e[0],e[1],e[2]),new As(s[0],s[1],s[2])),t.normalized){const e=Wm(Rm[t.componentType]);r.min.multiplyScalar(e),r.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new As,e=new As;for(let i=0,r=s.length;i<r;i++){const r=s[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],s=i.min,a=i.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),i.normalized){const t=Wm(Rm[i.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(t)}t.boundingBox=r;const a=new qs;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,t.boundingSphere=a}(t,e,n),Promise.all(r).then((function(){return void 0!==e.targets?function(t,e,n){let i=!1,r=!1,s=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(t);const a=[],o=[],l=[];for(let h=0,c=e.length;h<c;h++){const c=e[h];if(i){const e=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):t.attributes.position;a.push(e)}if(r){const e=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):t.attributes.normal;o.push(e)}if(s){const e=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):t.attributes.color;l.push(e)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then((function(e){const n=e[0],a=e[1],o=e[2];return i&&(t.morphAttributes.position=n),r&&(t.morphAttributes.normal=a),s&&(t.morphAttributes.color=o),t.morphTargetsRelative=!0,t}))}(t,e.targets,n):t}))}class qm extends Au{constructor(t,e=new Map,n={}){super(),this.path="",this.resourcePath="",this.fileURL="",this.dataURLs=new Map,this.path=n.path||"","string"==typeof t?(this.fileURL=t,this.resourcePath=Zu.extractUrlBase(t)):(e.forEach(((e,n)=>this.fileURL=e===t?n:this.fileURL)),e.set(this.fileURL,t)),e.forEach(((t,e)=>{let n;n="string"==typeof t?t:URL.createObjectURL(new Blob([t])),this.dataURLs.set(e,n)})),this.setURLModifier((t=>{const e=decodeURI(t).replace(this.path,"").replace(this.resourcePath,"").replace(/^(\.?\/)/,""),n=this.dataURLs.get(e);return null!=n?n:t}))}dispose(){this.dataURLs.forEach(URL.revokeObjectURL)}}class Km{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 n=this._listeners[t].filter((t=>t!==e));return 0!==n.length?this._listeners[t]=n: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)}}t.CANVAS_EVENTS=p,t.CanvasEvents=u,t.Component=class{constructor(t){this.name=""}dispose(){}},t.Dragger=class{constructor(t){this.name=""}dispose(){}},t.Markup=an,t.Options=d,t.Viewer=class extends Km{constructor(t){super(),this._options=new d(this),this.client=t,this.canvasEvents=p,this.canvaseventlistener=t=>this.emit(t),this.models=[],this.selected=[],this.extents=new Ps,this.target=new As,this._activeDragger=null,this._components=[],this.renderTime=0,this.render=this.render.bind(this),this.update=this.update.bind(this),this._markup=new an}get options(){return this._options}get draggers(){return[...Lf.getDraggers().keys()]}get components(){return[...Kf.getComponents().keys()]}get markup(){return this._markup}initialize(t,e){this.addEventListener("optionschange",(t=>this.syncOptions(t.data))),this.scene=new Vc,this.helpers=new Vc;const n=t.parentElement.getBoundingClientRect(),i=n.width||1,r=n.height||1;this.camera=new ko(45,i/r,.01,1e3),this.camera.up.set(0,0,1),this.renderer=new Hc({canvas:t,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(i,r),this.renderer.toneMapping=Qn,this.canvas=t,this.canvasEvents.forEach((e=>t.addEventListener(e,this.canvaseventlistener))),this._markup.initialize(this.canvas,this.canvasEvents,this,this);for(let t of Kf.getComponents().keys())this._components.push(Kf.createComponent(t,this));return this.syncOptions(),this.syncOverlay(),this.renderTime=performance.now(),this.render(this.renderTime),"function"==typeof e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:1,total:1})),this.emitEvent({type:"initializeprogress",data:1,loaded:1,total:1}),this.emitEvent({type:"initialize"}),Promise.resolve(this)}dispose(){return this.cancel(),this.emitEvent({type:"dispose"}),this._components.forEach((t=>t.dispose())),this._components=[],this.setActiveDragger(),this.removeAllListeners(),this.clear(),this._markup.dispose(),this.canvas&&(this.canvasEvents.forEach((t=>this.canvas.removeEventListener(t,this.canvaseventlistener))),this.canvas=void 0),this.renderer&&this.renderer.dispose(),this.renderer=void 0,this.camera=void 0,this.scene=void 0,this.helpers=void 0,this}isInitialized(){return!!this.renderer}render(t){var e,n;if(!this.renderNeeded)return;if(!this.renderer)return;this.renderNeeded=!1,this.renderer.setViewport(0,0,this.canvas.offsetWidth,this.canvas.offsetHeight),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);const i=this.renderer.clippingPlanes;this.renderer.clippingPlanes=[],this.renderer.autoClear=!1,this.renderer.render(this.helpers,this.camera),this.renderer.clippingPlanes=i,null===(n=null===(e=this._activeDragger)||void 0===e?void 0:e.updatePreview)||void 0===n||n.call(e);const r=(t-this.renderTime)/1e3;this.renderTime=t,this.emitEvent({type:"render",time:t,deltaTime:r})}update(t=!1){this.renderNeeded=!0,t&&this.render(performance.now()),this.emitEvent({type:"update",data:t})}syncOptions(t=this.options){}loadReferences(t){return Promise.resolve(this)}async open(t){if(!this.renderer)return this;let e;if(this.cancel(),this.clear(),this.emitEvent({type:"open",file:t,model:t}),t){const n=await t.getModels()||[];e=n.find((t=>t.default))||n[0]}if(!e)throw new Error("No default model found");const n=e.database.split(".").pop();if("gltf"!==n)throw new Error(`Unknown geometry type: ${n}`);const i=`${e.httpClient.serverUrl}${e.path}/${e.database}`,r={requestHeader:e.httpClient.headers};return await this.loadReferences(e),await this.loadGltfFile(i,void 0,r),this}cancel(){return this.emitEvent({type:"cancel"}),this}openGltfFile(t,e=new Map,n={}){return this.renderer?(this.cancel(),this.clear(),this.emitEvent({type:"open"}),this.loadGltfFile(t,e,n)):Promise.resolve(this)}async loadGltfFile(t,e=new Map,n={}){const i=new qm(t,e,n);try{this.emitEvent({type:"geometrystart"});const t=new Qf(i);t.setPath(i.path),t.setRequestHeader(n.requestHeader),t.setCrossOrigin(n.crossOrigin||t.crossOrigin),t.setWithCredentials(n.withCredentials||t.withCredentials);const e=await t.loadAsync(i.fileURL,(t=>{const{lengthComputable:e,loaded:n,total:i}=t,r=e?n/i:1;this.emitEvent({type:"geometryprogress",data:r})}));if(!this.scene)return this;if(!e.scene)throw new Error("No glTF scene found");this.models.push(e),this.scene.add(e.scene),this.syncOptions(),this.syncOverlay(),this.update(),this.emitEvent({type:"databasechunk"}),this.emitEvent({type:"geometryend",data:e.scene})}catch(t){throw this.emitEvent({type:"geometryerror",data:t}),t}finally{i.dispose()}return this}clear(){if(!this.renderer)return this;function t(t){var e;t.geometry&&t.geometry.dispose(),t.material&&(e=t.material,(Array.isArray(e)?e:[e]).forEach((t=>{t.dispose()})))}return this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.helpers.traverse(t),this.helpers.clear(),this.models.forEach((e=>e.scene.traverse(t))),this.models.forEach((t=>t.scene.removeFromParent())),this.models=[],this.scene.clear(),this.syncOptions(),this.syncOverlay(),this.update(!0),this.emitEvent({type:"clear"}),this}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")}setSelected(t){this.executeCommand("setSelected",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=""){var e,n;if(!this._activeDragger||this._activeDragger.name!==t){const i=this._activeDragger;let r=null;this._activeDragger&&(this._activeDragger.dispose(),this._activeDragger=null),this.isInitialized()&&(r=Lf.createDragger(t,this),r&&(this._activeDragger=r,null===(n=(e=this._activeDragger).initialize)||void 0===n||n.call(e)));const s=this.canvas;s&&(i&&s.classList.remove(`oda-cursor-${i.name.toLowerCase()}`),r&&s.classList.add(`oda-cursor-${r.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))}is3D(){return!0}screenToWorld(t){if(!this.renderer)return{x:t.x,y:t.y,z:0};const e=this.canvas.getBoundingClientRect(),n=t.x/(e.width/2)-1,i=-t.y/(e.height/2)+1,r=new As(n,i,-1);return r.unproject(this.camera),{x:r.x,y:r.y,z:r.z}}worldToScreen(t){if(!this.renderer)return{x:t.x,y:t.y};const e=new As(t.x,t.y,t.z);e.project(this.camera);const n=this.canvas.getBoundingClientRect();return{x:(e.x+1)*(n.width/2),y:(1-e.y)*(n.height/2)}}getScale(){return{x:1,y:1,z:1}}executeCommand(t,...e){return kf.executeCommand(t,this,...e)}getComponent(t){return this._components.find((e=>e.name===t))}drawViewpoint(t){var e,n,i;if(!this.renderer)return;const r=({x:t,y:e,z:n})=>new As(t,e,n),s=null===(e=this._activeDragger)||void 0===e?void 0:e.name;this.setActiveDragger(),this.clearSlices(),this.clearOverlay(),this.clearSelected(),this.showAll(),this.explode(),(t=>{t&&(this.camera.up.copy(r(t.up_vector)),this.camera.fov=t.field_of_view,this.camera.position.copy(r(t.view_point)),this.camera.lookAt(r(t.direction).add(this.camera.position)),this.camera.updateMatrixWorld(),this.camera.updateProjectionMatrix())})(t.perspective_camera),(t=>{null==t||t.forEach((t=>{const e=new jo;e.setFromNormalAndCoplanarPoint(r(t.direction),r(t.location)),this.renderer.clippingPlanes.push(e)}))})(t.clipping_planes),(t=>{this.setSelected(null==t?void 0:t.map((t=>t.handle)))})(t.selection),this._markup.setViewpoint(t),this.target=r(null!==(i=null===(n=t.custom_fields)||void 0===n?void 0:n.camera_target)&&void 0!==i?i:this.target),this.setActiveDragger(s),this.emitEvent({type:"drawviewpoint",data:t}),this.update()}createViewpoint(){if(!this.renderer)return{};const t=({x:t,y:e,z:n})=>({x:t,y:e,z:n}),e={custom_fields:{}};return e.perspective_camera=(()=>({view_point:t(this.camera.position),direction:t(this.camera.getWorldDirection(new As)),up_vector:t(this.camera.up),field_of_view:this.camera.fov}))(),e.clipping_planes=(()=>{const e=[];return this.renderer.clippingPlanes.forEach((n=>{const i={location:t(n.coplanarPoint(new As)),direction:t(n.normal)};e.push(i)})),e})(),e.selection=(()=>this.getSelected().map((t=>({handle:t}))))(),e.description=(new Date).toDateString(),this._markup.getViewpoint(e),e.custom_fields.camera_target=t(this.target),this.emitEvent({type:"createviewpoint",data:e}),e}},t.commands=kf,t.commandsRegistry=i,t.components=Kf,t.componentsRegistry=h,t.defaultOptions=c,t.draggers=Lf,t.draggersRegistry=a}));
|