@tresjs/cientos 3.0.0 → 3.1.0
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/trescientos.umd.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/cientos
|
|
3
|
-
* version: v3.
|
|
3
|
+
* version: v3.1.0
|
|
4
4
|
* (c) 2023
|
|
5
5
|
* description: Collection of useful helpers and fully functional, ready-made abstractions for Tres
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
(function($,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("vue"),require("three"),require("@tresjs/core")):typeof define=="function"&&define.amd?define(["exports","vue","three","@tresjs/core"],_):($=typeof globalThis<"u"?globalThis:$||self,_($.trescientos={},$.Vue,$.Three,$.TresjsCore))})(this,function($,_,m,Ae){"use strict";var bd=Object.defineProperty;var wd=($,_,m)=>_ in $?bd($,_,{enumerable:!0,configurable:!0,writable:!0,value:m}):$[_]=m;var ao=($,_,m)=>(wd($,typeof _!="symbol"?_+"":_,m),m);function Ua(v,t){for(var n=0;n<t.length;n++){const i=t[n];if(typeof i!="string"&&!Array.isArray(i)){for(const o in i)if(o!=="default"&&!(o in v)){const a=Object.getOwnPropertyDescriptor(i,o);a&&Object.defineProperty(v,o,a.get?a:{enumerable:!0,get:()=>i[o]})}}}return Object.freeze(Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}))}function lo(v,t){if(t===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),v;if(t===m.TriangleFanDrawMode||t===m.TriangleStripDrawMode){let n=v.getIndex();if(n===null){const c=[],p=v.getAttribute("position");if(p!==void 0){for(let d=0;d<p.count;d++)c.push(d);v.setIndex(c),n=v.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),v}const i=n.count-2,o=[];if(n)if(t===m.TriangleFanDrawMode)for(let c=1;c<=i;c++)o.push(n.getX(0)),o.push(n.getX(c)),o.push(n.getX(c+1));else for(let c=0;c<i;c++)c%2===0?(o.push(n.getX(c)),o.push(n.getX(c+1)),o.push(n.getX(c+2))):(o.push(n.getX(c+2)),o.push(n.getX(c+1)),o.push(n.getX(c)));o.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=v.clone();return a.setIndex(o),a.clearGroups(),a}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),v}var rt=Uint8Array,jt=Uint16Array,Vi=Uint32Array,co=new rt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ho=new rt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),za=new rt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),po=function(v,t){for(var n=new jt(31),i=0;i<31;++i)n[i]=t+=1<<v[i-1];for(var o=new Vi(n[30]),i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)o[a]=a-n[i]<<5|i;return[n,o]},uo=po(co,2),mo=uo[0],Ra=uo[1];mo[28]=258,Ra[258]=28;for(var ja=po(ho,0),Ga=ja[0],Ii=new jt(32768),Ee=0;Ee<32768;++Ee){var Gt=(Ee&43690)>>>1|(Ee&21845)<<1;Gt=(Gt&52428)>>>2|(Gt&13107)<<2,Gt=(Gt&61680)>>>4|(Gt&3855)<<4,Ii[Ee]=((Gt&65280)>>>8|(Gt&255)<<8)>>>1}for(var ps=function(v,t,n){for(var i=v.length,o=0,a=new jt(t);o<i;++o)++a[v[o]-1];var c=new jt(t);for(o=0;o<t;++o)c[o]=c[o-1]+a[o-1]<<1;var p;if(n){p=new jt(1<<t);var d=15-t;for(o=0;o<i;++o)if(v[o])for(var g=o<<4|v[o],y=t-v[o],b=c[v[o]-1]++<<y,C=b|(1<<y)-1;b<=C;++b)p[Ii[b]>>>d]=g}else for(p=new jt(i),o=0;o<i;++o)v[o]&&(p[o]=Ii[c[v[o]-1]++]>>>15-v[o]);return p},us=new rt(288),Ee=0;Ee<144;++Ee)us[Ee]=8;for(var Ee=144;Ee<256;++Ee)us[Ee]=9;for(var Ee=256;Ee<280;++Ee)us[Ee]=7;for(var Ee=280;Ee<288;++Ee)us[Ee]=8;for(var fo=new rt(32),Ee=0;Ee<32;++Ee)fo[Ee]=5;var Ka=ps(us,9,1),Ya=ps(fo,5,1),Bi=function(v){for(var t=v[0],n=1;n<v.length;++n)v[n]>t&&(t=v[n]);return t},ft=function(v,t,n){var i=t/8|0;return(v[i]|v[i+1]<<8)>>(t&7)&n},Fi=function(v,t){var n=t/8|0;return(v[n]|v[n+1]<<8|v[n+2]<<16)>>(t&7)},Xa=function(v){return(v/8|0)+(v&7&&1)},Za=function(v,t,n){(t==null||t<0)&&(t=0),(n==null||n>v.length)&&(n=v.length);var i=new(v instanceof jt?jt:v instanceof Vi?Vi:rt)(n-t);return i.set(v.subarray(t,n)),i},qa=function(v,t,n){var i=v.length;if(!i||n&&!n.l&&i<5)return t||new rt(0);var o=!t||n,a=!n||n.i;n||(n={}),t||(t=new rt(i*3));var c=function(ze){var Ge=t.length;if(ze>Ge){var Te=new rt(Math.max(Ge*2,ze));Te.set(t),t=Te}},p=n.f||0,d=n.p||0,g=n.b||0,y=n.l,b=n.d,C=n.m,A=n.n,E=i*8;do{if(!y){n.f=p=ft(v,d,1);var k=ft(v,d+1,3);if(d+=3,k)if(k==1)y=Ka,b=Ya,C=9,A=5;else if(k==2){var F=ft(v,d,31)+257,M=ft(v,d+10,15)+4,D=F+ft(v,d+5,31)+1;d+=14;for(var U=new rt(D),S=new rt(19),T=0;T<M;++T)S[za[T]]=ft(v,d+T*3,7);d+=M*3;for(var j=Bi(S),X=(1<<j)-1,Z=ps(S,j,1),T=0;T<D;){var J=Z[ft(v,d,X)];d+=J&15;var O=J>>>4;if(O<16)U[T++]=O;else{var le=0,he=0;for(O==16?(he=3+ft(v,d,3),d+=2,le=U[T-1]):O==17?(he=3+ft(v,d,7),d+=3):O==18&&(he=11+ft(v,d,127),d+=7);he--;)U[T++]=le}}var oe=U.subarray(0,F),re=U.subarray(F);C=Bi(oe),A=Bi(re),y=ps(oe,C,1),b=ps(re,A,1)}else throw"invalid block type";else{var O=Xa(d)+4,R=v[O-4]|v[O-3]<<8,N=O+R;if(N>i){if(a)throw"unexpected EOF";break}o&&c(g+R),t.set(v.subarray(O,N),g),n.b=g+=R,n.p=d=N*8;continue}if(d>E){if(a)throw"unexpected EOF";break}}o&&c(g+131072);for(var ne=(1<<C)-1,H=(1<<A)-1,Ce=d;;Ce=d){var le=y[Fi(v,d)&ne],ge=le>>>4;if(d+=le&15,d>E){if(a)throw"unexpected EOF";break}if(!le)throw"invalid length/literal";if(ge<256)t[g++]=ge;else if(ge==256){Ce=d,y=null;break}else{var de=ge-254;if(ge>264){var T=ge-257,me=co[T];de=ft(v,d,(1<<me)-1)+mo[T],d+=me}var ke=b[Fi(v,d)&H],B=ke>>>4;if(!ke)throw"invalid distance";d+=ke&15;var re=Ga[B];if(B>3){var me=ho[B];re+=Fi(v,d)&(1<<me)-1,d+=me}if(d>E){if(a)throw"unexpected EOF";break}o&&c(g+131072);for(var we=g+de;g<we;g+=4)t[g]=t[g-re],t[g+1]=t[g+1-re],t[g+2]=t[g+2-re],t[g+3]=t[g+3-re];g=we}}n.l=y,n.p=Ce,n.b=g,y&&(p=1,n.m=C,n.d=b,n.n=A)}while(!p);return g==t.length?t:Za(t,0,g)},Qa=new rt(0),Wa=function(v){if((v[0]&15)!=8||v[0]>>>4>7||(v[0]<<8|v[1])%31)throw"invalid zlib data";if(v[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Ja(v,t){return qa((Wa(v),v.subarray(2,-4)),t)}var Ha=typeof TextDecoder<"u"&&new TextDecoder,$a=0;try{Ha.decode(Qa,{stream:!0}),$a=1}catch{}var el=Object.defineProperty,tl=(v,t,n)=>t in v?el(v,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):v[t]=n,K=(v,t,n)=>(tl(v,typeof t!="symbol"?t+"":t,n),n);class nl extends m.Object3D{constructor(t,n){super(),K(this,"isTransformControls",!0),K(this,"visible",!1),K(this,"domElement"),K(this,"raycaster",new m.Raycaster),K(this,"gizmo"),K(this,"plane"),K(this,"tempVector",new m.Vector3),K(this,"tempVector2",new m.Vector3),K(this,"tempQuaternion",new m.Quaternion),K(this,"unit",{X:new m.Vector3(1,0,0),Y:new m.Vector3(0,1,0),Z:new m.Vector3(0,0,1)}),K(this,"pointStart",new m.Vector3),K(this,"pointEnd",new m.Vector3),K(this,"offset",new m.Vector3),K(this,"rotationAxis",new m.Vector3),K(this,"startNorm",new m.Vector3),K(this,"endNorm",new m.Vector3),K(this,"rotationAngle",0),K(this,"cameraPosition",new m.Vector3),K(this,"cameraQuaternion",new m.Quaternion),K(this,"cameraScale",new m.Vector3),K(this,"parentPosition",new m.Vector3),K(this,"parentQuaternion",new m.Quaternion),K(this,"parentQuaternionInv",new m.Quaternion),K(this,"parentScale",new m.Vector3),K(this,"worldPositionStart",new m.Vector3),K(this,"worldQuaternionStart",new m.Quaternion),K(this,"worldScaleStart",new m.Vector3),K(this,"worldPosition",new m.Vector3),K(this,"worldQuaternion",new m.Quaternion),K(this,"worldQuaternionInv",new m.Quaternion),K(this,"worldScale",new m.Vector3),K(this,"eye",new m.Vector3),K(this,"positionStart",new m.Vector3),K(this,"quaternionStart",new m.Quaternion),K(this,"scaleStart",new m.Vector3),K(this,"camera"),K(this,"object"),K(this,"enabled",!0),K(this,"axis",null),K(this,"mode","translate"),K(this,"translationSnap",null),K(this,"rotationSnap",null),K(this,"scaleSnap",null),K(this,"space","world"),K(this,"size",1),K(this,"dragging",!1),K(this,"showX",!0),K(this,"showY",!0),K(this,"showZ",!0),K(this,"changeEvent",{type:"change"}),K(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),K(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),K(this,"objectChangeEvent",{type:"objectChange"}),K(this,"intersectObjectWithRay",(o,a,c)=>{const p=a.intersectObject(o,!0);for(let d=0;d<p.length;d++)if(p[d].object.visible||c)return p[d];return!1}),K(this,"attach",o=>(this.object=o,this.visible=!0,this)),K(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),K(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),K(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),K(this,"pointerHover",o=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(o,this.camera);const a=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);a?this.axis=a.object.name:this.axis=null}),K(this,"pointerDown",o=>{if(!(this.object===void 0||this.dragging===!0||o.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(o,this.camera);const a=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(a){let c=this.space;if(this.mode==="scale"?c="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(c="world"),c==="local"&&this.mode==="rotate"){const p=this.rotationSnap;this.axis==="X"&&p&&(this.object.rotation.x=Math.round(this.object.rotation.x/p)*p),this.axis==="Y"&&p&&(this.object.rotation.y=Math.round(this.object.rotation.y/p)*p),this.axis==="Z"&&p&&(this.object.rotation.z=Math.round(this.object.rotation.z/p)*p)}this.object.updateMatrixWorld(),this.object.parent&&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(a.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),K(this,"pointerMove",o=>{const a=this.axis,c=this.mode,p=this.object;let d=this.space;if(c==="scale"?d="local":(a==="E"||a==="XYZE"||a==="XYZ")&&(d="world"),p===void 0||a===null||this.dragging===!1||o.button!==-1)return;this.raycaster.setFromCamera(o,this.camera);const g=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(g){if(this.pointEnd.copy(g.point).sub(this.worldPositionStart),c==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),d==="local"&&a!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),a.indexOf("X")===-1&&(this.offset.x=0),a.indexOf("Y")===-1&&(this.offset.y=0),a.indexOf("Z")===-1&&(this.offset.z=0),d==="local"&&a!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),p.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(d==="local"&&(p.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),a.search("X")!==-1&&(p.position.x=Math.round(p.position.x/this.translationSnap)*this.translationSnap),a.search("Y")!==-1&&(p.position.y=Math.round(p.position.y/this.translationSnap)*this.translationSnap),a.search("Z")!==-1&&(p.position.z=Math.round(p.position.z/this.translationSnap)*this.translationSnap),p.position.applyQuaternion(this.quaternionStart)),d==="world"&&(p.parent&&p.position.add(this.tempVector.setFromMatrixPosition(p.parent.matrixWorld)),a.search("X")!==-1&&(p.position.x=Math.round(p.position.x/this.translationSnap)*this.translationSnap),a.search("Y")!==-1&&(p.position.y=Math.round(p.position.y/this.translationSnap)*this.translationSnap),a.search("Z")!==-1&&(p.position.z=Math.round(p.position.z/this.translationSnap)*this.translationSnap),p.parent&&p.position.sub(this.tempVector.setFromMatrixPosition(p.parent.matrixWorld))));else if(c==="scale"){if(a.search("XYZ")!==-1){let y=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(y*=-1),this.tempVector2.set(y,y,y)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),a.search("X")===-1&&(this.tempVector2.x=1),a.search("Y")===-1&&(this.tempVector2.y=1),a.search("Z")===-1&&(this.tempVector2.z=1);p.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(a.search("X")!==-1&&(this.object.scale.x=Math.round(p.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),a.search("Y")!==-1&&(p.scale.y=Math.round(p.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),a.search("Z")!==-1&&(p.scale.z=Math.round(p.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(c==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const y=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));a==="E"?(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):a==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*y):(a==="X"||a==="Y"||a==="Z")&&(this.rotationAxis.copy(this.unit[a]),this.tempVector.copy(this.unit[a]),d==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*y),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),d==="local"&&a!=="E"&&a!=="XYZE"?(p.quaternion.copy(this.quaternionStart),p.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),p.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),p.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),K(this,"pointerUp",o=>{o.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),K(this,"getPointer",o=>{var a,c;if(this.domElement&&((a=this.domElement.ownerDocument)!=null&&a.pointerLockElement))return{x:0,y:0,button:o.button};{const p=o.changedTouches?o.changedTouches[0]:o,d=(c=this.domElement)==null?void 0:c.getBoundingClientRect();return{x:(p.clientX-d.left)/d.width*2-1,y:-(p.clientY-d.top)/d.height*2+1,button:o.button}}}),K(this,"onPointerHover",o=>{if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(o));break}}),K(this,"onPointerDown",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(o)),this.pointerDown(this.getPointer(o)))}),K(this,"onPointerMove",o=>{this.enabled&&this.pointerMove(this.getPointer(o))}),K(this,"onPointerUp",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(o)))}),K(this,"getMode",()=>this.mode),K(this,"setMode",o=>{this.mode=o}),K(this,"setTranslationSnap",o=>{this.translationSnap=o}),K(this,"setRotationSnap",o=>{this.rotationSnap=o}),K(this,"setScaleSnap",o=>{this.scaleSnap=o}),K(this,"setSize",o=>{this.size=o}),K(this,"setSpace",o=>{this.space=o}),K(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),K(this,"connect",o=>{o===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=o,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),K(this,"dispose",()=>{var o,a,c,p,d,g;(o=this.domElement)==null||o.removeEventListener("pointerdown",this.onPointerDown),(a=this.domElement)==null||a.removeEventListener("pointermove",this.onPointerHover),(p=(c=this.domElement)==null?void 0:c.ownerDocument)==null||p.removeEventListener("pointermove",this.onPointerMove),(g=(d=this.domElement)==null?void 0:d.ownerDocument)==null||g.removeEventListener("pointerup",this.onPointerUp),this.traverse(y=>{const b=y;b.geometry&&b.geometry.dispose(),b.material&&b.material.dispose()})}),this.domElement=n,this.camera=t,this.gizmo=new sl,this.add(this.gizmo),this.plane=new il,this.add(this.plane);const i=(o,a)=>{let c=a;Object.defineProperty(this,o,{get:function(){return c!==void 0?c:a},set:function(p){c!==p&&(c=p,this.plane[o]=p,this.gizmo[o]=p,this.dispatchEvent({type:o+"-changed",value:p}),this.dispatchEvent(this.changeEvent))}}),this[o]=a,this.plane[o]=a,this.gizmo[o]=a};i("camera",this.camera),i("object",this.object),i("enabled",this.enabled),i("axis",this.axis),i("mode",this.mode),i("translationSnap",this.translationSnap),i("rotationSnap",this.rotationSnap),i("scaleSnap",this.scaleSnap),i("space",this.space),i("size",this.size),i("dragging",this.dragging),i("showX",this.showX),i("showY",this.showY),i("showZ",this.showZ),i("worldPosition",this.worldPosition),i("worldPositionStart",this.worldPositionStart),i("worldQuaternion",this.worldQuaternion),i("worldQuaternionStart",this.worldQuaternionStart),i("cameraPosition",this.cameraPosition),i("cameraQuaternion",this.cameraQuaternion),i("pointStart",this.pointStart),i("pointEnd",this.pointEnd),i("rotationAxis",this.rotationAxis),i("rotationAngle",this.rotationAngle),i("eye",this.eye),n!==void 0&&this.connect(n)}}class sl extends m.Object3D{constructor(){super(),K(this,"isTransformControlsGizmo",!0),K(this,"type","TransformControlsGizmo"),K(this,"tempVector",new m.Vector3(0,0,0)),K(this,"tempEuler",new m.Euler),K(this,"alignVector",new m.Vector3(0,1,0)),K(this,"zeroVector",new m.Vector3(0,0,0)),K(this,"lookAtMatrix",new m.Matrix4),K(this,"tempQuaternion",new m.Quaternion),K(this,"tempQuaternion2",new m.Quaternion),K(this,"identityQuaternion",new m.Quaternion),K(this,"unitX",new m.Vector3(1,0,0)),K(this,"unitY",new m.Vector3(0,1,0)),K(this,"unitZ",new m.Vector3(0,0,1)),K(this,"gizmo"),K(this,"picker"),K(this,"helper"),K(this,"rotationAxis",new m.Vector3),K(this,"cameraPosition",new m.Vector3),K(this,"worldPositionStart",new m.Vector3),K(this,"worldQuaternionStart",new m.Quaternion),K(this,"worldPosition",new m.Vector3),K(this,"worldQuaternion",new m.Quaternion),K(this,"eye",new m.Vector3),K(this,"camera",null),K(this,"enabled",!0),K(this,"axis",null),K(this,"mode","translate"),K(this,"space","world"),K(this,"size",1),K(this,"dragging",!1),K(this,"showX",!0),K(this,"showY",!0),K(this,"showZ",!0),K(this,"updateMatrixWorld",()=>{let ge=this.space;this.mode==="scale"&&(ge="local");const de=ge==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let me=[];me=me.concat(this.picker[this.mode].children),me=me.concat(this.gizmo[this.mode].children),me=me.concat(this.helper[this.mode].children);for(let ke=0;ke<me.length;ke++){const B=me[ke];B.visible=!0,B.rotation.set(0,0,0),B.position.copy(this.worldPosition);let we;if(this.camera.isOrthographicCamera?we=(this.camera.top-this.camera.bottom)/this.camera.zoom:we=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),B.scale.set(1,1,1).multiplyScalar(we*this.size/7),B.tag==="helper"){B.visible=!1,B.name==="AXIS"?(B.position.copy(this.worldPositionStart),B.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),B.quaternion.copy(de).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(de).dot(this.eye))>.9&&(B.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),B.quaternion.copy(de).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(de).dot(this.eye))>.9&&(B.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),B.quaternion.copy(de).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(de).dot(this.eye))>.9&&(B.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),B.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),B.quaternion.multiply(this.tempQuaternion),B.visible=this.dragging),this.axis==="E"&&(B.visible=!1)):B.name==="START"?(B.position.copy(this.worldPositionStart),B.visible=this.dragging):B.name==="END"?(B.position.copy(this.worldPosition),B.visible=this.dragging):B.name==="DELTA"?(B.position.copy(this.worldPositionStart),B.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),B.scale.copy(this.tempVector),B.visible=this.dragging):(B.quaternion.copy(de),this.dragging?B.position.copy(this.worldPositionStart):B.position.copy(this.worldPosition),this.axis&&(B.visible=this.axis.search(B.name)!==-1));continue}B.quaternion.copy(de),this.mode==="translate"||this.mode==="scale"?((B.name==="X"||B.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(de).dot(this.eye))>.99&&(B.scale.set(1e-10,1e-10,1e-10),B.visible=!1),(B.name==="Y"||B.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(de).dot(this.eye))>.99&&(B.scale.set(1e-10,1e-10,1e-10),B.visible=!1),(B.name==="Z"||B.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(de).dot(this.eye))>.99&&(B.scale.set(1e-10,1e-10,1e-10),B.visible=!1),B.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(de).dot(this.eye))<.2&&(B.scale.set(1e-10,1e-10,1e-10),B.visible=!1),B.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(de).dot(this.eye))<.2&&(B.scale.set(1e-10,1e-10,1e-10),B.visible=!1),B.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(de).dot(this.eye))<.2&&(B.scale.set(1e-10,1e-10,1e-10),B.visible=!1),B.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(de).dot(this.eye)<0?B.tag==="fwd"?B.visible=!1:B.scale.x*=-1:B.tag==="bwd"&&(B.visible=!1)),B.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(de).dot(this.eye)<0?B.tag==="fwd"?B.visible=!1:B.scale.y*=-1:B.tag==="bwd"&&(B.visible=!1)),B.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(de).dot(this.eye)<0?B.tag==="fwd"?B.visible=!1:B.scale.z*=-1:B.tag==="bwd"&&(B.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(de),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(de).invert()),B.name.search("E")!==-1&&B.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),B.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),B.quaternion.copy(this.tempQuaternion)),B.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),B.quaternion.copy(this.tempQuaternion)),B.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),B.quaternion.copy(this.tempQuaternion))),B.visible=B.visible&&(B.name.indexOf("X")===-1||this.showX),B.visible=B.visible&&(B.name.indexOf("Y")===-1||this.showY),B.visible=B.visible&&(B.name.indexOf("Z")===-1||this.showZ),B.visible=B.visible&&(B.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),B.material.tempOpacity=B.material.tempOpacity||B.material.opacity,B.material.tempColor=B.material.tempColor||B.material.color.clone(),B.material.color.copy(B.material.tempColor),B.material.opacity=B.material.tempOpacity,this.enabled?this.axis&&(B.name===this.axis?(B.material.opacity=1,B.material.color.lerp(new m.Color(1,1,1),.5)):this.axis.split("").some(function(ze){return B.name===ze})?(B.material.opacity=1,B.material.color.lerp(new m.Color(1,1,1),.5)):(B.material.opacity*=.25,B.material.color.lerp(new m.Color(1,1,1),.5))):(B.material.opacity*=.5,B.material.color.lerp(new m.Color(1,1,1),.5))}super.updateMatrixWorld()});const t=new m.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:m.DoubleSide,fog:!1,toneMapped:!1}),n=new m.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),i=t.clone();i.opacity=.15;const o=t.clone();o.opacity=.33;const a=t.clone();a.color.set(16711680);const c=t.clone();c.color.set(65280);const p=t.clone();p.color.set(255);const d=t.clone();d.opacity=.25;const g=d.clone();g.color.set(16776960);const y=d.clone();y.color.set(65535);const b=d.clone();b.color.set(16711935),t.clone().color.set(16776960);const A=n.clone();A.color.set(16711680);const E=n.clone();E.color.set(65280);const k=n.clone();k.color.set(255);const O=n.clone();O.color.set(65535);const R=n.clone();R.color.set(16711935);const N=n.clone();N.color.set(16776960);const F=n.clone();F.color.set(7895160);const M=N.clone();M.opacity=.25;const D=new m.CylinderGeometry(0,.05,.2,12,1,!1),U=new m.BoxGeometry(.125,.125,.125),S=new m.BufferGeometry;S.setAttribute("position",new m.Float32BufferAttribute([0,0,0,1,0,0],3));const T=(ge,de)=>{const me=new m.BufferGeometry,ke=[];for(let B=0;B<=64*de;++B)ke.push(0,Math.cos(B/32*Math.PI)*ge,Math.sin(B/32*Math.PI)*ge);return me.setAttribute("position",new m.Float32BufferAttribute(ke,3)),me},j=()=>{const ge=new m.BufferGeometry;return ge.setAttribute("position",new m.Float32BufferAttribute([0,0,0,1,1,1],3)),ge},X={X:[[new m.Mesh(D,a),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new m.Mesh(D,a),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new m.Line(S,A)]],Y:[[new m.Mesh(D,c),[0,1,0],null,null,"fwd"],[new m.Mesh(D,c),[0,1,0],[Math.PI,0,0],null,"bwd"],[new m.Line(S,E),null,[0,0,Math.PI/2]]],Z:[[new m.Mesh(D,p),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new m.Mesh(D,p),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new m.Line(S,k),null,[0,-Math.PI/2,0]]],XYZ:[[new m.Mesh(new m.OctahedronGeometry(.1,0),d.clone()),[0,0,0],[0,0,0]]],XY:[[new m.Mesh(new m.PlaneGeometry(.295,.295),g.clone()),[.15,.15,0]],[new m.Line(S,N),[.18,.3,0],null,[.125,1,1]],[new m.Line(S,N),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new m.Mesh(new m.PlaneGeometry(.295,.295),y.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new m.Line(S,O),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new m.Line(S,O),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new m.Mesh(new m.PlaneGeometry(.295,.295),b.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new m.Line(S,R),[.18,0,.3],null,[.125,1,1]],[new m.Line(S,R),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},Z={X:[[new m.Mesh(new m.CylinderGeometry(.2,0,1,4,1,!1),i),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new m.Mesh(new m.CylinderGeometry(.2,0,1,4,1,!1),i),[0,.6,0]]],Z:[[new m.Mesh(new m.CylinderGeometry(.2,0,1,4,1,!1),i),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new m.Mesh(new m.OctahedronGeometry(.2,0),i)]],XY:[[new m.Mesh(new m.PlaneGeometry(.4,.4),i),[.2,.2,0]]],YZ:[[new m.Mesh(new m.PlaneGeometry(.4,.4),i),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new m.Mesh(new m.PlaneGeometry(.4,.4),i),[.2,0,.2],[-Math.PI/2,0,0]]]},J={START:[[new m.Mesh(new m.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new m.Mesh(new m.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new m.Line(j(),o),null,null,null,"helper"]],X:[[new m.Line(S,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new m.Line(S,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new m.Line(S,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},le={X:[[new m.Line(T(1,.5),A)],[new m.Mesh(new m.OctahedronGeometry(.04,0),a),[0,0,.99],null,[1,3,1]]],Y:[[new m.Line(T(1,.5),E),null,[0,0,-Math.PI/2]],[new m.Mesh(new m.OctahedronGeometry(.04,0),c),[0,0,.99],null,[3,1,1]]],Z:[[new m.Line(T(1,.5),k),null,[0,Math.PI/2,0]],[new m.Mesh(new m.OctahedronGeometry(.04,0),p),[.99,0,0],null,[1,3,1]]],E:[[new m.Line(T(1.25,1),M),null,[0,Math.PI/2,0]],[new m.Mesh(new m.CylinderGeometry(.03,0,.15,4,1,!1),M),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new m.Mesh(new m.CylinderGeometry(.03,0,.15,4,1,!1),M),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new m.Mesh(new m.CylinderGeometry(.03,0,.15,4,1,!1),M),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new m.Mesh(new m.CylinderGeometry(.03,0,.15,4,1,!1),M),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new m.Line(T(1,1),F),null,[0,Math.PI/2,0]]]},he={AXIS:[[new m.Line(S,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},oe={X:[[new m.Mesh(new m.TorusGeometry(1,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new m.Mesh(new m.TorusGeometry(1,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new m.Mesh(new m.TorusGeometry(1,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new m.Mesh(new m.TorusGeometry(1.25,.1,2,24),i)]],XYZE:[[new m.Mesh(new m.SphereGeometry(.7,10,8),i)]]},re={X:[[new m.Mesh(U,a),[.8,0,0],[0,0,-Math.PI/2]],[new m.Line(S,A),null,null,[.8,1,1]]],Y:[[new m.Mesh(U,c),[0,.8,0]],[new m.Line(S,E),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new m.Mesh(U,p),[0,0,.8],[Math.PI/2,0,0]],[new m.Line(S,k),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new m.Mesh(U,g),[.85,.85,0],null,[2,2,.2]],[new m.Line(S,N),[.855,.98,0],null,[.125,1,1]],[new m.Line(S,N),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new m.Mesh(U,y),[0,.85,.85],null,[.2,2,2]],[new m.Line(S,O),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new m.Line(S,O),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new m.Mesh(U,b),[.85,0,.85],null,[2,.2,2]],[new m.Line(S,R),[.855,0,.98],null,[.125,1,1]],[new m.Line(S,R),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new m.Mesh(new m.BoxGeometry(.125,.125,.125),d.clone()),[1.1,0,0]]],XYZY:[[new m.Mesh(new m.BoxGeometry(.125,.125,.125),d.clone()),[0,1.1,0]]],XYZZ:[[new m.Mesh(new m.BoxGeometry(.125,.125,.125),d.clone()),[0,0,1.1]]]},ne={X:[[new m.Mesh(new m.CylinderGeometry(.2,0,.8,4,1,!1),i),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new m.Mesh(new m.CylinderGeometry(.2,0,.8,4,1,!1),i),[0,.5,0]]],Z:[[new m.Mesh(new m.CylinderGeometry(.2,0,.8,4,1,!1),i),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new m.Mesh(U,i),[.85,.85,0],null,[3,3,.2]]],YZ:[[new m.Mesh(U,i),[0,.85,.85],null,[.2,3,3]]],XZ:[[new m.Mesh(U,i),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new m.Mesh(new m.BoxGeometry(.2,.2,.2),i),[1.1,0,0]]],XYZY:[[new m.Mesh(new m.BoxGeometry(.2,.2,.2),i),[0,1.1,0]]],XYZZ:[[new m.Mesh(new m.BoxGeometry(.2,.2,.2),i),[0,0,1.1]]]},H={X:[[new m.Line(S,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new m.Line(S,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new m.Line(S,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},Ce=ge=>{const de=new m.Object3D;for(let me in ge)for(let ke=ge[me].length;ke--;){const B=ge[me][ke][0].clone(),we=ge[me][ke][1],ze=ge[me][ke][2],Ge=ge[me][ke][3],Te=ge[me][ke][4];B.name=me,B.tag=Te,we&&B.position.set(we[0],we[1],we[2]),ze&&B.rotation.set(ze[0],ze[1],ze[2]),Ge&&B.scale.set(Ge[0],Ge[1],Ge[2]),B.updateMatrix();const lt=B.geometry.clone();lt.applyMatrix4(B.matrix),B.geometry=lt,B.renderOrder=1/0,B.position.set(0,0,0),B.rotation.set(0,0,0),B.scale.set(1,1,1),de.add(B)}return de};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Ce(X)),this.add(this.gizmo.rotate=Ce(le)),this.add(this.gizmo.scale=Ce(re)),this.add(this.picker.translate=Ce(Z)),this.add(this.picker.rotate=Ce(oe)),this.add(this.picker.scale=Ce(ne)),this.add(this.helper.translate=Ce(J)),this.add(this.helper.rotate=Ce(he)),this.add(this.helper.scale=Ce(H)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class il extends m.Mesh{constructor(){super(new m.PlaneGeometry(1e5,1e5,2,2),new m.MeshBasicMaterial({visible:!1,wireframe:!0,side:m.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),K(this,"isTransformControlsPlane",!0),K(this,"type","TransformControlsPlane"),K(this,"unitX",new m.Vector3(1,0,0)),K(this,"unitY",new m.Vector3(0,1,0)),K(this,"unitZ",new m.Vector3(0,0,1)),K(this,"tempVector",new m.Vector3),K(this,"dirVector",new m.Vector3),K(this,"alignVector",new m.Vector3),K(this,"tempMatrix",new m.Matrix4),K(this,"identityQuaternion",new m.Quaternion),K(this,"cameraQuaternion",new m.Quaternion),K(this,"worldPosition",new m.Vector3),K(this,"worldQuaternion",new m.Quaternion),K(this,"eye",new m.Vector3),K(this,"axis",null),K(this,"mode","translate"),K(this,"space","world"),K(this,"updateMatrixWorld",()=>{let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),this.unitX.set(1,0,0).applyQuaternion(t==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(t==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(t==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var rl=Object.defineProperty,ol=(v,t,n)=>t in v?rl(v,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):v[t]=n,Ue=(v,t,n)=>(ol(v,typeof t!="symbol"?t+"":t,n),n);const Vn=new m.Euler(0,0,0,"YXZ"),In=new m.Vector3,al={type:"change"},ll={type:"lock"},cl={type:"unlock"},vo=Math.PI/2;class Ni extends m.EventDispatcher{constructor(t,n){super(),Ue(this,"camera"),Ue(this,"domElement"),Ue(this,"isLocked"),Ue(this,"minPolarAngle"),Ue(this,"maxPolarAngle"),Ue(this,"pointerSpeed"),Ue(this,"onMouseMove",i=>{if(!this.domElement||this.isLocked===!1)return;const o=i.movementX||i.mozMovementX||i.webkitMovementX||0,a=i.movementY||i.mozMovementY||i.webkitMovementY||0;Vn.setFromQuaternion(this.camera.quaternion),Vn.y-=o*.002*this.pointerSpeed,Vn.x-=a*.002*this.pointerSpeed,Vn.x=Math.max(vo-this.maxPolarAngle,Math.min(vo-this.minPolarAngle,Vn.x)),this.camera.quaternion.setFromEuler(Vn),this.dispatchEvent(al)}),Ue(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(ll),this.isLocked=!0):(this.dispatchEvent(cl),this.isLocked=!1))}),Ue(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),Ue(this,"connect",i=>{this.domElement=i||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),Ue(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),Ue(this,"dispose",()=>{this.disconnect()}),Ue(this,"getObject",()=>this.camera),Ue(this,"direction",new m.Vector3(0,0,-1)),Ue(this,"getDirection",i=>i.copy(this.direction).applyQuaternion(this.camera.quaternion)),Ue(this,"moveForward",i=>{In.setFromMatrixColumn(this.camera.matrix,0),In.crossVectors(this.camera.up,In),this.camera.position.addScaledVector(In,i)}),Ue(this,"moveRight",i=>{In.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(In,i)}),Ue(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),Ue(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=t,this.domElement=n,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,n&&this.connect(n)}}var hl=Object.defineProperty,pl=(v,t,n)=>t in v?hl(v,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):v[t]=n,ce=(v,t,n)=>(pl(v,typeof t!="symbol"?t+"":t,n),n);const _o=(v,t)=>(v%t+t)%t;class go extends m.EventDispatcher{constructor(t,n){super(),ce(this,"object"),ce(this,"domElement"),ce(this,"enabled",!0),ce(this,"target",new m.Vector3),ce(this,"minDistance",0),ce(this,"maxDistance",1/0),ce(this,"minZoom",0),ce(this,"maxZoom",1/0),ce(this,"minPolarAngle",0),ce(this,"maxPolarAngle",Math.PI),ce(this,"minAzimuthAngle",-1/0),ce(this,"maxAzimuthAngle",1/0),ce(this,"enableDamping",!1),ce(this,"dampingFactor",.05),ce(this,"enableZoom",!0),ce(this,"zoomSpeed",1),ce(this,"enableRotate",!0),ce(this,"rotateSpeed",1),ce(this,"enablePan",!0),ce(this,"panSpeed",1),ce(this,"screenSpacePanning",!0),ce(this,"keyPanSpeed",7),ce(this,"autoRotate",!1),ce(this,"autoRotateSpeed",2),ce(this,"reverseOrbit",!1),ce(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),ce(this,"mouseButtons",{LEFT:m.MOUSE.ROTATE,MIDDLE:m.MOUSE.DOLLY,RIGHT:m.MOUSE.PAN}),ce(this,"touches",{ONE:m.TOUCH.ROTATE,TWO:m.TOUCH.DOLLY_PAN}),ce(this,"target0"),ce(this,"position0"),ce(this,"zoom0"),ce(this,"_domElementKeyEvents",null),ce(this,"getPolarAngle"),ce(this,"getAzimuthalAngle"),ce(this,"setPolarAngle"),ce(this,"setAzimuthalAngle"),ce(this,"getDistance"),ce(this,"listenToKeyEvents"),ce(this,"saveState"),ce(this,"reset"),ce(this,"update"),ce(this,"connect"),ce(this,"dispose"),this.object=t,this.domElement=n,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>y.phi,this.getAzimuthalAngle=()=>y.theta,this.setPolarAngle=z=>{let W=_o(z,2*Math.PI),ae=y.phi;ae<0&&(ae+=2*Math.PI),W<0&&(W+=2*Math.PI);let fe=Math.abs(W-ae);2*Math.PI-fe<fe&&(W<ae?W+=2*Math.PI:ae+=2*Math.PI),b.phi=W-ae,i.update()},this.setAzimuthalAngle=z=>{let W=_o(z,2*Math.PI),ae=y.theta;ae<0&&(ae+=2*Math.PI),W<0&&(W+=2*Math.PI);let fe=Math.abs(W-ae);2*Math.PI-fe<fe&&(W<ae?W+=2*Math.PI:ae+=2*Math.PI),b.theta=W-ae,i.update()},this.getDistance=()=>i.object.position.distanceTo(i.target),this.listenToKeyEvents=z=>{z.addEventListener("keydown",Mt),this._domElementKeyEvents=z},this.saveState=()=>{i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=()=>{i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(o),i.update(),d=p.NONE},this.update=(()=>{const z=new m.Vector3,W=new m.Quaternion().setFromUnitVectors(t.up,new m.Vector3(0,1,0)),ae=W.clone().invert(),fe=new m.Vector3,Oe=new m.Quaternion,je=2*Math.PI;return function(){const fn=i.object.position;z.copy(fn).sub(i.target),z.applyQuaternion(W),y.setFromVector3(z),i.autoRotate&&d===p.NONE&&J(X()),i.enableDamping?(y.theta+=b.theta*i.dampingFactor,y.phi+=b.phi*i.dampingFactor):(y.theta+=b.theta,y.phi+=b.phi);let Xe=i.minAzimuthAngle,Ze=i.maxAzimuthAngle;return isFinite(Xe)&&isFinite(Ze)&&(Xe<-Math.PI?Xe+=je:Xe>Math.PI&&(Xe-=je),Ze<-Math.PI?Ze+=je:Ze>Math.PI&&(Ze-=je),Xe<=Ze?y.theta=Math.max(Xe,Math.min(Ze,y.theta)):y.theta=y.theta>(Xe+Ze)/2?Math.max(Xe,y.theta):Math.min(Ze,y.theta)),y.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,y.phi)),y.makeSafe(),y.radius*=C,y.radius=Math.max(i.minDistance,Math.min(i.maxDistance,y.radius)),i.enableDamping===!0?i.target.addScaledVector(A,i.dampingFactor):i.target.add(A),z.setFromSpherical(y),z.applyQuaternion(ae),fn.copy(i.target).add(z),i.object.lookAt(i.target),i.enableDamping===!0?(b.theta*=1-i.dampingFactor,b.phi*=1-i.dampingFactor,A.multiplyScalar(1-i.dampingFactor)):(b.set(0,0,0),A.set(0,0,0)),C=1,E||fe.distanceToSquared(i.object.position)>g||8*(1-Oe.dot(i.object.quaternion))>g?(i.dispatchEvent(o),fe.copy(i.object.position),Oe.copy(i.object.quaternion),E=!1,!0):!1}})(),this.connect=z=>{z===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),i.domElement=z,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",mn),i.domElement.addEventListener("pointerdown",ct),i.domElement.addEventListener("pointercancel",Yn),i.domElement.addEventListener("wheel",Zn)},this.dispose=()=>{var z,W,ae,fe,Oe,je;(z=i.domElement)==null||z.removeEventListener("contextmenu",mn),(W=i.domElement)==null||W.removeEventListener("pointerdown",ct),(ae=i.domElement)==null||ae.removeEventListener("pointercancel",Yn),(fe=i.domElement)==null||fe.removeEventListener("wheel",Zn),(Oe=i.domElement)==null||Oe.ownerDocument.removeEventListener("pointermove",dn),(je=i.domElement)==null||je.ownerDocument.removeEventListener("pointerup",bt),i._domElementKeyEvents!==null&&i._domElementKeyEvents.removeEventListener("keydown",Mt)};const i=this,o={type:"change"},a={type:"start"},c={type:"end"},p={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let d=p.NONE;const g=1e-6,y=new m.Spherical,b=new m.Spherical;let C=1;const A=new m.Vector3;let E=!1;const k=new m.Vector2,O=new m.Vector2,R=new m.Vector2,N=new m.Vector2,F=new m.Vector2,M=new m.Vector2,D=new m.Vector2,U=new m.Vector2,S=new m.Vector2,T=[],j={};function X(){return 2*Math.PI/60/60*i.autoRotateSpeed}function Z(){return Math.pow(.95,i.zoomSpeed)}function J(z){i.reverseOrbit?b.theta+=z:b.theta-=z}function le(z){i.reverseOrbit?b.phi+=z:b.phi-=z}const he=(()=>{const z=new m.Vector3;return function(ae,fe){z.setFromMatrixColumn(fe,0),z.multiplyScalar(-ae),A.add(z)}})(),oe=(()=>{const z=new m.Vector3;return function(ae,fe){i.screenSpacePanning===!0?z.setFromMatrixColumn(fe,1):(z.setFromMatrixColumn(fe,0),z.crossVectors(i.object.up,z)),z.multiplyScalar(ae),A.add(z)}})(),re=(()=>{const z=new m.Vector3;return function(ae,fe){const Oe=i.domElement;if(Oe&&i.object instanceof m.PerspectiveCamera&&i.object.isPerspectiveCamera){const je=i.object.position;z.copy(je).sub(i.target);let qt=z.length();qt*=Math.tan(i.object.fov/2*Math.PI/180),he(2*ae*qt/Oe.clientHeight,i.object.matrix),oe(2*fe*qt/Oe.clientHeight,i.object.matrix)}else Oe&&i.object instanceof m.OrthographicCamera&&i.object.isOrthographicCamera?(he(ae*(i.object.right-i.object.left)/i.object.zoom/Oe.clientWidth,i.object.matrix),oe(fe*(i.object.top-i.object.bottom)/i.object.zoom/Oe.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function ne(z){i.object instanceof m.PerspectiveCamera&&i.object.isPerspectiveCamera?C/=z:i.object instanceof m.OrthographicCamera&&i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*z)),i.object.updateProjectionMatrix(),E=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function H(z){i.object instanceof m.PerspectiveCamera&&i.object.isPerspectiveCamera?C*=z:i.object instanceof m.OrthographicCamera&&i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/z)),i.object.updateProjectionMatrix(),E=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function Ce(z){k.set(z.clientX,z.clientY)}function ge(z){D.set(z.clientX,z.clientY)}function de(z){N.set(z.clientX,z.clientY)}function me(z){O.set(z.clientX,z.clientY),R.subVectors(O,k).multiplyScalar(i.rotateSpeed);const W=i.domElement;W&&(J(2*Math.PI*R.x/W.clientHeight),le(2*Math.PI*R.y/W.clientHeight)),k.copy(O),i.update()}function ke(z){U.set(z.clientX,z.clientY),S.subVectors(U,D),S.y>0?ne(Z()):S.y<0&&H(Z()),D.copy(U),i.update()}function B(z){F.set(z.clientX,z.clientY),M.subVectors(F,N).multiplyScalar(i.panSpeed),re(M.x,M.y),N.copy(F),i.update()}function we(z){z.deltaY<0?H(Z()):z.deltaY>0&&ne(Z()),i.update()}function ze(z){let W=!1;switch(z.code){case i.keys.UP:re(0,i.keyPanSpeed),W=!0;break;case i.keys.BOTTOM:re(0,-i.keyPanSpeed),W=!0;break;case i.keys.LEFT:re(i.keyPanSpeed,0),W=!0;break;case i.keys.RIGHT:re(-i.keyPanSpeed,0),W=!0;break}W&&(z.preventDefault(),i.update())}function Ge(){if(T.length==1)k.set(T[0].pageX,T[0].pageY);else{const z=.5*(T[0].pageX+T[1].pageX),W=.5*(T[0].pageY+T[1].pageY);k.set(z,W)}}function Te(){if(T.length==1)N.set(T[0].pageX,T[0].pageY);else{const z=.5*(T[0].pageX+T[1].pageX),W=.5*(T[0].pageY+T[1].pageY);N.set(z,W)}}function lt(){const z=T[0].pageX-T[1].pageX,W=T[0].pageY-T[1].pageY,ae=Math.sqrt(z*z+W*W);D.set(0,ae)}function Gn(){i.enableZoom&<(),i.enablePan&&Te()}function He(){i.enableZoom&<(),i.enableRotate&&Ge()}function Kn(z){if(T.length==1)O.set(z.pageX,z.pageY);else{const ae=Dt(z),fe=.5*(z.pageX+ae.x),Oe=.5*(z.pageY+ae.y);O.set(fe,Oe)}R.subVectors(O,k).multiplyScalar(i.rotateSpeed);const W=i.domElement;W&&(J(2*Math.PI*R.x/W.clientHeight),le(2*Math.PI*R.y/W.clientHeight)),k.copy(O)}function un(z){if(T.length==1)F.set(z.pageX,z.pageY);else{const W=Dt(z),ae=.5*(z.pageX+W.x),fe=.5*(z.pageY+W.y);F.set(ae,fe)}M.subVectors(F,N).multiplyScalar(i.panSpeed),re(M.x,M.y),N.copy(F)}function gt(z){const W=Dt(z),ae=z.pageX-W.x,fe=z.pageY-W.y,Oe=Math.sqrt(ae*ae+fe*fe);U.set(0,Oe),S.set(0,Math.pow(U.y/D.y,i.zoomSpeed)),ne(S.y),D.copy(U)}function Et(z){i.enableZoom&>(z),i.enablePan&&un(z)}function Ye(z){i.enableZoom&>(z),i.enableRotate&&Kn(z)}function ct(z){var W,ae;i.enabled!==!1&&(T.length===0&&((W=i.domElement)==null||W.ownerDocument.addEventListener("pointermove",dn),(ae=i.domElement)==null||ae.ownerDocument.addEventListener("pointerup",bt)),Qn(z),z.pointerType==="touch"?Ot(z):ws(z))}function dn(z){i.enabled!==!1&&(z.pointerType==="touch"?qn(z):Xn(z))}function bt(z){var W,ae,fe;kt(z),T.length===0&&((W=i.domElement)==null||W.releasePointerCapture(z.pointerId),(ae=i.domElement)==null||ae.ownerDocument.removeEventListener("pointermove",dn),(fe=i.domElement)==null||fe.ownerDocument.removeEventListener("pointerup",bt)),i.dispatchEvent(c),d=p.NONE}function Yn(z){kt(z)}function ws(z){let W;switch(z.button){case 0:W=i.mouseButtons.LEFT;break;case 1:W=i.mouseButtons.MIDDLE;break;case 2:W=i.mouseButtons.RIGHT;break;default:W=-1}switch(W){case m.MOUSE.DOLLY:if(i.enableZoom===!1)return;ge(z),d=p.DOLLY;break;case m.MOUSE.ROTATE:if(z.ctrlKey||z.metaKey||z.shiftKey){if(i.enablePan===!1)return;de(z),d=p.PAN}else{if(i.enableRotate===!1)return;Ce(z),d=p.ROTATE}break;case m.MOUSE.PAN:if(z.ctrlKey||z.metaKey||z.shiftKey){if(i.enableRotate===!1)return;Ce(z),d=p.ROTATE}else{if(i.enablePan===!1)return;de(z),d=p.PAN}break;default:d=p.NONE}d!==p.NONE&&i.dispatchEvent(a)}function Xn(z){if(i.enabled!==!1)switch(d){case p.ROTATE:if(i.enableRotate===!1)return;me(z);break;case p.DOLLY:if(i.enableZoom===!1)return;ke(z);break;case p.PAN:if(i.enablePan===!1)return;B(z);break}}function Zn(z){i.enabled===!1||i.enableZoom===!1||d!==p.NONE&&d!==p.ROTATE||(z.preventDefault(),i.dispatchEvent(a),we(z),i.dispatchEvent(c))}function Mt(z){i.enabled===!1||i.enablePan===!1||ze(z)}function Ot(z){switch(wt(z),T.length){case 1:switch(i.touches.ONE){case m.TOUCH.ROTATE:if(i.enableRotate===!1)return;Ge(),d=p.TOUCH_ROTATE;break;case m.TOUCH.PAN:if(i.enablePan===!1)return;Te(),d=p.TOUCH_PAN;break;default:d=p.NONE}break;case 2:switch(i.touches.TWO){case m.TOUCH.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Gn(),d=p.TOUCH_DOLLY_PAN;break;case m.TOUCH.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;He(),d=p.TOUCH_DOLLY_ROTATE;break;default:d=p.NONE}break;default:d=p.NONE}d!==p.NONE&&i.dispatchEvent(a)}function qn(z){switch(wt(z),d){case p.TOUCH_ROTATE:if(i.enableRotate===!1)return;Kn(z),i.update();break;case p.TOUCH_PAN:if(i.enablePan===!1)return;un(z),i.update();break;case p.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Et(z),i.update();break;case p.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Ye(z),i.update();break;default:d=p.NONE}}function mn(z){i.enabled!==!1&&z.preventDefault()}function Qn(z){T.push(z)}function kt(z){delete j[z.pointerId];for(let W=0;W<T.length;W++)if(T[W].pointerId==z.pointerId){T.splice(W,1);return}}function wt(z){let W=j[z.pointerId];W===void 0&&(W=new m.Vector2,j[z.pointerId]=W),W.set(z.pageX,z.pageY)}function Dt(z){const W=z.pointerId===T[0].pointerId?T[1]:T[0];return j[W.pointerId]}n!==void 0&&this.connect(n),this.update()}}class ul extends go{constructor(t,n){super(t,n),this.screenSpacePanning=!1,this.mouseButtons.LEFT=m.MOUSE.PAN,this.mouseButtons.RIGHT=m.MOUSE.ROTATE,this.touches.ONE=m.TOUCH.PAN,this.touches.TWO=m.TOUCH.DOLLY_ROTATE}}class dl extends m.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new gl(n)}),this.register(function(n){return new Ml(n)}),this.register(function(n){return new kl(n)}),this.register(function(n){return new Ll(n)}),this.register(function(n){return new wl(n)}),this.register(function(n){return new yl(n)}),this.register(function(n){return new xl(n)}),this.register(function(n){return new Cl(n)}),this.register(function(n){return new _l(n)}),this.register(function(n){return new Pl(n)}),this.register(function(n){return new bl(n)}),this.register(function(n){return new Al(n)}),this.register(function(n){return new fl(n)}),this.register(function(n){return new Sl(n)}),this.register(function(n){return new Tl(n)})}load(t,n,i,o){const a=this;let c;this.resourcePath!==""?c=this.resourcePath:this.path!==""?c=this.path:c=m.LoaderUtils.extractUrlBase(t),this.manager.itemStart(t);const p=function(g){o?o(g):console.error(g),a.manager.itemError(t),a.manager.itemEnd(t)},d=new m.FileLoader(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(this.withCredentials),d.load(t,function(g){try{a.parse(g,c,function(y){n(y),a.manager.itemEnd(t)},p)}catch(y){p(y)}},i,p)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,n,i,o){let a;const c={},p={};if(typeof t=="string")a=JSON.parse(t);else if(t instanceof ArrayBuffer)if(m.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4)))===bo){try{c[_e.KHR_BINARY_GLTF]=new El(t)}catch(y){o&&o(y);return}a=JSON.parse(c[_e.KHR_BINARY_GLTF].content)}else a=JSON.parse(m.LoaderUtils.decodeText(new Uint8Array(t)));else a=t;if(a.asset===void 0||a.asset.version[0]<2){o&&o(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const d=new Kl(a,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let g=0;g<this.pluginCallbacks.length;g++){const y=this.pluginCallbacks[g](d);p[y.name]=y,c[y.name]=!0}if(a.extensionsUsed)for(let g=0;g<a.extensionsUsed.length;++g){const y=a.extensionsUsed[g],b=a.extensionsRequired||[];switch(y){case _e.KHR_MATERIALS_UNLIT:c[y]=new vl;break;case _e.KHR_DRACO_MESH_COMPRESSION:c[y]=new Ol(a,this.dracoLoader);break;case _e.KHR_TEXTURE_TRANSFORM:c[y]=new Dl;break;case _e.KHR_MESH_QUANTIZATION:c[y]=new Vl;break;default:b.indexOf(y)>=0&&p[y]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+y+'".')}}d.setExtensions(c),d.setPlugins(p),d.parse(i,o)}parseAsync(t,n){const i=this;return new Promise(function(o,a){i.parse(t,n,o,a)})}}function ml(){let v={};return{get:function(t){return v[t]},add:function(t,n){v[t]=n},remove:function(t){delete v[t]},removeAll:function(){v={}}}}const _e={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_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_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 fl{constructor(t){this.parser=t,this.name=_e.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,n=this.parser.json.nodes||[];for(let i=0,o=n.length;i<o;i++){const a=n[i];a.extensions&&a.extensions[this.name]&&a.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(t){const n=this.parser,i="light:"+t;let o=n.cache.get(i);if(o)return o;const a=n.json,d=((a.extensions&&a.extensions[this.name]||{}).lights||[])[t];let g;const y=new m.Color(16777215);d.color!==void 0&&y.fromArray(d.color);const b=d.range!==void 0?d.range:0;switch(d.type){case"directional":g=new m.DirectionalLight(y),g.target.position.set(0,0,-1),g.add(g.target);break;case"point":g=new m.PointLight(y),g.distance=b;break;case"spot":g=new m.SpotLight(y),g.distance=b,d.spot=d.spot||{},d.spot.innerConeAngle=d.spot.innerConeAngle!==void 0?d.spot.innerConeAngle:0,d.spot.outerConeAngle=d.spot.outerConeAngle!==void 0?d.spot.outerConeAngle:Math.PI/4,g.angle=d.spot.outerConeAngle,g.penumbra=1-d.spot.innerConeAngle/d.spot.outerConeAngle,g.target.position.set(0,0,-1),g.add(g.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+d.type)}return g.position.set(0,0,0),g.decay=2,Yt(g,d),d.intensity!==void 0&&(g.intensity=d.intensity),g.name=n.createUniqueName(d.name||"light_"+t),o=Promise.resolve(g),n.cache.add(i,o),o}getDependency(t,n){if(t==="light")return this._loadLight(n)}createNodeAttachment(t){const n=this,i=this.parser,a=i.json.nodes[t],p=(a.extensions&&a.extensions[this.name]||{}).light;return p===void 0?null:this._loadLight(p).then(function(d){return i._getNodeRef(n.cache,p,d)})}}class vl{constructor(){this.name=_e.KHR_MATERIALS_UNLIT}getMaterialType(){return m.MeshBasicMaterial}extendParams(t,n,i){const o=[];t.color=new m.Color(1,1,1),t.opacity=1;const a=n.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){const c=a.baseColorFactor;t.color.fromArray(c),t.opacity=c[3]}a.baseColorTexture!==void 0&&o.push(i.assignTexture(t,"map",a.baseColorTexture,3001))}return Promise.all(o)}}class _l{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,n){const o=this.parser.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=o.extensions[this.name].emissiveStrength;return a!==void 0&&(n.emissiveIntensity=a),Promise.resolve()}}class gl{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const i=this.parser,o=i.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=[],c=o.extensions[this.name];if(c.clearcoatFactor!==void 0&&(n.clearcoat=c.clearcoatFactor),c.clearcoatTexture!==void 0&&a.push(i.assignTexture(n,"clearcoatMap",c.clearcoatTexture)),c.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=c.clearcoatRoughnessFactor),c.clearcoatRoughnessTexture!==void 0&&a.push(i.assignTexture(n,"clearcoatRoughnessMap",c.clearcoatRoughnessTexture)),c.clearcoatNormalTexture!==void 0&&(a.push(i.assignTexture(n,"clearcoatNormalMap",c.clearcoatNormalTexture)),c.clearcoatNormalTexture.scale!==void 0)){const p=c.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new m.Vector2(p,p)}return Promise.all(a)}}class bl{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const i=this.parser,o=i.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=[],c=o.extensions[this.name];return c.iridescenceFactor!==void 0&&(n.iridescence=c.iridescenceFactor),c.iridescenceTexture!==void 0&&a.push(i.assignTexture(n,"iridescenceMap",c.iridescenceTexture)),c.iridescenceIor!==void 0&&(n.iridescenceIOR=c.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),c.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=c.iridescenceThicknessMinimum),c.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=c.iridescenceThicknessMaximum),c.iridescenceThicknessTexture!==void 0&&a.push(i.assignTexture(n,"iridescenceThicknessMap",c.iridescenceThicknessTexture)),Promise.all(a)}}class wl{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_SHEEN}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const i=this.parser,o=i.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=[];n.sheenColor=new m.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const c=o.extensions[this.name];return c.sheenColorFactor!==void 0&&n.sheenColor.fromArray(c.sheenColorFactor),c.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=c.sheenRoughnessFactor),c.sheenColorTexture!==void 0&&a.push(i.assignTexture(n,"sheenColorMap",c.sheenColorTexture,3001)),c.sheenRoughnessTexture!==void 0&&a.push(i.assignTexture(n,"sheenRoughnessMap",c.sheenRoughnessTexture)),Promise.all(a)}}class yl{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const i=this.parser,o=i.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=[],c=o.extensions[this.name];return c.transmissionFactor!==void 0&&(n.transmission=c.transmissionFactor),c.transmissionTexture!==void 0&&a.push(i.assignTexture(n,"transmissionMap",c.transmissionTexture)),Promise.all(a)}}class xl{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_VOLUME}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const i=this.parser,o=i.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=[],c=o.extensions[this.name];n.thickness=c.thicknessFactor!==void 0?c.thicknessFactor:0,c.thicknessTexture!==void 0&&a.push(i.assignTexture(n,"thicknessMap",c.thicknessTexture)),n.attenuationDistance=c.attenuationDistance||1/0;const p=c.attenuationColor||[1,1,1];return n.attenuationColor=new m.Color(p[0],p[1],p[2]),Promise.all(a)}}class Cl{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_IOR}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const o=this.parser.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=o.extensions[this.name];return n.ior=a.ior!==void 0?a.ior:1.5,Promise.resolve()}}class Pl{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_SPECULAR}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const i=this.parser,o=i.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=[],c=o.extensions[this.name];n.specularIntensity=c.specularFactor!==void 0?c.specularFactor:1,c.specularTexture!==void 0&&a.push(i.assignTexture(n,"specularIntensityMap",c.specularTexture));const p=c.specularColorFactor||[1,1,1];return n.specularColor=new m.Color(p[0],p[1],p[2]),c.specularColorTexture!==void 0&&a.push(i.assignTexture(n,"specularColorMap",c.specularColorTexture,3001)),Promise.all(a)}}class Al{constructor(t){this.parser=t,this.name=_e.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const i=this.parser.json.materials[t];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,n){const i=this.parser,o=i.json.materials[t];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const a=[],c=o.extensions[this.name];return c.anisotropyStrength!==void 0&&(n.anisotropy=c.anisotropyStrength),c.anisotropyRotation!==void 0&&(n.anisotropyRotation=c.anisotropyRotation),c.anisotropyTexture!==void 0&&a.push(i.assignTexture(n,"anisotropyMap",c.anisotropyTexture)),Promise.all(a)}}class Ml{constructor(t){this.parser=t,this.name=_e.KHR_TEXTURE_BASISU}loadTexture(t){const n=this.parser,i=n.json,o=i.textures[t];if(!o.extensions||!o.extensions[this.name])return null;const a=o.extensions[this.name],c=n.options.ktx2Loader;if(!c){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(t,a.source,c)}}class kl{constructor(t){this.parser=t,this.name=_e.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,o=i.json,a=o.textures[t];if(!a.extensions||!a.extensions[n])return null;const c=a.extensions[n],p=o.images[c.source];let d=i.textureLoader;if(p.uri){const g=i.options.manager.getHandler(p.uri);g!==null&&(d=g)}return this.detectSupport().then(function(g){if(g)return i.loadTextureImage(t,c.source,d);if(o.extensionsRequired&&o.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){t(n.height===1)}})),this.isSupported}}class Ll{constructor(t){this.parser=t,this.name=_e.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,o=i.json,a=o.textures[t];if(!a.extensions||!a.extensions[n])return null;const c=a.extensions[n],p=o.images[c.source];let d=i.textureLoader;if(p.uri){const g=i.options.manager.getHandler(p.uri);g!==null&&(d=g)}return this.detectSupport().then(function(g){if(g)return i.loadTextureImage(t,c.source,d);if(o.extensionsRequired&&o.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){t(n.height===1)}})),this.isSupported}}class Sl{constructor(t){this.name=_e.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const n=this.parser.json,i=n.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const o=i.extensions[this.name],a=this.parser.getDependency("buffer",o.buffer),c=this.parser.options.meshoptDecoder;if(!c||!c.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return a.then(function(p){const d=o.byteOffset||0,g=o.byteLength||0,y=o.count,b=o.byteStride,C=new Uint8Array(p,d,g);return c.decodeGltfBufferAsync?c.decodeGltfBufferAsync(y,b,C,o.mode,o.filter).then(function(A){return A.buffer}):c.ready.then(function(){const A=new ArrayBuffer(y*b);return c.decodeGltfBuffer(new Uint8Array(A),y,b,C,o.mode,o.filter),A})})}else return null}}class Tl{constructor(t){this.name=_e.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const n=this.parser.json,i=n.nodes[t];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const o=n.meshes[i.mesh];for(const g of o.primitives)if(g.mode!==ot.TRIANGLES&&g.mode!==ot.TRIANGLE_STRIP&&g.mode!==ot.TRIANGLE_FAN&&g.mode!==void 0)return null;const c=i.extensions[this.name].attributes,p=[],d={};for(const g in c)p.push(this.parser.getDependency("accessor",c[g]).then(y=>(d[g]=y,d[g])));return p.length<1?null:(p.push(this.parser.createNodeMesh(t)),Promise.all(p).then(g=>{const y=g.pop(),b=y.isGroup?y.children:[y],C=g[0].count,A=[];for(const E of b){const k=new m.Matrix4,O=new m.Vector3,R=new m.Quaternion,N=new m.Vector3(1,1,1),F=new m.InstancedMesh(E.geometry,E.material,C);for(let M=0;M<C;M++)d.TRANSLATION&&O.fromBufferAttribute(d.TRANSLATION,M),d.ROTATION&&R.fromBufferAttribute(d.ROTATION,M),d.SCALE&&N.fromBufferAttribute(d.SCALE,M),F.setMatrixAt(M,k.compose(O,R,N));for(const M in d)M!=="TRANSLATION"&&M!=="ROTATION"&&M!=="SCALE"&&E.geometry.setAttribute(M,d[M]);m.Object3D.prototype.copy.call(F,E),this.parser.assignFinalMaterial(F),A.push(F)}return y.isGroup?(y.clear(),y.add(...A),y):A[0]}))}}const bo="glTF",ds=12,wo={JSON:1313821514,BIN:5130562};class El{constructor(t){this.name=_e.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(t,0,ds);if(this.header={magic:m.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==bo)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-ds,o=new DataView(t,ds);let a=0;for(;a<i;){const c=o.getUint32(a,!0);a+=4;const p=o.getUint32(a,!0);if(a+=4,p===wo.JSON){const d=new Uint8Array(t,ds+a,c);this.content=m.LoaderUtils.decodeText(d)}else if(p===wo.BIN){const d=ds+a;this.body=t.slice(d,d+c)}a+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ol{constructor(t,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_e.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(t,n){const i=this.json,o=this.dracoLoader,a=t.extensions[this.name].bufferView,c=t.extensions[this.name].attributes,p={},d={},g={};for(const y in c){const b=zi[y]||y.toLowerCase();p[b]=c[y]}for(const y in t.attributes){const b=zi[y]||y.toLowerCase();if(c[y]!==void 0){const C=i.accessors[t.attributes[y]],A=Bn[C.componentType];g[b]=A.name,d[b]=C.normalized===!0}}return n.getDependency("bufferView",a).then(function(y){return new Promise(function(b){o.decodeDracoFile(y,function(C){for(const A in C.attributes){const E=C.attributes[A],k=d[A];k!==void 0&&(E.normalized=k)}b(C)},p,g)})})}}class Dl{constructor(){this.name=_e.KHR_TEXTURE_TRANSFORM}extendTexture(t,n){return(n.texCoord===void 0||n.texCoord===t.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(t=t.clone(),n.texCoord!==void 0&&(t.channel=n.texCoord),n.offset!==void 0&&t.offset.fromArray(n.offset),n.rotation!==void 0&&(t.rotation=n.rotation),n.scale!==void 0&&t.repeat.fromArray(n.scale),t.needsUpdate=!0),t}}class Vl{constructor(){this.name=_e.KHR_MESH_QUANTIZATION}}class yo extends m.Interpolant{constructor(t,n,i,o){super(t,n,i,o)}copySampleValue_(t){const n=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=t*o*3+o;for(let c=0;c!==o;c++)n[c]=i[a+c];return n}interpolate_(t,n,i,o){const a=this.resultBuffer,c=this.sampleValues,p=this.valueSize,d=p*2,g=p*3,y=o-n,b=(i-n)/y,C=b*b,A=C*b,E=t*g,k=E-g,O=-2*A+3*C,R=A-C,N=1-O,F=R-C+b;for(let M=0;M!==p;M++){const D=c[k+M+p],U=c[k+M+d]*y,S=c[E+M+p],T=c[E+M]*y;a[M]=N*D+F*U+O*S+R*T}return a}}const Il=new m.Quaternion;class Bl extends yo{interpolate_(t,n,i,o){const a=super.interpolate_(t,n,i,o);return Il.fromArray(a).normalize().toArray(a),a}}const ot={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},Bn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},xo={9728:m.NearestFilter,9729:m.LinearFilter,9984:m.NearestMipmapNearestFilter,9985:m.LinearMipmapNearestFilter,9986:m.NearestMipmapLinearFilter,9987:m.LinearMipmapLinearFilter},Co={33071:m.ClampToEdgeWrapping,33648:m.MirroredRepeatWrapping,10497:m.RepeatWrapping},Ui={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zi={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...m.REVISION.replace(/\D+/g,"")>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Kt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Fl={CUBICSPLINE:void 0,LINEAR:m.InterpolateLinear,STEP:m.InterpolateDiscrete},Ri={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Nl(v){return v.DefaultMaterial===void 0&&(v.DefaultMaterial=new m.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m.FrontSide})),v.DefaultMaterial}function ln(v,t,n){for(const i in n.extensions)v[i]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function Yt(v,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(v.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Ul(v,t,n){let i=!1,o=!1,a=!1;for(let g=0,y=t.length;g<y;g++){const b=t[g];if(b.POSITION!==void 0&&(i=!0),b.NORMAL!==void 0&&(o=!0),b.COLOR_0!==void 0&&(a=!0),i&&o&&a)break}if(!i&&!o&&!a)return Promise.resolve(v);const c=[],p=[],d=[];for(let g=0,y=t.length;g<y;g++){const b=t[g];if(i){const C=b.POSITION!==void 0?n.getDependency("accessor",b.POSITION):v.attributes.position;c.push(C)}if(o){const C=b.NORMAL!==void 0?n.getDependency("accessor",b.NORMAL):v.attributes.normal;p.push(C)}if(a){const C=b.COLOR_0!==void 0?n.getDependency("accessor",b.COLOR_0):v.attributes.color;d.push(C)}}return Promise.all([Promise.all(c),Promise.all(p),Promise.all(d)]).then(function(g){const y=g[0],b=g[1],C=g[2];return i&&(v.morphAttributes.position=y),o&&(v.morphAttributes.normal=b),a&&(v.morphAttributes.color=C),v.morphTargetsRelative=!0,v})}function zl(v,t){if(v.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)v.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(v.morphTargetInfluences.length===n.length){v.morphTargetDictionary={};for(let i=0,o=n.length;i<o;i++)v.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Rl(v){let t;const n=v.extensions&&v.extensions[_e.KHR_DRACO_MESH_COMPRESSION];if(n?t="draco:"+n.bufferView+":"+n.indices+":"+ji(n.attributes):t=v.indices+":"+ji(v.attributes)+":"+v.mode,v.targets!==void 0)for(let i=0,o=v.targets.length;i<o;i++)t+=":"+ji(v.targets[i]);return t}function ji(v){let t="";const n=Object.keys(v).sort();for(let i=0,o=n.length;i<o;i++)t+=n[i]+":"+v[n[i]]+";";return t}function Gi(v){switch(v){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.")}}function jl(v){return v.search(/\.jpe?g($|\?)/i)>0||v.search(/^data\:image\/jpeg/)===0?"image/jpeg":v.search(/\.webp($|\?)/i)>0||v.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Gl=new m.Matrix4;class Kl{constructor(t={},n={}){this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new ml,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 i=!1,o=!1,a=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,o=navigator.userAgent.indexOf("Firefox")>-1,a=o?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||o&&a<98?this.textureLoader=new m.TextureLoader(this.options.manager):this.textureLoader=new m.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new m.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,n){const i=this,o=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(c){return c._markDefs&&c._markDefs()}),Promise.all(this._invokeAll(function(c){return c.beforeRoot&&c.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(c){const p={scene:c[0][o.scene||0],scenes:c[0],animations:c[1],cameras:c[2],asset:o.asset,parser:i,userData:{}};ln(a,p,o),Yt(p,o),Promise.all(i._invokeAll(function(d){return d.afterRoot&&d.afterRoot(p)})).then(function(){t(p)})}).catch(n)}_markDefs(){const t=this.json.nodes||[],n=this.json.skins||[],i=this.json.meshes||[];for(let o=0,a=n.length;o<a;o++){const c=n[o].joints;for(let p=0,d=c.length;p<d;p++)t[c[p]].isBone=!0}for(let o=0,a=t.length;o<a;o++){const c=t[o];c.mesh!==void 0&&(this._addNodeRef(this.meshCache,c.mesh),c.skin!==void 0&&(i[c.mesh].isSkinnedMesh=!0)),c.camera!==void 0&&this._addNodeRef(this.cameraCache,c.camera)}}_addNodeRef(t,n){n!==void 0&&(t.refs[n]===void 0&&(t.refs[n]=t.uses[n]=0),t.refs[n]++)}_getNodeRef(t,n,i){if(t.refs[n]<=1)return i;const o=i.clone(),a=(c,p)=>{const d=this.associations.get(c);d!=null&&this.associations.set(p,d);for(const[g,y]of c.children.entries())a(y,p.children[g])};return a(i,o),o.name+="_instance_"+t.uses[n]++,o}_invokeOne(t){const n=Object.values(this.plugins);n.push(this);for(let i=0;i<n.length;i++){const o=t(n[i]);if(o)return o}return null}_invokeAll(t){const n=Object.values(this.plugins);n.unshift(this);const i=[];for(let o=0;o<n.length;o++){const a=t(n[o]);a&&i.push(a)}return i}getDependency(t,n){const i=t+":"+n;let o=this.cache.get(i);if(!o){switch(t){case"scene":o=this.loadScene(n);break;case"node":o=this._invokeOne(function(a){return a.loadNode&&a.loadNode(n)});break;case"mesh":o=this._invokeOne(function(a){return a.loadMesh&&a.loadMesh(n)});break;case"accessor":o=this.loadAccessor(n);break;case"bufferView":o=this._invokeOne(function(a){return a.loadBufferView&&a.loadBufferView(n)});break;case"buffer":o=this.loadBuffer(n);break;case"material":o=this._invokeOne(function(a){return a.loadMaterial&&a.loadMaterial(n)});break;case"texture":o=this._invokeOne(function(a){return a.loadTexture&&a.loadTexture(n)});break;case"skin":o=this.loadSkin(n);break;case"animation":o=this._invokeOne(function(a){return a.loadAnimation&&a.loadAnimation(n)});break;case"camera":o=this.loadCamera(n);break;default:if(o=this._invokeOne(function(a){return a!=this&&a.getDependency&&a.getDependency(t,n)}),!o)throw new Error("Unknown type: "+t);break}this.cache.add(i,o)}return o}getDependencies(t){let n=this.cache.get(t);if(!n){const i=this,o=this.json[t+(t==="mesh"?"es":"s")]||[];n=Promise.all(o.map(function(a,c){return i.getDependency(t,c)})),this.cache.add(t,n)}return n}loadBuffer(t){const n=this.json.buffers[t],i=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&t===0)return Promise.resolve(this.extensions[_e.KHR_BINARY_GLTF].body);const o=this.options;return new Promise(function(a,c){i.load(m.LoaderUtils.resolveURL(n.uri,o.path),a,void 0,function(){c(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(t){const n=this.json.bufferViews[t];return this.getDependency("buffer",n.buffer).then(function(i){const o=n.byteLength||0,a=n.byteOffset||0;return i.slice(a,a+o)})}loadAccessor(t){const n=this,i=this.json,o=this.json.accessors[t];if(o.bufferView===void 0&&o.sparse===void 0){const c=Ui[o.type],p=Bn[o.componentType],d=o.normalized===!0,g=new p(o.count*c);return Promise.resolve(new m.BufferAttribute(g,c,d))}const a=[];return o.bufferView!==void 0?a.push(this.getDependency("bufferView",o.bufferView)):a.push(null),o.sparse!==void 0&&(a.push(this.getDependency("bufferView",o.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",o.sparse.values.bufferView))),Promise.all(a).then(function(c){const p=c[0],d=Ui[o.type],g=Bn[o.componentType],y=g.BYTES_PER_ELEMENT,b=y*d,C=o.byteOffset||0,A=o.bufferView!==void 0?i.bufferViews[o.bufferView].byteStride:void 0,E=o.normalized===!0;let k,O;if(A&&A!==b){const R=Math.floor(C/A),N="InterleavedBuffer:"+o.bufferView+":"+o.componentType+":"+R+":"+o.count;let F=n.cache.get(N);F||(k=new g(p,R*A,o.count*A/y),F=new m.InterleavedBuffer(k,A/y),n.cache.add(N,F)),O=new m.InterleavedBufferAttribute(F,d,C%A/y,E)}else p===null?k=new g(o.count*d):k=new g(p,C,o.count*d),O=new m.BufferAttribute(k,d,E);if(o.sparse!==void 0){const R=Ui.SCALAR,N=Bn[o.sparse.indices.componentType],F=o.sparse.indices.byteOffset||0,M=o.sparse.values.byteOffset||0,D=new N(c[1],F,o.sparse.count*R),U=new g(c[2],M,o.sparse.count*d);p!==null&&(O=new m.BufferAttribute(O.array.slice(),O.itemSize,O.normalized));for(let S=0,T=D.length;S<T;S++){const j=D[S];if(O.setX(j,U[S*d]),d>=2&&O.setY(j,U[S*d+1]),d>=3&&O.setZ(j,U[S*d+2]),d>=4&&O.setW(j,U[S*d+3]),d>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return O})}loadTexture(t){const n=this.json,i=this.options,a=n.textures[t].source,c=n.images[a];let p=this.textureLoader;if(c.uri){const d=i.manager.getHandler(c.uri);d!==null&&(p=d)}return this.loadTextureImage(t,a,p)}loadTextureImage(t,n,i){const o=this,a=this.json,c=a.textures[t],p=a.images[n],d=(p.uri||p.bufferView)+":"+c.sampler;if(this.textureCache[d])return this.textureCache[d];const g=this.loadImageSource(n,i).then(function(y){y.flipY=!1,y.name=c.name||p.name||"",y.name===""&&typeof p.uri=="string"&&p.uri.startsWith("data:image/")===!1&&(y.name=p.uri);const C=(a.samplers||{})[c.sampler]||{};return y.magFilter=xo[C.magFilter]||m.LinearFilter,y.minFilter=xo[C.minFilter]||m.LinearMipmapLinearFilter,y.wrapS=Co[C.wrapS]||m.RepeatWrapping,y.wrapT=Co[C.wrapT]||m.RepeatWrapping,o.associations.set(y,{textures:t}),y}).catch(function(){return null});return this.textureCache[d]=g,g}loadImageSource(t,n){const i=this,o=this.json,a=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(b=>b.clone());const c=o.images[t],p=self.URL||self.webkitURL;let d=c.uri||"",g=!1;if(c.bufferView!==void 0)d=i.getDependency("bufferView",c.bufferView).then(function(b){g=!0;const C=new Blob([b],{type:c.mimeType});return d=p.createObjectURL(C),d});else if(c.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const y=Promise.resolve(d).then(function(b){return new Promise(function(C,A){let E=C;n.isImageBitmapLoader===!0&&(E=function(k){const O=new m.Texture(k);O.needsUpdate=!0,C(O)}),n.load(m.LoaderUtils.resolveURL(b,a.path),E,void 0,A)})}).then(function(b){return g===!0&&p.revokeObjectURL(d),b.userData.mimeType=c.mimeType||jl(c.uri),b}).catch(function(b){throw console.error("THREE.GLTFLoader: Couldn't load texture",d),b});return this.sourceCache[t]=y,y}assignTexture(t,n,i,o){const a=this;return this.getDependency("texture",i.index).then(function(c){if(!c)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(c=c.clone(),c.channel=i.texCoord),a.extensions[_e.KHR_TEXTURE_TRANSFORM]){const p=i.extensions!==void 0?i.extensions[_e.KHR_TEXTURE_TRANSFORM]:void 0;if(p){const d=a.associations.get(c);c=a.extensions[_e.KHR_TEXTURE_TRANSFORM].extendTexture(c,p),a.associations.set(c,d)}}return o!==void 0&&("colorSpace"in c?c.colorSpace=o===3001?"srgb":"srgb-linear":c.encoding=o),t[n]=c,c})}assignFinalMaterial(t){const n=t.geometry;let i=t.material;const o=n.attributes.tangent===void 0,a=n.attributes.color!==void 0,c=n.attributes.normal===void 0;if(t.isPoints){const p="PointsMaterial:"+i.uuid;let d=this.cache.get(p);d||(d=new m.PointsMaterial,m.Material.prototype.copy.call(d,i),d.color.copy(i.color),d.map=i.map,d.sizeAttenuation=!1,this.cache.add(p,d)),i=d}else if(t.isLine){const p="LineBasicMaterial:"+i.uuid;let d=this.cache.get(p);d||(d=new m.LineBasicMaterial,m.Material.prototype.copy.call(d,i),d.color.copy(i.color),d.map=i.map,this.cache.add(p,d)),i=d}if(o||a||c){let p="ClonedMaterial:"+i.uuid+":";o&&(p+="derivative-tangents:"),a&&(p+="vertex-colors:"),c&&(p+="flat-shading:");let d=this.cache.get(p);d||(d=i.clone(),a&&(d.vertexColors=!0),c&&(d.flatShading=!0),o&&(d.normalScale&&(d.normalScale.y*=-1),d.clearcoatNormalScale&&(d.clearcoatNormalScale.y*=-1)),this.cache.add(p,d),this.associations.set(d,this.associations.get(i))),i=d}t.material=i}getMaterialType(){return m.MeshStandardMaterial}loadMaterial(t){const n=this,i=this.json,o=this.extensions,a=i.materials[t];let c;const p={},d=a.extensions||{},g=[];if(d[_e.KHR_MATERIALS_UNLIT]){const b=o[_e.KHR_MATERIALS_UNLIT];c=b.getMaterialType(),g.push(b.extendParams(p,a,n))}else{const b=a.pbrMetallicRoughness||{};if(p.color=new m.Color(1,1,1),p.opacity=1,Array.isArray(b.baseColorFactor)){const C=b.baseColorFactor;p.color.fromArray(C),p.opacity=C[3]}b.baseColorTexture!==void 0&&g.push(n.assignTexture(p,"map",b.baseColorTexture,3001)),p.metalness=b.metallicFactor!==void 0?b.metallicFactor:1,p.roughness=b.roughnessFactor!==void 0?b.roughnessFactor:1,b.metallicRoughnessTexture!==void 0&&(g.push(n.assignTexture(p,"metalnessMap",b.metallicRoughnessTexture)),g.push(n.assignTexture(p,"roughnessMap",b.metallicRoughnessTexture))),c=this._invokeOne(function(C){return C.getMaterialType&&C.getMaterialType(t)}),g.push(Promise.all(this._invokeAll(function(C){return C.extendMaterialParams&&C.extendMaterialParams(t,p)})))}a.doubleSided===!0&&(p.side=m.DoubleSide);const y=a.alphaMode||Ri.OPAQUE;if(y===Ri.BLEND?(p.transparent=!0,p.depthWrite=!1):(p.transparent=!1,y===Ri.MASK&&(p.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&c!==m.MeshBasicMaterial&&(g.push(n.assignTexture(p,"normalMap",a.normalTexture)),p.normalScale=new m.Vector2(1,1),a.normalTexture.scale!==void 0)){const b=a.normalTexture.scale;p.normalScale.set(b,b)}return a.occlusionTexture!==void 0&&c!==m.MeshBasicMaterial&&(g.push(n.assignTexture(p,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(p.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&c!==m.MeshBasicMaterial&&(p.emissive=new m.Color().fromArray(a.emissiveFactor)),a.emissiveTexture!==void 0&&c!==m.MeshBasicMaterial&&g.push(n.assignTexture(p,"emissiveMap",a.emissiveTexture,3001)),Promise.all(g).then(function(){const b=new c(p);return a.name&&(b.name=a.name),Yt(b,a),n.associations.set(b,{materials:t}),a.extensions&&ln(o,b,a),b})}createUniqueName(t){const n=m.PropertyBinding.sanitizeNodeName(t||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(t){const n=this,i=this.extensions,o=this.primitiveCache;function a(p){return i[_e.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(p,n).then(function(d){return Po(d,p,n)})}const c=[];for(let p=0,d=t.length;p<d;p++){const g=t[p],y=Rl(g),b=o[y];if(b)c.push(b.promise);else{let C;g.extensions&&g.extensions[_e.KHR_DRACO_MESH_COMPRESSION]?C=a(g):C=Po(new m.BufferGeometry,g,n),o[y]={primitive:g,promise:C},c.push(C)}}return Promise.all(c)}loadMesh(t){const n=this,i=this.json,o=this.extensions,a=i.meshes[t],c=a.primitives,p=[];for(let d=0,g=c.length;d<g;d++){const y=c[d].material===void 0?Nl(this.cache):this.getDependency("material",c[d].material);p.push(y)}return p.push(n.loadGeometries(c)),Promise.all(p).then(function(d){const g=d.slice(0,d.length-1),y=d[d.length-1],b=[];for(let A=0,E=y.length;A<E;A++){const k=y[A],O=c[A];let R;const N=g[A];if(O.mode===ot.TRIANGLES||O.mode===ot.TRIANGLE_STRIP||O.mode===ot.TRIANGLE_FAN||O.mode===void 0)R=a.isSkinnedMesh===!0?new m.SkinnedMesh(k,N):new m.Mesh(k,N),R.isSkinnedMesh===!0&&R.normalizeSkinWeights(),O.mode===ot.TRIANGLE_STRIP?R.geometry=lo(R.geometry,m.TriangleStripDrawMode):O.mode===ot.TRIANGLE_FAN&&(R.geometry=lo(R.geometry,m.TriangleFanDrawMode));else if(O.mode===ot.LINES)R=new m.LineSegments(k,N);else if(O.mode===ot.LINE_STRIP)R=new m.Line(k,N);else if(O.mode===ot.LINE_LOOP)R=new m.LineLoop(k,N);else if(O.mode===ot.POINTS)R=new m.Points(k,N);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+O.mode);Object.keys(R.geometry.morphAttributes).length>0&&zl(R,a),R.name=n.createUniqueName(a.name||"mesh_"+t),Yt(R,a),O.extensions&&ln(o,R,O),n.assignFinalMaterial(R),b.push(R)}for(let A=0,E=b.length;A<E;A++)n.associations.set(b[A],{meshes:t,primitives:A});if(b.length===1)return a.extensions&&ln(o,b[0],a),b[0];const C=new m.Group;a.extensions&&ln(o,C,a),n.associations.set(C,{meshes:t});for(let A=0,E=b.length;A<E;A++)C.add(b[A]);return C})}loadCamera(t){let n;const i=this.json.cameras[t],o=i[i.type];if(!o){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?n=new m.PerspectiveCamera(m.MathUtils.radToDeg(o.yfov),o.aspectRatio||1,o.znear||1,o.zfar||2e6):i.type==="orthographic"&&(n=new m.OrthographicCamera(-o.xmag,o.xmag,o.ymag,-o.ymag,o.znear,o.zfar)),i.name&&(n.name=this.createUniqueName(i.name)),Yt(n,i),Promise.resolve(n)}loadSkin(t){const n=this.json.skins[t],i=[];for(let o=0,a=n.joints.length;o<a;o++)i.push(this._loadNodeShallow(n.joints[o]));return n.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",n.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(o){const a=o.pop(),c=o,p=[],d=[];for(let g=0,y=c.length;g<y;g++){const b=c[g];if(b){p.push(b);const C=new m.Matrix4;a!==null&&C.fromArray(a.array,g*16),d.push(C)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[g])}return new m.Skeleton(p,d)})}loadAnimation(t){const i=this.json.animations[t],o=i.name?i.name:"animation_"+t,a=[],c=[],p=[],d=[],g=[];for(let y=0,b=i.channels.length;y<b;y++){const C=i.channels[y],A=i.samplers[C.sampler],E=C.target,k=E.node,O=i.parameters!==void 0?i.parameters[A.input]:A.input,R=i.parameters!==void 0?i.parameters[A.output]:A.output;E.node!==void 0&&(a.push(this.getDependency("node",k)),c.push(this.getDependency("accessor",O)),p.push(this.getDependency("accessor",R)),d.push(A),g.push(E))}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(p),Promise.all(d),Promise.all(g)]).then(function(y){const b=y[0],C=y[1],A=y[2],E=y[3],k=y[4],O=[];for(let R=0,N=b.length;R<N;R++){const F=b[R],M=C[R],D=A[R],U=E[R],S=k[R];if(F===void 0)continue;F.updateMatrix();let T;switch(Kt[S.path]){case Kt.weights:T=m.NumberKeyframeTrack;break;case Kt.rotation:T=m.QuaternionKeyframeTrack;break;case Kt.position:case Kt.scale:default:T=m.VectorKeyframeTrack;break}const j=F.name?F.name:F.uuid,X=U.interpolation!==void 0?Fl[U.interpolation]:m.InterpolateLinear,Z=[];Kt[S.path]===Kt.weights?F.traverse(function(le){le.morphTargetInfluences&&Z.push(le.name?le.name:le.uuid)}):Z.push(j);let J=D.array;if(D.normalized){const le=Gi(J.constructor),he=new Float32Array(J.length);for(let oe=0,re=J.length;oe<re;oe++)he[oe]=J[oe]*le;J=he}for(let le=0,he=Z.length;le<he;le++){const oe=new T(Z[le]+"."+Kt[S.path],M.array,J,X);U.interpolation==="CUBICSPLINE"&&(oe.createInterpolant=function(ne){const H=this instanceof m.QuaternionKeyframeTrack?Bl:yo;return new H(this.times,this.values,this.getValueSize()/3,ne)},oe.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),O.push(oe)}}return new m.AnimationClip(o,void 0,O)})}createNodeMesh(t){const n=this.json,i=this,o=n.nodes[t];return o.mesh===void 0?null:i.getDependency("mesh",o.mesh).then(function(a){const c=i._getNodeRef(i.meshCache,o.mesh,a);return o.weights!==void 0&&c.traverse(function(p){if(p.isMesh)for(let d=0,g=o.weights.length;d<g;d++)p.morphTargetInfluences[d]=o.weights[d]}),c})}loadNode(t){const n=this.json,i=this,o=n.nodes[t],a=i._loadNodeShallow(t),c=[],p=o.children||[];for(let g=0,y=p.length;g<y;g++)c.push(i.getDependency("node",p[g]));const d=o.skin===void 0?Promise.resolve(null):i.getDependency("skin",o.skin);return Promise.all([a,Promise.all(c),d]).then(function(g){const y=g[0],b=g[1],C=g[2];C!==null&&y.traverse(function(A){A.isSkinnedMesh&&A.bind(C,Gl)});for(let A=0,E=b.length;A<E;A++)y.add(b[A]);return y})}_loadNodeShallow(t){const n=this.json,i=this.extensions,o=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const a=n.nodes[t],c=a.name?o.createUniqueName(a.name):"",p=[],d=o._invokeOne(function(g){return g.createNodeMesh&&g.createNodeMesh(t)});return d&&p.push(d),a.camera!==void 0&&p.push(o.getDependency("camera",a.camera).then(function(g){return o._getNodeRef(o.cameraCache,a.camera,g)})),o._invokeAll(function(g){return g.createNodeAttachment&&g.createNodeAttachment(t)}).forEach(function(g){p.push(g)}),this.nodeCache[t]=Promise.all(p).then(function(g){let y;if(a.isBone===!0?y=new m.Bone:g.length>1?y=new m.Group:g.length===1?y=g[0]:y=new m.Object3D,y!==g[0])for(let b=0,C=g.length;b<C;b++)y.add(g[b]);if(a.name&&(y.userData.name=a.name,y.name=c),Yt(y,a),a.extensions&&ln(i,y,a),a.matrix!==void 0){const b=new m.Matrix4;b.fromArray(a.matrix),y.applyMatrix4(b)}else a.translation!==void 0&&y.position.fromArray(a.translation),a.rotation!==void 0&&y.quaternion.fromArray(a.rotation),a.scale!==void 0&&y.scale.fromArray(a.scale);return o.associations.has(y)||o.associations.set(y,{}),o.associations.get(y).nodes=t,y}),this.nodeCache[t]}loadScene(t){const n=this.extensions,i=this.json.scenes[t],o=this,a=new m.Group;i.name&&(a.name=o.createUniqueName(i.name)),Yt(a,i),i.extensions&&ln(n,a,i);const c=i.nodes||[],p=[];for(let d=0,g=c.length;d<g;d++)p.push(o.getDependency("node",c[d]));return Promise.all(p).then(function(d){for(let y=0,b=d.length;y<b;y++)a.add(d[y]);const g=y=>{const b=new Map;for(const[C,A]of o.associations)(C instanceof m.Material||C instanceof m.Texture)&&b.set(C,A);return y.traverse(C=>{const A=o.associations.get(C);A!=null&&b.set(C,A)}),b};return o.associations=g(a),a})}}function Yl(v,t,n){const i=t.attributes,o=new m.Box3;if(i.POSITION!==void 0){const p=n.json.accessors[i.POSITION],d=p.min,g=p.max;if(d!==void 0&&g!==void 0){if(o.set(new m.Vector3(d[0],d[1],d[2]),new m.Vector3(g[0],g[1],g[2])),p.normalized){const y=Gi(Bn[p.componentType]);o.min.multiplyScalar(y),o.max.multiplyScalar(y)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const a=t.targets;if(a!==void 0){const p=new m.Vector3,d=new m.Vector3;for(let g=0,y=a.length;g<y;g++){const b=a[g];if(b.POSITION!==void 0){const C=n.json.accessors[b.POSITION],A=C.min,E=C.max;if(A!==void 0&&E!==void 0){if(d.setX(Math.max(Math.abs(A[0]),Math.abs(E[0]))),d.setY(Math.max(Math.abs(A[1]),Math.abs(E[1]))),d.setZ(Math.max(Math.abs(A[2]),Math.abs(E[2]))),C.normalized){const k=Gi(Bn[C.componentType]);d.multiplyScalar(k)}p.max(d)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(p)}v.boundingBox=o;const c=new m.Sphere;o.getCenter(c.center),c.radius=o.min.distanceTo(o.max)/2,v.boundingSphere=c}function Po(v,t,n){const i=t.attributes,o=[];function a(c,p){return n.getDependency("accessor",c).then(function(d){v.setAttribute(p,d)})}for(const c in i){const p=zi[c]||c.toLowerCase();p in v.attributes||o.push(a(i[c],p))}if(t.indices!==void 0&&!v.index){const c=n.getDependency("accessor",t.indices).then(function(p){v.setIndex(p)});o.push(c)}return Yt(v,t),Yl(v,t,n),Promise.all(o).then(function(){return t.targets!==void 0?Ul(v,t.targets,n):v})}class Ao extends m.ExtrudeGeometry{constructor(t,n={}){const{bevelEnabled:i=!1,bevelSize:o=8,bevelThickness:a=10,font:c,height:p=50,size:d=100,lineHeight:g=1,letterSpacing:y=0,...b}=n;if(c===void 0)super();else{const C=c.generateShapes(t,d,{lineHeight:g,letterSpacing:y});super(C,{...b,bevelEnabled:i,bevelSize:o,bevelThickness:a,depth:p})}this.type="TextGeometry"}}const Xl={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
8
|
+
(function(B,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("vue"),require("three"),require("@tresjs/core"),require("tweakpane"),require("@tweakpane/plugin-essentials")):typeof define=="function"&&define.amd?define(["exports","vue","three","@tresjs/core","tweakpane","@tweakpane/plugin-essentials"],h):(B=typeof globalThis<"u"?globalThis:B||self,h(B.trescientos={},B.Vue,B.Three,B.TresjsCore,B.tweakpane,B.EssentialsPlugin))})(this,function(B,h,l,q,En,Gn){"use strict";var zr=Object.defineProperty;var Rr=(B,h,l)=>h in B?zr(B,h,{enumerable:!0,configurable:!0,writable:!0,value:l}):B[h]=l;var Nt=(B,h,l)=>(Rr(B,typeof h!="symbol"?h+"":h,l),l);function jn(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const Yn=jn(Gn);function zt(c,e){if(e===l.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),c;if(e===l.TriangleFanDrawMode||e===l.TriangleStripDrawMode){let t=c.getIndex();if(t===null){const i=[],r=c.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)i.push(a);c.setIndex(i),t=c.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),c}const n=t.count-2,s=[];if(t)if(e===l.TriangleFanDrawMode)for(let i=1;i<=n;i++)s.push(t.getX(0)),s.push(t.getX(i)),s.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(s.push(t.getX(i)),s.push(t.getX(i+1)),s.push(t.getX(i+2))):(s.push(t.getX(i+2)),s.push(t.getX(i+1)),s.push(t.getX(i)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=c.clone();return o.setIndex(s),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),c}var fe=Uint8Array,Oe=Uint16Array,pt=Uint32Array,Rt=new fe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Et=new fe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Xn=new fe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Gt=function(c,e){for(var t=new Oe(31),n=0;n<31;++n)t[n]=e+=1<<c[n-1];for(var s=new pt(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)s[o]=o-t[n]<<5|n;return[t,s]},jt=Gt(Rt,2),Yt=jt[0],Zn=jt[1];Yt[28]=258,Zn[258]=28;for(var Qn=Gt(Et,0),Kn=Qn[0],dt=new Oe(32768),se=0;se<32768;++se){var Pe=(se&43690)>>>1|(se&21845)<<1;Pe=(Pe&52428)>>>2|(Pe&13107)<<2,Pe=(Pe&61680)>>>4|(Pe&3855)<<4,dt[se]=((Pe&65280)>>>8|(Pe&255)<<8)>>>1}for(var Ke=function(c,e,t){for(var n=c.length,s=0,o=new Oe(e);s<n;++s)++o[c[s]-1];var i=new Oe(e);for(s=0;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;var r;if(t){r=new Oe(1<<e);var a=15-e;for(s=0;s<n;++s)if(c[s])for(var u=s<<4|c[s],d=e-c[s],p=i[c[s]-1]++<<d,f=p|(1<<d)-1;p<=f;++p)r[dt[p]>>>a]=u}else for(r=new Oe(n),s=0;s<n;++s)c[s]&&(r[s]=dt[i[c[s]-1]++]>>>15-c[s]);return r},We=new fe(288),se=0;se<144;++se)We[se]=8;for(var se=144;se<256;++se)We[se]=9;for(var se=256;se<280;++se)We[se]=7;for(var se=280;se<288;++se)We[se]=8;for(var Xt=new fe(32),se=0;se<32;++se)Xt[se]=5;var Wn=Ke(We,9,1),qn=Ke(Xt,5,1),ft=function(c){for(var e=c[0],t=1;t<c.length;++t)c[t]>e&&(e=c[t]);return e},ye=function(c,e,t){var n=e/8|0;return(c[n]|c[n+1]<<8)>>(e&7)&t},mt=function(c,e){var t=e/8|0;return(c[t]|c[t+1]<<8|c[t+2]<<16)>>(e&7)},Jn=function(c){return(c/8|0)+(c&7&&1)},Hn=function(c,e,t){(e==null||e<0)&&(e=0),(t==null||t>c.length)&&(t=c.length);var n=new(c instanceof Oe?Oe:c instanceof pt?pt:fe)(t-e);return n.set(c.subarray(e,t)),n},$n=function(c,e,t){var n=c.length;if(!n||t&&!t.l&&n<5)return e||new fe(0);var s=!e||t,o=!t||t.i;t||(t={}),e||(e=new fe(n*3));var i=function(_e){var Ae=e.length;if(_e>Ae){var Fe=new fe(Math.max(Ae*2,_e));Fe.set(e),e=Fe}},r=t.f||0,a=t.p||0,u=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,y=n*8;do{if(!d){t.f=r=ye(c,a,1);var _=ye(c,a+1,3);if(a+=3,_)if(_==1)d=Wn,p=qn,f=9,m=5;else if(_==2){var M=ye(c,a,31)+257,g=ye(c,a+10,15)+4,A=M+ye(c,a+5,31)+1;a+=14;for(var b=new fe(A),w=new fe(19),v=0;v<g;++v)w[Xn[v]]=ye(c,a+v*3,7);a+=g*3;for(var C=ft(w),k=(1<<C)-1,I=Ke(w,C,1),v=0;v<A;){var U=I[ye(c,a,k)];a+=U&15;var x=U>>>4;if(x<16)b[v++]=x;else{var j=0,H=0;for(x==16?(H=3+ye(c,a,3),a+=2,j=b[v-1]):x==17?(H=3+ye(c,a,7),a+=3):x==18&&(H=11+ye(c,a,127),a+=7);H--;)b[v++]=j}}var G=b.subarray(0,M),ne=b.subarray(M);f=ft(G),m=ft(ne),d=Ke(G,f,1),p=Ke(ne,m,1)}else throw"invalid block type";else{var x=Jn(a)+4,S=c[x-4]|c[x-3]<<8,O=x+S;if(O>n){if(o)throw"unexpected EOF";break}s&&i(u+S),e.set(c.subarray(x,O),u),t.b=u+=S,t.p=a=O*8;continue}if(a>y){if(o)throw"unexpected EOF";break}}s&&i(u+131072);for(var X=(1<<f)-1,ae=(1<<m)-1,re=a;;re=a){var j=d[mt(c,a)&X],$=j>>>4;if(a+=j&15,a>y){if(o)throw"unexpected EOF";break}if(!j)throw"invalid length/literal";if($<256)e[u++]=$;else if($==256){re=a,d=null;break}else{var Q=$-254;if($>264){var v=$-257,K=Rt[v];Q=ye(c,a,(1<<K)-1)+Yt[v],a+=K}var ce=p[mt(c,a)&ae],L=ce>>>4;if(!ce)throw"invalid distance";a+=ce&15;var ne=Kn[L];if(L>3){var K=Et[L];ne+=mt(c,a)&(1<<K)-1,a+=K}if(a>y){if(o)throw"unexpected EOF";break}s&&i(u+131072);for(var de=u+Q;u<de;u+=4)e[u]=e[u-ne],e[u+1]=e[u+1-ne],e[u+2]=e[u+2-ne],e[u+3]=e[u+3-ne];u=de}}t.l=d,t.p=re,t.b=u,d&&(r=1,t.m=f,t.d=p,t.n=m)}while(!r);return u==e.length?e:Hn(e,0,u)},es=new fe(0),ts=function(c){if((c[0]&15)!=8||c[0]>>>4>7||(c[0]<<8|c[1])%31)throw"invalid zlib data";if(c[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function ns(c,e){return $n((ts(c),c.subarray(2,-4)),e)}var ss=typeof TextDecoder<"u"&&new TextDecoder,os=0;try{ss.decode(es,{stream:!0}),os=1}catch{}var is=Object.defineProperty,rs=(c,e,t)=>e in c?is(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,P=(c,e,t)=>(rs(c,typeof e!="symbol"?e+"":e,t),t);class as extends l.Object3D{constructor(e,t){super(),P(this,"isTransformControls",!0),P(this,"visible",!1),P(this,"domElement"),P(this,"raycaster",new l.Raycaster),P(this,"gizmo"),P(this,"plane"),P(this,"tempVector",new l.Vector3),P(this,"tempVector2",new l.Vector3),P(this,"tempQuaternion",new l.Quaternion),P(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),P(this,"pointStart",new l.Vector3),P(this,"pointEnd",new l.Vector3),P(this,"offset",new l.Vector3),P(this,"rotationAxis",new l.Vector3),P(this,"startNorm",new l.Vector3),P(this,"endNorm",new l.Vector3),P(this,"rotationAngle",0),P(this,"cameraPosition",new l.Vector3),P(this,"cameraQuaternion",new l.Quaternion),P(this,"cameraScale",new l.Vector3),P(this,"parentPosition",new l.Vector3),P(this,"parentQuaternion",new l.Quaternion),P(this,"parentQuaternionInv",new l.Quaternion),P(this,"parentScale",new l.Vector3),P(this,"worldPositionStart",new l.Vector3),P(this,"worldQuaternionStart",new l.Quaternion),P(this,"worldScaleStart",new l.Vector3),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"worldQuaternionInv",new l.Quaternion),P(this,"worldScale",new l.Vector3),P(this,"eye",new l.Vector3),P(this,"positionStart",new l.Vector3),P(this,"quaternionStart",new l.Quaternion),P(this,"scaleStart",new l.Vector3),P(this,"camera"),P(this,"object"),P(this,"enabled",!0),P(this,"axis",null),P(this,"mode","translate"),P(this,"translationSnap",null),P(this,"rotationSnap",null),P(this,"scaleSnap",null),P(this,"space","world"),P(this,"size",1),P(this,"dragging",!1),P(this,"showX",!0),P(this,"showY",!0),P(this,"showZ",!0),P(this,"changeEvent",{type:"change"}),P(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),P(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),P(this,"objectChangeEvent",{type:"objectChange"}),P(this,"intersectObjectWithRay",(s,o,i)=>{const r=o.intersectObject(s,!0);for(let a=0;a<r.length;a++)if(r[a].object.visible||i)return r[a];return!1}),P(this,"attach",s=>(this.object=s,this.visible=!0,this)),P(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),P(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),P(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),P(this,"pointerHover",s=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(s,this.camera);const o=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);o?this.axis=o.object.name:this.axis=null}),P(this,"pointerDown",s=>{if(!(this.object===void 0||this.dragging===!0||s.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(s,this.camera);const o=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(o){let i=this.space;if(this.mode==="scale"?i="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(i="world"),i==="local"&&this.mode==="rotate"){const r=this.rotationSnap;this.axis==="X"&&r&&(this.object.rotation.x=Math.round(this.object.rotation.x/r)*r),this.axis==="Y"&&r&&(this.object.rotation.y=Math.round(this.object.rotation.y/r)*r),this.axis==="Z"&&r&&(this.object.rotation.z=Math.round(this.object.rotation.z/r)*r)}this.object.updateMatrixWorld(),this.object.parent&&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(o.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),P(this,"pointerMove",s=>{const o=this.axis,i=this.mode,r=this.object;let a=this.space;if(i==="scale"?a="local":(o==="E"||o==="XYZE"||o==="XYZ")&&(a="world"),r===void 0||o===null||this.dragging===!1||s.button!==-1)return;this.raycaster.setFromCamera(s,this.camera);const u=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(u){if(this.pointEnd.copy(u.point).sub(this.worldPositionStart),i==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&o!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),o.indexOf("X")===-1&&(this.offset.x=0),o.indexOf("Y")===-1&&(this.offset.y=0),o.indexOf("Z")===-1&&(this.offset.z=0),a==="local"&&o!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),r.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(a==="local"&&(r.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),o.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),o.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),o.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this.quaternionStart)),a==="world"&&(r.parent&&r.position.add(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld)),o.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),o.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),o.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld))));else if(i==="scale"){if(o.search("XYZ")!==-1){let d=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(d*=-1),this.tempVector2.set(d,d,d)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),o.search("X")===-1&&(this.tempVector2.x=1),o.search("Y")===-1&&(this.tempVector2.y=1),o.search("Z")===-1&&(this.tempVector2.z=1);r.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(o.search("X")!==-1&&(this.object.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),o.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),o.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const d=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));o==="E"?(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):o==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*d):(o==="X"||o==="Y"||o==="Z")&&(this.rotationAxis.copy(this.unit[o]),this.tempVector.copy(this.unit[o]),a==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*d),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&o!=="E"&&o!=="XYZE"?(r.quaternion.copy(this.quaternionStart),r.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),r.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),P(this,"pointerUp",s=>{s.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),P(this,"getPointer",s=>{var o,i;if(this.domElement&&((o=this.domElement.ownerDocument)!=null&&o.pointerLockElement))return{x:0,y:0,button:s.button};{const r=s.changedTouches?s.changedTouches[0]:s,a=(i=this.domElement)==null?void 0:i.getBoundingClientRect();return{x:(r.clientX-a.left)/a.width*2-1,y:-(r.clientY-a.top)/a.height*2+1,button:s.button}}}),P(this,"onPointerHover",s=>{if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(s));break}}),P(this,"onPointerDown",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(s)),this.pointerDown(this.getPointer(s)))}),P(this,"onPointerMove",s=>{this.enabled&&this.pointerMove(this.getPointer(s))}),P(this,"onPointerUp",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(s)))}),P(this,"getMode",()=>this.mode),P(this,"setMode",s=>{this.mode=s}),P(this,"setTranslationSnap",s=>{this.translationSnap=s}),P(this,"setRotationSnap",s=>{this.rotationSnap=s}),P(this,"setScaleSnap",s=>{this.scaleSnap=s}),P(this,"setSize",s=>{this.size=s}),P(this,"setSpace",s=>{this.space=s}),P(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),P(this,"connect",s=>{s===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=s,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),P(this,"dispose",()=>{var s,o,i,r,a,u;(s=this.domElement)==null||s.removeEventListener("pointerdown",this.onPointerDown),(o=this.domElement)==null||o.removeEventListener("pointermove",this.onPointerHover),(r=(i=this.domElement)==null?void 0:i.ownerDocument)==null||r.removeEventListener("pointermove",this.onPointerMove),(u=(a=this.domElement)==null?void 0:a.ownerDocument)==null||u.removeEventListener("pointerup",this.onPointerUp),this.traverse(d=>{const p=d;p.geometry&&p.geometry.dispose(),p.material&&p.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new ls,this.add(this.gizmo),this.plane=new cs,this.add(this.plane);const n=(s,o)=>{let i=o;Object.defineProperty(this,s,{get:function(){return i!==void 0?i:o},set:function(r){i!==r&&(i=r,this.plane[s]=r,this.gizmo[s]=r,this.dispatchEvent({type:s+"-changed",value:r}),this.dispatchEvent(this.changeEvent))}}),this[s]=o,this.plane[s]=o,this.gizmo[s]=o};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class ls extends l.Object3D{constructor(){super(),P(this,"isTransformControlsGizmo",!0),P(this,"type","TransformControlsGizmo"),P(this,"tempVector",new l.Vector3(0,0,0)),P(this,"tempEuler",new l.Euler),P(this,"alignVector",new l.Vector3(0,1,0)),P(this,"zeroVector",new l.Vector3(0,0,0)),P(this,"lookAtMatrix",new l.Matrix4),P(this,"tempQuaternion",new l.Quaternion),P(this,"tempQuaternion2",new l.Quaternion),P(this,"identityQuaternion",new l.Quaternion),P(this,"unitX",new l.Vector3(1,0,0)),P(this,"unitY",new l.Vector3(0,1,0)),P(this,"unitZ",new l.Vector3(0,0,1)),P(this,"gizmo"),P(this,"picker"),P(this,"helper"),P(this,"rotationAxis",new l.Vector3),P(this,"cameraPosition",new l.Vector3),P(this,"worldPositionStart",new l.Vector3),P(this,"worldQuaternionStart",new l.Quaternion),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"eye",new l.Vector3),P(this,"camera",null),P(this,"enabled",!0),P(this,"axis",null),P(this,"mode","translate"),P(this,"space","world"),P(this,"size",1),P(this,"dragging",!1),P(this,"showX",!0),P(this,"showY",!0),P(this,"showZ",!0),P(this,"updateMatrixWorld",()=>{let $=this.space;this.mode==="scale"&&($="local");const Q=$==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let K=[];K=K.concat(this.picker[this.mode].children),K=K.concat(this.gizmo[this.mode].children),K=K.concat(this.helper[this.mode].children);for(let ce=0;ce<K.length;ce++){const L=K[ce];L.visible=!0,L.rotation.set(0,0,0),L.position.copy(this.worldPosition);let de;if(this.camera.isOrthographicCamera?de=(this.camera.top-this.camera.bottom)/this.camera.zoom:de=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),L.scale.set(1,1,1).multiplyScalar(de*this.size/7),L.tag==="helper"){L.visible=!1,L.name==="AXIS"?(L.position.copy(this.worldPositionStart),L.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),L.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),L.quaternion.multiply(this.tempQuaternion),L.visible=this.dragging),this.axis==="E"&&(L.visible=!1)):L.name==="START"?(L.position.copy(this.worldPositionStart),L.visible=this.dragging):L.name==="END"?(L.position.copy(this.worldPosition),L.visible=this.dragging):L.name==="DELTA"?(L.position.copy(this.worldPositionStart),L.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),L.scale.copy(this.tempVector),L.visible=this.dragging):(L.quaternion.copy(Q),this.dragging?L.position.copy(this.worldPositionStart):L.position.copy(this.worldPosition),this.axis&&(L.visible=this.axis.search(L.name)!==-1));continue}L.quaternion.copy(Q),this.mode==="translate"||this.mode==="scale"?((L.name==="X"||L.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),(L.name==="Y"||L.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),(L.name==="Z"||L.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.x*=-1:L.tag==="bwd"&&(L.visible=!1)),L.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.y*=-1:L.tag==="bwd"&&(L.visible=!1)),L.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.z*=-1:L.tag==="bwd"&&(L.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(Q),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(Q).invert()),L.name.search("E")!==-1&&L.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),L.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion)),L.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion)),L.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion))),L.visible=L.visible&&(L.name.indexOf("X")===-1||this.showX),L.visible=L.visible&&(L.name.indexOf("Y")===-1||this.showY),L.visible=L.visible&&(L.name.indexOf("Z")===-1||this.showZ),L.visible=L.visible&&(L.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),L.material.tempOpacity=L.material.tempOpacity||L.material.opacity,L.material.tempColor=L.material.tempColor||L.material.color.clone(),L.material.color.copy(L.material.tempColor),L.material.opacity=L.material.tempOpacity,this.enabled?this.axis&&(L.name===this.axis?(L.material.opacity=1,L.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(_e){return L.name===_e})?(L.material.opacity=1,L.material.color.lerp(new l.Color(1,1,1),.5)):(L.material.opacity*=.25,L.material.color.lerp(new l.Color(1,1,1),.5))):(L.material.opacity*=.5,L.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const s=e.clone();s.opacity=.33;const o=e.clone();o.color.set(16711680);const i=e.clone();i.color.set(65280);const r=e.clone();r.color.set(255);const a=e.clone();a.opacity=.25;const u=a.clone();u.color.set(16776960);const d=a.clone();d.color.set(65535);const p=a.clone();p.color.set(16711935),e.clone().color.set(16776960);const m=t.clone();m.color.set(16711680);const y=t.clone();y.color.set(65280);const _=t.clone();_.color.set(255);const x=t.clone();x.color.set(65535);const S=t.clone();S.color.set(16711935);const O=t.clone();O.color.set(16776960);const M=t.clone();M.color.set(7895160);const g=O.clone();g.opacity=.25;const A=new l.CylinderGeometry(0,.05,.2,12,1,!1),b=new l.BoxGeometry(.125,.125,.125),w=new l.BufferGeometry;w.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const v=($,Q)=>{const K=new l.BufferGeometry,ce=[];for(let L=0;L<=64*Q;++L)ce.push(0,Math.cos(L/32*Math.PI)*$,Math.sin(L/32*Math.PI)*$);return K.setAttribute("position",new l.Float32BufferAttribute(ce,3)),K},C=()=>{const $=new l.BufferGeometry;return $.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),$},k={X:[[new l.Mesh(A,o),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(A,o),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(w,m)]],Y:[[new l.Mesh(A,i),[0,1,0],null,null,"fwd"],[new l.Mesh(A,i),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(w,y),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(A,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(A,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(w,_),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),a.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),u.clone()),[.15,.15,0]],[new l.Line(w,O),[.18,.3,0],null,[.125,1,1]],[new l.Line(w,O),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),d.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(w,x),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(w,x),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),p.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(w,S),[.18,0,.3],null,[.125,1,1]],[new l.Line(w,S),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},U={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new l.Line(C(),s),null,null,null,"helper"]],X:[[new l.Line(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(w,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(w,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},j={X:[[new l.Line(v(1,.5),m)],[new l.Mesh(new l.OctahedronGeometry(.04,0),o),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(v(1,.5),y),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(v(1,.5),_),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),r),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(v(1.25,1),g),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(v(1,1),M),null,[0,Math.PI/2,0]]]},H={AXIS:[[new l.Line(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},ne={X:[[new l.Mesh(b,o),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(w,m),null,null,[.8,1,1]]],Y:[[new l.Mesh(b,i),[0,.8,0]],[new l.Line(w,y),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(b,r),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(w,_),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(b,u),[.85,.85,0],null,[2,2,.2]],[new l.Line(w,O),[.855,.98,0],null,[.125,1,1]],[new l.Line(w,O),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(b,d),[0,.85,.85],null,[.2,2,2]],[new l.Line(w,x),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(w,x),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(b,p),[.85,0,.85],null,[2,.2,2]],[new l.Line(w,S),[.855,0,.98],null,[.125,1,1]],[new l.Line(w,S),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[0,0,1.1]]]},X={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(b,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(b,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(b,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},ae={X:[[new l.Line(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(w,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(w,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},re=$=>{const Q=new l.Object3D;for(let K in $)for(let ce=$[K].length;ce--;){const L=$[K][ce][0].clone(),de=$[K][ce][1],_e=$[K][ce][2],Ae=$[K][ce][3],Fe=$[K][ce][4];L.name=K,L.tag=Fe,de&&L.position.set(de[0],de[1],de[2]),_e&&L.rotation.set(_e[0],_e[1],_e[2]),Ae&&L.scale.set(Ae[0],Ae[1],Ae[2]),L.updateMatrix();const st=L.geometry.clone();st.applyMatrix4(L.matrix),L.geometry=st,L.renderOrder=1/0,L.position.set(0,0,0),L.rotation.set(0,0,0),L.scale.set(1,1,1),Q.add(L)}return Q};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=re(k)),this.add(this.gizmo.rotate=re(j)),this.add(this.gizmo.scale=re(ne)),this.add(this.picker.translate=re(I)),this.add(this.picker.rotate=re(G)),this.add(this.picker.scale=re(X)),this.add(this.helper.translate=re(U)),this.add(this.helper.rotate=re(H)),this.add(this.helper.scale=re(ae)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class cs extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),P(this,"isTransformControlsPlane",!0),P(this,"type","TransformControlsPlane"),P(this,"unitX",new l.Vector3(1,0,0)),P(this,"unitY",new l.Vector3(0,1,0)),P(this,"unitZ",new l.Vector3(0,0,1)),P(this,"tempVector",new l.Vector3),P(this,"dirVector",new l.Vector3),P(this,"alignVector",new l.Vector3),P(this,"tempMatrix",new l.Matrix4),P(this,"identityQuaternion",new l.Quaternion),P(this,"cameraQuaternion",new l.Quaternion),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"eye",new l.Vector3),P(this,"axis",null),P(this,"mode","translate"),P(this,"space","world"),P(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var hs=Object.defineProperty,us=(c,e,t)=>e in c?hs(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,le=(c,e,t)=>(us(c,typeof e!="symbol"?e+"":e,t),t);const ze=new l.Euler(0,0,0,"YXZ"),Re=new l.Vector3,ps={type:"change"},ds={type:"lock"},fs={type:"unlock"},Zt=Math.PI/2;class gt extends l.EventDispatcher{constructor(e,t){super(),le(this,"camera"),le(this,"domElement"),le(this,"isLocked"),le(this,"minPolarAngle"),le(this,"maxPolarAngle"),le(this,"pointerSpeed"),le(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const s=n.movementX||n.mozMovementX||n.webkitMovementX||0,o=n.movementY||n.mozMovementY||n.webkitMovementY||0;ze.setFromQuaternion(this.camera.quaternion),ze.y-=s*.002*this.pointerSpeed,ze.x-=o*.002*this.pointerSpeed,ze.x=Math.max(Zt-this.maxPolarAngle,Math.min(Zt-this.minPolarAngle,ze.x)),this.camera.quaternion.setFromEuler(ze),this.dispatchEvent(ps)}),le(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(ds),this.isLocked=!0):(this.dispatchEvent(fs),this.isLocked=!1))}),le(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),le(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),le(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),le(this,"dispose",()=>{this.disconnect()}),le(this,"getObject",()=>this.camera),le(this,"direction",new l.Vector3(0,0,-1)),le(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),le(this,"moveForward",n=>{Re.setFromMatrixColumn(this.camera.matrix,0),Re.crossVectors(this.camera.up,Re),this.camera.position.addScaledVector(Re,n)}),le(this,"moveRight",n=>{Re.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Re,n)}),le(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),le(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var ms=Object.defineProperty,gs=(c,e,t)=>e in c?ms(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,z=(c,e,t)=>(gs(c,typeof e!="symbol"?e+"":e,t),t);const Qt=(c,e)=>(c%e+e)%e;class Kt extends l.EventDispatcher{constructor(e,t){super(),z(this,"object"),z(this,"domElement"),z(this,"enabled",!0),z(this,"target",new l.Vector3),z(this,"minDistance",0),z(this,"maxDistance",1/0),z(this,"minZoom",0),z(this,"maxZoom",1/0),z(this,"minPolarAngle",0),z(this,"maxPolarAngle",Math.PI),z(this,"minAzimuthAngle",-1/0),z(this,"maxAzimuthAngle",1/0),z(this,"enableDamping",!1),z(this,"dampingFactor",.05),z(this,"enableZoom",!0),z(this,"zoomSpeed",1),z(this,"enableRotate",!0),z(this,"rotateSpeed",1),z(this,"enablePan",!0),z(this,"panSpeed",1),z(this,"screenSpacePanning",!0),z(this,"keyPanSpeed",7),z(this,"autoRotate",!1),z(this,"autoRotateSpeed",2),z(this,"reverseOrbit",!1),z(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),z(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),z(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),z(this,"target0"),z(this,"position0"),z(this,"zoom0"),z(this,"_domElementKeyEvents",null),z(this,"getPolarAngle"),z(this,"getAzimuthalAngle"),z(this,"setPolarAngle"),z(this,"setAzimuthalAngle"),z(this,"getDistance"),z(this,"listenToKeyEvents"),z(this,"saveState"),z(this,"reset"),z(this,"update"),z(this,"connect"),z(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>d.phi,this.getAzimuthalAngle=()=>d.theta,this.setPolarAngle=T=>{let F=Qt(T,2*Math.PI),E=d.phi;E<0&&(E+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-E);2*Math.PI-ee<ee&&(F<E?F+=2*Math.PI:E+=2*Math.PI),p.phi=F-E,n.update()},this.setAzimuthalAngle=T=>{let F=Qt(T,2*Math.PI),E=d.theta;E<0&&(E+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-E);2*Math.PI-ee<ee&&(F<E?F+=2*Math.PI:E+=2*Math.PI),p.theta=F-E,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=T=>{T.addEventListener("keydown",Bn),this._domElementKeyEvents=T},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(s),n.update(),a=r.NONE},this.update=(()=>{const T=new l.Vector3,F=new l.Quaternion().setFromUnitVectors(e.up,new l.Vector3(0,1,0)),E=F.clone().invert(),ee=new l.Vector3,he=new l.Quaternion,Te=2*Math.PI;return function(){const Rn=n.object.position;T.copy(Rn).sub(n.target),T.applyQuaternion(F),d.setFromVector3(T),n.autoRotate&&a===r.NONE&&U(k()),n.enableDamping?(d.theta+=p.theta*n.dampingFactor,d.phi+=p.phi*n.dampingFactor):(d.theta+=p.theta,d.phi+=p.phi);let Se=n.minAzimuthAngle,Le=n.maxAzimuthAngle;return isFinite(Se)&&isFinite(Le)&&(Se<-Math.PI?Se+=Te:Se>Math.PI&&(Se-=Te),Le<-Math.PI?Le+=Te:Le>Math.PI&&(Le-=Te),Se<=Le?d.theta=Math.max(Se,Math.min(Le,d.theta)):d.theta=d.theta>(Se+Le)/2?Math.max(Se,d.theta):Math.min(Le,d.theta)),d.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,d.phi)),d.makeSafe(),d.radius*=f,d.radius=Math.max(n.minDistance,Math.min(n.maxDistance,d.radius)),n.enableDamping===!0?n.target.addScaledVector(m,n.dampingFactor):n.target.add(m),T.setFromSpherical(d),T.applyQuaternion(E),Rn.copy(n.target).add(T),n.object.lookAt(n.target),n.enableDamping===!0?(p.theta*=1-n.dampingFactor,p.phi*=1-n.dampingFactor,m.multiplyScalar(1-n.dampingFactor)):(p.set(0,0,0),m.set(0,0,0)),f=1,y||ee.distanceToSquared(n.object.position)>u||8*(1-he.dot(n.object.quaternion))>u?(n.dispatchEvent(s),ee.copy(n.object.position),he.copy(n.object.quaternion),y=!1,!0):!1}})(),this.connect=T=>{T===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=T,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Vn),n.domElement.addEventListener("pointerdown",kn),n.domElement.addEventListener("pointercancel",Fn),n.domElement.addEventListener("wheel",Un)},this.dispose=()=>{var T,F,E,ee,he,Te;(T=n.domElement)==null||T.removeEventListener("contextmenu",Vn),(F=n.domElement)==null||F.removeEventListener("pointerdown",kn),(E=n.domElement)==null||E.removeEventListener("pointercancel",Fn),(ee=n.domElement)==null||ee.removeEventListener("wheel",Un),(he=n.domElement)==null||he.ownerDocument.removeEventListener("pointermove",Ut),(Te=n.domElement)==null||Te.ownerDocument.removeEventListener("pointerup",Bt),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Bn)};const n=this,s={type:"change"},o={type:"start"},i={type:"end"},r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=r.NONE;const u=1e-6,d=new l.Spherical,p=new l.Spherical;let f=1;const m=new l.Vector3;let y=!1;const _=new l.Vector2,x=new l.Vector2,S=new l.Vector2,O=new l.Vector2,M=new l.Vector2,g=new l.Vector2,A=new l.Vector2,b=new l.Vector2,w=new l.Vector2,v=[],C={};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function I(){return Math.pow(.95,n.zoomSpeed)}function U(T){n.reverseOrbit?p.theta+=T:p.theta-=T}function j(T){n.reverseOrbit?p.phi+=T:p.phi-=T}const H=(()=>{const T=new l.Vector3;return function(E,ee){T.setFromMatrixColumn(ee,0),T.multiplyScalar(-E),m.add(T)}})(),G=(()=>{const T=new l.Vector3;return function(E,ee){n.screenSpacePanning===!0?T.setFromMatrixColumn(ee,1):(T.setFromMatrixColumn(ee,0),T.crossVectors(n.object.up,T)),T.multiplyScalar(E),m.add(T)}})(),ne=(()=>{const T=new l.Vector3;return function(E,ee){const he=n.domElement;if(he&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const Te=n.object.position;T.copy(Te).sub(n.target);let ut=T.length();ut*=Math.tan(n.object.fov/2*Math.PI/180),H(2*E*ut/he.clientHeight,n.object.matrix),G(2*ee*ut/he.clientHeight,n.object.matrix)}else he&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(H(E*(n.object.right-n.object.left)/n.object.zoom/he.clientWidth,n.object.matrix),G(ee*(n.object.top-n.object.bottom)/n.object.zoom/he.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function X(T){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera?f/=T:n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*T)),n.object.updateProjectionMatrix(),y=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ae(T){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera?f*=T:n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/T)),n.object.updateProjectionMatrix(),y=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function re(T){_.set(T.clientX,T.clientY)}function $(T){A.set(T.clientX,T.clientY)}function Q(T){O.set(T.clientX,T.clientY)}function K(T){x.set(T.clientX,T.clientY),S.subVectors(x,_).multiplyScalar(n.rotateSpeed);const F=n.domElement;F&&(U(2*Math.PI*S.x/F.clientHeight),j(2*Math.PI*S.y/F.clientHeight)),_.copy(x),n.update()}function ce(T){b.set(T.clientX,T.clientY),w.subVectors(b,A),w.y>0?X(I()):w.y<0&&ae(I()),A.copy(b),n.update()}function L(T){M.set(T.clientX,T.clientY),g.subVectors(M,O).multiplyScalar(n.panSpeed),ne(g.x,g.y),O.copy(M),n.update()}function de(T){T.deltaY<0?ae(I()):T.deltaY>0&&X(I()),n.update()}function _e(T){let F=!1;switch(T.code){case n.keys.UP:ne(0,n.keyPanSpeed),F=!0;break;case n.keys.BOTTOM:ne(0,-n.keyPanSpeed),F=!0;break;case n.keys.LEFT:ne(n.keyPanSpeed,0),F=!0;break;case n.keys.RIGHT:ne(-n.keyPanSpeed,0),F=!0;break}F&&(T.preventDefault(),n.update())}function Ae(){if(v.length==1)_.set(v[0].pageX,v[0].pageY);else{const T=.5*(v[0].pageX+v[1].pageX),F=.5*(v[0].pageY+v[1].pageY);_.set(T,F)}}function Fe(){if(v.length==1)O.set(v[0].pageX,v[0].pageY);else{const T=.5*(v[0].pageX+v[1].pageX),F=.5*(v[0].pageY+v[1].pageY);O.set(T,F)}}function st(){const T=v[0].pageX-v[1].pageX,F=v[0].pageY-v[1].pageY,E=Math.sqrt(T*T+F*F);A.set(0,E)}function Cr(){n.enableZoom&&st(),n.enablePan&&Fe()}function Dr(){n.enableZoom&&st(),n.enableRotate&&Ae()}function Cn(T){if(v.length==1)x.set(T.pageX,T.pageY);else{const E=Vt(T),ee=.5*(T.pageX+E.x),he=.5*(T.pageY+E.y);x.set(ee,he)}S.subVectors(x,_).multiplyScalar(n.rotateSpeed);const F=n.domElement;F&&(U(2*Math.PI*S.x/F.clientHeight),j(2*Math.PI*S.y/F.clientHeight)),_.copy(x)}function Dn(T){if(v.length==1)M.set(T.pageX,T.pageY);else{const F=Vt(T),E=.5*(T.pageX+F.x),ee=.5*(T.pageY+F.y);M.set(E,ee)}g.subVectors(M,O).multiplyScalar(n.panSpeed),ne(g.x,g.y),O.copy(M)}function In(T){const F=Vt(T),E=T.pageX-F.x,ee=T.pageY-F.y,he=Math.sqrt(E*E+ee*ee);b.set(0,he),w.set(0,Math.pow(b.y/A.y,n.zoomSpeed)),X(w.y),A.copy(b)}function Ir(T){n.enableZoom&&In(T),n.enablePan&&Dn(T)}function kr(T){n.enableZoom&&In(T),n.enableRotate&&Cn(T)}function kn(T){var F,E;n.enabled!==!1&&(v.length===0&&((F=n.domElement)==null||F.ownerDocument.addEventListener("pointermove",Ut),(E=n.domElement)==null||E.ownerDocument.addEventListener("pointerup",Bt)),Nr(T),T.pointerType==="touch"?Br(T):Fr(T))}function Ut(T){n.enabled!==!1&&(T.pointerType==="touch"?Vr(T):Ur(T))}function Bt(T){var F,E,ee;Nn(T),v.length===0&&((F=n.domElement)==null||F.releasePointerCapture(T.pointerId),(E=n.domElement)==null||E.ownerDocument.removeEventListener("pointermove",Ut),(ee=n.domElement)==null||ee.ownerDocument.removeEventListener("pointerup",Bt)),n.dispatchEvent(i),a=r.NONE}function Fn(T){Nn(T)}function Fr(T){let F;switch(T.button){case 0:F=n.mouseButtons.LEFT;break;case 1:F=n.mouseButtons.MIDDLE;break;case 2:F=n.mouseButtons.RIGHT;break;default:F=-1}switch(F){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;$(T),a=r.DOLLY;break;case l.MOUSE.ROTATE:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enablePan===!1)return;Q(T),a=r.PAN}else{if(n.enableRotate===!1)return;re(T),a=r.ROTATE}break;case l.MOUSE.PAN:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enableRotate===!1)return;re(T),a=r.ROTATE}else{if(n.enablePan===!1)return;Q(T),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&n.dispatchEvent(o)}function Ur(T){if(n.enabled!==!1)switch(a){case r.ROTATE:if(n.enableRotate===!1)return;K(T);break;case r.DOLLY:if(n.enableZoom===!1)return;ce(T);break;case r.PAN:if(n.enablePan===!1)return;L(T);break}}function Un(T){n.enabled===!1||n.enableZoom===!1||a!==r.NONE&&a!==r.ROTATE||(T.preventDefault(),n.dispatchEvent(o),de(T),n.dispatchEvent(i))}function Bn(T){n.enabled===!1||n.enablePan===!1||_e(T)}function Br(T){switch(zn(T),v.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;Ae(),a=r.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;Fe(),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Cr(),a=r.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Dr(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&n.dispatchEvent(o)}function Vr(T){switch(zn(T),a){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;Cn(T),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;Dn(T),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ir(T),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;kr(T),n.update();break;default:a=r.NONE}}function Vn(T){n.enabled!==!1&&T.preventDefault()}function Nr(T){v.push(T)}function Nn(T){delete C[T.pointerId];for(let F=0;F<v.length;F++)if(v[F].pointerId==T.pointerId){v.splice(F,1);return}}function zn(T){let F=C[T.pointerId];F===void 0&&(F=new l.Vector2,C[T.pointerId]=F),F.set(T.pageX,T.pageY)}function Vt(T){const F=T.pointerId===v[0].pointerId?v[1]:v[0];return C[F.pointerId]}t!==void 0&&this.connect(t),this.update()}}class _s extends Kt{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}class ys extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ms(t)}),this.register(function(t){return new Ds(t)}),this.register(function(t){return new Is(t)}),this.register(function(t){return new ks(t)}),this.register(function(t){return new Ts(t)}),this.register(function(t){return new Ss(t)}),this.register(function(t){return new Ls(t)}),this.register(function(t){return new Os(t)}),this.register(function(t){return new xs(t)}),this.register(function(t){return new Ps(t)}),this.register(function(t){return new bs(t)}),this.register(function(t){return new Cs(t)}),this.register(function(t){return new vs(t)}),this.register(function(t){return new Fs(t)}),this.register(function(t){return new Us(t)})}load(e,t,n,s){const o=this;let i;this.resourcePath!==""?i=this.resourcePath:this.path!==""?i=this.path:i=l.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const r=function(u){s?s(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},a=new l.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(u){try{o.parse(u,i,function(d){t(d),o.manager.itemEnd(e)},r)}catch(d){r(d)}},n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let o;const i={},r={};if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===Wt){try{i[Z.KHR_BINARY_GLTF]=new Bs(e)}catch(d){s&&s(d);return}o=JSON.parse(i[Z.KHR_BINARY_GLTF].content)}else o=JSON.parse(l.LoaderUtils.decodeText(new Uint8Array(e)));else o=e;if(o.asset===void 0||o.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const a=new Ws(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](a);r[d.name]=d,i[d.name]=!0}if(o.extensionsUsed)for(let u=0;u<o.extensionsUsed.length;++u){const d=o.extensionsUsed[u],p=o.extensionsRequired||[];switch(d){case Z.KHR_MATERIALS_UNLIT:i[d]=new As;break;case Z.KHR_DRACO_MESH_COMPRESSION:i[d]=new Vs(o,this.dracoLoader);break;case Z.KHR_TEXTURE_TRANSFORM:i[d]=new Ns;break;case Z.KHR_MESH_QUANTIZATION:i[d]=new zs;break;default:p.indexOf(d)>=0&&r[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}a.setExtensions(i),a.setPlugins(r),a.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,o){n.parse(e,t,s,o)})}}function ws(){let c={};return{get:function(e){return c[e]},add:function(e,t){c[e]=t},remove:function(e){delete c[e]},removeAll:function(){c={}}}}const Z={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_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_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 vs{constructor(e){this.parser=e,this.name=Z.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const o=t.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const d=new l.Color(16777215);a.color!==void 0&&d.fromArray(a.color);const p=a.range!==void 0?a.range:0;switch(a.type){case"directional":u=new l.DirectionalLight(d),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new l.PointLight(d),u.distance=p;break;case"spot":u=new l.SpotLight(d),u.distance=p,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,u.angle=a.spot.outerConeAngle,u.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return u.position.set(0,0,0),u.decay=2,De(u,a),a.intensity!==void 0&&(u.intensity=a.intensity),u.name=t.createUniqueName(a.name||"light_"+e),s=Promise.resolve(u),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],r=(o.extensions&&o.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return n._getNodeRef(t.cache,r,a)})}}class As{constructor(){this.name=Z.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new l.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const i=o.baseColorFactor;e.color.fromArray(i),e.opacity=i[3]}o.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",o.baseColorTexture,3001))}return Promise.all(s)}}class xs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class Ms{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const r=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(r,r)}return Promise.all(o)}}class bs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(o)}}class Ts{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=s.extensions[this.name];return i.sheenColorFactor!==void 0&&t.sheenColor.fromArray(i.sheenColorFactor),i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,3001)),i.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class Ss{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(o)}}class Ls{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const r=i.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color(r[0],r[1],r[2]),Promise.all(o)}}class Os{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class Ps{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const r=i.specularColorFactor||[1,1,1];return t.specularColor=new l.Color(r[0],r[1],r[2]),i.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,3001)),Promise.all(o)}}class Cs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(o)}}class Ds{constructor(e){this.parser=e,this.name=Z.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.extensions[this.name],i=t.options.ktx2Loader;if(!i){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 t.loadTextureImage(e,o.source,i)}}class Is{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],r=s.images[i.source];let a=n.textureLoader;if(r.uri){const u=n.options.manager.getHandler(r.uri);u!==null&&(a=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ks{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],r=s.images[i.source];let a=n.textureLoader;if(r.uri){const u=n.options.manager.getHandler(r.uri);u!==null&&(a=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Fs{constructor(e){this.name=Z.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],o=this.parser.getDependency("buffer",s.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(r){const a=s.byteOffset||0,u=s.byteLength||0,d=s.count,p=s.byteStride,f=new Uint8Array(r,a,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(d,p,f,s.mode,s.filter).then(function(m){return m.buffer}):i.ready.then(function(){const m=new ArrayBuffer(d*p);return i.decodeGltfBuffer(new Uint8Array(m),d,p,f,s.mode,s.filter),m})})}else return null}}class Us{constructor(e){this.name=Z.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const u of s.primitives)if(u.mode!==me.TRIANGLES&&u.mode!==me.TRIANGLE_STRIP&&u.mode!==me.TRIANGLE_FAN&&u.mode!==void 0)return null;const i=n.extensions[this.name].attributes,r=[],a={};for(const u in i)r.push(this.parser.getDependency("accessor",i[u]).then(d=>(a[u]=d,a[u])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(u=>{const d=u.pop(),p=d.isGroup?d.children:[d],f=u[0].count,m=[];for(const y of p){const _=new l.Matrix4,x=new l.Vector3,S=new l.Quaternion,O=new l.Vector3(1,1,1),M=new l.InstancedMesh(y.geometry,y.material,f);for(let g=0;g<f;g++)a.TRANSLATION&&x.fromBufferAttribute(a.TRANSLATION,g),a.ROTATION&&S.fromBufferAttribute(a.ROTATION,g),a.SCALE&&O.fromBufferAttribute(a.SCALE,g),M.setMatrixAt(g,_.compose(x,S,O));for(const g in a)g!=="TRANSLATION"&&g!=="ROTATION"&&g!=="SCALE"&&y.geometry.setAttribute(g,a[g]);l.Object3D.prototype.copy.call(M,y),this.parser.assignFinalMaterial(M),m.push(M)}return d.isGroup?(d.clear(),d.add(...m),d):m[0]}))}}const Wt="glTF",qe=12,qt={JSON:1313821514,BIN:5130562};class Bs{constructor(e){this.name=Z.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,qe);if(this.header={magic:l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Wt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-qe,s=new DataView(e,qe);let o=0;for(;o<n;){const i=s.getUint32(o,!0);o+=4;const r=s.getUint32(o,!0);if(o+=4,r===qt.JSON){const a=new Uint8Array(e,qe+o,i);this.content=l.LoaderUtils.decodeText(a)}else if(r===qt.BIN){const a=qe+o;this.body=e.slice(a,a+i)}o+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Vs{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Z.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,r={},a={},u={};for(const d in i){const p=yt[d]||d.toLowerCase();r[p]=i[d]}for(const d in e.attributes){const p=yt[d]||d.toLowerCase();if(i[d]!==void 0){const f=n.accessors[e.attributes[d]],m=Ee[f.componentType];u[p]=m.name,a[p]=f.normalized===!0}}return t.getDependency("bufferView",o).then(function(d){return new Promise(function(p){s.decodeDracoFile(d,function(f){for(const m in f.attributes){const y=f.attributes[m],_=a[m];_!==void 0&&(y.normalized=_)}p(f)},r,u)})})}}class Ns{constructor(){this.name=Z.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class zs{constructor(){this.name=Z.KHR_MESH_QUANTIZATION}}class Jt extends l.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let i=0;i!==s;i++)t[i]=n[o+i];return t}interpolate_(e,t,n,s){const o=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=r*2,u=r*3,d=s-t,p=(n-t)/d,f=p*p,m=f*p,y=e*u,_=y-u,x=-2*m+3*f,S=m-f,O=1-x,M=S-f+p;for(let g=0;g!==r;g++){const A=i[_+g+r],b=i[_+g+a]*d,w=i[y+g+r],v=i[y+g]*d;o[g]=O*A+M*b+x*w+S*v}return o}}const Rs=new l.Quaternion;class Es extends Jt{interpolate_(e,t,n,s){const o=super.interpolate_(e,t,n,s);return Rs.fromArray(o).normalize().toArray(o),o}}const me={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},Ee={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ht={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},$t={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},_t={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...l.REVISION.replace(/\D+/g,"")>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ce={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Gs={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},wt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function js(c){return c.DefaultMaterial===void 0&&(c.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),c.DefaultMaterial}function Ue(c,e,t){for(const n in t.extensions)c[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function De(c,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(c.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ys(c,e,t){let n=!1,s=!1,o=!1;for(let u=0,d=e.length;u<d;u++){const p=e[u];if(p.POSITION!==void 0&&(n=!0),p.NORMAL!==void 0&&(s=!0),p.COLOR_0!==void 0&&(o=!0),n&&s&&o)break}if(!n&&!s&&!o)return Promise.resolve(c);const i=[],r=[],a=[];for(let u=0,d=e.length;u<d;u++){const p=e[u];if(n){const f=p.POSITION!==void 0?t.getDependency("accessor",p.POSITION):c.attributes.position;i.push(f)}if(s){const f=p.NORMAL!==void 0?t.getDependency("accessor",p.NORMAL):c.attributes.normal;r.push(f)}if(o){const f=p.COLOR_0!==void 0?t.getDependency("accessor",p.COLOR_0):c.attributes.color;a.push(f)}}return Promise.all([Promise.all(i),Promise.all(r),Promise.all(a)]).then(function(u){const d=u[0],p=u[1],f=u[2];return n&&(c.morphAttributes.position=d),s&&(c.morphAttributes.normal=p),o&&(c.morphAttributes.color=f),c.morphTargetsRelative=!0,c})}function Xs(c,e){if(c.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)c.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(c.morphTargetInfluences.length===t.length){c.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)c.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Zs(c){let e;const t=c.extensions&&c.extensions[Z.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+vt(t.attributes):e=c.indices+":"+vt(c.attributes)+":"+c.mode,c.targets!==void 0)for(let n=0,s=c.targets.length;n<s;n++)e+=":"+vt(c.targets[n]);return e}function vt(c){let e="";const t=Object.keys(c).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+c[t[n]]+";";return e}function At(c){switch(c){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.")}}function Qs(c){return c.search(/\.jpe?g($|\?)/i)>0||c.search(/^data\:image\/jpeg/)===0?"image/jpeg":c.search(/\.webp($|\?)/i)>0||c.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Ks=new l.Matrix4;class Ws{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ws,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,s=!1,o=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||s&&o<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const r={scene:i[0][s.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:s.asset,parser:n,userData:{}};Ue(o,r,s),De(r,s),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(r)})).then(function(){e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,o=t.length;s<o;s++){const i=t[s].joints;for(let r=0,a=i.length;r<a;r++)e[i[r]].isBone=!0}for(let s=0,o=e.length;s<o;s++){const i=e[s];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),o=(i,r)=>{const a=this.associations.get(i);a!=null&&this.associations.set(r,a);for(const[u,d]of i.children.entries())o(d,r.children[u])};return o(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const o=e(t[s]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":s=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(o,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Z.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(o,i){n.load(l.LoaderUtils.resolveURL(t.uri,s.path),o,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const i=_t[s.type],r=Ee[s.componentType],a=s.normalized===!0,u=new r(s.count*i);return Promise.resolve(new l.BufferAttribute(u,i,a))}const o=[];return s.bufferView!==void 0?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),s.sparse!==void 0&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then(function(i){const r=i[0],a=_t[s.type],u=Ee[s.componentType],d=u.BYTES_PER_ELEMENT,p=d*a,f=s.byteOffset||0,m=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,y=s.normalized===!0;let _,x;if(m&&m!==p){const S=Math.floor(f/m),O="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+S+":"+s.count;let M=t.cache.get(O);M||(_=new u(r,S*m,s.count*m/d),M=new l.InterleavedBuffer(_,m/d),t.cache.add(O,M)),x=new l.InterleavedBufferAttribute(M,a,f%m/d,y)}else r===null?_=new u(s.count*a):_=new u(r,f,s.count*a),x=new l.BufferAttribute(_,a,y);if(s.sparse!==void 0){const S=_t.SCALAR,O=Ee[s.sparse.indices.componentType],M=s.sparse.indices.byteOffset||0,g=s.sparse.values.byteOffset||0,A=new O(i[1],M,s.sparse.count*S),b=new u(i[2],g,s.sparse.count*a);r!==null&&(x=new l.BufferAttribute(x.array.slice(),x.itemSize,x.normalized));for(let w=0,v=A.length;w<v;w++){const C=A[w];if(x.setX(C,b[w*a]),a>=2&&x.setY(C,b[w*a+1]),a>=3&&x.setZ(C,b[w*a+2]),a>=4&&x.setW(C,b[w*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return x})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,i=t.images[o];let r=this.textureLoader;if(i.uri){const a=n.manager.getHandler(i.uri);a!==null&&(r=a)}return this.loadTextureImage(e,o,r)}loadTextureImage(e,t,n){const s=this,o=this.json,i=o.textures[e],r=o.images[t],a=(r.uri||r.bufferView)+":"+i.sampler;if(this.textureCache[a])return this.textureCache[a];const u=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=i.name||r.name||"",d.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(d.name=r.uri);const f=(o.samplers||{})[i.sampler]||{};return d.magFilter=Ht[f.magFilter]||l.LinearFilter,d.minFilter=Ht[f.minFilter]||l.LinearMipmapLinearFilter,d.wrapS=$t[f.wrapS]||l.RepeatWrapping,d.wrapT=$t[f.wrapT]||l.RepeatWrapping,s.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[a]=u,u}loadImageSource(e,t){const n=this,s=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(p=>p.clone());const i=s.images[e],r=self.URL||self.webkitURL;let a=i.uri||"",u=!1;if(i.bufferView!==void 0)a=n.getDependency("bufferView",i.bufferView).then(function(p){u=!0;const f=new Blob([p],{type:i.mimeType});return a=r.createObjectURL(f),a});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(a).then(function(p){return new Promise(function(f,m){let y=f;t.isImageBitmapLoader===!0&&(y=function(_){const x=new l.Texture(_);x.needsUpdate=!0,f(x)}),t.load(l.LoaderUtils.resolveURL(p,o.path),y,void 0,m)})}).then(function(p){return u===!0&&r.revokeObjectURL(a),p.userData.mimeType=i.mimeType||Qs(i.uri),p}).catch(function(p){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),p});return this.sourceCache[e]=d,d}assignTexture(e,t,n,s){const o=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),o.extensions[Z.KHR_TEXTURE_TRANSFORM]){const r=n.extensions!==void 0?n.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=o.associations.get(i);i=o.extensions[Z.KHR_TEXTURE_TRANSFORM].extendTexture(i,r),o.associations.set(i,a)}}return s!==void 0&&("colorSpace"in i?i.colorSpace=s===3001?"srgb":"srgb-linear":i.encoding=s),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new l.PointsMaterial,l.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(r,a)),n=a}else if(e.isLine){const r="LineBasicMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new l.LineBasicMaterial,l.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(r,a)),n=a}if(s||o||i){let r="ClonedMaterial:"+n.uuid+":";s&&(r+="derivative-tangents:"),o&&(r+="vertex-colors:"),i&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=n.clone(),o&&(a.vertexColors=!0),i&&(a.flatShading=!0),s&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(n))),n=a}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,o=n.materials[e];let i;const r={},a=o.extensions||{},u=[];if(a[Z.KHR_MATERIALS_UNLIT]){const p=s[Z.KHR_MATERIALS_UNLIT];i=p.getMaterialType(),u.push(p.extendParams(r,o,t))}else{const p=o.pbrMetallicRoughness||{};if(r.color=new l.Color(1,1,1),r.opacity=1,Array.isArray(p.baseColorFactor)){const f=p.baseColorFactor;r.color.fromArray(f),r.opacity=f[3]}p.baseColorTexture!==void 0&&u.push(t.assignTexture(r,"map",p.baseColorTexture,3001)),r.metalness=p.metallicFactor!==void 0?p.metallicFactor:1,r.roughness=p.roughnessFactor!==void 0?p.roughnessFactor:1,p.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(r,"metalnessMap",p.metallicRoughnessTexture)),u.push(t.assignTexture(r,"roughnessMap",p.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,r)})))}o.doubleSided===!0&&(r.side=l.DoubleSide);const d=o.alphaMode||wt.OPAQUE;if(d===wt.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===wt.MASK&&(r.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&i!==l.MeshBasicMaterial&&(u.push(t.assignTexture(r,"normalMap",o.normalTexture)),r.normalScale=new l.Vector2(1,1),o.normalTexture.scale!==void 0)){const p=o.normalTexture.scale;r.normalScale.set(p,p)}return o.occlusionTexture!==void 0&&i!==l.MeshBasicMaterial&&(u.push(t.assignTexture(r,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&i!==l.MeshBasicMaterial&&(r.emissive=new l.Color().fromArray(o.emissiveFactor)),o.emissiveTexture!==void 0&&i!==l.MeshBasicMaterial&&u.push(t.assignTexture(r,"emissiveMap",o.emissiveTexture,3001)),Promise.all(u).then(function(){const p=new i(r);return o.name&&(p.name=o.name),De(p,o),t.associations.set(p,{materials:e}),o.extensions&&Ue(s,p,o),p})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function o(r){return n[Z.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return en(a,r,t)})}const i=[];for(let r=0,a=e.length;r<a;r++){const u=e[r],d=Zs(u),p=s[d];if(p)i.push(p.promise);else{let f;u.extensions&&u.extensions[Z.KHR_DRACO_MESH_COMPRESSION]?f=o(u):f=en(new l.BufferGeometry,u,t),s[d]={primitive:u,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,s=this.extensions,o=n.meshes[e],i=o.primitives,r=[];for(let a=0,u=i.length;a<u;a++){const d=i[a].material===void 0?js(this.cache):this.getDependency("material",i[a].material);r.push(d)}return r.push(t.loadGeometries(i)),Promise.all(r).then(function(a){const u=a.slice(0,a.length-1),d=a[a.length-1],p=[];for(let m=0,y=d.length;m<y;m++){const _=d[m],x=i[m];let S;const O=u[m];if(x.mode===me.TRIANGLES||x.mode===me.TRIANGLE_STRIP||x.mode===me.TRIANGLE_FAN||x.mode===void 0)S=o.isSkinnedMesh===!0?new l.SkinnedMesh(_,O):new l.Mesh(_,O),S.isSkinnedMesh===!0&&S.normalizeSkinWeights(),x.mode===me.TRIANGLE_STRIP?S.geometry=zt(S.geometry,l.TriangleStripDrawMode):x.mode===me.TRIANGLE_FAN&&(S.geometry=zt(S.geometry,l.TriangleFanDrawMode));else if(x.mode===me.LINES)S=new l.LineSegments(_,O);else if(x.mode===me.LINE_STRIP)S=new l.Line(_,O);else if(x.mode===me.LINE_LOOP)S=new l.LineLoop(_,O);else if(x.mode===me.POINTS)S=new l.Points(_,O);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(S.geometry.morphAttributes).length>0&&Xs(S,o),S.name=t.createUniqueName(o.name||"mesh_"+e),De(S,o),x.extensions&&Ue(s,S,x),t.assignFinalMaterial(S),p.push(S)}for(let m=0,y=p.length;m<y;m++)t.associations.set(p[m],{meshes:e,primitives:m});if(p.length===1)return o.extensions&&Ue(s,p[0],o),p[0];const f=new l.Group;o.extensions&&Ue(s,f,o),t.associations.set(f,{meshes:e});for(let m=0,y=p.length;m<y;m++)f.add(p[m]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),De(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,o=t.joints.length;s<o;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const o=s.pop(),i=s,r=[],a=[];for(let u=0,d=i.length;u<d;u++){const p=i[u];if(p){r.push(p);const f=new l.Matrix4;o!==null&&f.fromArray(o.array,u*16),a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new l.Skeleton(r,a)})}loadAnimation(e){const n=this.json.animations[e],s=n.name?n.name:"animation_"+e,o=[],i=[],r=[],a=[],u=[];for(let d=0,p=n.channels.length;d<p;d++){const f=n.channels[d],m=n.samplers[f.sampler],y=f.target,_=y.node,x=n.parameters!==void 0?n.parameters[m.input]:m.input,S=n.parameters!==void 0?n.parameters[m.output]:m.output;y.node!==void 0&&(o.push(this.getDependency("node",_)),i.push(this.getDependency("accessor",x)),r.push(this.getDependency("accessor",S)),a.push(m),u.push(y))}return Promise.all([Promise.all(o),Promise.all(i),Promise.all(r),Promise.all(a),Promise.all(u)]).then(function(d){const p=d[0],f=d[1],m=d[2],y=d[3],_=d[4],x=[];for(let S=0,O=p.length;S<O;S++){const M=p[S],g=f[S],A=m[S],b=y[S],w=_[S];if(M===void 0)continue;M.updateMatrix();let v;switch(Ce[w.path]){case Ce.weights:v=l.NumberKeyframeTrack;break;case Ce.rotation:v=l.QuaternionKeyframeTrack;break;case Ce.position:case Ce.scale:default:v=l.VectorKeyframeTrack;break}const C=M.name?M.name:M.uuid,k=b.interpolation!==void 0?Gs[b.interpolation]:l.InterpolateLinear,I=[];Ce[w.path]===Ce.weights?M.traverse(function(j){j.morphTargetInfluences&&I.push(j.name?j.name:j.uuid)}):I.push(C);let U=A.array;if(A.normalized){const j=At(U.constructor),H=new Float32Array(U.length);for(let G=0,ne=U.length;G<ne;G++)H[G]=U[G]*j;U=H}for(let j=0,H=I.length;j<H;j++){const G=new v(I[j]+"."+Ce[w.path],g.array,U,k);b.interpolation==="CUBICSPLINE"&&(G.createInterpolant=function(X){const ae=this instanceof l.QuaternionKeyframeTrack?Es:Jt;return new ae(this.times,this.values,this.getValueSize()/3,X)},G.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),x.push(G)}}return new l.AnimationClip(s,void 0,x)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(o){const i=n._getNodeRef(n.meshCache,s.mesh,o);return s.weights!==void 0&&i.traverse(function(r){if(r.isMesh)for(let a=0,u=s.weights.length;a<u;a++)r.morphTargetInfluences[a]=s.weights[a]}),i})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],o=n._loadNodeShallow(e),i=[],r=s.children||[];for(let u=0,d=r.length;u<d;u++)i.push(n.getDependency("node",r[u]));const a=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([o,Promise.all(i),a]).then(function(u){const d=u[0],p=u[1],f=u[2];f!==null&&d.traverse(function(m){m.isSkinnedMesh&&m.bind(f,Ks)});for(let m=0,y=p.length;m<y;m++)d.add(p[m]);return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],i=o.name?s.createUniqueName(o.name):"",r=[],a=s._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return a&&r.push(a),o.camera!==void 0&&r.push(s.getDependency("camera",o.camera).then(function(u){return s._getNodeRef(s.cameraCache,o.camera,u)})),s._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){r.push(u)}),this.nodeCache[e]=Promise.all(r).then(function(u){let d;if(o.isBone===!0?d=new l.Bone:u.length>1?d=new l.Group:u.length===1?d=u[0]:d=new l.Object3D,d!==u[0])for(let p=0,f=u.length;p<f;p++)d.add(u[p]);if(o.name&&(d.userData.name=o.name,d.name=i),De(d,o),o.extensions&&Ue(n,d,o),o.matrix!==void 0){const p=new l.Matrix4;p.fromArray(o.matrix),d.applyMatrix4(p)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return s.associations.has(d)||s.associations.set(d,{}),s.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,o=new l.Group;n.name&&(o.name=s.createUniqueName(n.name)),De(o,n),n.extensions&&Ue(t,o,n);const i=n.nodes||[],r=[];for(let a=0,u=i.length;a<u;a++)r.push(s.getDependency("node",i[a]));return Promise.all(r).then(function(a){for(let d=0,p=a.length;d<p;d++)o.add(a[d]);const u=d=>{const p=new Map;for(const[f,m]of s.associations)(f instanceof l.Material||f instanceof l.Texture)&&p.set(f,m);return d.traverse(f=>{const m=s.associations.get(f);m!=null&&p.set(f,m)}),p};return s.associations=u(o),o})}}function qs(c,e,t){const n=e.attributes,s=new l.Box3;if(n.POSITION!==void 0){const r=t.json.accessors[n.POSITION],a=r.min,u=r.max;if(a!==void 0&&u!==void 0){if(s.set(new l.Vector3(a[0],a[1],a[2]),new l.Vector3(u[0],u[1],u[2])),r.normalized){const d=At(Ee[r.componentType]);s.min.multiplyScalar(d),s.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const r=new l.Vector3,a=new l.Vector3;for(let u=0,d=o.length;u<d;u++){const p=o[u];if(p.POSITION!==void 0){const f=t.json.accessors[p.POSITION],m=f.min,y=f.max;if(m!==void 0&&y!==void 0){if(a.setX(Math.max(Math.abs(m[0]),Math.abs(y[0]))),a.setY(Math.max(Math.abs(m[1]),Math.abs(y[1]))),a.setZ(Math.max(Math.abs(m[2]),Math.abs(y[2]))),f.normalized){const _=At(Ee[f.componentType]);a.multiplyScalar(_)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(r)}c.boundingBox=s;const i=new l.Sphere;s.getCenter(i.center),i.radius=s.min.distanceTo(s.max)/2,c.boundingSphere=i}function en(c,e,t){const n=e.attributes,s=[];function o(i,r){return t.getDependency("accessor",i).then(function(a){c.setAttribute(r,a)})}for(const i in n){const r=yt[i]||i.toLowerCase();r in c.attributes||s.push(o(n[i],r))}if(e.indices!==void 0&&!c.index){const i=t.getDependency("accessor",e.indices).then(function(r){c.setIndex(r)});s.push(i)}return De(c,e),qs(c,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Ys(c,e.targets,t):c})}class tn extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:s=8,bevelThickness:o=10,font:i,height:r=50,size:a=100,lineHeight:u=1,letterSpacing:d=0,...p}=t;if(i===void 0)super();else{const f=i.generateShapes(e,a,{lineHeight:u,letterSpacing:d});super(f,{...p,bevelEnabled:n,bevelSize:s,bevelThickness:o,depth:r})}this.type="TextGeometry"}}const Js={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
9
9
|
varying vec2 vUv;
|
|
10
10
|
|
|
11
11
|
void main() {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
gl_FragColor = sum;
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
`},
|
|
40
|
+
`},Hs={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`
|
|
41
41
|
varying vec2 vUv;
|
|
42
42
|
|
|
43
43
|
void main() {
|
|
@@ -70,29 +70,26 @@
|
|
|
70
70
|
gl_FragColor = sum;
|
|
71
71
|
|
|
72
72
|
}
|
|
73
|
-
`};function Mo(v,t,n){const i=n.length-v-1;if(t>=n[i])return i-1;if(t<=n[v])return v;let o=v,a=i,c=Math.floor((o+a)/2);for(;t<n[c]||t>=n[c+1];)t<n[c]?a=c:o=c,c=Math.floor((o+a)/2);return c}function ql(v,t,n,i){const o=[],a=[],c=[];o[0]=1;for(let p=1;p<=n;++p){a[p]=t-i[v+1-p],c[p]=i[v+p]-t;let d=0;for(let g=0;g<p;++g){const y=c[g+1],b=a[p-g],C=o[g]/(y+b);o[g]=d+y*C,d=b*C}o[p]=d}return o}function Ql(v,t,n,i){const o=Mo(v,i,t),a=ql(o,i,v,t),c=new m.Vector4(0,0,0,0);for(let p=0;p<=v;++p){const d=n[o-v+p],g=a[p],y=d.w*g;c.x+=d.x*y,c.y+=d.y*y,c.z+=d.z*y,c.w+=d.w*g}return c}function Wl(v,t,n,i,o){const a=[];for(let b=0;b<=n;++b)a[b]=0;const c=[];for(let b=0;b<=i;++b)c[b]=a.slice(0);const p=[];for(let b=0;b<=n;++b)p[b]=a.slice(0);p[0][0]=1;const d=a.slice(0),g=a.slice(0);for(let b=1;b<=n;++b){d[b]=t-o[v+1-b],g[b]=o[v+b]-t;let C=0;for(let A=0;A<b;++A){const E=g[A+1],k=d[b-A];p[b][A]=E+k;const O=p[A][b-1]/p[b][A];p[A][b]=C+E*O,C=k*O}p[b][b]=C}for(let b=0;b<=n;++b)c[0][b]=p[b][n];for(let b=0;b<=n;++b){let C=0,A=1;const E=[];for(let k=0;k<=n;++k)E[k]=a.slice(0);E[0][0]=1;for(let k=1;k<=i;++k){let O=0;const R=b-k,N=n-k;b>=k&&(E[A][0]=E[C][0]/p[N+1][R],O=E[A][0]*p[R][N]);const F=R>=-1?1:-R,M=b-1<=N?k-1:n-b;for(let U=F;U<=M;++U)E[A][U]=(E[C][U]-E[C][U-1])/p[N+1][R+U],O+=E[A][U]*p[R+U][N];b<=N&&(E[A][k]=-E[C][k-1]/p[N+1][b],O+=E[A][k]*p[b][N]),c[k][b]=O;const D=C;C=A,A=D}}let y=n;for(let b=1;b<=i;++b){for(let C=0;C<=n;++C)c[b][C]*=y;y*=n-b}return c}function Jl(v,t,n,i,o){const a=o<v?o:v,c=[],p=Mo(v,i,t),d=Wl(p,i,v,a,t),g=[];for(let y=0;y<n.length;++y){const b=n[y].clone(),C=b.w;b.x*=C,b.y*=C,b.z*=C,g[y]=b}for(let y=0;y<=a;++y){const b=g[p-v].clone().multiplyScalar(d[y][0]);for(let C=1;C<=v;++C)b.add(g[p-v+C].clone().multiplyScalar(d[y][C]));c[y]=b}for(let y=a+1;y<=o+1;++y)c[y]=new m.Vector4(0,0,0);return c}function Hl(v,t){let n=1;for(let o=2;o<=v;++o)n*=o;let i=1;for(let o=2;o<=t;++o)i*=o;for(let o=2;o<=v-t;++o)i*=o;return n/i}function $l(v){const t=v.length,n=[],i=[];for(let a=0;a<t;++a){const c=v[a];n[a]=new m.Vector3(c.x,c.y,c.z),i[a]=c.w}const o=[];for(let a=0;a<t;++a){const c=n[a].clone();for(let p=1;p<=a;++p)c.sub(o[a-p].clone().multiplyScalar(Hl(a,p)*i[p]));o[a]=c.divideScalar(i[0])}return o}function ec(v,t,n,i,o){const a=Jl(v,t,n,i,o);return $l(a)}class ko extends m.Curve{constructor(t,n,i,o,a){super(),this.degree=t,this.knots=n,this.controlPoints=[],this.startKnot=o||0,this.endKnot=a||this.knots.length-1;for(let c=0;c<i.length;++c){const p=i[c];this.controlPoints[c]=new m.Vector4(p.x,p.y,p.z,p.w)}}getPoint(t,n){const i=n||new m.Vector3,o=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),a=Ql(this.degree,this.knots,this.controlPoints,o);return a.w!=1&&a.divideScalar(a.w),i.set(a.x,a.y,a.z)}getTangent(t,n){const i=n||new m.Vector3,o=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),a=ec(this.degree,this.knots,this.controlPoints,o,1);return i.copy(a[1]).normalize(),i}}let ve,Be,We;class tc extends m.Loader{constructor(t){super(t)}load(t,n,i,o){const a=this,c=a.path===""?m.LoaderUtils.extractUrlBase(t):a.path,p=new m.FileLoader(this.manager);p.setPath(a.path),p.setResponseType("arraybuffer"),p.setRequestHeader(a.requestHeader),p.setWithCredentials(a.withCredentials),p.load(t,function(d){try{n(a.parse(d,c))}catch(g){o?o(g):console.error(g),a.manager.itemError(t)}},i,o)}parse(t,n){if(ac(t))ve=new oc().parse(t);else{const o=Do(t);if(!lc(o))throw new Error("THREE.FBXLoader: Unknown format.");if(To(o)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+To(o));ve=new rc().parse(o)}const i=new m.TextureLoader(this.manager).setPath(this.resourcePath||n).setCrossOrigin(this.crossOrigin);return new nc(i,this.manager).parse(ve)}}class nc{constructor(t,n){this.textureLoader=t,this.manager=n}parse(){Be=this.parseConnections();const t=this.parseImages(),n=this.parseTextures(t),i=this.parseMaterials(n),o=this.parseDeformers(),a=new sc().parse(o);return this.parseScene(o,a,i),We}parseConnections(){const t=new Map;return"Connections"in ve&&ve.Connections.connections.forEach(function(i){const o=i[0],a=i[1],c=i[2];t.has(o)||t.set(o,{parents:[],children:[]});const p={ID:a,relationship:c};t.get(o).parents.push(p),t.has(a)||t.set(a,{parents:[],children:[]});const d={ID:o,relationship:c};t.get(a).children.push(d)}),t}parseImages(){const t={},n={};if("Video"in ve.Objects){const i=ve.Objects.Video;for(const o in i){const a=i[o],c=parseInt(o);if(t[c]=a.RelativeFilename||a.Filename,"Content"in a){const p=a.Content instanceof ArrayBuffer&&a.Content.byteLength>0,d=typeof a.Content=="string"&&a.Content!=="";if(p||d){const g=this.parseImage(i[o]);n[a.RelativeFilename||a.Filename]=g}}}}for(const i in t){const o=t[i];n[o]!==void 0?t[i]=n[o]:t[i]=t[i].split("\\").pop()}return t}parseImage(t){const n=t.Content,i=t.RelativeFilename||t.Filename,o=i.slice(i.lastIndexOf(".")+1).toLowerCase();let a;switch(o){case"bmp":a="image/bmp";break;case"jpg":case"jpeg":a="image/jpeg";break;case"png":a="image/png";break;case"tif":a="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",i),a="image/tga";break;default:console.warn('FBXLoader: Image type "'+o+'" is not supported.');return}if(typeof n=="string")return"data:"+a+";base64,"+n;{const c=new Uint8Array(n);return window.URL.createObjectURL(new Blob([c],{type:a}))}}parseTextures(t){const n=new Map;if("Texture"in ve.Objects){const i=ve.Objects.Texture;for(const o in i){const a=this.parseTexture(i[o],t);n.set(parseInt(o),a)}}return n}parseTexture(t,n){const i=this.loadTexture(t,n);i.ID=t.id,i.name=t.attrName;const o=t.WrapModeU,a=t.WrapModeV,c=o!==void 0?o.value:0,p=a!==void 0?a.value:0;if(i.wrapS=c===0?m.RepeatWrapping:m.ClampToEdgeWrapping,i.wrapT=p===0?m.RepeatWrapping:m.ClampToEdgeWrapping,"Scaling"in t){const d=t.Scaling.value;i.repeat.x=d[0],i.repeat.y=d[1]}return i}loadTexture(t,n){let i;const o=this.textureLoader.path,a=Be.get(t.id).children;a!==void 0&&a.length>0&&n[a[0].ID]!==void 0&&(i=n[a[0].ID],(i.indexOf("blob:")===0||i.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let c;const p=t.FileName.slice(-3).toLowerCase();if(p==="tga"){const d=this.manager.getHandler(".tga");d===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),c=new m.Texture):(d.setPath(this.textureLoader.path),c=d.load(i))}else p==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),c=new m.Texture):c=this.textureLoader.load(i);return this.textureLoader.setPath(o),c}parseMaterials(t){const n=new Map;if("Material"in ve.Objects){const i=ve.Objects.Material;for(const o in i){const a=this.parseMaterial(i[o],t);a!==null&&n.set(parseInt(o),a)}}return n}parseMaterial(t,n){const i=t.id,o=t.attrName;let a=t.ShadingModel;if(typeof a=="object"&&(a=a.value),!Be.has(i))return null;const c=this.parseParameters(t,n,i);let p;switch(a.toLowerCase()){case"phong":p=new m.MeshPhongMaterial;break;case"lambert":p=new m.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',a),p=new m.MeshPhongMaterial;break}return p.setValues(c),p.name=o,p}parseParameters(t,n,i){const o={};t.BumpFactor&&(o.bumpScale=t.BumpFactor.value),t.Diffuse?o.color=new m.Color().fromArray(t.Diffuse.value):t.DiffuseColor&&(t.DiffuseColor.type==="Color"||t.DiffuseColor.type==="ColorRGB")&&(o.color=new m.Color().fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(o.displacementScale=t.DisplacementFactor.value),t.Emissive?o.emissive=new m.Color().fromArray(t.Emissive.value):t.EmissiveColor&&(t.EmissiveColor.type==="Color"||t.EmissiveColor.type==="ColorRGB")&&(o.emissive=new m.Color().fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(o.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(o.opacity=parseFloat(t.Opacity.value)),o.opacity<1&&(o.transparent=!0),t.ReflectionFactor&&(o.reflectivity=t.ReflectionFactor.value),t.Shininess&&(o.shininess=t.Shininess.value),t.Specular?o.specular=new m.Color().fromArray(t.Specular.value):t.SpecularColor&&t.SpecularColor.type==="Color"&&(o.specular=new m.Color().fromArray(t.SpecularColor.value));const a=this;return Be.get(i).children.forEach(function(c){const p=c.relationship;switch(p){case"Bump":o.bumpMap=a.getTexture(n,c.ID);break;case"Maya|TEX_ao_map":o.aoMap=a.getTexture(n,c.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=a.getTexture(n,c.ID),o.map!==void 0&&("colorSpace"in o.map?o.map.colorSpace="srgb":o.map.encoding=3001);break;case"DisplacementColor":o.displacementMap=a.getTexture(n,c.ID);break;case"EmissiveColor":o.emissiveMap=a.getTexture(n,c.ID),o.emissiveMap!==void 0&&("colorSpace"in o.emissiveMap?o.emissiveMap.colorSpace="srgb":o.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=a.getTexture(n,c.ID);break;case"ReflectionColor":o.envMap=a.getTexture(n,c.ID),o.envMap!==void 0&&(o.envMap.mapping=m.EquirectangularReflectionMapping,"colorSpace"in o.envMap?o.envMap.colorSpace="srgb":o.envMap.encoding=3001);break;case"SpecularColor":o.specularMap=a.getTexture(n,c.ID),o.specularMap!==void 0&&("colorSpace"in o.specularMap?o.specularMap.colorSpace="srgb":o.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=a.getTexture(n,c.ID),o.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",p);break}}),o}getTexture(t,n){return"LayeredTexture"in ve.Objects&&n in ve.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),n=Be.get(n).children[0].ID),t.get(n)}parseDeformers(){const t={},n={};if("Deformer"in ve.Objects){const i=ve.Objects.Deformer;for(const o in i){const a=i[o],c=Be.get(parseInt(o));if(a.attrType==="Skin"){const p=this.parseSkeleton(c,i);p.ID=o,c.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),p.geometryID=c.parents[0].ID,t[o]=p}else if(a.attrType==="BlendShape"){const p={id:o};p.rawTargets=this.parseMorphTargets(c,i),p.id=o,c.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),n[o]=p}}}return{skeletons:t,morphTargets:n}}parseSkeleton(t,n){const i=[];return t.children.forEach(function(o){const a=n[o.ID];if(a.attrType!=="Cluster")return;const c={ID:o.ID,indices:[],weights:[],transformLink:new m.Matrix4().fromArray(a.TransformLink.a)};"Indexes"in a&&(c.indices=a.Indexes.a,c.weights=a.Weights.a),i.push(c)}),{rawBones:i,bones:[]}}parseMorphTargets(t,n){const i=[];for(let o=0;o<t.children.length;o++){const a=t.children[o],c=n[a.ID],p={name:c.attrName,initialWeight:c.DeformPercent,id:c.id,fullWeights:c.FullWeights.a};if(c.attrType!=="BlendShapeChannel")return;p.geoID=Be.get(parseInt(a.ID)).children.filter(function(d){return d.relationship===void 0})[0].ID,i.push(p)}return i}parseScene(t,n,i){We=new m.Group;const o=this.parseModels(t.skeletons,n,i),a=ve.Objects.Model,c=this;o.forEach(function(d){const g=a[d.ID];c.setLookAtProperties(d,g),Be.get(d.ID).parents.forEach(function(b){const C=o.get(b.ID);C!==void 0&&C.add(d)}),d.parent===null&&We.add(d)}),this.bindSkeleton(t.skeletons,n,o),this.createAmbientLight(),We.traverse(function(d){if(d.userData.transformData){d.parent&&(d.userData.transformData.parentMatrix=d.parent.matrix,d.userData.transformData.parentMatrixWorld=d.parent.matrixWorld);const g=Eo(d.userData.transformData);d.applyMatrix4(g),d.updateWorldMatrix()}});const p=new ic().parse();We.children.length===1&&We.children[0].isGroup&&(We.children[0].animations=p,We=We.children[0]),We.animations=p}parseModels(t,n,i){const o=new Map,a=ve.Objects.Model;for(const c in a){const p=parseInt(c),d=a[c],g=Be.get(p);let y=this.buildSkeleton(g,t,p,d.attrName);if(!y){switch(d.attrType){case"Camera":y=this.createCamera(g);break;case"Light":y=this.createLight(g);break;case"Mesh":y=this.createMesh(g,n,i);break;case"NurbsCurve":y=this.createCurve(g,n);break;case"LimbNode":case"Root":y=new m.Bone;break;case"Null":default:y=new m.Group;break}y.name=d.attrName?m.PropertyBinding.sanitizeNodeName(d.attrName):"",y.ID=p}this.getTransformData(y,d),o.set(p,y)}return o}buildSkeleton(t,n,i,o){let a=null;return t.parents.forEach(function(c){for(const p in n){const d=n[p];d.rawBones.forEach(function(g,y){if(g.ID===c.ID){const b=a;a=new m.Bone,a.matrixWorld.copy(g.transformLink),a.name=o?m.PropertyBinding.sanitizeNodeName(o):"",a.ID=i,d.bones[y]=a,b!==null&&a.add(b)}})}}),a}createCamera(t){let n,i;if(t.children.forEach(function(o){const a=ve.Objects.NodeAttribute[o.ID];a!==void 0&&(i=a)}),i===void 0)n=new m.Object3D;else{let o=0;i.CameraProjectionType!==void 0&&i.CameraProjectionType.value===1&&(o=1);let a=1;i.NearPlane!==void 0&&(a=i.NearPlane.value/1e3);let c=1e3;i.FarPlane!==void 0&&(c=i.FarPlane.value/1e3);let p=window.innerWidth,d=window.innerHeight;i.AspectWidth!==void 0&&i.AspectHeight!==void 0&&(p=i.AspectWidth.value,d=i.AspectHeight.value);const g=p/d;let y=45;i.FieldOfView!==void 0&&(y=i.FieldOfView.value);const b=i.FocalLength?i.FocalLength.value:null;switch(o){case 0:n=new m.PerspectiveCamera(y,g,a,c),b!==null&&n.setFocalLength(b);break;case 1:n=new m.OrthographicCamera(-p/2,p/2,d/2,-d/2,a,c);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+o+"."),n=new m.Object3D;break}}return n}createLight(t){let n,i;if(t.children.forEach(function(o){const a=ve.Objects.NodeAttribute[o.ID];a!==void 0&&(i=a)}),i===void 0)n=new m.Object3D;else{let o;i.LightType===void 0?o=0:o=i.LightType.value;let a=16777215;i.Color!==void 0&&(a=new m.Color().fromArray(i.Color.value));let c=i.Intensity===void 0?1:i.Intensity.value/100;i.CastLightOnObject!==void 0&&i.CastLightOnObject.value===0&&(c=0);let p=0;i.FarAttenuationEnd!==void 0&&(i.EnableFarAttenuation!==void 0&&i.EnableFarAttenuation.value===0?p=0:p=i.FarAttenuationEnd.value);const d=1;switch(o){case 0:n=new m.PointLight(a,c,p,d);break;case 1:n=new m.DirectionalLight(a,c);break;case 2:let g=Math.PI/3;i.InnerAngle!==void 0&&(g=m.MathUtils.degToRad(i.InnerAngle.value));let y=0;i.OuterAngle!==void 0&&(y=m.MathUtils.degToRad(i.OuterAngle.value),y=Math.max(y,1)),n=new m.SpotLight(a,c,p,g,y,d);break;default:console.warn("THREE.FBXLoader: Unknown light type "+i.LightType.value+", defaulting to a PointLight."),n=new m.PointLight(a,c);break}i.CastShadows!==void 0&&i.CastShadows.value===1&&(n.castShadow=!0)}return n}createMesh(t,n,i){let o,a=null,c=null;const p=[];return t.children.forEach(function(d){n.has(d.ID)&&(a=n.get(d.ID)),i.has(d.ID)&&p.push(i.get(d.ID))}),p.length>1?c=p:p.length>0?c=p[0]:(c=new m.MeshPhongMaterial({color:13421772}),p.push(c)),"color"in a.attributes&&p.forEach(function(d){d.vertexColors=!0}),a.FBX_Deformer?(o=new m.SkinnedMesh(a,c),o.normalizeSkinWeights()):o=new m.Mesh(a,c),o}createCurve(t,n){const i=t.children.reduce(function(a,c){return n.has(c.ID)&&(a=n.get(c.ID)),a},null),o=new m.LineBasicMaterial({color:3342591,linewidth:1});return new m.Line(i,o)}getTransformData(t,n){const i={};"InheritType"in n&&(i.inheritType=parseInt(n.InheritType.value)),"RotationOrder"in n?i.eulerOrder=Oo(n.RotationOrder.value):i.eulerOrder="ZYX","Lcl_Translation"in n&&(i.translation=n.Lcl_Translation.value),"PreRotation"in n&&(i.preRotation=n.PreRotation.value),"Lcl_Rotation"in n&&(i.rotation=n.Lcl_Rotation.value),"PostRotation"in n&&(i.postRotation=n.PostRotation.value),"Lcl_Scaling"in n&&(i.scale=n.Lcl_Scaling.value),"ScalingOffset"in n&&(i.scalingOffset=n.ScalingOffset.value),"ScalingPivot"in n&&(i.scalingPivot=n.ScalingPivot.value),"RotationOffset"in n&&(i.rotationOffset=n.RotationOffset.value),"RotationPivot"in n&&(i.rotationPivot=n.RotationPivot.value),t.userData.transformData=i}setLookAtProperties(t,n){"LookAtProperty"in n&&Be.get(t.ID).children.forEach(function(o){if(o.relationship==="LookAtProperty"){const a=ve.Objects.Model[o.ID];if("Lcl_Translation"in a){const c=a.Lcl_Translation.value;t.target!==void 0?(t.target.position.fromArray(c),We.add(t.target)):t.lookAt(new m.Vector3().fromArray(c))}}})}bindSkeleton(t,n,i){const o=this.parsePoseNodes();for(const a in t){const c=t[a];Be.get(parseInt(c.ID)).parents.forEach(function(d){if(n.has(d.ID)){const g=d.ID;Be.get(g).parents.forEach(function(b){i.has(b.ID)&&i.get(b.ID).bind(new m.Skeleton(c.bones),o[b.ID])})}})}}parsePoseNodes(){const t={};if("Pose"in ve.Objects){const n=ve.Objects.Pose;for(const i in n)if(n[i].attrType==="BindPose"&&n[i].NbPoseNodes>0){const o=n[i].PoseNode;Array.isArray(o)?o.forEach(function(a){t[a.Node]=new m.Matrix4().fromArray(a.Matrix.a)}):t[o.Node]=new m.Matrix4().fromArray(o.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in ve&&"AmbientColor"in ve.GlobalSettings){const t=ve.GlobalSettings.AmbientColor.value,n=t[0],i=t[1],o=t[2];if(n!==0||i!==0||o!==0){const a=new m.Color(n,i,o);We.add(new m.AmbientLight(a,1))}}}}class sc{parse(t){const n=new Map;if("Geometry"in ve.Objects){const i=ve.Objects.Geometry;for(const o in i){const a=Be.get(parseInt(o)),c=this.parseGeometry(a,i[o],t);n.set(parseInt(o),c)}}return n}parseGeometry(t,n,i){switch(n.attrType){case"Mesh":return this.parseMeshGeometry(t,n,i);case"NurbsCurve":return this.parseNurbsGeometry(n)}}parseMeshGeometry(t,n,i){const o=i.skeletons,a=[],c=t.parents.map(function(b){return ve.Objects.Model[b.ID]});if(c.length===0)return;const p=t.children.reduce(function(b,C){return o[C.ID]!==void 0&&(b=o[C.ID]),b},null);t.children.forEach(function(b){i.morphTargets[b.ID]!==void 0&&a.push(i.morphTargets[b.ID])});const d=c[0],g={};"RotationOrder"in d&&(g.eulerOrder=Oo(d.RotationOrder.value)),"InheritType"in d&&(g.inheritType=parseInt(d.InheritType.value)),"GeometricTranslation"in d&&(g.translation=d.GeometricTranslation.value),"GeometricRotation"in d&&(g.rotation=d.GeometricRotation.value),"GeometricScaling"in d&&(g.scale=d.GeometricScaling.value);const y=Eo(g);return this.genGeometry(n,p,a,y)}genGeometry(t,n,i,o){const a=new m.BufferGeometry;t.attrName&&(a.name=t.attrName);const c=this.parseGeoNode(t,n),p=this.genBuffers(c),d=new m.Float32BufferAttribute(p.vertex,3);if(d.applyMatrix4(o),a.setAttribute("position",d),p.colors.length>0&&a.setAttribute("color",new m.Float32BufferAttribute(p.colors,3)),n&&(a.setAttribute("skinIndex",new m.Uint16BufferAttribute(p.weightsIndices,4)),a.setAttribute("skinWeight",new m.Float32BufferAttribute(p.vertexWeights,4)),a.FBX_Deformer=n),p.normal.length>0){const g=new m.Matrix3().getNormalMatrix(o),y=new m.Float32BufferAttribute(p.normal,3);y.applyNormalMatrix(g),a.setAttribute("normal",y)}if(p.uvs.forEach(function(g,y){let b="uv"+(y+1).toString();y===0&&(b="uv"),a.setAttribute(b,new m.Float32BufferAttribute(p.uvs[y],2))}),c.material&&c.material.mappingType!=="AllSame"){let g=p.materialIndex[0],y=0;if(p.materialIndex.forEach(function(b,C){b!==g&&(a.addGroup(y,C-y,g),g=b,y=C)}),a.groups.length>0){const b=a.groups[a.groups.length-1],C=b.start+b.count;C!==p.materialIndex.length&&a.addGroup(C,p.materialIndex.length-C,g)}a.groups.length===0&&a.addGroup(0,p.materialIndex.length,p.materialIndex[0])}return this.addMorphTargets(a,t,i,o),a}parseGeoNode(t,n){const i={};if(i.vertexPositions=t.Vertices!==void 0?t.Vertices.a:[],i.vertexIndices=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(i.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(i.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(i.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){i.uv=[];let o=0;for(;t.LayerElementUV[o];)t.LayerElementUV[o].UV&&i.uv.push(this.parseUVs(t.LayerElementUV[o])),o++}return i.weightTable={},n!==null&&(i.skeleton=n,n.rawBones.forEach(function(o,a){o.indices.forEach(function(c,p){i.weightTable[c]===void 0&&(i.weightTable[c]=[]),i.weightTable[c].push({id:a,weight:o.weights[p]})})})),i}genBuffers(t){const n={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let i=0,o=0,a=!1,c=[],p=[],d=[],g=[],y=[],b=[];const C=this;return t.vertexIndices.forEach(function(A,E){let k,O=!1;A<0&&(A=A^-1,O=!0);let R=[],N=[];if(c.push(A*3,A*3+1,A*3+2),t.color){const F=Js(E,i,A,t.color);d.push(F[0],F[1],F[2])}if(t.skeleton){if(t.weightTable[A]!==void 0&&t.weightTable[A].forEach(function(F){N.push(F.weight),R.push(F.id)}),N.length>4){a||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),a=!0);const F=[0,0,0,0],M=[0,0,0,0];N.forEach(function(D,U){let S=D,T=R[U];M.forEach(function(j,X,Z){if(S>j){Z[X]=S,S=j;const J=F[X];F[X]=T,T=J}})}),R=F,N=M}for(;N.length<4;)N.push(0),R.push(0);for(let F=0;F<4;++F)y.push(N[F]),b.push(R[F])}if(t.normal){const F=Js(E,i,A,t.normal);p.push(F[0],F[1],F[2])}t.material&&t.material.mappingType!=="AllSame"&&(k=Js(E,i,A,t.material)[0]),t.uv&&t.uv.forEach(function(F,M){const D=Js(E,i,A,F);g[M]===void 0&&(g[M]=[]),g[M].push(D[0]),g[M].push(D[1])}),o++,O&&(C.genFace(n,t,c,k,p,d,g,y,b,o),i++,o=0,c=[],p=[],d=[],g=[],y=[],b=[])}),n}genFace(t,n,i,o,a,c,p,d,g,y){for(let b=2;b<y;b++)t.vertex.push(n.vertexPositions[i[0]]),t.vertex.push(n.vertexPositions[i[1]]),t.vertex.push(n.vertexPositions[i[2]]),t.vertex.push(n.vertexPositions[i[(b-1)*3]]),t.vertex.push(n.vertexPositions[i[(b-1)*3+1]]),t.vertex.push(n.vertexPositions[i[(b-1)*3+2]]),t.vertex.push(n.vertexPositions[i[b*3]]),t.vertex.push(n.vertexPositions[i[b*3+1]]),t.vertex.push(n.vertexPositions[i[b*3+2]]),n.skeleton&&(t.vertexWeights.push(d[0]),t.vertexWeights.push(d[1]),t.vertexWeights.push(d[2]),t.vertexWeights.push(d[3]),t.vertexWeights.push(d[(b-1)*4]),t.vertexWeights.push(d[(b-1)*4+1]),t.vertexWeights.push(d[(b-1)*4+2]),t.vertexWeights.push(d[(b-1)*4+3]),t.vertexWeights.push(d[b*4]),t.vertexWeights.push(d[b*4+1]),t.vertexWeights.push(d[b*4+2]),t.vertexWeights.push(d[b*4+3]),t.weightsIndices.push(g[0]),t.weightsIndices.push(g[1]),t.weightsIndices.push(g[2]),t.weightsIndices.push(g[3]),t.weightsIndices.push(g[(b-1)*4]),t.weightsIndices.push(g[(b-1)*4+1]),t.weightsIndices.push(g[(b-1)*4+2]),t.weightsIndices.push(g[(b-1)*4+3]),t.weightsIndices.push(g[b*4]),t.weightsIndices.push(g[b*4+1]),t.weightsIndices.push(g[b*4+2]),t.weightsIndices.push(g[b*4+3])),n.color&&(t.colors.push(c[0]),t.colors.push(c[1]),t.colors.push(c[2]),t.colors.push(c[(b-1)*3]),t.colors.push(c[(b-1)*3+1]),t.colors.push(c[(b-1)*3+2]),t.colors.push(c[b*3]),t.colors.push(c[b*3+1]),t.colors.push(c[b*3+2])),n.material&&n.material.mappingType!=="AllSame"&&(t.materialIndex.push(o),t.materialIndex.push(o),t.materialIndex.push(o)),n.normal&&(t.normal.push(a[0]),t.normal.push(a[1]),t.normal.push(a[2]),t.normal.push(a[(b-1)*3]),t.normal.push(a[(b-1)*3+1]),t.normal.push(a[(b-1)*3+2]),t.normal.push(a[b*3]),t.normal.push(a[b*3+1]),t.normal.push(a[b*3+2])),n.uv&&n.uv.forEach(function(C,A){t.uvs[A]===void 0&&(t.uvs[A]=[]),t.uvs[A].push(p[A][0]),t.uvs[A].push(p[A][1]),t.uvs[A].push(p[A][(b-1)*2]),t.uvs[A].push(p[A][(b-1)*2+1]),t.uvs[A].push(p[A][b*2]),t.uvs[A].push(p[A][b*2+1])})}addMorphTargets(t,n,i,o){if(i.length===0)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const a=this;i.forEach(function(c){c.rawTargets.forEach(function(p){const d=ve.Objects.Geometry[p.geoID];d!==void 0&&a.genMorphGeometry(t,n,d,o,p.name)})})}genMorphGeometry(t,n,i,o,a){const c=n.PolygonVertexIndex!==void 0?n.PolygonVertexIndex.a:[],p=i.Vertices!==void 0?i.Vertices.a:[],d=i.Indexes!==void 0?i.Indexes.a:[],g=t.attributes.position.count*3,y=new Float32Array(g);for(let E=0;E<d.length;E++){const k=d[E]*3;y[k]=p[E*3],y[k+1]=p[E*3+1],y[k+2]=p[E*3+2]}const b={vertexIndices:c,vertexPositions:y},C=this.genBuffers(b),A=new m.Float32BufferAttribute(C.vertex,3);A.name=a||i.attrName,A.applyMatrix4(o),t.morphAttributes.position.push(A)}parseNormals(t){const n=t.MappingInformationType,i=t.ReferenceInformationType,o=t.Normals.a;let a=[];return i==="IndexToDirect"&&("NormalIndex"in t?a=t.NormalIndex.a:"NormalsIndex"in t&&(a=t.NormalsIndex.a)),{dataSize:3,buffer:o,indices:a,mappingType:n,referenceType:i}}parseUVs(t){const n=t.MappingInformationType,i=t.ReferenceInformationType,o=t.UV.a;let a=[];return i==="IndexToDirect"&&(a=t.UVIndex.a),{dataSize:2,buffer:o,indices:a,mappingType:n,referenceType:i}}parseVertexColors(t){const n=t.MappingInformationType,i=t.ReferenceInformationType,o=t.Colors.a;let a=[];return i==="IndexToDirect"&&(a=t.ColorIndex.a),{dataSize:4,buffer:o,indices:a,mappingType:n,referenceType:i}}parseMaterialIndices(t){const n=t.MappingInformationType,i=t.ReferenceInformationType;if(n==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:i};const o=t.Materials.a,a=[];for(let c=0;c<o.length;++c)a.push(c);return{dataSize:1,buffer:o,indices:a,mappingType:n,referenceType:i}}parseNurbsGeometry(t){if(ko===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new m.BufferGeometry;const n=parseInt(t.Order);if(isNaN(n))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new m.BufferGeometry;const i=n-1,o=t.KnotVector.a,a=[],c=t.Points.a;for(let b=0,C=c.length;b<C;b+=4)a.push(new m.Vector4().fromArray(c,b));let p,d;if(t.Form==="Closed")a.push(a[0]);else if(t.Form==="Periodic"){p=i,d=o.length-1-p;for(let b=0;b<i;++b)a.push(a[b])}const y=new ko(i,o,a,p,d).getPoints(a.length*12);return new m.BufferGeometry().setFromPoints(y)}}class ic{parse(){const t=[],n=this.parseClips();if(n!==void 0)for(const i in n){const o=n[i],a=this.addClip(o);t.push(a)}return t}parseClips(){if(ve.Objects.AnimationCurve===void 0)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const n=this.parseAnimationLayers(t);return this.parseAnimStacks(n)}parseAnimationCurveNodes(){const t=ve.Objects.AnimationCurveNode,n=new Map;for(const i in t){const o=t[i];if(o.attrName.match(/S|R|T|DeformPercent/)!==null){const a={id:o.id,attr:o.attrName,curves:{}};n.set(a.id,a)}}return n}parseAnimationCurves(t){const n=ve.Objects.AnimationCurve;for(const i in n){const o={id:n[i].id,times:n[i].KeyTime.a.map(cc),values:n[i].KeyValueFloat.a},a=Be.get(o.id);if(a!==void 0){const c=a.parents[0].ID,p=a.parents[0].relationship;p.match(/X/)?t.get(c).curves.x=o:p.match(/Y/)?t.get(c).curves.y=o:p.match(/Z/)?t.get(c).curves.z=o:p.match(/d|DeformPercent/)&&t.has(c)&&(t.get(c).curves.morph=o)}}}parseAnimationLayers(t){const n=ve.Objects.AnimationLayer,i=new Map;for(const o in n){const a=[],c=Be.get(parseInt(o));c!==void 0&&(c.children.forEach(function(d,g){if(t.has(d.ID)){const y=t.get(d.ID);if(y.curves.x!==void 0||y.curves.y!==void 0||y.curves.z!==void 0){if(a[g]===void 0){const b=Be.get(d.ID).parents.filter(function(C){return C.relationship!==void 0})[0].ID;if(b!==void 0){const C=ve.Objects.Model[b.toString()];if(C===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",d);return}const A={modelName:C.attrName?m.PropertyBinding.sanitizeNodeName(C.attrName):"",ID:C.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};We.traverse(function(E){E.ID===C.id&&(A.transform=E.matrix,E.userData.transformData&&(A.eulerOrder=E.userData.transformData.eulerOrder))}),A.transform||(A.transform=new m.Matrix4),"PreRotation"in C&&(A.preRotation=C.PreRotation.value),"PostRotation"in C&&(A.postRotation=C.PostRotation.value),a[g]=A}}a[g]&&(a[g][y.attr]=y)}else if(y.curves.morph!==void 0){if(a[g]===void 0){const b=Be.get(d.ID).parents.filter(function(R){return R.relationship!==void 0})[0].ID,C=Be.get(b).parents[0].ID,A=Be.get(C).parents[0].ID,E=Be.get(A).parents[0].ID,k=ve.Objects.Model[E],O={modelName:k.attrName?m.PropertyBinding.sanitizeNodeName(k.attrName):"",morphName:ve.Objects.Deformer[b].attrName};a[g]=O}a[g][y.attr]=y}}}),i.set(parseInt(o),a))}return i}parseAnimStacks(t){const n=ve.Objects.AnimationStack,i={};for(const o in n){const a=Be.get(parseInt(o)).children;a.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const c=t.get(a[0].ID);i[o]={name:n[o].attrName,layer:c}}return i}addClip(t){let n=[];const i=this;return t.layer.forEach(function(o){n=n.concat(i.generateTracks(o))}),new m.AnimationClip(t.name,-1,n)}generateTracks(t){const n=[];let i=new m.Vector3,o=new m.Quaternion,a=new m.Vector3;if(t.transform&&t.transform.decompose(i,o,a),i=i.toArray(),o=new m.Euler().setFromQuaternion(o,t.eulerOrder).toArray(),a=a.toArray(),t.T!==void 0&&Object.keys(t.T.curves).length>0){const c=this.generateVectorTrack(t.modelName,t.T.curves,i,"position");c!==void 0&&n.push(c)}if(t.R!==void 0&&Object.keys(t.R.curves).length>0){const c=this.generateRotationTrack(t.modelName,t.R.curves,o,t.preRotation,t.postRotation,t.eulerOrder);c!==void 0&&n.push(c)}if(t.S!==void 0&&Object.keys(t.S.curves).length>0){const c=this.generateVectorTrack(t.modelName,t.S.curves,a,"scale");c!==void 0&&n.push(c)}if(t.DeformPercent!==void 0){const c=this.generateMorphTrack(t);c!==void 0&&n.push(c)}return n}generateVectorTrack(t,n,i,o){const a=this.getTimesForAllAxes(n),c=this.getKeyframeTrackValues(a,n,i);return new m.VectorKeyframeTrack(t+"."+o,a,c)}generateRotationTrack(t,n,i,o,a,c){n.x!==void 0&&(this.interpolateRotations(n.x),n.x.values=n.x.values.map(m.MathUtils.degToRad)),n.y!==void 0&&(this.interpolateRotations(n.y),n.y.values=n.y.values.map(m.MathUtils.degToRad)),n.z!==void 0&&(this.interpolateRotations(n.z),n.z.values=n.z.values.map(m.MathUtils.degToRad));const p=this.getTimesForAllAxes(n),d=this.getKeyframeTrackValues(p,n,i);o!==void 0&&(o=o.map(m.MathUtils.degToRad),o.push(c),o=new m.Euler().fromArray(o),o=new m.Quaternion().setFromEuler(o)),a!==void 0&&(a=a.map(m.MathUtils.degToRad),a.push(c),a=new m.Euler().fromArray(a),a=new m.Quaternion().setFromEuler(a).invert());const g=new m.Quaternion,y=new m.Euler,b=[];for(let C=0;C<d.length;C+=3)y.set(d[C],d[C+1],d[C+2],c),g.setFromEuler(y),o!==void 0&&g.premultiply(o),a!==void 0&&g.multiply(a),g.toArray(b,C/3*4);return new m.QuaternionKeyframeTrack(t+".quaternion",p,b)}generateMorphTrack(t){const n=t.DeformPercent.curves.morph,i=n.values.map(function(a){return a/100}),o=We.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new m.NumberKeyframeTrack(t.modelName+".morphTargetInfluences["+o+"]",n.times,i)}getTimesForAllAxes(t){let n=[];if(t.x!==void 0&&(n=n.concat(t.x.times)),t.y!==void 0&&(n=n.concat(t.y.times)),t.z!==void 0&&(n=n.concat(t.z.times)),n=n.sort(function(i,o){return i-o}),n.length>1){let i=1,o=n[0];for(let a=1;a<n.length;a++){const c=n[a];c!==o&&(n[i]=c,o=c,i++)}n=n.slice(0,i)}return n}getKeyframeTrackValues(t,n,i){const o=i,a=[];let c=-1,p=-1,d=-1;return t.forEach(function(g){if(n.x&&(c=n.x.times.indexOf(g)),n.y&&(p=n.y.times.indexOf(g)),n.z&&(d=n.z.times.indexOf(g)),c!==-1){const y=n.x.values[c];a.push(y),o[0]=y}else a.push(o[0]);if(p!==-1){const y=n.y.values[p];a.push(y),o[1]=y}else a.push(o[1]);if(d!==-1){const y=n.z.values[d];a.push(y),o[2]=y}else a.push(o[2])}),a}interpolateRotations(t){for(let n=1;n<t.values.length;n++){const i=t.values[n-1],o=t.values[n]-i,a=Math.abs(o);if(a>=180){const c=a/180,p=o/c;let d=i+p;const g=t.times[n-1],b=(t.times[n]-g)/c;let C=g+b;const A=[],E=[];for(;C<t.times[n];)A.push(C),C+=b,E.push(d),d+=p;t.times=Vo(t.times,n,A),t.values=Vo(t.values,n,E)}}}}class rc{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,n){this.currentProp=t,this.currentPropName=n}parse(t){this.currentIndent=0,this.allNodes=new So,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const n=this,i=t.split(/[\r\n]+/);return i.forEach(function(o,a){const c=o.match(/^[\s\t]*;/),p=o.match(/^[\s\t]*$/);if(c||p)return;const d=o.match("^\\t{"+n.currentIndent+"}(\\w+):(.*){",""),g=o.match("^\\t{"+n.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),y=o.match("^\\t{"+(n.currentIndent-1)+"}}");d?n.parseNodeBegin(o,d):g?n.parseNodeProperty(o,g,i[++a]):y?n.popStack():o.match(/^[^\s\t}]/)&&n.parseNodePropertyContinued(o)}),this.allNodes}parseNodeBegin(t,n){const i=n[1].trim().replace(/^"/,"").replace(/"$/,""),o=n[2].split(",").map(function(d){return d.trim().replace(/^"/,"").replace(/"$/,"")}),a={name:i},c=this.parseNodeAttr(o),p=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(i,a):i in p?(i==="PoseNode"?p.PoseNode.push(a):p[i].id!==void 0&&(p[i]={},p[i][p[i].id]=p[i]),c.id!==""&&(p[i][c.id]=a)):typeof c.id=="number"?(p[i]={},p[i][c.id]=a):i!=="Properties70"&&(i==="PoseNode"?p[i]=[a]:p[i]=a),typeof c.id=="number"&&(a.id=c.id),c.name!==""&&(a.attrName=c.name),c.type!==""&&(a.attrType=c.type),this.pushStack(a)}parseNodeAttr(t){let n=t[0];t[0]!==""&&(n=parseInt(t[0]),isNaN(n)&&(n=t[0]));let i="",o="";return t.length>1&&(i=t[1].replace(/^(\w+)::/,""),o=t[2]),{id:n,name:i,type:o}}parseNodeProperty(t,n,i){let o=n[1].replace(/^"/,"").replace(/"$/,"").trim(),a=n[2].replace(/^"/,"").replace(/"$/,"").trim();o==="Content"&&a===","&&(a=i.replace(/"/g,"").replace(/,$/,"").trim());const c=this.getCurrentNode();if(c.name==="Properties70"){this.parseNodeSpecialProperty(t,o,a);return}if(o==="C"){const d=a.split(",").slice(1),g=parseInt(d[0]),y=parseInt(d[1]);let b=a.split(",").slice(3);b=b.map(function(C){return C.trim().replace(/^"/,"")}),o="connections",a=[g,y],pc(a,b),c[o]===void 0&&(c[o]=[])}o==="Node"&&(c.id=a),o in c&&Array.isArray(c[o])?c[o].push(a):o!=="a"?c[o]=a:c.a=a,this.setCurrentProp(c,o),o==="a"&&a.slice(-1)!==","&&(c.a=Yi(a))}parseNodePropertyContinued(t){const n=this.getCurrentNode();n.a+=t,t.slice(-1)!==","&&(n.a=Yi(n.a))}parseNodeSpecialProperty(t,n,i){const o=i.split('",').map(function(y){return y.trim().replace(/^\"/,"").replace(/\s/,"_")}),a=o[0],c=o[1],p=o[2],d=o[3];let g=o[4];switch(c){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":g=parseFloat(g);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":g=Yi(g);break}this.getPrevNode()[a]={type:c,type2:p,flag:d,value:g},this.setCurrentProp(this.getPrevNode(),a)}}class oc{parse(t){const n=new Lo(t);n.skip(23);const i=n.getUint32();if(i<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+i);const o=new So;for(;!this.endOfContent(n);){const a=this.parseNode(n,i);a!==null&&o.add(a.name,a)}return o}endOfContent(t){return t.size()%16===0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,n){const i={},o=n>=7500?t.getUint64():t.getUint32(),a=n>=7500?t.getUint64():t.getUint32();n>=7500?t.getUint64():t.getUint32();const c=t.getUint8(),p=t.getString(c);if(o===0)return null;const d=[];for(let C=0;C<a;C++)d.push(this.parseProperty(t));const g=d.length>0?d[0]:"",y=d.length>1?d[1]:"",b=d.length>2?d[2]:"";for(i.singleProperty=a===1&&t.getOffset()===o;o>t.getOffset();){const C=this.parseNode(t,n);C!==null&&this.parseSubNode(p,i,C)}return i.propertyList=d,typeof g=="number"&&(i.id=g),y!==""&&(i.attrName=y),b!==""&&(i.attrType=b),p!==""&&(i.name=p),i}parseSubNode(t,n,i){if(i.singleProperty===!0){const o=i.propertyList[0];Array.isArray(o)?(n[i.name]=i,i.a=o):n[i.name]=o}else if(t==="Connections"&&i.name==="C"){const o=[];i.propertyList.forEach(function(a,c){c!==0&&o.push(a)}),n.connections===void 0&&(n.connections=[]),n.connections.push(o)}else if(i.name==="Properties70")Object.keys(i).forEach(function(a){n[a]=i[a]});else if(t==="Properties70"&&i.name==="P"){let o=i.propertyList[0],a=i.propertyList[1];const c=i.propertyList[2],p=i.propertyList[3];let d;o.indexOf("Lcl ")===0&&(o=o.replace("Lcl ","Lcl_")),a.indexOf("Lcl ")===0&&(a=a.replace("Lcl ","Lcl_")),a==="Color"||a==="ColorRGB"||a==="Vector"||a==="Vector3D"||a.indexOf("Lcl_")===0?d=[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:d=i.propertyList[4],n[o]={type:a,type2:c,flag:p,value:d}}else n[i.name]===void 0?typeof i.id=="number"?(n[i.name]={},n[i.name][i.id]=i):n[i.name]=i:i.name==="PoseNode"?(Array.isArray(n[i.name])||(n[i.name]=[n[i.name]]),n[i.name].push(i)):n[i.name][i.id]===void 0&&(n[i.name][i.id]=i)}parseProperty(t){const n=t.getString(1);let i;switch(n){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return i=t.getUint32(),t.getArrayBuffer(i);case"S":return i=t.getUint32(),t.getString(i);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const o=t.getUint32(),a=t.getUint32(),c=t.getUint32();if(a===0)switch(n){case"b":case"c":return t.getBooleanArray(o);case"d":return t.getFloat64Array(o);case"f":return t.getFloat32Array(o);case"i":return t.getInt32Array(o);case"l":return t.getInt64Array(o)}const p=Ja(new Uint8Array(t.getArrayBuffer(c))),d=new Lo(p.buffer);switch(n){case"b":case"c":return d.getBooleanArray(o);case"d":return d.getFloat64Array(o);case"f":return d.getFloat32Array(o);case"i":return d.getInt32Array(o);case"l":return d.getInt64Array(o)}default:throw new Error("THREE.FBXLoader: Unknown property type "+n)}}}class Lo{constructor(t,n){this.dv=new DataView(t),this.offset=0,this.littleEndian=n!==void 0?n:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(t){const n=[];for(let i=0;i<t;i++)n.push(this.getBoolean());return n}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const n=[];for(let i=0;i<t;i++)n.push(this.getInt32());return n}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,n;return this.littleEndian?(t=this.getUint32(),n=this.getUint32()):(n=this.getUint32(),t=this.getUint32()),n&2147483648?(n=~n&4294967295,t=~t&4294967295,t===4294967295&&(n=n+1&4294967295),t=t+1&4294967295,-(n*4294967296+t)):n*4294967296+t}getInt64Array(t){const n=[];for(let i=0;i<t;i++)n.push(this.getInt64());return n}getUint64(){let t,n;return this.littleEndian?(t=this.getUint32(),n=this.getUint32()):(n=this.getUint32(),t=this.getUint32()),n*4294967296+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const n=[];for(let i=0;i<t;i++)n.push(this.getFloat32());return n}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const n=[];for(let i=0;i<t;i++)n.push(this.getFloat64());return n}getArrayBuffer(t){const n=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,n}getString(t){let n=[];for(let o=0;o<t;o++)n[o]=this.getUint8();const i=n.indexOf(0);return i>=0&&(n=n.slice(0,i)),m.LoaderUtils.decodeText(new Uint8Array(n))}}class So{add(t,n){this[t]=n}}function ac(v){const t="Kaydara FBX Binary \0";return v.byteLength>=t.length&&t===Do(v,0,t.length)}function lc(v){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function i(o){const a=v[o-1];return v=v.slice(n+o),n++,a}for(let o=0;o<t.length;++o)if(i(1)===t[o])return!1;return!0}function To(v){const t=/FBXVersion: (\d+)/,n=v.match(t);if(n)return parseInt(n[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function cc(v){return v/46186158e3}const hc=[];function Js(v,t,n,i){let o;switch(i.mappingType){case"ByPolygonVertex":o=v;break;case"ByPolygon":o=t;break;case"ByVertice":o=n;break;case"AllSame":o=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}i.referenceType==="IndexToDirect"&&(o=i.indices[o]);const a=o*i.dataSize,c=a+i.dataSize;return uc(hc,i.buffer,a,c)}const Ki=new m.Euler,Fn=new m.Vector3;function Eo(v){const t=new m.Matrix4,n=new m.Matrix4,i=new m.Matrix4,o=new m.Matrix4,a=new m.Matrix4,c=new m.Matrix4,p=new m.Matrix4,d=new m.Matrix4,g=new m.Matrix4,y=new m.Matrix4,b=new m.Matrix4,C=new m.Matrix4,A=v.inheritType?v.inheritType:0;if(v.translation&&t.setPosition(Fn.fromArray(v.translation)),v.preRotation){const X=v.preRotation.map(m.MathUtils.degToRad);X.push(v.eulerOrder),n.makeRotationFromEuler(Ki.fromArray(X))}if(v.rotation){const X=v.rotation.map(m.MathUtils.degToRad);X.push(v.eulerOrder),i.makeRotationFromEuler(Ki.fromArray(X))}if(v.postRotation){const X=v.postRotation.map(m.MathUtils.degToRad);X.push(v.eulerOrder),o.makeRotationFromEuler(Ki.fromArray(X)),o.invert()}v.scale&&a.scale(Fn.fromArray(v.scale)),v.scalingOffset&&p.setPosition(Fn.fromArray(v.scalingOffset)),v.scalingPivot&&c.setPosition(Fn.fromArray(v.scalingPivot)),v.rotationOffset&&d.setPosition(Fn.fromArray(v.rotationOffset)),v.rotationPivot&&g.setPosition(Fn.fromArray(v.rotationPivot)),v.parentMatrixWorld&&(b.copy(v.parentMatrix),y.copy(v.parentMatrixWorld));const E=n.clone().multiply(i).multiply(o),k=new m.Matrix4;k.extractRotation(y);const O=new m.Matrix4;O.copyPosition(y);const R=O.clone().invert().multiply(y),N=k.clone().invert().multiply(R),F=a,M=new m.Matrix4;if(A===0)M.copy(k).multiply(E).multiply(N).multiply(F);else if(A===1)M.copy(k).multiply(N).multiply(E).multiply(F);else{const Z=new m.Matrix4().scale(new m.Vector3().setFromMatrixScale(b)).clone().invert(),J=N.clone().multiply(Z);M.copy(k).multiply(E).multiply(J).multiply(F)}const D=g.clone().invert(),U=c.clone().invert();let S=t.clone().multiply(d).multiply(g).multiply(n).multiply(i).multiply(o).multiply(D).multiply(p).multiply(c).multiply(a).multiply(U);const T=new m.Matrix4().copyPosition(S),j=y.clone().multiply(T);return C.copyPosition(j),S=C.clone().multiply(M),S.premultiply(y.invert()),S}function Oo(v){v=v||0;const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return v===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[v]}function Yi(v){return v.split(",").map(function(n){return parseFloat(n)})}function Do(v,t,n){return t===void 0&&(t=0),n===void 0&&(n=v.byteLength),m.LoaderUtils.decodeText(new Uint8Array(v,t,n))}function pc(v,t){for(let n=0,i=v.length,o=t.length;n<o;n++,i++)v[i]=t[n]}function uc(v,t,n,i){for(let o=n,a=0;o<i;o++,a++)v[a]=t[o];return v}function Vo(v,t,n){return v.slice(0,t).concat(n).concat(v.slice(t))}var dc=Object.defineProperty,mc=(v,t,n)=>t in v?dc(v,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):v[t]=n,Xi=(v,t,n)=>(mc(v,typeof t!="symbol"?t+"":t,n),n);class fc extends m.Loader{constructor(t){super(t)}load(t,n,i,o){const a=new m.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,c=>{if(typeof c!="string")throw new Error("unsupported data type");const p=JSON.parse(c),d=this.parse(p);n&&n(d)},i,o)}loadAsync(t,n){return super.loadAsync(t,n)}parse(t){return new Zi(t)}}class Zi{constructor(t){Xi(this,"data"),this.data=t}generateShapes(t,n=100,i){const o=[],a={letterSpacing:0,lineHeight:1,...i},c=vc(t,n,this.data,a);for(let p=0,d=c.length;p<d;p++)Array.prototype.push.apply(o,c[p].toShapes(!1));return o}}Xi(Zi,"isFont"),Xi(Zi,"type");function vc(v,t,n,i){const o=Array.from(v),a=t/n.resolution,c=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*a,p=[];let d=0,g=0;for(let y=0;y<o.length;y++){const b=o[y];if(b===`
|
|
74
|
-
`)
|
|
75
|
-
`,
|
|
76
|
-
`;
|
|
77
|
-
`,
|
|
78
|
-
`;continue}if((
|
|
79
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([c]))}),this.decoderPending}_getWorker(t,n){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const o=new Worker(this.workerSourceURL);o._callbacks={},o._taskCosts={},o._taskLoad=0,o.postMessage({type:"init",decoderConfig:this.decoderConfig}),o.onmessage=function(a){const c=a.data;switch(c.type){case"decode":o._callbacks[c.id].resolve(c);break;case"error":o._callbacks[c.id].reject(c);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+c.type+'"')}},this.workerPool.push(o)}else this.workerPool.sort(function(o,a){return o._taskLoad>a._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=n,i._taskLoad+=n,i})}_releaseTask(t,n){t._taskLoad-=t._taskCosts[n],delete t._callbacks[n],delete t._taskCosts[n]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this}}function yc(){let v,t;onmessage=function(c){const p=c.data;switch(p.type){case"init":v=p.decoderConfig,t=new Promise(function(y){v.onModuleLoaded=function(b){y({draco:b})},DracoDecoderModule(v)});break;case"decode":const d=p.buffer,g=p.taskConfig;t.then(y=>{const b=y.draco,C=new b.Decoder,A=new b.DecoderBuffer;A.Init(new Int8Array(d),d.byteLength);try{const E=n(b,C,A,g),k=E.attributes.map(O=>O.array.buffer);E.index&&k.push(E.index.array.buffer),self.postMessage({type:"decode",id:p.id,geometry:E},k)}catch(E){console.error(E),self.postMessage({type:"error",id:p.id,error:E.message})}finally{b.destroy(A),b.destroy(C)}});break}};function n(c,p,d,g){const y=g.attributeIDs,b=g.attributeTypes;let C,A;const E=p.GetEncodedGeometryType(d);if(E===c.TRIANGULAR_MESH)C=new c.Mesh,A=p.DecodeBufferToMesh(d,C);else if(E===c.POINT_CLOUD)C=new c.PointCloud,A=p.DecodeBufferToPointCloud(d,C);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!A.ok()||C.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+A.error_msg());const k={index:null,attributes:[]};for(const O in y){const R=self[b[O]];let N,F;if(g.useUniqueIDs)F=y[O],N=p.GetAttributeByUniqueId(C,F);else{if(F=p.GetAttributeId(C,c[y[O]]),F===-1)continue;N=p.GetAttribute(C,F)}k.attributes.push(o(c,p,C,O,R,N))}return E===c.TRIANGULAR_MESH&&(k.index=i(c,p,C)),c.destroy(C),k}function i(c,p,d){const y=d.num_faces()*3,b=y*4,C=c._malloc(b);p.GetTrianglesUInt32Array(d,b,C);const A=new Uint32Array(c.HEAPF32.buffer,C,y).slice();return c._free(C),{array:A,itemSize:1}}function o(c,p,d,g,y,b){const C=b.num_components(),E=d.num_points()*C,k=E*y.BYTES_PER_ELEMENT,O=a(c,y),R=c._malloc(k);p.GetAttributeDataArrayForAllPoints(d,b,O,k,R);const N=new y(c.HEAPF32.buffer,R,E).slice();return c._free(R),{name:g,array:N,itemSize:C}}function a(c,p){switch(p){case Float32Array:return c.DT_FLOAT32;case Int8Array:return c.DT_INT8;case Int16Array:return c.DT_INT16;case Int32Array:return c.DT_INT32;case Uint8Array:return c.DT_UINT8;case Uint16Array:return c.DT_UINT16;case Uint32Array:return c.DT_UINT32}}}const xc=["args","center"],Cc=_.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(v,{expose:t}){let n,i;const o=v,{center:a,font:c,text:p,needUpdates:d,size:g,height:y,curveSegments:b,bevelEnabled:C,bevelThickness:A,bevelSize:E,bevelOffset:k,bevelSegments:O}=_.toRefs(o),{extend:R}=Ae.useTresContext();R({TextGeometry:Ao});const N=new fc,F=_.useSlots(),M=_.computed(()=>{var T;return p!=null&&p.value?p.value:F.default?(T=F.default()[0].children)==null?void 0:T.trim():d.value?"":"TresJS"}),D=_.shallowRef();t({value:D});const U=([n,i]=_.withAsyncContext(()=>new Promise((T,j)=>{try{typeof c.value=="string"?N.load(c.value,X=>{T(X)}):T(c.value)}catch(X){j(console.error("cientos",X))}})),n=await n,i(),n),S=_.computed(()=>({font:U,size:_.toValue(g),height:_.toValue(y),curveSegments:_.toValue(b),bevelEnabled:_.toValue(C),bevelThickness:_.toValue(A),bevelSize:_.toValue(E),bevelOffset:_.toValue(k),bevelSegments:_.toValue(O)}));return _.watchEffect(()=>{D.value&&d.value&&(D.value.geometry.dispose(),D.value.geometry=new Ao(M.value,S.value),a.value&&D.value.geometry.center())}),(T,j)=>_.unref(c)?(_.openBlock(),_.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:D},[M.value?(_.openBlock(),_.createElementBlock("TresTextGeometry",{key:0,args:[M.value,S.value],center:_.unref(a)},null,8,xc)):_.createCommentVNode("",!0),_.renderSlot(T.$slots,"default")],512)):_.createCommentVNode("",!0)}});function Pc(v,t){const n=_.ref(t),i=new m.AnimationMixer(n.value),o=_.shallowReactive({});v.forEach(c=>{const p=i.clipAction(c,n.value);o[c.name]=p});const{onLoop:a}=Ae.useRenderLoop();return a(({delta:c})=>{i.update(c)}),{actions:o,mixer:i}}const Qi={sunset:"venice/venice_sunset_4k.hdr"};async function Bo({files:v=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],blur:t=0,background:n=!1,path:i="/",preset:o=void 0}){const{scene:a}=Ae.useTresContext();if(o){if(!(o in Qi))throw new Error("Preset must be one of: "+Object.keys(Qi).join(", "));v=Qi[o],i="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const c=Array.isArray(v),p=c?m.CubeTextureLoader:bc,d=await Ae.useLoader(p,c?[v]:v,y=>{i&&y.setPath(i)}),g=c?d[0]:d;return g&&(g.mapping=c?m.CubeReflectionMapping:m.EquirectangularReflectionMapping,g.colorSpace=m.SRGBColorSpace),a.value&&(a.value.environment=g,n&&(a.value.background=g),t&&(a.value.backgroundBlurriness=t|0)),g}const Ac=_.defineComponent({name:"Environment",props:["background","blur","files","encoding","path","preset"],async setup(v,{expose:t}){let n=null;return t({getTexture:()=>n}),n=await Bo(v),()=>{}}}),Mc=["position","a-scale"],kc=["size","size-attenuation","transparent","alpha-test","alpha-map"],Lc=_.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(v,{expose:t}){const n=v,i=_.ref(),o=_.ref(),{radius:a,depth:c,count:p,size:d,sizeAttenuation:g,transparent:y,alphaMap:b,alphaTest:C}=_.toRefs(n),A=()=>{let k=a.value+c.value;const O=_.computed(()=>c.value/p.value),R=[],N=Array.from({length:p.value},()=>(.5+.5*Math.random())*4),F=M=>new m.Vector3().setFromSpherical(new m.Spherical(M,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let M=0;M<p.value;M++)k-=O.value*Math.random(),R.push(...F(k));i.value=new Float32Array(R),o.value=new Float32Array(N)};_.watchEffect(()=>{A()});const E=_.shallowRef();return t({value:E}),(k,O)=>(_.openBlock(),_.createElementBlock("TresPoints",{ref_key:"starsRef",ref:E},[_.createElementVNode("TresBufferGeometry",{position:[i.value,3],"a-scale":[o.value,1]},null,8,Mc),_.createElementVNode("TresPointsMaterial",{size:_.unref(d),"size-attenuation":_.unref(g),transparent:_.unref(y),"alpha-test":_.unref(C),"alpha-map":_.unref(b)},null,8,kc)],512))}}),Sc=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Tc=["position","velocity"],Ec=_.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(v){const t=v,{size:n,area:i,color:o,alphaMap:a,map:c,opacity:p,alphaTest:d,depthWrite:g,transparent:y,sizeAttenuation:b,count:C,speed:A,randomness:E}=_.toRefs(t),k=_.shallowRef();let O=[],R=[];const N=()=>{O=new Float32Array(C.value*3);for(let D=0;D<C.value;D++){const U=D*3;O[U]=(Math.random()-.5)*i.value[0],O[U+1]=(Math.random()-.5)*i.value[1],O[U+2]=(Math.random()-.5)*i.value[2]}},F=()=>{R=new Float32Array(C.value*2);for(let D=0;D<C.value*2;D+=2)R[D]=(Math.random()-.5)/5*A.value*E.value,R[D+1]=Math.random()/5*A.value+.01};F(),N(),_.watchEffect(()=>{F(),N()});const{onLoop:M}=Ae.useRenderLoop();return M(()=>{var D,U;if((D=k.value)!=null&&D.attributes.position.array&&((U=k.value)!=null&&U.attributes.position.count)){const S=k.value.attributes.position.array;for(let T=0;T<k.value.attributes.position.count;T++){const j=R[T*2],X=R[T*2+1];S[T*3]+=j,S[T*3+1]-=X,(S[T*3]<=-i.value[0]/2||S[T*3]>=i.value[0]/2)&&(S[T*3]=S[T*3]*-1),(S[T*3+1]<=-i.value[1]/2||S[T*3+1]>=i.value[1]/2)&&(S[T*3+1]=S[T*3+1]*-1)}k.value.attributes.position.needsUpdate=!0}}),(D,U)=>(_.openBlock(),_.createElementBlock("TresPoints",null,[_.createElementVNode("TresPointsMaterial",{size:_.unref(n),color:_.unref(o),"alpha-map":_.unref(a),map:_.unref(c),opacity:_.unref(p),"alpha-test":_.unref(d),"depth-write":_.unref(g),transparent:_.unref(y),"size-attenuation":_.unref(b)},null,8,Sc),_.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:k,position:[_.unref(O),3],velocity:[_.unref(R)]},null,8,Tc)]))}}),Oc=["position"],Dc=["position"],Vc=["scale"],Ic=["map","depth-test","color-space","color","opacity"],Bc=_.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(v,{expose:t}){let n,i;const o=v,{width:a,depth:c,segments:p,texture:d,color:g,depthTest:y,opacity:b,speed:C}=_.toRefs(o),A=_.shallowRef(),E=_.shallowRef();t({value:A});const k=[...new Array(p)].map((U,S)=>({x:a.value/2-Math.random()*a.value,y:a.value/2-Math.random()*a.value,scale:.4+Math.sin((S+1)/p.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*C.value})),O=(U,S)=>U/6*S*b.value,{map:R}=([n,i]=_.withAsyncContext(()=>Ae.useTexture({map:d.value})),n=await n,i(),n),{renderer:N,camera:F}=Ae.useTresContext(),M=_.computed(()=>{var U;return(U=N.value)==null?void 0:U.outputColorSpace}),{onLoop:D}=Ae.useRenderLoop();return D(()=>{var U,S;A.value&&F.value&&E.value&&((U=E.value)==null||U.children.forEach((T,j)=>{T.rotation.z+=k[j].rotation}),A.value.lookAt((S=F.value)==null?void 0:S.position))}),(U,S)=>(_.openBlock(),_.createElementBlock("TresGroup",_.mergeProps({ref_key:"smokeRef",ref:A},U.$attrs),[_.createElementVNode("TresGroup",{ref_key:"groupRef",ref:E,position:[0,0,_.unref(p)/2*_.unref(c)]},[(_.openBlock(!0),_.createElementBlock(_.Fragment,null,_.renderList(_.unref(k),({scale:T,x:j,y:X,density:Z},J)=>(_.openBlock(),_.createElementBlock("TresMesh",{key:`${J}`,position:[j,X,-J*_.unref(c)]},[_.createElementVNode("TresPlaneGeometry",{scale:[T,T,T],rotation:[0,0,0]},null,8,Vc),_.createElementVNode("TresMeshStandardMaterial",{map:_.unref(R),"depth-test":_.unref(y),"color-space":M.value,color:_.unref(g),"depth-write":!1,transparent:"",opacity:O(T,Z)},null,8,Ic)],8,Dc))),128))],8,Oc)],16))}}),Fc=_.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(v,{expose:t}){const n=v,i=_.shallowRef();t({value:i});const{onLoop:o}=Ae.useRenderLoop(),a=_.ref(Math.random()*1e4);return o(({elapsed:c})=>{var g,y;if(!i.value)return;const p=a.value+c;i.value.rotation.x=Math.cos(p/4*n.speed)/8*n.rotationFactor,i.value.rotation.y=Math.sin(p/4*n.speed)/8*n.rotationFactor,i.value.rotation.z=Math.sin(p/4*n.speed)/20*n.rotationFactor;let d=Math.sin(p/4*n.speed)/10;d=m.MathUtils.mapLinear(d,-.1,.1,((g=n.range)==null?void 0:g[0])??-.1,((y=n.range)==null?void 0:y[1])??.1),i.value.position.y=d*n.floatFactor}),(c,p)=>(_.openBlock(),_.createElementBlock("TresGroup",_.mergeProps(c.$attrs,{ref_key:"groupRef",ref:i}),[_.renderSlot(c.$slots,"default")],16))}}),Nc=["geometry"],Uc=["map","opacity","depth-write"],zc=["args"],Rc=["rotation","args"],jc=_.createElementVNode("TresAxesHelper",{args:[10]},null,-1),Gc=_.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(v,{expose:t}){const n=v,i=_.shallowRef(),o=_.shallowRef();t(i);let a,c,p,d,g;const{renderer:y,scene:b}=Ae.useTresContext(),C=_.computed(()=>n.width*(Array.isArray(n.scale)?n.scale[0]:n.scale||1)),A=_.computed(()=>n.height*(Array.isArray(n.scale)?n.scale[1]:n.scale||1));_.watchEffect(()=>{a&&a.dispose(),c&&c.dispose(),p&&p.dispose(),d&&d.geometry.dispose(),a=new m.WebGLRenderTarget(n.resolution,n.resolution),c=new m.WebGLRenderTarget(n.resolution,n.resolution),c.texture.generateMipmaps=a.texture.generateMipmaps=!1,o.value=new m.OrthographicCamera(-C.value/2,C.value/2,A.value/2,-A.value/2,0,n.far),p=new m.PlaneGeometry(C.value,A.value).rotateX(Math.PI/2),d=new m.Mesh(p),d.visible=!1}),_.watchEffect(()=>{n.color&&(g&&g.dispose(),g=new m.MeshDepthMaterial,g.depthTest=g.depthWrite=!1,g.onBeforeCompile=D=>{D.uniforms={...D.uniforms,ucolor:{value:n.color?new m.Color(n.color):new m.Color}},D.fragmentShader=D.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
|
|
73
|
+
`};function nn(c,e,t){const n=t.length-c-1;if(e>=t[n])return n-1;if(e<=t[c])return c;let s=c,o=n,i=Math.floor((s+o)/2);for(;e<t[i]||e>=t[i+1];)e<t[i]?o=i:s=i,i=Math.floor((s+o)/2);return i}function $s(c,e,t,n){const s=[],o=[],i=[];s[0]=1;for(let r=1;r<=t;++r){o[r]=e-n[c+1-r],i[r]=n[c+r]-e;let a=0;for(let u=0;u<r;++u){const d=i[u+1],p=o[r-u],f=s[u]/(d+p);s[u]=a+d*f,a=p*f}s[r]=a}return s}function eo(c,e,t,n){const s=nn(c,n,e),o=$s(s,n,c,e),i=new l.Vector4(0,0,0,0);for(let r=0;r<=c;++r){const a=t[s-c+r],u=o[r],d=a.w*u;i.x+=a.x*d,i.y+=a.y*d,i.z+=a.z*d,i.w+=a.w*u}return i}function to(c,e,t,n,s){const o=[];for(let p=0;p<=t;++p)o[p]=0;const i=[];for(let p=0;p<=n;++p)i[p]=o.slice(0);const r=[];for(let p=0;p<=t;++p)r[p]=o.slice(0);r[0][0]=1;const a=o.slice(0),u=o.slice(0);for(let p=1;p<=t;++p){a[p]=e-s[c+1-p],u[p]=s[c+p]-e;let f=0;for(let m=0;m<p;++m){const y=u[m+1],_=a[p-m];r[p][m]=y+_;const x=r[m][p-1]/r[p][m];r[m][p]=f+y*x,f=_*x}r[p][p]=f}for(let p=0;p<=t;++p)i[0][p]=r[p][t];for(let p=0;p<=t;++p){let f=0,m=1;const y=[];for(let _=0;_<=t;++_)y[_]=o.slice(0);y[0][0]=1;for(let _=1;_<=n;++_){let x=0;const S=p-_,O=t-_;p>=_&&(y[m][0]=y[f][0]/r[O+1][S],x=y[m][0]*r[S][O]);const M=S>=-1?1:-S,g=p-1<=O?_-1:t-p;for(let b=M;b<=g;++b)y[m][b]=(y[f][b]-y[f][b-1])/r[O+1][S+b],x+=y[m][b]*r[S+b][O];p<=O&&(y[m][_]=-y[f][_-1]/r[O+1][p],x+=y[m][_]*r[p][O]),i[_][p]=x;const A=f;f=m,m=A}}let d=t;for(let p=1;p<=n;++p){for(let f=0;f<=t;++f)i[p][f]*=d;d*=t-p}return i}function no(c,e,t,n,s){const o=s<c?s:c,i=[],r=nn(c,n,e),a=to(r,n,c,o,e),u=[];for(let d=0;d<t.length;++d){const p=t[d].clone(),f=p.w;p.x*=f,p.y*=f,p.z*=f,u[d]=p}for(let d=0;d<=o;++d){const p=u[r-c].clone().multiplyScalar(a[d][0]);for(let f=1;f<=c;++f)p.add(u[r-c+f].clone().multiplyScalar(a[d][f]));i[d]=p}for(let d=o+1;d<=s+1;++d)i[d]=new l.Vector4(0,0,0);return i}function so(c,e){let t=1;for(let s=2;s<=c;++s)t*=s;let n=1;for(let s=2;s<=e;++s)n*=s;for(let s=2;s<=c-e;++s)n*=s;return t/n}function oo(c){const e=c.length,t=[],n=[];for(let o=0;o<e;++o){const i=c[o];t[o]=new l.Vector3(i.x,i.y,i.z),n[o]=i.w}const s=[];for(let o=0;o<e;++o){const i=t[o].clone();for(let r=1;r<=o;++r)i.sub(s[o-r].clone().multiplyScalar(so(o,r)*n[r]));s[o]=i.divideScalar(n[0])}return s}function io(c,e,t,n,s){const o=no(c,e,t,n,s);return oo(o)}class sn extends l.Curve{constructor(e,t,n,s,o){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=s||0,this.endKnot=o||this.knots.length-1;for(let i=0;i<n.length;++i){const r=n[i];this.controlPoints[i]=new l.Vector4(r.x,r.y,r.z,r.w)}}getPoint(e,t){const n=t||new l.Vector3,s=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),o=eo(this.degree,this.knots,this.controlPoints,s);return o.w!=1&&o.divideScalar(o.w),n.set(o.x,o.y,o.z)}getTangent(e,t){const n=t||new l.Vector3,s=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),o=io(this.degree,this.knots,this.controlPoints,s,1);return n.copy(o[1]).normalize(),n}}let Y,ie,ue;class ro extends l.Loader{constructor(e){super(e)}load(e,t,n,s){const o=this,i=o.path===""?l.LoaderUtils.extractUrlBase(e):o.path,r=new l.FileLoader(this.manager);r.setPath(o.path),r.setResponseType("arraybuffer"),r.setRequestHeader(o.requestHeader),r.setWithCredentials(o.withCredentials),r.load(e,function(a){try{t(o.parse(a,i))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e,t){if(po(e))Y=new uo().parse(e);else{const s=hn(e);if(!fo(s))throw new Error("THREE.FBXLoader: Unknown format.");if(an(s)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+an(s));Y=new ho().parse(s)}const n=new l.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new ao(n,this.manager).parse(Y)}}class ao{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ie=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),s=this.parseDeformers(),o=new lo().parse(s);return this.parseScene(s,o,n),ue}parseConnections(){const e=new Map;return"Connections"in Y&&Y.Connections.connections.forEach(function(n){const s=n[0],o=n[1],i=n[2];e.has(s)||e.set(s,{parents:[],children:[]});const r={ID:o,relationship:i};e.get(s).parents.push(r),e.has(o)||e.set(o,{parents:[],children:[]});const a={ID:s,relationship:i};e.get(o).children.push(a)}),e}parseImages(){const e={},t={};if("Video"in Y.Objects){const n=Y.Objects.Video;for(const s in n){const o=n[s],i=parseInt(s);if(e[i]=o.RelativeFilename||o.Filename,"Content"in o){const r=o.Content instanceof ArrayBuffer&&o.Content.byteLength>0,a=typeof o.Content=="string"&&o.Content!=="";if(r||a){const u=this.parseImage(n[s]);t[o.RelativeFilename||o.Filename]=u}}}}for(const n in e){const s=e[n];t[s]!==void 0?e[n]=t[s]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,s=n.slice(n.lastIndexOf(".")+1).toLowerCase();let o;switch(s){case"bmp":o="image/bmp";break;case"jpg":case"jpeg":o="image/jpeg";break;case"png":o="image/png";break;case"tif":o="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),o="image/tga";break;default:console.warn('FBXLoader: Image type "'+s+'" is not supported.');return}if(typeof t=="string")return"data:"+o+";base64,"+t;{const i=new Uint8Array(t);return window.URL.createObjectURL(new Blob([i],{type:o}))}}parseTextures(e){const t=new Map;if("Texture"in Y.Objects){const n=Y.Objects.Texture;for(const s in n){const o=this.parseTexture(n[s],e);t.set(parseInt(s),o)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const s=e.WrapModeU,o=e.WrapModeV,i=s!==void 0?s.value:0,r=o!==void 0?o.value:0;if(n.wrapS=i===0?l.RepeatWrapping:l.ClampToEdgeWrapping,n.wrapT=r===0?l.RepeatWrapping:l.ClampToEdgeWrapping,"Scaling"in e){const a=e.Scaling.value;n.repeat.x=a[0],n.repeat.y=a[1]}return n}loadTexture(e,t){let n;const s=this.textureLoader.path,o=ie.get(e.id).children;o!==void 0&&o.length>0&&t[o[0].ID]!==void 0&&(n=t[o[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let i;const r=e.FileName.slice(-3).toLowerCase();if(r==="tga"){const a=this.manager.getHandler(".tga");a===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):(a.setPath(this.textureLoader.path),i=a.load(n))}else r==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):i=this.textureLoader.load(n);return this.textureLoader.setPath(s),i}parseMaterials(e){const t=new Map;if("Material"in Y.Objects){const n=Y.Objects.Material;for(const s in n){const o=this.parseMaterial(n[s],e);o!==null&&t.set(parseInt(s),o)}}return t}parseMaterial(e,t){const n=e.id,s=e.attrName;let o=e.ShadingModel;if(typeof o=="object"&&(o=o.value),!ie.has(n))return null;const i=this.parseParameters(e,t,n);let r;switch(o.toLowerCase()){case"phong":r=new l.MeshPhongMaterial;break;case"lambert":r=new l.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),r=new l.MeshPhongMaterial;break}return r.setValues(i),r.name=s,r}parseParameters(e,t,n){const s={};e.BumpFactor&&(s.bumpScale=e.BumpFactor.value),e.Diffuse?s.color=new l.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(s.color=new l.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(s.displacementScale=e.DisplacementFactor.value),e.Emissive?s.emissive=new l.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(s.emissive=new l.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(s.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(s.opacity=parseFloat(e.Opacity.value)),s.opacity<1&&(s.transparent=!0),e.ReflectionFactor&&(s.reflectivity=e.ReflectionFactor.value),e.Shininess&&(s.shininess=e.Shininess.value),e.Specular?s.specular=new l.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(s.specular=new l.Color().fromArray(e.SpecularColor.value));const o=this;return ie.get(n).children.forEach(function(i){const r=i.relationship;switch(r){case"Bump":s.bumpMap=o.getTexture(t,i.ID);break;case"Maya|TEX_ao_map":s.aoMap=o.getTexture(t,i.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":s.map=o.getTexture(t,i.ID),s.map!==void 0&&("colorSpace"in s.map?s.map.colorSpace="srgb":s.map.encoding=3001);break;case"DisplacementColor":s.displacementMap=o.getTexture(t,i.ID);break;case"EmissiveColor":s.emissiveMap=o.getTexture(t,i.ID),s.emissiveMap!==void 0&&("colorSpace"in s.emissiveMap?s.emissiveMap.colorSpace="srgb":s.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":s.normalMap=o.getTexture(t,i.ID);break;case"ReflectionColor":s.envMap=o.getTexture(t,i.ID),s.envMap!==void 0&&(s.envMap.mapping=l.EquirectangularReflectionMapping,"colorSpace"in s.envMap?s.envMap.colorSpace="srgb":s.envMap.encoding=3001);break;case"SpecularColor":s.specularMap=o.getTexture(t,i.ID),s.specularMap!==void 0&&("colorSpace"in s.specularMap?s.specularMap.colorSpace="srgb":s.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":s.alphaMap=o.getTexture(t,i.ID),s.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r);break}}),s}getTexture(e,t){return"LayeredTexture"in Y.Objects&&t in Y.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ie.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Y.Objects){const n=Y.Objects.Deformer;for(const s in n){const o=n[s],i=ie.get(parseInt(s));if(o.attrType==="Skin"){const r=this.parseSkeleton(i,n);r.ID=s,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),r.geometryID=i.parents[0].ID,e[s]=r}else if(o.attrType==="BlendShape"){const r={id:s};r.rawTargets=this.parseMorphTargets(i,n),r.id=s,i.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[s]=r}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(s){const o=t[s.ID];if(o.attrType!=="Cluster")return;const i={ID:s.ID,indices:[],weights:[],transformLink:new l.Matrix4().fromArray(o.TransformLink.a)};"Indexes"in o&&(i.indices=o.Indexes.a,i.weights=o.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let s=0;s<e.children.length;s++){const o=e.children[s],i=t[o.ID],r={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if(i.attrType!=="BlendShapeChannel")return;r.geoID=ie.get(parseInt(o.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,n.push(r)}return n}parseScene(e,t,n){ue=new l.Group;const s=this.parseModels(e.skeletons,t,n),o=Y.Objects.Model,i=this;s.forEach(function(a){const u=o[a.ID];i.setLookAtProperties(a,u),ie.get(a.ID).parents.forEach(function(p){const f=s.get(p.ID);f!==void 0&&f.add(a)}),a.parent===null&&ue.add(a)}),this.bindSkeleton(e.skeletons,t,s),this.createAmbientLight(),ue.traverse(function(a){if(a.userData.transformData){a.parent&&(a.userData.transformData.parentMatrix=a.parent.matrix,a.userData.transformData.parentMatrixWorld=a.parent.matrixWorld);const u=ln(a.userData.transformData);a.applyMatrix4(u),a.updateWorldMatrix()}});const r=new co().parse();ue.children.length===1&&ue.children[0].isGroup&&(ue.children[0].animations=r,ue=ue.children[0]),ue.animations=r}parseModels(e,t,n){const s=new Map,o=Y.Objects.Model;for(const i in o){const r=parseInt(i),a=o[i],u=ie.get(r);let d=this.buildSkeleton(u,e,r,a.attrName);if(!d){switch(a.attrType){case"Camera":d=this.createCamera(u);break;case"Light":d=this.createLight(u);break;case"Mesh":d=this.createMesh(u,t,n);break;case"NurbsCurve":d=this.createCurve(u,t);break;case"LimbNode":case"Root":d=new l.Bone;break;case"Null":default:d=new l.Group;break}d.name=a.attrName?l.PropertyBinding.sanitizeNodeName(a.attrName):"",d.ID=r}this.getTransformData(d,a),s.set(r,d)}return s}buildSkeleton(e,t,n,s){let o=null;return e.parents.forEach(function(i){for(const r in t){const a=t[r];a.rawBones.forEach(function(u,d){if(u.ID===i.ID){const p=o;o=new l.Bone,o.matrixWorld.copy(u.transformLink),o.name=s?l.PropertyBinding.sanitizeNodeName(s):"",o.ID=n,a.bones[d]=o,p!==null&&o.add(p)}})}}),o}createCamera(e){let t,n;if(e.children.forEach(function(s){const o=Y.Objects.NodeAttribute[s.ID];o!==void 0&&(n=o)}),n===void 0)t=new l.Object3D;else{let s=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(s=1);let o=1;n.NearPlane!==void 0&&(o=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let r=window.innerWidth,a=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(r=n.AspectWidth.value,a=n.AspectHeight.value);const u=r/a;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const p=n.FocalLength?n.FocalLength.value:null;switch(s){case 0:t=new l.PerspectiveCamera(d,u,o,i),p!==null&&t.setFocalLength(p);break;case 1:t=new l.OrthographicCamera(-r/2,r/2,a/2,-a/2,o,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+s+"."),t=new l.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(s){const o=Y.Objects.NodeAttribute[s.ID];o!==void 0&&(n=o)}),n===void 0)t=new l.Object3D;else{let s;n.LightType===void 0?s=0:s=n.LightType.value;let o=16777215;n.Color!==void 0&&(o=new l.Color().fromArray(n.Color.value));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let r=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?r=0:r=n.FarAttenuationEnd.value);const a=1;switch(s){case 0:t=new l.PointLight(o,i,r,a);break;case 1:t=new l.DirectionalLight(o,i);break;case 2:let u=Math.PI/3;n.InnerAngle!==void 0&&(u=l.MathUtils.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=l.MathUtils.degToRad(n.OuterAngle.value),d=Math.max(d,1)),t=new l.SpotLight(o,i,r,u,d,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new l.PointLight(o,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let s,o=null,i=null;const r=[];return e.children.forEach(function(a){t.has(a.ID)&&(o=t.get(a.ID)),n.has(a.ID)&&r.push(n.get(a.ID))}),r.length>1?i=r:r.length>0?i=r[0]:(i=new l.MeshPhongMaterial({color:13421772}),r.push(i)),"color"in o.attributes&&r.forEach(function(a){a.vertexColors=!0}),o.FBX_Deformer?(s=new l.SkinnedMesh(o,i),s.normalizeSkinWeights()):s=new l.Mesh(o,i),s}createCurve(e,t){const n=e.children.reduce(function(o,i){return t.has(i.ID)&&(o=t.get(i.ID)),o},null),s=new l.LineBasicMaterial({color:3342591,linewidth:1});return new l.Line(n,s)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=cn(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&ie.get(e.ID).children.forEach(function(s){if(s.relationship==="LookAtProperty"){const o=Y.Objects.Model[s.ID];if("Lcl_Translation"in o){const i=o.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),ue.add(e.target)):e.lookAt(new l.Vector3().fromArray(i))}}})}bindSkeleton(e,t,n){const s=this.parsePoseNodes();for(const o in e){const i=e[o];ie.get(parseInt(i.ID)).parents.forEach(function(a){if(t.has(a.ID)){const u=a.ID;ie.get(u).parents.forEach(function(p){n.has(p.ID)&&n.get(p.ID).bind(new l.Skeleton(i.bones),s[p.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in Y.Objects){const t=Y.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const s=t[n].PoseNode;Array.isArray(s)?s.forEach(function(o){e[o.Node]=new l.Matrix4().fromArray(o.Matrix.a)}):e[s.Node]=new l.Matrix4().fromArray(s.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Y&&"AmbientColor"in Y.GlobalSettings){const e=Y.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],s=e[2];if(t!==0||n!==0||s!==0){const o=new l.Color(t,n,s);ue.add(new l.AmbientLight(o,1))}}}}class lo{parse(e){const t=new Map;if("Geometry"in Y.Objects){const n=Y.Objects.Geometry;for(const s in n){const o=ie.get(parseInt(s)),i=this.parseGeometry(o,n[s],e);t.set(parseInt(s),i)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const s=n.skeletons,o=[],i=e.parents.map(function(p){return Y.Objects.Model[p.ID]});if(i.length===0)return;const r=e.children.reduce(function(p,f){return s[f.ID]!==void 0&&(p=s[f.ID]),p},null);e.children.forEach(function(p){n.morphTargets[p.ID]!==void 0&&o.push(n.morphTargets[p.ID])});const a=i[0],u={};"RotationOrder"in a&&(u.eulerOrder=cn(a.RotationOrder.value)),"InheritType"in a&&(u.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(u.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(u.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(u.scale=a.GeometricScaling.value);const d=ln(u);return this.genGeometry(t,r,o,d)}genGeometry(e,t,n,s){const o=new l.BufferGeometry;e.attrName&&(o.name=e.attrName);const i=this.parseGeoNode(e,t),r=this.genBuffers(i),a=new l.Float32BufferAttribute(r.vertex,3);if(a.applyMatrix4(s),o.setAttribute("position",a),r.colors.length>0&&o.setAttribute("color",new l.Float32BufferAttribute(r.colors,3)),t&&(o.setAttribute("skinIndex",new l.Uint16BufferAttribute(r.weightsIndices,4)),o.setAttribute("skinWeight",new l.Float32BufferAttribute(r.vertexWeights,4)),o.FBX_Deformer=t),r.normal.length>0){const u=new l.Matrix3().getNormalMatrix(s),d=new l.Float32BufferAttribute(r.normal,3);d.applyNormalMatrix(u),o.setAttribute("normal",d)}if(r.uvs.forEach(function(u,d){let p="uv"+(d+1).toString();d===0&&(p="uv"),o.setAttribute(p,new l.Float32BufferAttribute(r.uvs[d],2))}),i.material&&i.material.mappingType!=="AllSame"){let u=r.materialIndex[0],d=0;if(r.materialIndex.forEach(function(p,f){p!==u&&(o.addGroup(d,f-d,u),u=p,d=f)}),o.groups.length>0){const p=o.groups[o.groups.length-1],f=p.start+p.count;f!==r.materialIndex.length&&o.addGroup(f,r.materialIndex.length-f,u)}o.groups.length===0&&o.addGroup(0,r.materialIndex.length,r.materialIndex[0])}return this.addMorphTargets(o,e,n,s),o}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let s=0;for(;e.LayerElementUV[s];)e.LayerElementUV[s].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[s])),s++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(s,o){s.indices.forEach(function(i,r){n.weightTable[i]===void 0&&(n.weightTable[i]=[]),n.weightTable[i].push({id:o,weight:s.weights[r]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,s=0,o=!1,i=[],r=[],a=[],u=[],d=[],p=[];const f=this;return e.vertexIndices.forEach(function(m,y){let _,x=!1;m<0&&(m=m^-1,x=!0);let S=[],O=[];if(i.push(m*3,m*3+1,m*3+2),e.color){const M=ot(y,n,m,e.color);a.push(M[0],M[1],M[2])}if(e.skeleton){if(e.weightTable[m]!==void 0&&e.weightTable[m].forEach(function(M){O.push(M.weight),S.push(M.id)}),O.length>4){o||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),o=!0);const M=[0,0,0,0],g=[0,0,0,0];O.forEach(function(A,b){let w=A,v=S[b];g.forEach(function(C,k,I){if(w>C){I[k]=w,w=C;const U=M[k];M[k]=v,v=U}})}),S=M,O=g}for(;O.length<4;)O.push(0),S.push(0);for(let M=0;M<4;++M)d.push(O[M]),p.push(S[M])}if(e.normal){const M=ot(y,n,m,e.normal);r.push(M[0],M[1],M[2])}e.material&&e.material.mappingType!=="AllSame"&&(_=ot(y,n,m,e.material)[0]),e.uv&&e.uv.forEach(function(M,g){const A=ot(y,n,m,M);u[g]===void 0&&(u[g]=[]),u[g].push(A[0]),u[g].push(A[1])}),s++,x&&(f.genFace(t,e,i,_,r,a,u,d,p,s),n++,s=0,i=[],r=[],a=[],u=[],d=[],p=[])}),t}genFace(e,t,n,s,o,i,r,a,u,d){for(let p=2;p<d;p++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(p-1)*3]]),e.vertex.push(t.vertexPositions[n[(p-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(p-1)*3+2]]),e.vertex.push(t.vertexPositions[n[p*3]]),e.vertex.push(t.vertexPositions[n[p*3+1]]),e.vertex.push(t.vertexPositions[n[p*3+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[(p-1)*4]),e.vertexWeights.push(a[(p-1)*4+1]),e.vertexWeights.push(a[(p-1)*4+2]),e.vertexWeights.push(a[(p-1)*4+3]),e.vertexWeights.push(a[p*4]),e.vertexWeights.push(a[p*4+1]),e.vertexWeights.push(a[p*4+2]),e.vertexWeights.push(a[p*4+3]),e.weightsIndices.push(u[0]),e.weightsIndices.push(u[1]),e.weightsIndices.push(u[2]),e.weightsIndices.push(u[3]),e.weightsIndices.push(u[(p-1)*4]),e.weightsIndices.push(u[(p-1)*4+1]),e.weightsIndices.push(u[(p-1)*4+2]),e.weightsIndices.push(u[(p-1)*4+3]),e.weightsIndices.push(u[p*4]),e.weightsIndices.push(u[p*4+1]),e.weightsIndices.push(u[p*4+2]),e.weightsIndices.push(u[p*4+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[(p-1)*3]),e.colors.push(i[(p-1)*3+1]),e.colors.push(i[(p-1)*3+2]),e.colors.push(i[p*3]),e.colors.push(i[p*3+1]),e.colors.push(i[p*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(o[0]),e.normal.push(o[1]),e.normal.push(o[2]),e.normal.push(o[(p-1)*3]),e.normal.push(o[(p-1)*3+1]),e.normal.push(o[(p-1)*3+2]),e.normal.push(o[p*3]),e.normal.push(o[p*3+1]),e.normal.push(o[p*3+2])),t.uv&&t.uv.forEach(function(f,m){e.uvs[m]===void 0&&(e.uvs[m]=[]),e.uvs[m].push(r[m][0]),e.uvs[m].push(r[m][1]),e.uvs[m].push(r[m][(p-1)*2]),e.uvs[m].push(r[m][(p-1)*2+1]),e.uvs[m].push(r[m][p*2]),e.uvs[m].push(r[m][p*2+1])})}addMorphTargets(e,t,n,s){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const o=this;n.forEach(function(i){i.rawTargets.forEach(function(r){const a=Y.Objects.Geometry[r.geoID];a!==void 0&&o.genMorphGeometry(e,t,a,s,r.name)})})}genMorphGeometry(e,t,n,s,o){const i=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],r=n.Vertices!==void 0?n.Vertices.a:[],a=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,d=new Float32Array(u);for(let y=0;y<a.length;y++){const _=a[y]*3;d[_]=r[y*3],d[_+1]=r[y*3+1],d[_+2]=r[y*3+2]}const p={vertexIndices:i,vertexPositions:d},f=this.genBuffers(p),m=new l.Float32BufferAttribute(f.vertex,3);m.name=o||n.attrName,m.applyMatrix4(s),e.morphAttributes.position.push(m)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Normals.a;let o=[];return n==="IndexToDirect"&&("NormalIndex"in e?o=e.NormalIndex.a:"NormalsIndex"in e&&(o=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:o,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.UV.a;let o=[];return n==="IndexToDirect"&&(o=e.UVIndex.a),{dataSize:2,buffer:s,indices:o,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Colors.a;let o=[];return n==="IndexToDirect"&&(o=e.ColorIndex.a),{dataSize:4,buffer:s,indices:o,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const s=e.Materials.a,o=[];for(let i=0;i<s.length;++i)o.push(i);return{dataSize:1,buffer:s,indices:o,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(sn===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new l.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new l.BufferGeometry;const n=t-1,s=e.KnotVector.a,o=[],i=e.Points.a;for(let p=0,f=i.length;p<f;p+=4)o.push(new l.Vector4().fromArray(i,p));let r,a;if(e.Form==="Closed")o.push(o[0]);else if(e.Form==="Periodic"){r=n,a=s.length-1-r;for(let p=0;p<n;++p)o.push(o[p])}const d=new sn(n,s,o,r,a).getPoints(o.length*12);return new l.BufferGeometry().setFromPoints(d)}}class co{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const s=t[n],o=this.addClip(s);e.push(o)}return e}parseClips(){if(Y.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Y.Objects.AnimationCurveNode,t=new Map;for(const n in e){const s=e[n];if(s.attrName.match(/S|R|T|DeformPercent/)!==null){const o={id:s.id,attr:s.attrName,curves:{}};t.set(o.id,o)}}return t}parseAnimationCurves(e){const t=Y.Objects.AnimationCurve;for(const n in t){const s={id:t[n].id,times:t[n].KeyTime.a.map(mo),values:t[n].KeyValueFloat.a},o=ie.get(s.id);if(o!==void 0){const i=o.parents[0].ID,r=o.parents[0].relationship;r.match(/X/)?e.get(i).curves.x=s:r.match(/Y/)?e.get(i).curves.y=s:r.match(/Z/)?e.get(i).curves.z=s:r.match(/d|DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=s)}}}parseAnimationLayers(e){const t=Y.Objects.AnimationLayer,n=new Map;for(const s in t){const o=[],i=ie.get(parseInt(s));i!==void 0&&(i.children.forEach(function(a,u){if(e.has(a.ID)){const d=e.get(a.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(o[u]===void 0){const p=ie.get(a.ID).parents.filter(function(f){return f.relationship!==void 0})[0].ID;if(p!==void 0){const f=Y.Objects.Model[p.toString()];if(f===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const m={modelName:f.attrName?l.PropertyBinding.sanitizeNodeName(f.attrName):"",ID:f.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ue.traverse(function(y){y.ID===f.id&&(m.transform=y.matrix,y.userData.transformData&&(m.eulerOrder=y.userData.transformData.eulerOrder))}),m.transform||(m.transform=new l.Matrix4),"PreRotation"in f&&(m.preRotation=f.PreRotation.value),"PostRotation"in f&&(m.postRotation=f.PostRotation.value),o[u]=m}}o[u]&&(o[u][d.attr]=d)}else if(d.curves.morph!==void 0){if(o[u]===void 0){const p=ie.get(a.ID).parents.filter(function(S){return S.relationship!==void 0})[0].ID,f=ie.get(p).parents[0].ID,m=ie.get(f).parents[0].ID,y=ie.get(m).parents[0].ID,_=Y.Objects.Model[y],x={modelName:_.attrName?l.PropertyBinding.sanitizeNodeName(_.attrName):"",morphName:Y.Objects.Deformer[p].attrName};o[u]=x}o[u][d.attr]=d}}}),n.set(parseInt(s),o))}return n}parseAnimStacks(e){const t=Y.Objects.AnimationStack,n={};for(const s in t){const o=ie.get(parseInt(s)).children;o.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(o[0].ID);n[s]={name:t[s].attrName,layer:i}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(s){t=t.concat(n.generateTracks(s))}),new l.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new l.Vector3,s=new l.Quaternion,o=new l.Vector3;if(e.transform&&e.transform.decompose(n,s,o),n=n.toArray(),s=new l.Euler().setFromQuaternion(s,e.eulerOrder).toArray(),o=o.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");i!==void 0&&t.push(i)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,s,e.preRotation,e.postRotation,e.eulerOrder);i!==void 0&&t.push(i)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,o,"scale");i!==void 0&&t.push(i)}if(e.DeformPercent!==void 0){const i=this.generateMorphTrack(e);i!==void 0&&t.push(i)}return t}generateVectorTrack(e,t,n,s){const o=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(o,t,n);return new l.VectorKeyframeTrack(e+"."+s,o,i)}generateRotationTrack(e,t,n,s,o,i){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(l.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(l.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(l.MathUtils.degToRad));const r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);s!==void 0&&(s=s.map(l.MathUtils.degToRad),s.push(i),s=new l.Euler().fromArray(s),s=new l.Quaternion().setFromEuler(s)),o!==void 0&&(o=o.map(l.MathUtils.degToRad),o.push(i),o=new l.Euler().fromArray(o),o=new l.Quaternion().setFromEuler(o).invert());const u=new l.Quaternion,d=new l.Euler,p=[];for(let f=0;f<a.length;f+=3)d.set(a[f],a[f+1],a[f+2],i),u.setFromEuler(d),s!==void 0&&u.premultiply(s),o!==void 0&&u.multiply(o),u.toArray(p,f/3*4);return new l.QuaternionKeyframeTrack(e+".quaternion",r,p)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(o){return o/100}),s=ue.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+s+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,s){return n-s}),t.length>1){let n=1,s=t[0];for(let o=1;o<t.length;o++){const i=t[o];i!==s&&(t[n]=i,s=i,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const s=n,o=[];let i=-1,r=-1,a=-1;return e.forEach(function(u){if(t.x&&(i=t.x.times.indexOf(u)),t.y&&(r=t.y.times.indexOf(u)),t.z&&(a=t.z.times.indexOf(u)),i!==-1){const d=t.x.values[i];o.push(d),s[0]=d}else o.push(s[0]);if(r!==-1){const d=t.y.values[r];o.push(d),s[1]=d}else o.push(s[1]);if(a!==-1){const d=t.z.values[a];o.push(d),s[2]=d}else o.push(s[2])}),o}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],s=e.values[t]-n,o=Math.abs(s);if(o>=180){const i=o/180,r=s/i;let a=n+r;const u=e.times[t-1],p=(e.times[t]-u)/i;let f=u+p;const m=[],y=[];for(;f<e.times[t];)m.push(f),f+=p,y.push(a),a+=r;e.times=un(e.times,t,m),e.values=un(e.values,t,y)}}}}class ho{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new rn,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(s,o){const i=s.match(/^[\s\t]*;/),r=s.match(/^[\s\t]*$/);if(i||r)return;const a=s.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),u=s.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=s.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(s,a):u?t.parseNodeProperty(s,u,n[++o]):d?t.popStack():s.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(s)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),s=t[2].split(",").map(function(a){return a.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:n},i=this.parseNodeAttr(s),r=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,o):n in r?(n==="PoseNode"?r.PoseNode.push(o):r[n].id!==void 0&&(r[n]={},r[n][r[n].id]=r[n]),i.id!==""&&(r[n][i.id]=o)):typeof i.id=="number"?(r[n]={},r[n][i.id]=o):n!=="Properties70"&&(n==="PoseNode"?r[n]=[o]:r[n]=o),typeof i.id=="number"&&(o.id=i.id),i.name!==""&&(o.attrName=i.name),i.type!==""&&(o.attrType=i.type),this.pushStack(o)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",s="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:n,type:s}}parseNodeProperty(e,t,n){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();s==="Content"&&o===","&&(o=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if(i.name==="Properties70"){this.parseNodeSpecialProperty(e,s,o);return}if(s==="C"){const a=o.split(",").slice(1),u=parseInt(a[0]),d=parseInt(a[1]);let p=o.split(",").slice(3);p=p.map(function(f){return f.trim().replace(/^"/,"")}),s="connections",o=[u,d],_o(o,p),i[s]===void 0&&(i[s]=[])}s==="Node"&&(i.id=o),s in i&&Array.isArray(i[s])?i[s].push(o):s!=="a"?i[s]=o:i.a=o,this.setCurrentProp(i,s),s==="a"&&o.slice(-1)!==","&&(i.a=Mt(o))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Mt(t.a))}parseNodeSpecialProperty(e,t,n){const s=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),o=s[0],i=s[1],r=s[2],a=s[3];let u=s[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":u=parseFloat(u);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":u=Mt(u);break}this.getPrevNode()[o]={type:i,type2:r,flag:a,value:u},this.setCurrentProp(this.getPrevNode(),o)}}class uo{parse(e){const t=new on(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const s=new rn;for(;!this.endOfContent(t);){const o=this.parseNode(t,n);o!==null&&s.add(o.name,o)}return s}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},s=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),r=e.getString(i);if(s===0)return null;const a=[];for(let f=0;f<o;f++)a.push(this.parseProperty(e));const u=a.length>0?a[0]:"",d=a.length>1?a[1]:"",p=a.length>2?a[2]:"";for(n.singleProperty=o===1&&e.getOffset()===s;s>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(r,n,f)}return n.propertyList=a,typeof u=="number"&&(n.id=u),d!==""&&(n.attrName=d),p!==""&&(n.attrType=p),r!==""&&(n.name=r),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const s=n.propertyList[0];Array.isArray(s)?(t[n.name]=n,n.a=s):t[n.name]=s}else if(e==="Connections"&&n.name==="C"){const s=[];n.propertyList.forEach(function(o,i){i!==0&&s.push(o)}),t.connections===void 0&&(t.connections=[]),t.connections.push(s)}else if(n.name==="Properties70")Object.keys(n).forEach(function(o){t[o]=n[o]});else if(e==="Properties70"&&n.name==="P"){let s=n.propertyList[0],o=n.propertyList[1];const i=n.propertyList[2],r=n.propertyList[3];let a;s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),o.indexOf("Lcl ")===0&&(o=o.replace("Lcl ","Lcl_")),o==="Color"||o==="ColorRGB"||o==="Vector"||o==="Vector3D"||o.indexOf("Lcl_")===0?a=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:a=n.propertyList[4],t[s]={type:o,type2:i,flag:r,value:a}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const s=e.getUint32(),o=e.getUint32(),i=e.getUint32();if(o===0)switch(t){case"b":case"c":return e.getBooleanArray(s);case"d":return e.getFloat64Array(s);case"f":return e.getFloat32Array(s);case"i":return e.getInt32Array(s);case"l":return e.getInt64Array(s)}const r=ns(new Uint8Array(e.getArrayBuffer(i))),a=new on(r.buffer);switch(t){case"b":case"c":return a.getBooleanArray(s);case"d":return a.getFloat64Array(s);case"f":return a.getFloat32Array(s);case"i":return a.getInt32Array(s);case"l":return a.getInt64Array(s)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class on{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let s=0;s<e;s++)t[s]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),l.LoaderUtils.decodeText(new Uint8Array(t))}}class rn{add(e,t){this[e]=t}}function po(c){const e="Kaydara FBX Binary \0";return c.byteLength>=e.length&&e===hn(c,0,e.length)}function fo(c){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(s){const o=c[s-1];return c=c.slice(t+s),t++,o}for(let s=0;s<e.length;++s)if(n(1)===e[s])return!1;return!0}function an(c){const e=/FBXVersion: (\d+)/,t=c.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function mo(c){return c/46186158e3}const go=[];function ot(c,e,t,n){let s;switch(n.mappingType){case"ByPolygonVertex":s=c;break;case"ByPolygon":s=e;break;case"ByVertice":s=t;break;case"AllSame":s=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(s=n.indices[s]);const o=s*n.dataSize,i=o+n.dataSize;return yo(go,n.buffer,o,i)}const xt=new l.Euler,Ge=new l.Vector3;function ln(c){const e=new l.Matrix4,t=new l.Matrix4,n=new l.Matrix4,s=new l.Matrix4,o=new l.Matrix4,i=new l.Matrix4,r=new l.Matrix4,a=new l.Matrix4,u=new l.Matrix4,d=new l.Matrix4,p=new l.Matrix4,f=new l.Matrix4,m=c.inheritType?c.inheritType:0;if(c.translation&&e.setPosition(Ge.fromArray(c.translation)),c.preRotation){const k=c.preRotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),t.makeRotationFromEuler(xt.fromArray(k))}if(c.rotation){const k=c.rotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),n.makeRotationFromEuler(xt.fromArray(k))}if(c.postRotation){const k=c.postRotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),s.makeRotationFromEuler(xt.fromArray(k)),s.invert()}c.scale&&o.scale(Ge.fromArray(c.scale)),c.scalingOffset&&r.setPosition(Ge.fromArray(c.scalingOffset)),c.scalingPivot&&i.setPosition(Ge.fromArray(c.scalingPivot)),c.rotationOffset&&a.setPosition(Ge.fromArray(c.rotationOffset)),c.rotationPivot&&u.setPosition(Ge.fromArray(c.rotationPivot)),c.parentMatrixWorld&&(p.copy(c.parentMatrix),d.copy(c.parentMatrixWorld));const y=t.clone().multiply(n).multiply(s),_=new l.Matrix4;_.extractRotation(d);const x=new l.Matrix4;x.copyPosition(d);const S=x.clone().invert().multiply(d),O=_.clone().invert().multiply(S),M=o,g=new l.Matrix4;if(m===0)g.copy(_).multiply(y).multiply(O).multiply(M);else if(m===1)g.copy(_).multiply(O).multiply(y).multiply(M);else{const I=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(p)).clone().invert(),U=O.clone().multiply(I);g.copy(_).multiply(y).multiply(U).multiply(M)}const A=u.clone().invert(),b=i.clone().invert();let w=e.clone().multiply(a).multiply(u).multiply(t).multiply(n).multiply(s).multiply(A).multiply(r).multiply(i).multiply(o).multiply(b);const v=new l.Matrix4().copyPosition(w),C=d.clone().multiply(v);return f.copyPosition(C),w=f.clone().multiply(g),w.premultiply(d.invert()),w}function cn(c){c=c||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return c===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[c]}function Mt(c){return c.split(",").map(function(t){return parseFloat(t)})}function hn(c,e,t){return e===void 0&&(e=0),t===void 0&&(t=c.byteLength),l.LoaderUtils.decodeText(new Uint8Array(c,e,t))}function _o(c,e){for(let t=0,n=c.length,s=e.length;t<s;t++,n++)c[n]=e[t]}function yo(c,e,t,n){for(let s=t,o=0;s<n;s++,o++)c[o]=e[s];return c}function un(c,e,t){return c.slice(0,e).concat(t).concat(c.slice(e))}var wo=Object.defineProperty,vo=(c,e,t)=>e in c?wo(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,bt=(c,e,t)=>(vo(c,typeof e!="symbol"?e+"":e,t),t);class Ao extends l.Loader{constructor(e){super(e)}load(e,t,n,s){const o=new l.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{if(typeof i!="string")throw new Error("unsupported data type");const r=JSON.parse(i),a=this.parse(r);t&&t(a)},n,s)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new Tt(e)}}class Tt{constructor(e){bt(this,"data"),this.data=e}generateShapes(e,t=100,n){const s=[],o={letterSpacing:0,lineHeight:1,...n},i=xo(e,t,this.data,o);for(let r=0,a=i.length;r<a;r++)Array.prototype.push.apply(s,i[r].toShapes(!1));return s}}bt(Tt,"isFont"),bt(Tt,"type");function xo(c,e,t,n){const s=Array.from(c),o=e/t.resolution,i=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*o,r=[];let a=0,u=0;for(let d=0;d<s.length;d++){const p=s[d];if(p===`
|
|
74
|
+
`)a=0,u-=i*n.lineHeight;else{const f=Mo(p,o,a,u,t);f&&(a+=f.offsetX+n.letterSpacing,r.push(f.path))}}return r}function Mo(c,e,t,n,s){const o=s.glyphs[c]||s.glyphs["?"];if(!o){console.error('THREE.Font: character "'+c+'" does not exists in font family '+s.familyName+".");return}const i=new l.ShapePath;let r,a,u,d,p,f,m,y;if(o.o){const _=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let x=0,S=_.length;x<S;)switch(_[x++]){case"m":r=parseInt(_[x++])*e+t,a=parseInt(_[x++])*e+n,i.moveTo(r,a);break;case"l":r=parseInt(_[x++])*e+t,a=parseInt(_[x++])*e+n,i.lineTo(r,a);break;case"q":u=parseInt(_[x++])*e+t,d=parseInt(_[x++])*e+n,p=parseInt(_[x++])*e+t,f=parseInt(_[x++])*e+n,i.quadraticCurveTo(p,f,u,d);break;case"b":u=parseInt(_[x++])*e+t,d=parseInt(_[x++])*e+n,p=parseInt(_[x++])*e+t,f=parseInt(_[x++])*e+n,m=parseInt(_[x++])*e+t,y=parseInt(_[x++])*e+n,i.bezierCurveTo(p,f,m,y,u,d);break}}return{offsetX:o.ha*e,path:i}}class bo extends l.DataTextureLoader{constructor(e){super(e),this.type=l.HalfFloatType}parse(e){const r=function(M,g){switch(M){case 1:console.error("THREE.RGBELoader Read Error: "+(g||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(g||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(g||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(g||""))}return-1},p=`
|
|
75
|
+
`,f=function(M,g,A){g=g||1024;let w=M.pos,v=-1,C=0,k="",I=String.fromCharCode.apply(null,new Uint16Array(M.subarray(w,w+128)));for(;0>(v=I.indexOf(p))&&C<g&&w<M.byteLength;)k+=I,C+=I.length,w+=128,I+=String.fromCharCode.apply(null,new Uint16Array(M.subarray(w,w+128)));return-1<v?(A!==!1&&(M.pos+=C+v+1),k+I.slice(0,v)):!1},m=function(M){const g=/^#\?(\S+)/,A=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,w=/^\s*FORMAT=(\S+)\s*$/,v=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,C={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let k,I;if(M.pos>=M.byteLength||!(k=f(M)))return r(1,"no header found");if(!(I=k.match(g)))return r(3,"bad initial token");for(C.valid|=1,C.programtype=I[1],C.string+=k+`
|
|
76
|
+
`;k=f(M),k!==!1;){if(C.string+=k+`
|
|
77
|
+
`,k.charAt(0)==="#"){C.comments+=k+`
|
|
78
|
+
`;continue}if((I=k.match(A))&&(C.gamma=parseFloat(I[1])),(I=k.match(b))&&(C.exposure=parseFloat(I[1])),(I=k.match(w))&&(C.valid|=2,C.format=I[1]),(I=k.match(v))&&(C.valid|=4,C.height=parseInt(I[1],10),C.width=parseInt(I[2],10)),C.valid&2&&C.valid&4)break}return C.valid&2?C.valid&4?C:r(3,"missing image size specifier"):r(3,"missing format specifier")},y=function(M,g,A){const b=g;if(b<8||b>32767||M[0]!==2||M[1]!==2||M[2]&128)return new Uint8Array(M);if(b!==(M[2]<<8|M[3]))return r(3,"wrong scanline width");const w=new Uint8Array(4*g*A);if(!w.length)return r(4,"unable to allocate buffer space");let v=0,C=0;const k=4*b,I=new Uint8Array(4),U=new Uint8Array(k);let j=A;for(;j>0&&C<M.byteLength;){if(C+4>M.byteLength)return r(1);if(I[0]=M[C++],I[1]=M[C++],I[2]=M[C++],I[3]=M[C++],I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=b)return r(3,"bad rgbe scanline format");let H=0,G;for(;H<k&&C<M.byteLength;){G=M[C++];const X=G>128;if(X&&(G-=128),G===0||H+G>k)return r(3,"bad scanline data");if(X){const ae=M[C++];for(let re=0;re<G;re++)U[H++]=ae}else U.set(M.subarray(C,C+G),H),H+=G,C+=G}const ne=b;for(let X=0;X<ne;X++){let ae=0;w[v]=U[X+ae],ae+=b,w[v+1]=U[X+ae],ae+=b,w[v+2]=U[X+ae],ae+=b,w[v+3]=U[X+ae],v+=4}j--}return w},_=function(M,g,A,b){const w=M[g+3],v=Math.pow(2,w-128)/255;A[b+0]=M[g+0]*v,A[b+1]=M[g+1]*v,A[b+2]=M[g+2]*v,A[b+3]=1},x=function(M,g,A,b){const w=M[g+3],v=Math.pow(2,w-128)/255;A[b+0]=l.DataUtils.toHalfFloat(Math.min(M[g+0]*v,65504)),A[b+1]=l.DataUtils.toHalfFloat(Math.min(M[g+1]*v,65504)),A[b+2]=l.DataUtils.toHalfFloat(Math.min(M[g+2]*v,65504)),A[b+3]=l.DataUtils.toHalfFloat(1)},S=new Uint8Array(e);S.pos=0;const O=m(S);if(O!==-1){const M=O.width,g=O.height,A=y(S.subarray(S.pos),M,g);if(A!==-1){let b,w,v;switch(this.type){case l.FloatType:v=A.length/4;const C=new Float32Array(v*4);for(let I=0;I<v;I++)_(A,I*4,C,I*4);b=C,w=l.FloatType;break;case l.HalfFloatType:v=A.length/4;const k=new Uint16Array(v*4);for(let I=0;I<v;I++)x(A,I*4,k,I*4);b=k,w=l.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:M,height:g,data:b,header:O.string,gamma:O.gamma,exposure:O.exposure,type:w}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,s){function o(i,r){switch(i.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=l.LinearFilter,i.magFilter=l.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,r)}return super.load(e,o,n,s)}}const St=new WeakMap;class To extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const o=new l.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{const r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(i,r).then(t).catch(s)},n,s)}decodeDracoFile(e,t,n,s){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){for(const a in t.attributeTypes){const u=t.attributeTypes[a];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[a]=u.name)}const n=JSON.stringify(t);if(St.has(e)){const a=St.get(e);if(a.key===n)return a.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const o=this.workerNextTaskID++,i=e.byteLength,r=this._getWorker(o,i).then(a=>(s=a,new Promise((u,d)=>{s._callbacks[o]={resolve:u,reject:d},s.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return r.catch(()=>!0).then(()=>{s&&o&&this._releaseTask(s,o)}),St.set(e,{key:n,promise:r}),r}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],o=s.name,i=s.array,r=s.itemSize;t.setAttribute(o,new l.BufferAttribute(i,r))}return t}_loadLibrary(e,t){const n=new l.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,o)=>{n.load(e,s,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=So.toString(),i=["/* draco decoder */",s,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
|
79
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){const i=o.data;switch(i.type){case"decode":s._callbacks[i.id].resolve(i);break;case"error":s._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function So(){let c,e;onmessage=function(i){const r=i.data;switch(r.type){case"init":c=r.decoderConfig,e=new Promise(function(d){c.onModuleLoaded=function(p){d({draco:p})},DracoDecoderModule(c)});break;case"decode":const a=r.buffer,u=r.taskConfig;e.then(d=>{const p=d.draco,f=new p.Decoder,m=new p.DecoderBuffer;m.Init(new Int8Array(a),a.byteLength);try{const y=t(p,f,m,u),_=y.attributes.map(x=>x.array.buffer);y.index&&_.push(y.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:y},_)}catch(y){console.error(y),self.postMessage({type:"error",id:r.id,error:y.message})}finally{p.destroy(m),p.destroy(f)}});break}};function t(i,r,a,u){const d=u.attributeIDs,p=u.attributeTypes;let f,m;const y=r.GetEncodedGeometryType(a);if(y===i.TRIANGULAR_MESH)f=new i.Mesh,m=r.DecodeBufferToMesh(a,f);else if(y===i.POINT_CLOUD)f=new i.PointCloud,m=r.DecodeBufferToPointCloud(a,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!m.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+m.error_msg());const _={index:null,attributes:[]};for(const x in d){const S=self[p[x]];let O,M;if(u.useUniqueIDs)M=d[x],O=r.GetAttributeByUniqueId(f,M);else{if(M=r.GetAttributeId(f,i[d[x]]),M===-1)continue;O=r.GetAttribute(f,M)}_.attributes.push(s(i,r,f,x,S,O))}return y===i.TRIANGULAR_MESH&&(_.index=n(i,r,f)),i.destroy(f),_}function n(i,r,a){const d=a.num_faces()*3,p=d*4,f=i._malloc(p);r.GetTrianglesUInt32Array(a,p,f);const m=new Uint32Array(i.HEAPF32.buffer,f,d).slice();return i._free(f),{array:m,itemSize:1}}function s(i,r,a,u,d,p){const f=p.num_components(),y=a.num_points()*f,_=y*d.BYTES_PER_ELEMENT,x=o(i,d),S=i._malloc(_);r.GetAttributeDataArrayForAllPoints(a,p,x,_,S);const O=new d(i.HEAPF32.buffer,S,y).slice();return i._free(S),{name:u,array:O,itemSize:f}}function o(i,r){switch(r){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}const Lo=["args","center"],Oo=h.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(c,{expose:e}){let t,n;const s=c,{center:o,font:i,text:r,needUpdates:a,size:u,height:d,curveSegments:p,bevelEnabled:f,bevelThickness:m,bevelSize:y,bevelOffset:_,bevelSegments:x}=h.toRefs(s),{extend:S}=q.useTresContext();S({TextGeometry:tn});const O=new Ao,M=h.useSlots(),g=h.computed(()=>{var v;return r!=null&&r.value?r.value:M.default?(v=M.default()[0].children)==null?void 0:v.trim():a.value?"":"TresJS"}),A=h.shallowRef();e({value:A});const b=([t,n]=h.withAsyncContext(()=>new Promise((v,C)=>{try{typeof i.value=="string"?O.load(i.value,k=>{v(k)}):v(i.value)}catch(k){C(console.error("cientos",k))}})),t=await t,n(),t),w=h.computed(()=>({font:b,size:h.toValue(u),height:h.toValue(d),curveSegments:h.toValue(p),bevelEnabled:h.toValue(f),bevelThickness:h.toValue(m),bevelSize:h.toValue(y),bevelOffset:h.toValue(_),bevelSegments:h.toValue(x)}));return h.watchEffect(()=>{A.value&&a.value&&(A.value.geometry.dispose(),A.value.geometry=new tn(g.value,w.value),o.value&&A.value.geometry.center())}),(v,C)=>h.unref(i)?(h.openBlock(),h.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:A},[g.value?(h.openBlock(),h.createElementBlock("TresTextGeometry",{key:0,args:[g.value,w.value],center:h.unref(o)},null,8,Lo)):h.createCommentVNode("",!0),h.renderSlot(v.$slots,"default")],512)):h.createCommentVNode("",!0)}});function Po(c,e){const t=h.ref(e),n=new l.AnimationMixer(t.value),s=h.shallowReactive({});c.forEach(i=>{const r=n.clipAction(i,t.value);s[i.name]=r});const{onLoop:o}=q.useRenderLoop();return o(({delta:i})=>{n.update(i)}),{actions:s,mixer:n}}const Lt={sunset:"venice/venice_sunset_4k.hdr"};async function pn({files:c=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],blur:e=0,background:t=!1,path:n="/",preset:s=void 0}){const{scene:o}=q.useTresContext();if(s){if(!(s in Lt))throw new Error("Preset must be one of: "+Object.keys(Lt).join(", "));c=Lt[s],n="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const i=Array.isArray(c),r=i?l.CubeTextureLoader:bo,a=await q.useLoader(r,i?[c]:c,d=>{n&&d.setPath(n)}),u=i?a[0]:a;return u&&(u.mapping=i?l.CubeReflectionMapping:l.EquirectangularReflectionMapping,u.colorSpace=l.SRGBColorSpace),o.value&&(o.value.environment=u,t&&(o.value.background=u),e&&(o.value.backgroundBlurriness=e|0)),u}const Co=h.defineComponent({name:"Environment",props:["background","blur","files","encoding","path","preset"],async setup(c,{expose:e}){let t=null;return e({getTexture:()=>t}),t=await pn(c),()=>{}}}),Do=["position","a-scale"],Io=["size","size-attenuation","transparent","alpha-test","alpha-map"],ko=h.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(c,{expose:e}){const t=c,n=h.ref(),s=h.ref(),{radius:o,depth:i,count:r,size:a,sizeAttenuation:u,transparent:d,alphaMap:p,alphaTest:f}=h.toRefs(t),m=()=>{let _=o.value+i.value;const x=h.computed(()=>i.value/r.value),S=[],O=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),M=g=>new l.Vector3().setFromSpherical(new l.Spherical(g,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let g=0;g<r.value;g++)_-=x.value*Math.random(),S.push(...M(_));n.value=new Float32Array(S),s.value=new Float32Array(O)};h.watchEffect(()=>{m()});const y=h.shallowRef();return e({value:y}),(_,x)=>(h.openBlock(),h.createElementBlock("TresPoints",{ref_key:"starsRef",ref:y},[h.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[s.value,1]},null,8,Do),h.createElementVNode("TresPointsMaterial",{size:h.unref(a),"size-attenuation":h.unref(u),transparent:h.unref(d),"alpha-test":h.unref(f),"alpha-map":h.unref(p)},null,8,Io)],512))}}),Fo=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Uo=["position","velocity"],Bo=h.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(c){const e=c,{size:t,area:n,color:s,alphaMap:o,map:i,opacity:r,alphaTest:a,depthWrite:u,transparent:d,sizeAttenuation:p,count:f,speed:m,randomness:y}=h.toRefs(e),_=h.shallowRef();let x=[],S=[];const O=()=>{x=new Float32Array(f.value*3);for(let A=0;A<f.value;A++){const b=A*3;x[b]=(Math.random()-.5)*n.value[0],x[b+1]=(Math.random()-.5)*n.value[1],x[b+2]=(Math.random()-.5)*n.value[2]}},M=()=>{S=new Float32Array(f.value*2);for(let A=0;A<f.value*2;A+=2)S[A]=(Math.random()-.5)/5*m.value*y.value,S[A+1]=Math.random()/5*m.value+.01};M(),O(),h.watchEffect(()=>{M(),O()});const{onLoop:g}=q.useRenderLoop();return g(()=>{var A,b;if((A=_.value)!=null&&A.attributes.position.array&&((b=_.value)!=null&&b.attributes.position.count)){const w=_.value.attributes.position.array;for(let v=0;v<_.value.attributes.position.count;v++){const C=S[v*2],k=S[v*2+1];w[v*3]+=C,w[v*3+1]-=k,(w[v*3]<=-n.value[0]/2||w[v*3]>=n.value[0]/2)&&(w[v*3]=w[v*3]*-1),(w[v*3+1]<=-n.value[1]/2||w[v*3+1]>=n.value[1]/2)&&(w[v*3+1]=w[v*3+1]*-1)}_.value.attributes.position.needsUpdate=!0}}),(A,b)=>(h.openBlock(),h.createElementBlock("TresPoints",null,[h.createElementVNode("TresPointsMaterial",{size:h.unref(t),color:h.unref(s),"alpha-map":h.unref(o),map:h.unref(i),opacity:h.unref(r),"alpha-test":h.unref(a),"depth-write":h.unref(u),transparent:h.unref(d),"size-attenuation":h.unref(p)},null,8,Fo),h.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:_,position:[h.unref(x),3],velocity:[h.unref(S)]},null,8,Uo)]))}}),Vo=["position"],No=["position"],zo=["scale"],Ro=["map","depth-test","color-space","color","opacity"],Eo=h.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(c,{expose:e}){let t,n;const s=c,{width:o,depth:i,segments:r,texture:a,color:u,depthTest:d,opacity:p,speed:f}=h.toRefs(s),m=h.shallowRef(),y=h.shallowRef();e({value:m});const _=[...new Array(r)].map((b,w)=>({x:o.value/2-Math.random()*o.value,y:o.value/2-Math.random()*o.value,scale:.4+Math.sin((w+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*f.value})),x=(b,w)=>b/6*w*p.value,{map:S}=([t,n]=h.withAsyncContext(()=>q.useTexture({map:a.value})),t=await t,n(),t),{renderer:O,camera:M}=q.useTresContext(),g=h.computed(()=>{var b;return(b=O.value)==null?void 0:b.outputColorSpace}),{onLoop:A}=q.useRenderLoop();return A(()=>{var b,w;m.value&&M.value&&y.value&&((b=y.value)==null||b.children.forEach((v,C)=>{v.rotation.z+=_[C].rotation}),m.value.lookAt((w=M.value)==null?void 0:w.position))}),(b,w)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"smokeRef",ref:m},b.$attrs),[h.createElementVNode("TresGroup",{ref_key:"groupRef",ref:y,position:[0,0,h.unref(r)/2*h.unref(i)]},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(h.unref(_),({scale:v,x:C,y:k,density:I},U)=>(h.openBlock(),h.createElementBlock("TresMesh",{key:`${U}`,position:[C,k,-U*h.unref(i)]},[h.createElementVNode("TresPlaneGeometry",{scale:[v,v,v],rotation:[0,0,0]},null,8,zo),h.createElementVNode("TresMeshStandardMaterial",{map:h.unref(S),"depth-test":h.unref(d),"color-space":g.value,color:h.unref(u),"depth-write":!1,transparent:"",opacity:x(v,I)},null,8,Ro)],8,No))),128))],8,Vo)],16))}}),Go=h.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(c,{expose:e}){const t=c,n=h.shallowRef();e({value:n});const{onLoop:s}=q.useRenderLoop(),o=h.ref(Math.random()*1e4);return s(({elapsed:i})=>{var u,d;if(!n.value)return;const r=o.value+i;n.value.rotation.x=Math.cos(r/4*t.speed)/8*t.rotationFactor,n.value.rotation.y=Math.sin(r/4*t.speed)/8*t.rotationFactor,n.value.rotation.z=Math.sin(r/4*t.speed)/20*t.rotationFactor;let a=Math.sin(r/4*t.speed)/10;a=l.MathUtils.mapLinear(a,-.1,.1,((u=t.range)==null?void 0:u[0])??-.1,((d=t.range)==null?void 0:d[1])??.1),n.value.position.y=a*t.floatFactor}),(i,r)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps(i.$attrs,{ref_key:"groupRef",ref:n}),[h.renderSlot(i.$slots,"default")],16))}}),jo=["geometry"],Yo=["map","opacity","depth-write"],Xo=["args"],Zo=["rotation","args"],Qo=h.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(c,{expose:e}){const t=c,n=h.shallowRef(),s=h.shallowRef();e(n);let o,i,r,a,u;const{renderer:d,scene:p}=q.useTresContext(),f=h.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),m=h.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));h.watchEffect(()=>{o&&o.dispose(),i&&i.dispose(),r&&r.dispose(),a&&a.geometry.dispose(),o=new l.WebGLRenderTarget(t.resolution,t.resolution),i=new l.WebGLRenderTarget(t.resolution,t.resolution),i.texture.generateMipmaps=o.texture.generateMipmaps=!1,s.value=new l.OrthographicCamera(-f.value/2,f.value/2,m.value/2,-m.value/2,0,t.far),r=new l.PlaneGeometry(f.value,m.value).rotateX(Math.PI/2),a=new l.Mesh(r),a.visible=!1}),h.watchEffect(()=>{t.color&&(u&&u.dispose(),u=new l.MeshDepthMaterial,u.depthTest=u.depthWrite=!1,u.onBeforeCompile=A=>{A.uniforms={...A.uniforms,ucolor:{value:t.color?new l.Color(t.color):new l.Color}},A.fragmentShader=A.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
|
|
80
80
|
void main() {
|
|
81
|
-
`),D.fragmentShader=D.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const E=new m.ShaderMaterial(Xl),k=new m.ShaderMaterial(Zl);k.depthTest=E.depthTest=!1;function O(D){!y.value||!o.value||(d.visible=!0,d.material=E,E.uniforms.tDiffuse.value=a.texture,E.uniforms.h.value=D/256,y.value.setRenderTarget(c),y.value.render(d,o.value),d.material=k,k.uniforms.tDiffuse.value=c.texture,k.uniforms.v.value=D/256,y.value.setRenderTarget(a),y.value.render(d,o.value),d.visible=!1)}const{onLoop:R}=Ae.useRenderLoop();let N=0,F,M;return R(()=>{!o.value||b.value===void 0||y.value===void 0||(n.frames===1/0||N<n.frames)&&(N++,F=b.value.background,M=b.value.overrideMaterial,i.value.visible=!1,b.value.background=null,b.value.overrideMaterial=g,y.value.setRenderTarget(a),y.value.render(b.value,o.value),O(n.blur),n.smooth&&O(n.blur*.4),y.value.setRenderTarget(null),i.value.visible=!0,b.value.background=F,b.value.overrideMaterial=M)}),(D,U)=>{const S=_.resolveComponent("primitive");return _.openBlock(),_.createElementBlock("TresGroup",_.mergeProps({ref_key:"groupRef",ref:i},D.$attrs),[_.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:_.unref(p)},[_.createElementVNode("TresMeshBasicMaterial",{map:_.unref(a).texture,opacity:D.opacity,"depth-write":D.depthWrite,transparent:!0},null,8,Uc)],8,Nc),_.createVNode(S,{object:_.unref(d)},null,8,["object"]),o.value&&D.helper?(_.openBlock(),_.createElementBlock("TresCameraHelper",{key:0,args:[o.value]},null,8,zc)):_.createCommentVNode("",!0),_.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:o,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-C.value/2,C.value/2,A.value/2,-A.value/2,0,D.far]},null,8,Rc),jc],16)}}});function Fo(v){return _.getCurrentScope()?(_.onScopeDispose(v),!0):!1}function vt(v){return typeof v=="function"?v():_.unref(v)}const Kc=typeof window<"u",Xt=()=>{};function No(v,t){function n(...i){return new Promise((o,a)=>{Promise.resolve(v(()=>t.apply(this,i),{fn:t,thisArg:this,args:i})).then(o).catch(a)})}return n}function Yc(v,t={}){let n,i,o=Xt;const a=p=>{clearTimeout(p),o(),o=Xt};return p=>{const d=vt(v),g=vt(t.maxWait);return n&&a(n),d<=0||g!==void 0&&g<=0?(i&&(a(i),i=null),Promise.resolve(p())):new Promise((y,b)=>{o=t.rejectOnCancel?b:y,g&&!i&&(i=setTimeout(()=>{n&&a(n),i=null,y(p())},g)),n=setTimeout(()=>{i&&a(i),i=null,y(p())},d)})}}function Xc(v,t=!0,n=!0,i=!1){let o=0,a,c=!0,p=Xt,d;const g=()=>{a&&(clearTimeout(a),a=void 0,p(),p=Xt)};return b=>{const C=vt(v),A=Date.now()-o,E=()=>d=b();return g(),C<=0?(o=Date.now(),E()):(A>C&&(n||!c)?(o=Date.now(),E()):t&&(d=new Promise((k,O)=>{p=i?O:k,a=setTimeout(()=>{o=Date.now(),c=!0,k(E()),g()},Math.max(0,C-A))})),!n&&!a&&(a=setTimeout(()=>c=!0,C)),c=!1,d)}}function Zc(...v){if(v.length!==1)return _.toRef(...v);const t=v[0];return typeof t=="function"?_.readonly(_.customRef(()=>({get:t,set:Xt}))):_.ref(t)}function qc(v,t=200,n={}){return No(Yc(t,n),v)}function Qc(v,t=200,n=!1,i=!0,o=!1){return No(Xc(t,n,i,o),v)}function Wc(v,t=!0){_.getCurrentInstance()?_.onMounted(v):t?v():_.nextTick(v)}function Jc(v){var t;const n=vt(v);return(t=n==null?void 0:n.$el)!=null?t:n}const Nn=Kc?window:void 0;function De(...v){let t,n,i,o;if(typeof v[0]=="string"||Array.isArray(v[0])?([n,i,o]=v,t=Nn):[t,n,i,o]=v,!t)return Xt;Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i]);const a=[],c=()=>{a.forEach(y=>y()),a.length=0},p=(y,b,C,A)=>(y.addEventListener(b,C,A),()=>y.removeEventListener(b,C,A)),d=_.watch(()=>[Jc(t),vt(o)],([y,b])=>{c(),y&&a.push(...n.flatMap(C=>i.map(A=>p(y,C,A,b))))},{immediate:!0,flush:"post"}),g=()=>{d(),c()};return Fo(g),g}function Hc(v){return typeof v=="function"?v:typeof v=="string"?t=>t.key===v:Array.isArray(v)?t=>v.includes(t.key):()=>!0}function cn(...v){let t,n,i={};v.length===3?(t=v[0],n=v[1],i=v[2]):v.length===2?typeof v[1]=="object"?(t=!0,n=v[0],i=v[1]):(t=v[0],n=v[1]):(t=!0,n=v[0]);const{target:o=Nn,eventName:a="keydown",passive:c=!1,dedupe:p=!1}=i,d=Hc(t);return De(o,a,y=>{y.repeat&&vt(p)||d(y)&&n(y)},c)}function $c(){const v=_.ref(!1);return _.getCurrentInstance()&&_.onMounted(()=>{v.value=!0}),v}function eh(v){const t=$c();return _.computed(()=>(t.value,!!v()))}function th(v,t={}){const{window:n=Nn}=t,i=eh(()=>n&&"matchMedia"in n&&typeof n.matchMedia=="function");let o;const a=_.ref(!1),c=()=>{o&&("removeEventListener"in o?o.removeEventListener("change",p):o.removeListener(p))},p=()=>{i.value&&(c(),o=n.matchMedia(Zc(v).value),a.value=!!(o!=null&&o.matches),o&&("addEventListener"in o?o.addEventListener("change",p):o.addListener(p)))};return _.watchEffect(p),Fo(()=>c()),a}const Uo=1;function nh(v,t={}){const{throttle:n=0,idle:i=200,onStop:o=Xt,onScroll:a=Xt,offset:c={left:0,right:0,top:0,bottom:0},eventListenerOptions:p={capture:!1,passive:!0},behavior:d="auto"}=t,g=_.ref(0),y=_.ref(0),b=_.computed({get(){return g.value},set(D){A(D,void 0)}}),C=_.computed({get(){return y.value},set(D){A(void 0,D)}});function A(D,U){var S,T,j;const X=vt(v);X&&((j=X instanceof Document?document.body:X)==null||j.scrollTo({top:(S=vt(U))!=null?S:C.value,left:(T=vt(D))!=null?T:b.value,behavior:vt(d)}))}const E=_.ref(!1),k=_.reactive({left:!0,right:!1,top:!0,bottom:!1}),O=_.reactive({left:!1,right:!1,top:!1,bottom:!1}),R=D=>{E.value&&(E.value=!1,O.left=!1,O.right=!1,O.top=!1,O.bottom=!1,o(D))},N=qc(R,n+i),F=D=>{const U=D===window?D.document.documentElement:D===document?D.documentElement:D,{display:S,flexDirection:T}=getComputedStyle(U),j=U.scrollLeft;O.left=j<g.value,O.right=j>g.value;const X=Math.abs(j)<=0+(c.left||0),Z=Math.abs(j)+U.clientWidth>=U.scrollWidth-(c.right||0)-Uo;S==="flex"&&T==="row-reverse"?(k.left=Z,k.right=X):(k.left=X,k.right=Z),g.value=j;let J=U.scrollTop;D===document&&!J&&(J=document.body.scrollTop),O.top=J<y.value,O.bottom=J>y.value;const le=Math.abs(J)<=0+(c.top||0),he=Math.abs(J)+U.clientHeight>=U.scrollHeight-(c.bottom||0)-Uo;S==="flex"&&T==="column-reverse"?(k.top=he,k.bottom=le):(k.top=le,k.bottom=he),y.value=J},M=D=>{const U=D.target===document?D.target.documentElement:D.target;F(U),E.value=!0,N(D),a(D)};return De(v,"scroll",n?Qc(M,n,!0,!1):M,p),De(v,"scrollend",R,p),{x:b,y:C,isScrolling:E,arrivedState:k,directions:O,measure(){const D=vt(v);D&&F(D)}}}const sh={page:v=>[v.pageX,v.pageY],client:v=>[v.clientX,v.clientY],screen:v=>[v.screenX,v.screenY],movement:v=>v instanceof Touch?null:[v.movementX,v.movementY]};function ih(v={}){const{type:t="page",touch:n=!0,resetOnTouchEnds:i=!1,initialValue:o={x:0,y:0},window:a=Nn,target:c=a,eventFilter:p}=v,d=_.ref(o.x),g=_.ref(o.y),y=_.ref(null),b=typeof t=="function"?t:sh[t],C=R=>{const N=b(R);N&&([d.value,g.value]=N,y.value="mouse")},A=R=>{if(R.touches.length>0){const N=b(R.touches[0]);N&&([d.value,g.value]=N,y.value="touch")}},E=()=>{d.value=o.x,g.value=o.y},k=p?R=>p(()=>C(R),{}):R=>C(R),O=p?R=>p(()=>A(R),{}):R=>A(R);return c&&(De(c,"mousemove",k,{passive:!0}),De(c,"dragover",k,{passive:!0}),n&&t!=="movement"&&(De(c,"touchstart",O,{passive:!0}),De(c,"touchmove",O,{passive:!0}),i&&De(c,"touchend",E,{passive:!0}))),{x:d,y:g,sourceType:y}}function rh({window:v=Nn}={}){if(!v)return{x:_.ref(0),y:_.ref(0)};const t=_.ref(v.scrollX),n=_.ref(v.scrollY);return De(v,"scroll",()=>{t.value=v.scrollX,n.value=v.scrollY},{capture:!1,passive:!0}),{x:t,y:n}}function zo(v={}){const{window:t=Nn,initialWidth:n=1/0,initialHeight:i=1/0,listenOrientation:o=!0,includeScrollbar:a=!0}=v,c=_.ref(n),p=_.ref(i),d=()=>{t&&(a?(c.value=t.innerWidth,p.value=t.innerHeight):(c.value=t.document.documentElement.clientWidth,p.value=t.document.documentElement.clientHeight))};if(d(),Wc(d),De("resize",d,{passive:!0}),o){const g=th("(orientation: portrait)");_.watch(g,()=>d())}return{width:c,height:p}}const oh=_.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(v){const t=v,{camera:n}=Ae.useTresContext(),{disabled:i,factor:o,ease:a}=_.toRefs(t),{x:c,y:p}=ih(),{width:d,height:g}=zo(),y=_.ref(),b=_.computed(()=>(c.value/d.value-.5)*o.value),C=_.computed(()=>-(p.value/g.value-.5)*o.value),{onLoop:A}=Ae.useRenderLoop();return A(({delta:E})=>{i.value||!y.value||(y.value.position.x+=(b.value-y.value.position.x)*a.value*E,y.value.position.y+=(C.value-y.value.position.y)*a.value*E)}),_.watch(()=>y.value,E=>{E==null||E.add(n.value)}),(E,k)=>(_.openBlock(),_.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:y},null,512))}});let Hs=null;function ah(v,t){return n=>{t&&t(n),v.draco&&(Hs||(Hs=new wc),Hs.setDecoderPath(v.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),n.setDRACOLoader(Hs))}}async function Ro(v,t={draco:!1},n){return await Ae.useLoader(dl,v,ah(t,n))}const lh=_.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"}},async setup(v,{expose:t}){let n,i;const o=v,a=_.ref();t({value:a});const{scene:c}=([n,i]=_.withAsyncContext(()=>Ro(o.path,{draco:o.draco,decoderPath:o.decoderPath})),n=await n,i(),n);return(p,d)=>{const g=_.resolveComponent("primitive");return _.openBlock(),_.createBlock(g,_.mergeProps({ref_key:"modelRef",ref:a,object:_.unref(c)},p.$attrs),null,16,["object"])}}});async function jo(v){return await Ae.useLoader(tc,v)}const ch=_.defineComponent({__name:"component",props:{path:{}},async setup(v,{expose:t}){let n,i;const o=v,a=_.ref();t({value:a});const c=([n,i]=_.withAsyncContext(()=>jo(o.path)),n=await n,i(),n);return(p,d)=>{const g=_.resolveComponent("primitive");return _.openBlock(),_.createBlock(g,_.mergeProps({ref_key:"modelRef",ref:a,object:_.unref(c)},p.$attrs),null,16,["object"])}}}),Go="[TresJS - Cientos ▲ ■ ♥] ";function hh(){function v(i,o){console.error(`${Go} ${i}`,o||"")}function t(i){console.warn(`${Go} ${i}`)}function n(i,o){}return{logError:v,logWarning:t,logMessage:n}}let Wi=0;function ph(){const v=_.ref(!1),t=_.ref(0),n=_.ref([]),{logError:i}=hh();return new Promise(o=>{m.DefaultLoadingManager.onStart=()=>{v.value=!1},m.DefaultLoadingManager.onLoad=()=>{v.value=!0},m.DefaultLoadingManager.onProgress=(a,c,p)=>{c===p&&(Wi=p,v.value=!0,n.value.push(a)),t.value=Math.round((c-Wi)/(p-Wi)*100||100,2)},m.DefaultLoadingManager.onError=a=>{i("Error loading assets",new Error(a)),v.value=!0},o({items:n,hasFinishLoading:v,progress:t})})}const uh=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],dh=_.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!1},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:m.TOUCH.ROTATE,TWO:m.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(v,{emit:t}){const n=v,{makeDefault:i,autoRotate:o,autoRotateSpeed:a,enableDamping:c,dampingFactor:p,enablePan:d,keyPanSpeed:g,maxAzimuthAngle:y,minAzimuthAngle:b,maxPolarAngle:C,minPolarAngle:A,minDistance:E,maxDistance:k,minZoom:O,maxZoom:R,enableZoom:N,zoomSpeed:F,enableRotate:M,touches:D,rotateSpeed:U,target:S}=_.toRefs(n),{camera:T,renderer:j,extend:X,controls:Z}=Ae.useTresContext(),J=_.ref(null);X({OrbitControls:go}),_.watch(J,oe=>{le(),oe&&i.value?Z.value=oe:Z.value=null});function le(){De(J.value,"change",()=>t("change",J.value)),De(J.value,"start",()=>t("start",J.value)),De(J.value,"end",()=>t("end",J.value))}const{onLoop:he}=Ae.useRenderLoop();return he(()=>{J.value&&(c.value||o.value)&&J.value.update()}),_.onUnmounted(()=>{J.value&&J.value.dispose()}),(oe,re)=>{var ne;return _.unref(T)&&_.unref(j)?(_.openBlock(),_.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:J,target:_.unref(S),"auto-rotate":_.unref(o),"auto-rotate-speed":_.unref(a),"enable-damping":_.unref(c),"damping-factor":_.unref(p),"enable-pan":_.unref(d),"key-pan-speed":_.unref(g),keys:oe.keys,"max-azimuth-angle":_.unref(y),"min-azimuth-angle":_.unref(b),"max-polar-angle":_.unref(C),"min-polar-angle":_.unref(A),"min-distance":_.unref(E),"max-distance":_.unref(k),"min-zoom":_.unref(O),"max-zoom":_.unref(R),touches:_.unref(D),"enable-zoom":_.unref(N),"zoom-speed":_.unref(F),"enable-rotate":_.unref(M),"rotate-speed":_.unref(U),args:[_.unref(T)||oe.camera,((ne=_.unref(j))==null?void 0:ne.domElement)||oe.domElement]},null,8,uh)):_.createCommentVNode("",!0)}}}),mh=5,fh=6,vh=.3,_h=_.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(v){var X;const t=v,{forward:n,back:i,left:o,right:a,jump:c,gravity:p,moveSpeed:d,headBobbing:g,is2D:y}=_.toRefs(t),{camera:b,controls:C}=Ae.useTresContext(),A=_.ref(0),E=_.ref(0),k=_.ref(!1),O=_.ref(!1),R=_.ref(0),N=_.shallowRef(),F=y.value?"y":"z";let M=((X=b.value.position)==null?void 0:X.y)||0;cn(n.value,()=>{k.value=!0,E.value=d.value},{eventName:"keydown"}),cn(i.value,()=>{k.value=!0,E.value=-d.value},{eventName:"keydown"}),cn([...n.value,...i.value],()=>{k.value=!1,E.value=0},{eventName:"keyup"}),cn(o.value,()=>{k.value=!0,A.value=-d.value},{eventName:"keydown"}),cn(a.value,()=>{k.value=!0,A.value=d.value},{eventName:"keydown"}),cn([...o.value,...a.value],()=>{k.value=!1,A.value=0},{eventName:"keyup"}),cn(c.value,()=>{O.value||(R.value=Date.now()),O.value=!0});const D=Z=>k.value?Math.sin(Z*mh)*vh+M:M,U=()=>(Date.now()-R.value)/1e3*3,S=Z=>M+fh*Z-.5*p.value*Math.pow(Z,2),T=()=>{if(O.value){const Z=S(U());return Z<=M&&(O.value=!1),Z}return 0},{onLoop:j}=Ae.useRenderLoop();return j(({elapsed:Z})=>{var J;C.value instanceof Ni&&((J=C.value)!=null&&J.isLocked)?(C.value.moveForward(E.value),C.value.moveRight(A.value),b.value.position&&(b.value.position.y=g.value?D(Z):M,b.value.position.y+=T())):N.value.children.length>0&&!(C.value instanceof Ni)&&(N.value.position.x+=A.value,N.value.position[F]+=y.value?E.value:-E.value)}),(Z,J)=>(_.openBlock(),_.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:N},[_.renderSlot(Z.$slots,"default")],512))}}),gh=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],bh=_.defineComponent({__name:"TransformControls",props:{object:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(v,{emit:t}){const n=v,{object:i,mode:o,enabled:a,axis:c,translationSnap:p,rotationSnap:d,scaleSnap:g,space:y,size:b,showX:C,showY:A,showZ:E}=_.toRefs(n),k=_.shallowRef(),{controls:O,camera:R,renderer:N,extend:F}=Ae.useTresContext();F({TransformControls:nl});const M=U=>{O.value&&(O.value.enabled=!U.value),t("dragging",U.value)};function D(){De(k.value,"change",()=>t("change")),De(k.value,"dragging-changed",M),De(k.value,"mouseDown",()=>t("mouseDown")),De(k.value,"mouseUp",()=>t("mouseUp")),De(k.value,"objectChange",()=>t("objectChange"))}return _.watchEffect(()=>{k.value&&D()}),_.onUnmounted(()=>{k.value&&k.value.dispose()}),(U,S)=>_.unref(R)&&_.unref(N)?(_.openBlock(),_.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:k,object:_.unref(i),args:[_.unref(R),_.unref(N).domElement],mode:_.unref(o),enabled:_.unref(a),axis:_.unref(c),"translation-snap":_.unref(p),"rotation-snap":_.unref(d),"scale-snap":_.unref(g),space:_.unref(y),size:_.unref(b),"show-x":_.unref(C),"show-y":_.unref(A),"show-z":_.unref(E),visible:!0},null,8,gh)):_.createCommentVNode("",!0)}}),wh=["args"],yh=_.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},setup(v,{expose:t}){const n=v,{camera:i,renderer:o,extend:a,controls:c}=Ae.useTresContext(),p=_.ref(null);let d;return a({PointerLockControls:Ni}),_.watch(p,g=>{g&&n.makeDefault?c.value=g:c.value=null;const y=document.getElementById(n.selector||"");d=y||o.value.domElement,De(d,"click",()=>{g==null||g.lock()})}),_.onUnmounted(()=>{p.value&&p.value.dispose()}),t({value:c}),(g,y)=>{var b;return _.unref(i)&&_.unref(o)?(_.openBlock(),_.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:p,args:[_.unref(i)||g.camera,((b=_.unref(o))==null?void 0:b.domElement)||g.domElement]},null,8,wh)):_.createCommentVNode("",!0)}}}),xh=["args"],Ch=_.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(v){const t=v,{camera:n,renderer:i,extend:o,controls:a}=Ae.useTresContext(),c=_.ref(null);return o({MapControls:ul}),_.watch(a,p=>{p&&t.makeDefault?a.value=p:a.value=null}),_.onUnmounted(()=>{c.value&&c.value.dispose()}),(p,d)=>{var g;return _.unref(n)&&_.unref(i)?(_.openBlock(),_.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:c,args:[_.unref(n)||p.camera,((g=_.unref(i))==null?void 0:g.domElement)||p.domElement]},null,8,xh)):_.createCommentVNode("",!0)}}}),Ph=_.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(v,{emit:t}){const n=v,{logWarning:i}=Ae.useLogger();n.smoothScroll<0&&i("SmoothControl must be greater than zero"),n.pages<0&&i("Pages must be greater than zero");const{camera:o,controls:a,renderer:c}=Ae.useTresContext(),p=_.shallowRef(),d=document.createElement("div"),{y:g}=rh(),{x:y,y:b,isScrolling:C}=nh(d),{height:A,width:E}=zo();let k=0;const O=_.ref(!1),R=_.ref(0),N=_.ref(0),F=_.ref(0),M=n.horizontal?"x":"y",D=_.watch(o,S=>{if(O.value){D();return}k=n.horizontal?(S==null?void 0:S.position.x)||0:(S==null?void 0:S.position.y)||0,O.value=!0},{immediate:!0});_.watch(C,S=>{a.value&&(a.value.enabled=!S)},{immediate:!0}),_.watch(g,S=>{!C.value&&!n.htmlScroll||(N.value=parseFloat((S/A.value/(F.value/A.value-1)).toFixed(2)),R.value=-1*N.value,t("update:modelValue",N.value))}),_.watch(b,S=>{N.value=parseFloat((S/A.value/(F.value/A.value)).toFixed(2)),R.value=-1*N.value,t("update:modelValue",N.value)}),_.watch(y,S=>{N.value=parseFloat((S/E.value/(F.value/E.value-1)).toFixed(2)),R.value=+N.value,t("update:modelValue",N.value)}),_.watch(c,S=>{var j,X;const T=S==null?void 0:S.domElement;if(n.htmlScroll&&(S!=null&&S.domElement))T!=null&&T.style.width&&(T!=null&&T.style.position)&&(T!=null&&T.style.top)&&(T!=null&&T.style.left)&&(T.style.width="100%",T.style.position="fixed",T.style.zIndex=" -99999",T.style.top="0",T.style.left="0"),F.value=document.body.scrollHeight;else{const Z=document.createElement("div"),J=document.createElement("div");d.style[n.horizontal?"overflowX":"overflowY"]="auto",d.style[n.horizontal?"overflowY":"overflowX"]="hidden",d.style.position="absolute",d.style.width="100%",d.style.height=" 100%",d.style.top="0",d.style.left="0",d.classList.add("scrollContainer"),Z.style.position="sticky",Z.style.top="0px",Z.style.left="0px",Z.style.width="100%",Z.style.height="100%",Z.style.overflow="hidden",d.appendChild(Z),J.style.height=n.horizontal?"100%":`${A.value*n.pages}px`,J.style.width=n.horizontal?`${E.value*n.pages}px`:"100vw",J.style.pointerEvents="none",T.style.position="fixed",T.style.zIndex="0",T!=null&&T.style.width&&(T.style.width="100%"),d.appendChild(J),S.domElement.parentNode.style.position="relative",(X=(j=S==null?void 0:S.domElement)==null?void 0:j.parentNode)==null||X.appendChild(d),F.value=n.horizontal?E.value*n.pages:A.value*n.pages}},{immediate:!0});const{onLoop:U}=Ae.useRenderLoop();return U(()=>{var S;if((S=o.value)!=null&&S.position){const T=(R.value*n.distance-o.value.position[M]+k)*n.smoothScroll;o.value.position[M]+=T,p.value.children.length>0&&(p.value.position[M]+=T)}}),(S,T)=>(_.openBlock(),_.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:p},[_.renderSlot(S.$slots,"default")],512))}});/*!
|
|
81
|
+
`),A.fragmentShader=A.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const y=new l.ShaderMaterial(Js),_=new l.ShaderMaterial(Hs);_.depthTest=y.depthTest=!1;function x(A){!d.value||!s.value||(a.visible=!0,a.material=y,y.uniforms.tDiffuse.value=o.texture,y.uniforms.h.value=A/256,d.value.setRenderTarget(i),d.value.render(a,s.value),a.material=_,_.uniforms.tDiffuse.value=i.texture,_.uniforms.v.value=A/256,d.value.setRenderTarget(o),d.value.render(a,s.value),a.visible=!1)}const{onLoop:S}=q.useRenderLoop();let O=0,M,g;return S(()=>{!s.value||p.value===void 0||d.value===void 0||(t.frames===1/0||O<t.frames)&&(O++,M=p.value.background,g=p.value.overrideMaterial,n.value.visible=!1,p.value.background=null,p.value.overrideMaterial=u,d.value.setRenderTarget(o),d.value.render(p.value,s.value),x(t.blur),t.smooth&&x(t.blur*.4),d.value.setRenderTarget(null),n.value.visible=!0,p.value.background=M,p.value.overrideMaterial=g)}),(A,b)=>{const w=h.resolveComponent("primitive");return h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"groupRef",ref:n},A.$attrs),[h.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:h.unref(r)},[h.createElementVNode("TresMeshBasicMaterial",{map:h.unref(o).texture,opacity:A.opacity,"depth-write":A.depthWrite,transparent:!0},null,8,Yo)],8,jo),h.createVNode(w,{object:h.unref(a)},null,8,["object"]),s.value&&A.helper?(h.openBlock(),h.createElementBlock("TresCameraHelper",{key:0,args:[s.value]},null,8,Xo)):h.createCommentVNode("",!0),h.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:s,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-f.value/2,f.value/2,m.value/2,-m.value/2,0,A.far]},null,8,Zo)],16)}}});function dn(c){return h.getCurrentScope()?(h.onScopeDispose(c),!0):!1}function we(c){return typeof c=="function"?c():h.unref(c)}const Ko=typeof window<"u",Ie=()=>{};function fn(c,e){function t(...n){return new Promise((s,o)=>{Promise.resolve(c(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(s).catch(o)})}return t}function Wo(c,e={}){let t,n,s=Ie;const o=r=>{clearTimeout(r),s(),s=Ie};return r=>{const a=we(c),u=we(e.maxWait);return t&&o(t),a<=0||u!==void 0&&u<=0?(n&&(o(n),n=null),Promise.resolve(r())):new Promise((d,p)=>{s=e.rejectOnCancel?p:d,u&&!n&&(n=setTimeout(()=>{t&&o(t),n=null,d(r())},u)),t=setTimeout(()=>{n&&o(n),n=null,d(r())},a)})}}function qo(c,e=!0,t=!0,n=!1){let s=0,o,i=!0,r=Ie,a;const u=()=>{o&&(clearTimeout(o),o=void 0,r(),r=Ie)};return p=>{const f=we(c),m=Date.now()-s,y=()=>a=p();return u(),f<=0?(s=Date.now(),y()):(m>f&&(t||!i)?(s=Date.now(),y()):e&&(a=new Promise((_,x)=>{r=n?x:_,o=setTimeout(()=>{s=Date.now(),i=!0,_(y()),u()},Math.max(0,f-m))})),!t&&!o&&(o=setTimeout(()=>i=!0,f)),i=!1,a)}}function Jo(...c){if(c.length!==1)return h.toRef(...c);const e=c[0];return typeof e=="function"?h.readonly(h.customRef(()=>({get:e,set:Ie}))):h.ref(e)}function Ho(c,e=200,t={}){return fn(Wo(e,t),c)}function $o(c,e=200,t=!1,n=!0,s=!1){return fn(qo(e,t,n,s),c)}function ei(c,e=!0){h.getCurrentInstance()?h.onMounted(c):e?c():h.nextTick(c)}function ti(c){var e;const t=we(c);return(e=t==null?void 0:t.$el)!=null?e:t}const je=Ko?window:void 0;function oe(...c){let e,t,n,s;if(typeof c[0]=="string"||Array.isArray(c[0])?([t,n,s]=c,e=je):[e,t,n,s]=c,!e)return Ie;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const o=[],i=()=>{o.forEach(d=>d()),o.length=0},r=(d,p,f,m)=>(d.addEventListener(p,f,m),()=>d.removeEventListener(p,f,m)),a=h.watch(()=>[ti(e),we(s)],([d,p])=>{i(),d&&o.push(...t.flatMap(f=>n.map(m=>r(d,f,m,p))))},{immediate:!0,flush:"post"}),u=()=>{a(),i()};return dn(u),u}function ni(c){return typeof c=="function"?c:typeof c=="string"?e=>e.key===c:Array.isArray(c)?e=>c.includes(e.key):()=>!0}function Be(...c){let e,t,n={};c.length===3?(e=c[0],t=c[1],n=c[2]):c.length===2?typeof c[1]=="object"?(e=!0,t=c[0],n=c[1]):(e=c[0],t=c[1]):(e=!0,t=c[0]);const{target:s=je,eventName:o="keydown",passive:i=!1,dedupe:r=!1}=n,a=ni(e);return oe(s,o,d=>{d.repeat&&we(r)||a(d)&&t(d)},i)}function si(){const c=h.ref(!1);return h.getCurrentInstance()&&h.onMounted(()=>{c.value=!0}),c}function oi(c){const e=si();return h.computed(()=>(e.value,!!c()))}function ii(c,e={}){const{window:t=je}=e,n=oi(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let s;const o=h.ref(!1),i=()=>{s&&("removeEventListener"in s?s.removeEventListener("change",r):s.removeListener(r))},r=()=>{n.value&&(i(),s=t.matchMedia(Jo(c).value),o.value=!!(s!=null&&s.matches),s&&("addEventListener"in s?s.addEventListener("change",r):s.addListener(r)))};return h.watchEffect(r),dn(()=>i()),o}const mn=1;function ri(c,e={}){const{throttle:t=0,idle:n=200,onStop:s=Ie,onScroll:o=Ie,offset:i={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:a="auto"}=e,u=h.ref(0),d=h.ref(0),p=h.computed({get(){return u.value},set(A){m(A,void 0)}}),f=h.computed({get(){return d.value},set(A){m(void 0,A)}});function m(A,b){var w,v,C;const k=we(c);k&&((C=k instanceof Document?document.body:k)==null||C.scrollTo({top:(w=we(b))!=null?w:f.value,left:(v=we(A))!=null?v:p.value,behavior:we(a)}))}const y=h.ref(!1),_=h.reactive({left:!0,right:!1,top:!0,bottom:!1}),x=h.reactive({left:!1,right:!1,top:!1,bottom:!1}),S=A=>{y.value&&(y.value=!1,x.left=!1,x.right=!1,x.top=!1,x.bottom=!1,s(A))},O=Ho(S,t+n),M=A=>{const b=A===window?A.document.documentElement:A===document?A.documentElement:A,{display:w,flexDirection:v}=getComputedStyle(b),C=b.scrollLeft;x.left=C<u.value,x.right=C>u.value;const k=Math.abs(C)<=0+(i.left||0),I=Math.abs(C)+b.clientWidth>=b.scrollWidth-(i.right||0)-mn;w==="flex"&&v==="row-reverse"?(_.left=I,_.right=k):(_.left=k,_.right=I),u.value=C;let U=b.scrollTop;A===document&&!U&&(U=document.body.scrollTop),x.top=U<d.value,x.bottom=U>d.value;const j=Math.abs(U)<=0+(i.top||0),H=Math.abs(U)+b.clientHeight>=b.scrollHeight-(i.bottom||0)-mn;w==="flex"&&v==="column-reverse"?(_.top=H,_.bottom=j):(_.top=j,_.bottom=H),d.value=U},g=A=>{const b=A.target===document?A.target.documentElement:A.target;M(b),y.value=!0,O(A),o(A)};return oe(c,"scroll",t?$o(g,t,!0,!1):g,r),oe(c,"scrollend",S,r),{x:p,y:f,isScrolling:y,arrivedState:_,directions:x,measure(){const A=we(c);A&&M(A)}}}const ai={page:c=>[c.pageX,c.pageY],client:c=>[c.clientX,c.clientY],screen:c=>[c.screenX,c.screenY],movement:c=>c instanceof Touch?null:[c.movementX,c.movementY]};function li(c={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:s={x:0,y:0},window:o=je,target:i=o,eventFilter:r}=c,a=h.ref(s.x),u=h.ref(s.y),d=h.ref(null),p=typeof e=="function"?e:ai[e],f=S=>{const O=p(S);O&&([a.value,u.value]=O,d.value="mouse")},m=S=>{if(S.touches.length>0){const O=p(S.touches[0]);O&&([a.value,u.value]=O,d.value="touch")}},y=()=>{a.value=s.x,u.value=s.y},_=r?S=>r(()=>f(S),{}):S=>f(S),x=r?S=>r(()=>m(S),{}):S=>m(S);return i&&(oe(i,"mousemove",_,{passive:!0}),oe(i,"dragover",_,{passive:!0}),t&&e!=="movement"&&(oe(i,"touchstart",x,{passive:!0}),oe(i,"touchmove",x,{passive:!0}),n&&oe(i,"touchend",y,{passive:!0}))),{x:a,y:u,sourceType:d}}function ci({window:c=je}={}){if(!c)return{x:h.ref(0),y:h.ref(0)};const e=h.ref(c.scrollX),t=h.ref(c.scrollY);return oe(c,"scroll",()=>{e.value=c.scrollX,t.value=c.scrollY},{capture:!1,passive:!0}),{x:e,y:t}}function gn(c={}){const{window:e=je,initialWidth:t=1/0,initialHeight:n=1/0,listenOrientation:s=!0,includeScrollbar:o=!0}=c,i=h.ref(t),r=h.ref(n),a=()=>{e&&(o?(i.value=e.innerWidth,r.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,r.value=e.document.documentElement.clientHeight))};if(a(),ei(a),oe("resize",a,{passive:!0}),s){const u=ii("(orientation: portrait)");h.watch(u,()=>a())}return{width:i,height:r}}const hi=h.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(c){const e=c,{camera:t}=q.useTresContext(),{disabled:n,factor:s,ease:o}=h.toRefs(e),{x:i,y:r}=li(),{width:a,height:u}=gn(),d=h.ref(),p=h.computed(()=>(i.value/a.value-.5)*s.value),f=h.computed(()=>-(r.value/u.value-.5)*s.value),{onLoop:m}=q.useRenderLoop();return m(({delta:y})=>{n.value||!d.value||(d.value.position.x+=(p.value-d.value.position.x)*o.value*y,d.value.position.y+=(f.value-d.value.position.y)*o.value*y)}),h.watch(()=>d.value,y=>{y==null||y.add(t.value)}),(y,_)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:d},null,512))}});let it=null;function ui(c,e){return t=>{e&&e(t),c.draco&&(it||(it=new To),it.setDecoderPath(c.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(it))}}async function _n(c,e={draco:!1},t){return await q.useLoader(ys,c,ui(e,t))}const pi=h.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"}},async setup(c,{expose:e}){let t,n;const s=c,o=h.ref();e({value:o});const{scene:i}=([t,n]=h.withAsyncContext(()=>_n(s.path,{draco:s.draco,decoderPath:s.decoderPath})),t=await t,n(),t);return(r,a)=>{const u=h.resolveComponent("primitive");return h.openBlock(),h.createBlock(u,h.mergeProps({ref_key:"modelRef",ref:o,object:h.unref(i)},r.$attrs),null,16,["object"])}}});async function yn(c){return await q.useLoader(ro,c)}const di=h.defineComponent({__name:"component",props:{path:{}},async setup(c,{expose:e}){let t,n;const s=c,o=h.ref();e({value:o});const i=([t,n]=h.withAsyncContext(()=>yn(s.path)),t=await t,n(),t);return(r,a)=>{const u=h.resolveComponent("primitive");return h.openBlock(),h.createBlock(u,h.mergeProps({ref_key:"modelRef",ref:o,object:h.unref(i)},r.$attrs),null,16,["object"])}}}),wn="[TresJS - Cientos ▲ ■ ♥] ";function fi(){function c(n,s){console.error(`${wn} ${n}`,s||"")}function e(n){console.warn(`${wn} ${n}`)}function t(n,s){}return{logError:c,logWarning:e,logMessage:t}}let Ot=0;function mi(){const c=h.ref(!1),e=h.ref(0),t=h.ref([]),{logError:n}=fi();return new Promise(s=>{l.DefaultLoadingManager.onStart=()=>{c.value=!1},l.DefaultLoadingManager.onLoad=()=>{c.value=!0},l.DefaultLoadingManager.onProgress=(o,i,r)=>{i===r&&(Ot=r,c.value=!0,t.value.push(o)),e.value=Math.round((i-Ot)/(r-Ot)*100||100,2)},l.DefaultLoadingManager.onError=o=>{n("Error loading assets",new Error(o)),c.value=!0},s({items:t,hasFinishLoading:c,progress:e})})}const gi=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],_i=h.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!1},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(c,{emit:e}){const t=c,{makeDefault:n,autoRotate:s,autoRotateSpeed:o,enableDamping:i,dampingFactor:r,enablePan:a,keyPanSpeed:u,maxAzimuthAngle:d,minAzimuthAngle:p,maxPolarAngle:f,minPolarAngle:m,minDistance:y,maxDistance:_,minZoom:x,maxZoom:S,enableZoom:O,zoomSpeed:M,enableRotate:g,touches:A,rotateSpeed:b,target:w}=h.toRefs(t),{camera:v,renderer:C,extend:k,controls:I}=q.useTresContext(),U=h.ref(null);k({OrbitControls:Kt}),h.watch(U,G=>{j(),G&&n.value?I.value=G:I.value=null});function j(){oe(U.value,"change",()=>e("change",U.value)),oe(U.value,"start",()=>e("start",U.value)),oe(U.value,"end",()=>e("end",U.value))}const{onLoop:H}=q.useRenderLoop();return H(()=>{U.value&&(i.value||s.value)&&U.value.update()}),h.onUnmounted(()=>{U.value&&U.value.dispose()}),(G,ne)=>{var X;return h.unref(v)&&h.unref(C)?(h.openBlock(),h.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:U,target:h.unref(w),"auto-rotate":h.unref(s),"auto-rotate-speed":h.unref(o),"enable-damping":h.unref(i),"damping-factor":h.unref(r),"enable-pan":h.unref(a),"key-pan-speed":h.unref(u),keys:G.keys,"max-azimuth-angle":h.unref(d),"min-azimuth-angle":h.unref(p),"max-polar-angle":h.unref(f),"min-polar-angle":h.unref(m),"min-distance":h.unref(y),"max-distance":h.unref(_),"min-zoom":h.unref(x),"max-zoom":h.unref(S),touches:h.unref(A),"enable-zoom":h.unref(O),"zoom-speed":h.unref(M),"enable-rotate":h.unref(g),"rotate-speed":h.unref(b),args:[h.unref(v)||G.camera,((X=h.unref(C))==null?void 0:X.domElement)||G.domElement]},null,8,gi)):h.createCommentVNode("",!0)}}}),yi=5,wi=6,vi=.3,Ai=h.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(c){var k;const e=c,{forward:t,back:n,left:s,right:o,jump:i,gravity:r,moveSpeed:a,headBobbing:u,is2D:d}=h.toRefs(e),{camera:p,controls:f}=q.useTresContext(),m=h.ref(0),y=h.ref(0),_=h.ref(!1),x=h.ref(!1),S=h.ref(0),O=h.shallowRef(),M=d.value?"y":"z";let g=((k=p.value.position)==null?void 0:k.y)||0;Be(t.value,()=>{_.value=!0,y.value=a.value},{eventName:"keydown"}),Be(n.value,()=>{_.value=!0,y.value=-a.value},{eventName:"keydown"}),Be([...t.value,...n.value],()=>{_.value=!1,y.value=0},{eventName:"keyup"}),Be(s.value,()=>{_.value=!0,m.value=-a.value},{eventName:"keydown"}),Be(o.value,()=>{_.value=!0,m.value=a.value},{eventName:"keydown"}),Be([...s.value,...o.value],()=>{_.value=!1,m.value=0},{eventName:"keyup"}),Be(i.value,()=>{x.value||(S.value=Date.now()),x.value=!0});const A=I=>_.value?Math.sin(I*yi)*vi+g:g,b=()=>(Date.now()-S.value)/1e3*3,w=I=>g+wi*I-.5*r.value*Math.pow(I,2),v=()=>{if(x.value){const I=w(b());return I<=g&&(x.value=!1),I}return 0},{onLoop:C}=q.useRenderLoop();return C(({elapsed:I})=>{var U;f.value instanceof gt&&((U=f.value)!=null&&U.isLocked)?(f.value.moveForward(y.value),f.value.moveRight(m.value),p.value.position&&(p.value.position.y=u.value?A(I):g,p.value.position.y+=v())):O.value.children.length>0&&!(f.value instanceof gt)&&(O.value.position.x+=m.value,O.value.position[M]+=d.value?y.value:-y.value)}),(I,U)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:O},[h.renderSlot(I.$slots,"default")],512))}}),xi=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Mi=h.defineComponent({__name:"TransformControls",props:{object:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(c,{emit:e}){const t=c,{object:n,mode:s,enabled:o,axis:i,translationSnap:r,rotationSnap:a,scaleSnap:u,space:d,size:p,showX:f,showY:m,showZ:y}=h.toRefs(t),_=h.shallowRef(),{controls:x,camera:S,renderer:O,extend:M}=q.useTresContext();M({TransformControls:as});const g=b=>{x.value&&(x.value.enabled=!b.value),e("dragging",b.value)};function A(){oe(_.value,"change",()=>e("change")),oe(_.value,"dragging-changed",g),oe(_.value,"mouseDown",()=>e("mouseDown")),oe(_.value,"mouseUp",()=>e("mouseUp")),oe(_.value,"objectChange",()=>e("objectChange"))}return h.watchEffect(()=>{_.value&&A()}),h.onUnmounted(()=>{_.value&&_.value.dispose()}),(b,w)=>h.unref(S)&&h.unref(O)?(h.openBlock(),h.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:_,object:h.unref(n),args:[h.unref(S),h.unref(O).domElement],mode:h.unref(s),enabled:h.unref(o),axis:h.unref(i),"translation-snap":h.unref(r),"rotation-snap":h.unref(a),"scale-snap":h.unref(u),space:h.unref(d),size:h.unref(p),"show-x":h.unref(f),"show-y":h.unref(m),"show-z":h.unref(y),visible:!0},null,8,xi)):h.createCommentVNode("",!0)}}),bi=["args"],Ti=h.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock"],setup(c,{expose:e,emit:t}){const n=c,{camera:s,renderer:o,extend:i,controls:r}=q.useTresContext(),a=h.ref(null);let u;i({PointerLockControls:gt});const d=p=>{t("isLock",p)};return h.watch(a,p=>{p&&n.makeDefault?r.value=p:r.value=null;const f=document.getElementById(n.selector||"");u=f||o.value.domElement,oe(u,"click",()=>{var m,y,_;(m=r.value)==null||m.lock(),(y=r.value)==null||y.addEventListener("lock",()=>d(!0)),(_=r.value)==null||_.addEventListener("unlock",()=>d(!1))})}),h.onUnmounted(()=>{var p,f;(p=r.value)==null||p.removeEventListener("lock",()=>d(!0)),(f=r.value)==null||f.removeEventListener("unlock",()=>d(!1)),a.value&&a.value.dispose()}),e({value:r}),(p,f)=>{var m;return h.unref(s)&&h.unref(o)?(h.openBlock(),h.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:a,args:[h.unref(s)||p.camera,((m=h.unref(o))==null?void 0:m.domElement)||p.domElement]},null,8,bi)):h.createCommentVNode("",!0)}}}),Si=["args"],Li=h.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(c){const e=c,{camera:t,renderer:n,extend:s,controls:o}=q.useTresContext(),i=h.ref(null);return s({MapControls:_s}),h.watch(o,r=>{r&&e.makeDefault?o.value=r:o.value=null}),h.onUnmounted(()=>{i.value&&i.value.dispose()}),(r,a)=>{var u;return h.unref(t)&&h.unref(n)?(h.openBlock(),h.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:i,args:[h.unref(t)||r.camera,((u=h.unref(n))==null?void 0:u.domElement)||r.domElement]},null,8,Si)):h.createCommentVNode("",!0)}}}),Oi=h.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(c,{emit:e}){const t=c,{logWarning:n}=q.useLogger();t.smoothScroll<0&&n("SmoothControl must be greater than zero"),t.pages<0&&n("Pages must be greater than zero");const{camera:s,controls:o,renderer:i}=q.useTresContext(),r=h.shallowRef(),a=document.createElement("div"),{y:u}=ci(),{x:d,y:p,isScrolling:f}=ri(a),{height:m,width:y}=gn();let _=0;const x=h.ref(!1),S=h.ref(0),O=h.ref(0),M=h.ref(0),g=t.horizontal?"x":"y",A=h.watch(s,w=>{if(x.value){A();return}_=t.horizontal?(w==null?void 0:w.position.x)||0:(w==null?void 0:w.position.y)||0,x.value=!0},{immediate:!0});h.watch(f,w=>{o.value&&(o.value.enabled=!w)},{immediate:!0}),h.watch(u,w=>{!f.value&&!t.htmlScroll||(O.value=parseFloat((w/m.value/(M.value/m.value-1)).toFixed(2)),S.value=-1*O.value,e("update:modelValue",O.value))}),h.watch(p,w=>{O.value=parseFloat((w/m.value/(M.value/m.value)).toFixed(2)),S.value=-1*O.value,e("update:modelValue",O.value)}),h.watch(d,w=>{O.value=parseFloat((w/y.value/(M.value/y.value-1)).toFixed(2)),S.value=+O.value,e("update:modelValue",O.value)}),h.watch(i,w=>{var C,k;const v=w==null?void 0:w.domElement;if(t.htmlScroll&&(w!=null&&w.domElement))v!=null&&v.style.width&&(v!=null&&v.style.position)&&(v!=null&&v.style.top)&&(v!=null&&v.style.left)&&(v.style.width="100%",v.style.position="fixed",v.style.zIndex=" -99999",v.style.top="0",v.style.left="0"),M.value=document.body.scrollHeight;else{const I=document.createElement("div"),U=document.createElement("div");a.style[t.horizontal?"overflowX":"overflowY"]="auto",a.style[t.horizontal?"overflowY":"overflowX"]="hidden",a.style.position="absolute",a.style.width="100%",a.style.height=" 100%",a.style.top="0",a.style.left="0",a.classList.add("scrollContainer"),I.style.position="sticky",I.style.top="0px",I.style.left="0px",I.style.width="100%",I.style.height="100%",I.style.overflow="hidden",a.appendChild(I),U.style.height=t.horizontal?"100%":`${m.value*t.pages}px`,U.style.width=t.horizontal?`${y.value*t.pages}px`:"100vw",U.style.pointerEvents="none",v.style.position="fixed",v.style.zIndex="0",v!=null&&v.style.width&&(v.style.width="100%"),a.appendChild(U),w.domElement.parentNode.style.position="relative",(k=(C=w==null?void 0:w.domElement)==null?void 0:C.parentNode)==null||k.appendChild(a),M.value=t.horizontal?y.value*t.pages:m.value*t.pages}},{immediate:!0});const{onLoop:b}=q.useRenderLoop();return b(()=>{var w;if((w=s.value)!=null&&w.position){const v=(S.value*t.distance-s.value.position[g]+_)*t.smoothScroll;s.value.position[g]+=v,r.value.children.length>0&&(r.value.position[g]+=v)}}),(w,v)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[h.renderSlot(w.$slots,"default")],512))}});/*!
|
|
82
82
|
* camera-controls
|
|
83
83
|
* https://github.com/yomotsu/camera-controls
|
|
84
84
|
* (c) 2017 @yomotsu
|
|
85
85
|
* Released under the MIT License.
|
|
86
|
-
*/const ie={LEFT:1,RIGHT:2,MIDDLE:4},Y=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Un={NONE:0,IN:1,OUT:-1};function hn(v){return v.isPerspectiveCamera}function Zt(v){return v.isOrthographicCamera}const zn=Math.PI*2,Ko=Math.PI/2,Yo=1e-5,ms=Math.PI/180;function Ct(v,t,n){return Math.max(t,Math.min(n,v))}function Se(v,t=Yo){return Math.abs(v)<t}function Me(v,t,n=Yo){return Se(v-t,n)}function Xo(v,t){return Math.round(v/t)*t}function fs(v){return isFinite(v)?v:v<0?-Number.MAX_VALUE:Number.MAX_VALUE}function vs(v){return Math.abs(v)<Number.MAX_VALUE?v:v*(1/0)}function $s(v,t,n,i,o=1/0,a){i=Math.max(1e-4,i);const c=2/i,p=c*a,d=1/(1+p+.48*p*p+.235*p*p*p);let g=v-t;const y=t,b=o*i;g=Ct(g,-b,b),t=v-g;const C=(n.value+c*g)*a;n.value=(n.value-c*C)*d;let A=t+(g+C)*d;return y-v>0==A>y&&(A=y,n.value=(A-y)/a),A}function Zo(v,t,n,i,o=1/0,a,c){i=Math.max(1e-4,i);const p=2/i,d=p*a,g=1/(1+d+.48*d*d+.235*d*d*d);let y=t.x,b=t.y,C=t.z,A=v.x-y,E=v.y-b,k=v.z-C;const O=y,R=b,N=C,F=o*i,M=F*F,D=A*A+E*E+k*k;if(D>M){const oe=Math.sqrt(D);A=A/oe*F,E=E/oe*F,k=k/oe*F}y=v.x-A,b=v.y-E,C=v.z-k;const U=(n.x+p*A)*a,S=(n.y+p*E)*a,T=(n.z+p*k)*a;n.x=(n.x-p*U)*g,n.y=(n.y-p*S)*g,n.z=(n.z-p*T)*g,c.x=y+(A+U)*g,c.y=b+(E+S)*g,c.z=C+(k+T)*g;const j=O-v.x,X=R-v.y,Z=N-v.z,J=c.x-O,le=c.y-R,he=c.z-N;return j*J+X*le+Z*he>0&&(c.x=O,c.y=R,c.z=N,n.x=(c.x-O)/a,n.y=(c.y-R)/a,n.z=(c.z-N)/a),c}function Ji(v,t){t.set(0,0),v.forEach(n=>{t.x+=n.clientX,t.y+=n.clientY}),t.x/=v.length,t.y/=v.length}function Hi(v,t){return Zt(v)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class Ah{constructor(){this._listeners={}}addEventListener(t,n){const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(n)===-1&&i[t].push(n)}hasEventListener(t,n){const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(n)!==-1}removeEventListener(t,n){const o=this._listeners[t];if(o!==void 0){const a=o.indexOf(n);a!==-1&&o.splice(a,1)}}removeAllEventListeners(t){if(!t){this._listeners={};return}Array.isArray(this._listeners[t])&&(this._listeners[t].length=0)}dispatchEvent(t){const i=this._listeners[t.type];if(i!==void 0){t.target=this;const o=i.slice(0);for(let a=0,c=o.length;a<c;a++)o[a].call(this,t)}}}const Mh="2.7.0",ei=1/8,qo=typeof window<"u",kh=qo&&/Mac/.test(navigator.platform),Lh=!(qo&&"PointerEvent"in window);let te,Qo,ti,$i,Je,pe,ye,Rn,_s,Pt,At,pn,Wo,Jo,at,gs,jn,Ho,er,$o,tr,nr,ni;class bs extends Ah{static install(t){te=t.THREE,Qo=Object.freeze(new te.Vector3(0,0,0)),ti=Object.freeze(new te.Vector3(0,1,0)),$i=Object.freeze(new te.Vector3(0,0,1)),Je=new te.Vector2,pe=new te.Vector3,ye=new te.Vector3,Rn=new te.Vector3,_s=new te.Vector3,Pt=new te.Vector3,At=new te.Vector3,pn=new te.Vector3,Wo=new te.Vector3,Jo=new te.Vector3,at=new te.Spherical,gs=new te.Spherical,jn=new te.Box3,Ho=new te.Box3,er=new te.Sphere,$o=new te.Quaternion,tr=new te.Quaternion,nr=new te.Matrix4,ni=new te.Raycaster}static get ACTION(){return Y}constructor(t,n){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=Y.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Un.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new te.Vector3,this._focalOffsetVelocity=new te.Vector3,this._zoomVelocity={value:0},this._truckInternal=(M,D,U)=>{let S,T;if(hn(this._camera)){const j=pe.copy(this._camera.position).sub(this._target),X=this._camera.getEffectiveFOV()*ms,Z=j.length()*Math.tan(X*.5);S=this.truckSpeed*M*Z/this._elementRect.height,T=this.truckSpeed*D*Z/this._elementRect.height}else if(Zt(this._camera)){const j=this._camera;S=M*(j.right-j.left)/j.zoom/this._elementRect.width,T=D*(j.top-j.bottom)/j.zoom/this._elementRect.height}else return;this.verticalDragToForward?(U?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(S,0,!0),this.forward(-T,!0)):U?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y+T,this._focalOffsetEnd.z,!0):this.truck(S,T,!0)},this._rotateInternal=(M,D)=>{const U=zn*this.azimuthRotateSpeed*M/this._elementRect.height,S=zn*this.polarRotateSpeed*D/this._elementRect.height;this.rotate(U,S,!0)},this._dollyInternal=(M,D,U)=>{const S=Math.pow(.95,-M*this.dollySpeed),T=this._sphericalEnd.radius,j=this._sphericalEnd.radius*S,X=te.MathUtils.clamp(j,this.minDistance,this.maxDistance),Z=X-j;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(j,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(Z,!0),this._dollyToNoClamp(X,!0)):this._dollyToNoClamp(X,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?j:X)-T,this._dollyControlCoord.set(D,U)),this._lastDollyDirection=Math.sign(-M)},this._zoomInternal=(M,D,U)=>{const S=Math.pow(.95,M*this.dollySpeed),T=this._zoom,j=this._zoom*S;this.zoomTo(j,!0),this.dollyToCursor&&(this._changedZoom+=j-T,this._dollyControlCoord.set(D,U))},typeof te>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=new te.Quaternion().setFromUnitVectors(this._camera.up,ti),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=Y.NONE,this._target=new te.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new te.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new te.Spherical().setFromVector3(pe.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new te.Vector3,new te.Vector3,new te.Vector3,new te.Vector3],this._updateNearPlaneCorners(),this._boundary=new te.Box3(new te.Vector3(-1/0,-1/0,-1/0),new te.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new te.Vector2,this.mouseButtons={left:Y.ROTATE,middle:Y.DOLLY,right:Y.TRUCK,wheel:hn(this._camera)?Y.DOLLY:Zt(this._camera)?Y.ZOOM:Y.NONE},this.touches={one:Y.TOUCH_ROTATE,two:hn(this._camera)?Y.TOUCH_DOLLY_TRUCK:Zt(this._camera)?Y.TOUCH_ZOOM_TRUCK:Y.NONE,three:Y.TOUCH_TRUCK};const i=new te.Vector2,o=new te.Vector2,a=new te.Vector2,c=M=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const S=this._domElement.getBoundingClientRect(),T=M.clientX/S.width,j=M.clientY/S.height;if(T<this._interactiveArea.left||T>this._interactiveArea.right||j<this._interactiveArea.top||j>this._interactiveArea.bottom)return}const D=M.pointerType!=="mouse"?null:(M.buttons&ie.LEFT)===ie.LEFT?ie.LEFT:(M.buttons&ie.MIDDLE)===ie.MIDDLE?ie.MIDDLE:(M.buttons&ie.RIGHT)===ie.RIGHT?ie.RIGHT:null;if(D!==null){const S=this._findPointerByMouseButton(D);S&&this._disposePointer(S)}if((M.buttons&ie.LEFT)===ie.LEFT&&this._lockedPointer)return;const U={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY,deltaX:0,deltaY:0,mouseButton:D};this._activePointers.push(U),this._domElement.ownerDocument.removeEventListener("pointermove",d,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",y),this._domElement.ownerDocument.addEventListener("pointermove",d,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",y),this._isDragging=!0,k(M)},p=M=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const S=this._domElement.getBoundingClientRect(),T=M.clientX/S.width,j=M.clientY/S.height;if(T<this._interactiveArea.left||T>this._interactiveArea.right||j<this._interactiveArea.top||j>this._interactiveArea.bottom)return}const D=(M.buttons&ie.LEFT)===ie.LEFT?ie.LEFT:(M.buttons&ie.MIDDLE)===ie.MIDDLE?ie.MIDDLE:(M.buttons&ie.RIGHT)===ie.RIGHT?ie.RIGHT:null;if(D!==null){const S=this._findPointerByMouseButton(D);S&&this._disposePointer(S)}const U={pointerId:1,clientX:M.clientX,clientY:M.clientY,deltaX:0,deltaY:0,mouseButton:(M.buttons&ie.LEFT)===ie.LEFT?ie.LEFT:(M.buttons&ie.MIDDLE)===ie.LEFT?ie.MIDDLE:(M.buttons&ie.RIGHT)===ie.LEFT?ie.RIGHT:null};this._activePointers.push(U),this._domElement.ownerDocument.removeEventListener("mousemove",g),this._domElement.ownerDocument.removeEventListener("mouseup",b),this._domElement.ownerDocument.addEventListener("mousemove",g),this._domElement.ownerDocument.addEventListener("mouseup",b),this._isDragging=!0,k(M)},d=M=>{M.cancelable&&M.preventDefault();const D=M.pointerId,U=this._lockedPointer||this._findPointerById(D);if(U){if(U.clientX=M.clientX,U.clientY=M.clientY,U.deltaX=M.movementX,U.deltaY=M.movementY,this._state=0,M.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(M.buttons&ie.LEFT)===ie.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(M.buttons&ie.MIDDLE)===ie.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(M.buttons&ie.RIGHT)===ie.RIGHT&&(this._state=this._state|this.mouseButtons.right);O()}},g=M=>{const D=this._lockedPointer||this._findPointerById(1);D&&(D.clientX=M.clientX,D.clientY=M.clientY,D.deltaX=M.movementX,D.deltaY=M.movementY,this._state=0,(this._lockedPointer||(M.buttons&ie.LEFT)===ie.LEFT)&&(this._state=this._state|this.mouseButtons.left),(M.buttons&ie.MIDDLE)===ie.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(M.buttons&ie.RIGHT)===ie.RIGHT&&(this._state=this._state|this.mouseButtons.right),O())},y=M=>{const D=this._findPointerById(M.pointerId);if(!(D&&D===this._lockedPointer)){if(D&&this._disposePointer(D),M.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=Y.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=Y.NONE;R()}},b=()=>{const M=this._findPointerById(1);M&&M===this._lockedPointer||(M&&this._disposePointer(M),this._state=Y.NONE,R())};let C=-1;const A=M=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===Y.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const j=this._domElement.getBoundingClientRect(),X=M.clientX/j.width,Z=M.clientY/j.height;if(X<this._interactiveArea.left||X>this._interactiveArea.right||Z<this._interactiveArea.top||Z>this._interactiveArea.bottom)return}if(M.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===Y.ROTATE||this.mouseButtons.wheel===Y.TRUCK){const j=performance.now();C-j<1e3&&this._getClientRect(this._elementRect),C=j}const D=kh?-1:-3,U=M.deltaMode===1?M.deltaY/D:M.deltaY/(D*10),S=this.dollyToCursor?(M.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(M.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case Y.ROTATE:{this._rotateInternal(M.deltaX,M.deltaY),this._isUserControllingRotate=!0;break}case Y.TRUCK:{this._truckInternal(M.deltaX,M.deltaY,!1),this._isUserControllingTruck=!0;break}case Y.OFFSET:{this._truckInternal(M.deltaX,M.deltaY,!0),this._isUserControllingOffset=!0;break}case Y.DOLLY:{this._dollyInternal(-U,S,T),this._isUserControllingDolly=!0;break}case Y.ZOOM:{this._zoomInternal(-U,S,T),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},E=M=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===bs.ACTION.NONE){const D=M instanceof PointerEvent?M.pointerId:(M instanceof MouseEvent,0),U=this._findPointerById(D);U&&this._disposePointer(U),this._domElement.ownerDocument.removeEventListener("pointermove",d,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",y),this._domElement.ownerDocument.removeEventListener("mousemove",g),this._domElement.ownerDocument.removeEventListener("mouseup",b);return}M.preventDefault()}},k=M=>{if(!this._enabled)return;if(Ji(this._activePointers,Je),this._getClientRect(this._elementRect),i.copy(Je),o.copy(Je),this._activePointers.length>=2){const U=Je.x-this._activePointers[1].clientX,S=Je.y-this._activePointers[1].clientY,T=Math.sqrt(U*U+S*S);a.set(0,T);const j=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,X=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;o.set(j,X)}if(this._state=0,!M)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in M&&M.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(M.buttons&ie.LEFT)===ie.LEFT&&(this._state=this._state|this.mouseButtons.left),(M.buttons&ie.MIDDLE)===ie.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(M.buttons&ie.RIGHT)===ie.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&Y.ROTATE)===Y.ROTATE||(this._state&Y.TOUCH_ROTATE)===Y.TOUCH_ROTATE||(this._state&Y.TOUCH_DOLLY_ROTATE)===Y.TOUCH_DOLLY_ROTATE||(this._state&Y.TOUCH_ZOOM_ROTATE)===Y.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&Y.TRUCK)===Y.TRUCK||(this._state&Y.TOUCH_TRUCK)===Y.TOUCH_TRUCK||(this._state&Y.TOUCH_DOLLY_TRUCK)===Y.TOUCH_DOLLY_TRUCK||(this._state&Y.TOUCH_ZOOM_TRUCK)===Y.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&Y.DOLLY)===Y.DOLLY||(this._state&Y.TOUCH_DOLLY)===Y.TOUCH_DOLLY||(this._state&Y.TOUCH_DOLLY_TRUCK)===Y.TOUCH_DOLLY_TRUCK||(this._state&Y.TOUCH_DOLLY_OFFSET)===Y.TOUCH_DOLLY_OFFSET||(this._state&Y.TOUCH_DOLLY_ROTATE)===Y.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&Y.ZOOM)===Y.ZOOM||(this._state&Y.TOUCH_ZOOM)===Y.TOUCH_ZOOM||(this._state&Y.TOUCH_ZOOM_TRUCK)===Y.TOUCH_ZOOM_TRUCK||(this._state&Y.TOUCH_ZOOM_OFFSET)===Y.TOUCH_ZOOM_OFFSET||(this._state&Y.TOUCH_ZOOM_ROTATE)===Y.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&Y.OFFSET)===Y.OFFSET||(this._state&Y.TOUCH_OFFSET)===Y.TOUCH_OFFSET||(this._state&Y.TOUCH_DOLLY_OFFSET)===Y.TOUCH_DOLLY_OFFSET||(this._state&Y.TOUCH_ZOOM_OFFSET)===Y.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},O=()=>{if(!this._enabled)return;Ji(this._activePointers,Je);const D=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,U=D?-D.deltaX:o.x-Je.x,S=D?-D.deltaY:o.y-Je.y;if(o.copy(Je),((this._state&Y.ROTATE)===Y.ROTATE||(this._state&Y.TOUCH_ROTATE)===Y.TOUCH_ROTATE||(this._state&Y.TOUCH_DOLLY_ROTATE)===Y.TOUCH_DOLLY_ROTATE||(this._state&Y.TOUCH_ZOOM_ROTATE)===Y.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(U,S),this._isUserControllingRotate=!0),(this._state&Y.DOLLY)===Y.DOLLY||(this._state&Y.ZOOM)===Y.ZOOM){const T=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,j=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,X=this.dollyDragInverted?-1:1;(this._state&Y.DOLLY)===Y.DOLLY?(this._dollyInternal(X*S*ei,T,j),this._isUserControllingDolly=!0):(this._zoomInternal(X*S*ei,T,j),this._isUserControllingZoom=!0)}if((this._state&Y.TOUCH_DOLLY)===Y.TOUCH_DOLLY||(this._state&Y.TOUCH_ZOOM)===Y.TOUCH_ZOOM||(this._state&Y.TOUCH_DOLLY_TRUCK)===Y.TOUCH_DOLLY_TRUCK||(this._state&Y.TOUCH_ZOOM_TRUCK)===Y.TOUCH_ZOOM_TRUCK||(this._state&Y.TOUCH_DOLLY_OFFSET)===Y.TOUCH_DOLLY_OFFSET||(this._state&Y.TOUCH_ZOOM_OFFSET)===Y.TOUCH_ZOOM_OFFSET||(this._state&Y.TOUCH_DOLLY_ROTATE)===Y.TOUCH_DOLLY_ROTATE||(this._state&Y.TOUCH_ZOOM_ROTATE)===Y.TOUCH_ZOOM_ROTATE){const T=Je.x-this._activePointers[1].clientX,j=Je.y-this._activePointers[1].clientY,X=Math.sqrt(T*T+j*j),Z=a.y-X;a.set(0,X);const J=this.dollyToCursor?(o.x-this._elementRect.x)/this._elementRect.width*2-1:0,le=this.dollyToCursor?(o.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&Y.TOUCH_DOLLY)===Y.TOUCH_DOLLY||(this._state&Y.TOUCH_DOLLY_ROTATE)===Y.TOUCH_DOLLY_ROTATE||(this._state&Y.TOUCH_DOLLY_TRUCK)===Y.TOUCH_DOLLY_TRUCK||(this._state&Y.TOUCH_DOLLY_OFFSET)===Y.TOUCH_DOLLY_OFFSET?(this._dollyInternal(Z*ei,J,le),this._isUserControllingDolly=!0):(this._zoomInternal(Z*ei,J,le),this._isUserControllingZoom=!0)}((this._state&Y.TRUCK)===Y.TRUCK||(this._state&Y.TOUCH_TRUCK)===Y.TOUCH_TRUCK||(this._state&Y.TOUCH_DOLLY_TRUCK)===Y.TOUCH_DOLLY_TRUCK||(this._state&Y.TOUCH_ZOOM_TRUCK)===Y.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(U,S,!1),this._isUserControllingTruck=!0),((this._state&Y.OFFSET)===Y.OFFSET||(this._state&Y.TOUCH_OFFSET)===Y.TOUCH_OFFSET||(this._state&Y.TOUCH_DOLLY_OFFSET)===Y.TOUCH_DOLLY_OFFSET||(this._state&Y.TOUCH_ZOOM_OFFSET)===Y.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(U,S,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},R=()=>{Ji(this._activePointers,Je),o.copy(Je),(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",d,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",g),this._domElement.ownerDocument.removeEventListener("pointerup",y),this._domElement.ownerDocument.removeEventListener("mouseup",b),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",d,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",y),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",N),this._domElement.ownerDocument.addEventListener("pointerlockerror",F),this._domElement.ownerDocument.addEventListener("pointermove",d,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",y),k())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",N),this._domElement.ownerDocument.removeEventListener("pointerlockerror",F))};const N=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},F=()=>{this.unlockPointer()};this._addAllEventListeners=M=>{this._domElement=M,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",c),Lh&&this._domElement.addEventListener("mousedown",p),this._domElement.addEventListener("pointercancel",y),this._domElement.addEventListener("wheel",A,{passive:!1}),this._domElement.addEventListener("contextmenu",E)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",c),this._domElement.removeEventListener("mousedown",p),this._domElement.removeEventListener("pointercancel",y),this._domElement.removeEventListener("wheel",A,{passive:!1}),this._domElement.removeEventListener("contextmenu",E),this._domElement.ownerDocument.removeEventListener("pointermove",d,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",g),this._domElement.ownerDocument.removeEventListener("pointerup",y),this._domElement.ownerDocument.removeEventListener("mouseup",b),this._domElement.ownerDocument.removeEventListener("pointerlockchange",N),this._domElement.ownerDocument.removeEventListener("pointerlockerror",F))},this.cancel=()=>{this._state!==Y.NONE&&(this._state=Y.NONE,this._activePointers.length=0,R())},n&&this.connect(n),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=Ct(t.width,0,1),this._interactiveArea.height=Ct(t.height,0,1),this._interactiveArea.x=Ct(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ct(t.x,0,1-this._interactiveArea.height)}addEventListener(t,n){super.addEventListener(t,n)}removeEventListener(t,n){super.removeEventListener(t,n)}rotate(t,n,i=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+n,i)}rotateAzimuthTo(t,n=!1){return this.rotateTo(t,this._sphericalEnd.phi,n)}rotatePolarTo(t,n=!1){return this.rotateTo(this._sphericalEnd.theta,t,n)}rotateTo(t,n,i=!1){this._isUserControllingRotate=!1;const o=Ct(t,this.minAzimuthAngle,this.maxAzimuthAngle),a=Ct(n,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=o,this._sphericalEnd.phi=a,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const c=!i||Me(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Me(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(c)}dolly(t,n=!1){return this.dollyTo(this._sphericalEnd.radius-t,n)}dollyTo(t,n=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Un.NONE,this._changedDolly=0,this._dollyToNoClamp(Ct(t,this.minDistance,this.maxDistance),n)}_dollyToNoClamp(t,n=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const c=this._collisionTest(),p=Me(c,this._spherical.radius);if(!(i>t)&&p)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,c)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,n||(this._spherical.radius=this._sphericalEnd.radius);const a=!n||Me(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(a)}dollyInFixed(t,n=!1){this._targetEnd.add(this._getCameraDirection(_s).multiplyScalar(t)),n||this._target.copy(this._targetEnd);const i=!n||Me(this._target.x,this._targetEnd.x,this.restThreshold)&&Me(this._target.y,this._targetEnd.y,this.restThreshold)&&Me(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(t,n=!1){return this.zoomTo(this._zoomEnd+t,n)}zoomTo(t,n=!1){this._isUserControllingZoom=!1,this._zoomEnd=Ct(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,n||(this._zoom=this._zoomEnd);const i=!n||Me(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(t,n,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,n,i)}truck(t,n,i=!1){this._camera.updateMatrix(),Pt.setFromMatrixColumn(this._camera.matrix,0),At.setFromMatrixColumn(this._camera.matrix,1),Pt.multiplyScalar(t),At.multiplyScalar(-n);const o=pe.copy(Pt).add(At),a=ye.copy(this._targetEnd).add(o);return this.moveTo(a.x,a.y,a.z,i)}forward(t,n=!1){pe.setFromMatrixColumn(this._camera.matrix,0),pe.crossVectors(this._camera.up,pe),pe.multiplyScalar(t);const i=ye.copy(this._targetEnd).add(pe);return this.moveTo(i.x,i.y,i.z,n)}elevate(t,n=!1){return pe.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+pe.x,this._targetEnd.y+pe.y,this._targetEnd.z+pe.z,n)}moveTo(t,n,i,o=!1){this._isUserControllingTruck=!1;const a=pe.set(t,n,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,a,this.boundaryFriction),this._needsUpdate=!0,o||this._target.copy(this._targetEnd);const c=!o||Me(this._target.x,this._targetEnd.x,this.restThreshold)&&Me(this._target.y,this._targetEnd.y,this.restThreshold)&&Me(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(c)}lookInDirectionOf(t,n,i,o=!1){const p=pe.set(t,n,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(p.x,p.y,p.z,o)}fitToBox(t,n,{cover:i=!1,paddingLeft:o=0,paddingRight:a=0,paddingBottom:c=0,paddingTop:p=0}={}){const d=[],g=t.isBox3?jn.copy(t):jn.setFromObject(t);g.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const y=Xo(this._sphericalEnd.theta,Ko),b=Xo(this._sphericalEnd.phi,Ko);d.push(this.rotateTo(y,b,n));const C=pe.setFromSpherical(this._sphericalEnd).normalize(),A=$o.setFromUnitVectors(C,$i),E=Me(Math.abs(C.y),1);E&&A.multiply(tr.setFromAxisAngle(ti,y)),A.multiply(this._yAxisUpSpaceInverse);const k=Ho.makeEmpty();ye.copy(g.min).applyQuaternion(A),k.expandByPoint(ye),ye.copy(g.min).setX(g.max.x).applyQuaternion(A),k.expandByPoint(ye),ye.copy(g.min).setY(g.max.y).applyQuaternion(A),k.expandByPoint(ye),ye.copy(g.max).setZ(g.min.z).applyQuaternion(A),k.expandByPoint(ye),ye.copy(g.min).setZ(g.max.z).applyQuaternion(A),k.expandByPoint(ye),ye.copy(g.max).setY(g.min.y).applyQuaternion(A),k.expandByPoint(ye),ye.copy(g.max).setX(g.min.x).applyQuaternion(A),k.expandByPoint(ye),ye.copy(g.max).applyQuaternion(A),k.expandByPoint(ye),k.min.x-=o,k.min.y-=c,k.max.x+=a,k.max.y+=p,A.setFromUnitVectors($i,C),E&&A.premultiply(tr.invert()),A.premultiply(this._yAxisUpSpace);const O=k.getSize(pe),R=k.getCenter(ye).applyQuaternion(A);if(hn(this._camera)){const N=this.getDistanceToFitBox(O.x,O.y,O.z,i);d.push(this.moveTo(R.x,R.y,R.z,n)),d.push(this.dollyTo(N,n)),d.push(this.setFocalOffset(0,0,0,n))}else if(Zt(this._camera)){const N=this._camera,F=N.right-N.left,M=N.top-N.bottom,D=i?Math.max(F/O.x,M/O.y):Math.min(F/O.x,M/O.y);d.push(this.moveTo(R.x,R.y,R.z,n)),d.push(this.zoomTo(D,n)),d.push(this.setFocalOffset(0,0,0,n))}return Promise.all(d)}fitToSphere(t,n){const i=[],a=t instanceof te.Sphere?er.copy(t):bs.createBoundingSphere(t,er);if(i.push(this.moveTo(a.center.x,a.center.y,a.center.z,n)),hn(this._camera)){const c=this.getDistanceToFitSphere(a.radius);i.push(this.dollyTo(c,n))}else if(Zt(this._camera)){const c=this._camera.right-this._camera.left,p=this._camera.top-this._camera.bottom,d=2*a.radius,g=Math.min(c/d,p/d);i.push(this.zoomTo(g,n))}return i.push(this.setFocalOffset(0,0,0,n)),Promise.all(i)}setLookAt(t,n,i,o,a,c,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Un.NONE,this._changedDolly=0;const d=ye.set(o,a,c),g=pe.set(t,n,i);this._targetEnd.copy(d),this._sphericalEnd.setFromVector3(g.sub(d).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const y=!p||Me(this._target.x,this._targetEnd.x,this.restThreshold)&&Me(this._target.y,this._targetEnd.y,this.restThreshold)&&Me(this._target.z,this._targetEnd.z,this.restThreshold)&&Me(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Me(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Me(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(y)}lerpLookAt(t,n,i,o,a,c,p,d,g,y,b,C,A,E=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Un.NONE,this._changedDolly=0;const k=pe.set(o,a,c),O=ye.set(t,n,i);at.setFromVector3(O.sub(k).applyQuaternion(this._yAxisUpSpace));const R=Rn.set(y,b,C),N=ye.set(p,d,g);gs.setFromVector3(N.sub(R).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(k.lerp(R,A));const F=gs.theta-at.theta,M=gs.phi-at.phi,D=gs.radius-at.radius;this._sphericalEnd.set(at.radius+D*A,at.phi+M*A,at.theta+F*A),this.normalizeRotations(),this._needsUpdate=!0,E||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const U=!E||Me(this._target.x,this._targetEnd.x,this.restThreshold)&&Me(this._target.y,this._targetEnd.y,this.restThreshold)&&Me(this._target.z,this._targetEnd.z,this.restThreshold)&&Me(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Me(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Me(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(U)}setPosition(t,n,i,o=!1){return this.setLookAt(t,n,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,o)}setTarget(t,n,i,o=!1){const a=this.getPosition(pe),c=this.setLookAt(a.x,a.y,a.z,t,n,i,o);return this._sphericalEnd.phi=Ct(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),c}setFocalOffset(t,n,i,o=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,n,i),this._needsUpdate=!0,o||this._focalOffset.copy(this._focalOffsetEnd);const a=!o||Me(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Me(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Me(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}setOrbitPoint(t,n,i){this._camera.updateMatrixWorld(),Pt.setFromMatrixColumn(this._camera.matrixWorldInverse,0),At.setFromMatrixColumn(this._camera.matrixWorldInverse,1),pn.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const o=pe.set(t,n,i),a=o.distanceTo(this._camera.position),c=o.sub(this._camera.position);Pt.multiplyScalar(c.x),At.multiplyScalar(c.y),pn.multiplyScalar(c.z),pe.copy(Pt).add(At).add(pn),pe.z=pe.z+a,this.dollyTo(a,!1),this.setFocalOffset(-pe.x,pe.y,-pe.z,!1),this.moveTo(t,n,i,!1)}setBoundary(t){if(!t){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(t),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(t,n,i,o){if(t===null){this._viewport=null;return}this._viewport=this._viewport||new te.Vector4,typeof t=="number"?this._viewport.set(t,n,i,o):this._viewport.copy(t)}getDistanceToFitBox(t,n,i,o=!1){if(Hi(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const a=t/n,c=this._camera.getEffectiveFOV()*ms,p=this._camera.aspect;return((o?a>p:a<p)?n:t/p)*.5/Math.tan(c*.5)+i*.5}getDistanceToFitSphere(t){if(Hi(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const n=this._camera.getEffectiveFOV()*ms,i=Math.atan(Math.tan(n*.5)*this._camera.aspect)*2,o=1<this._camera.aspect?n:i;return t/Math.sin(o*.5)}getTarget(t,n=!0){return(t&&t.isVector3?t:new te.Vector3).copy(n?this._targetEnd:this._target)}getPosition(t,n=!0){return(t&&t.isVector3?t:new te.Vector3).setFromSpherical(n?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(n?this._targetEnd:this._target)}getSpherical(t,n=!0){return(t&&t instanceof te.Spherical?t:new te.Spherical).copy(n?this._sphericalEnd:this._spherical)}getFocalOffset(t,n=!0){return(t&&t.isVector3?t:new te.Vector3).copy(n?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%zn,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=zn),this._spherical.theta+=zn*Math.round((this._sphericalEnd.theta-this._spherical.theta)/zn)}reset(t=!1){if(!Me(this._camera.up.x,this._cameraUp0.x)||!Me(this._camera.up.y,this._cameraUp0.y)||!Me(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(pe);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const n=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];return Promise.all(n)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,ti),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=pe.subVectors(this._target,this._camera.position).normalize(),n=ye.crossVectors(t,this._camera.up);this._camera.up.crossVectors(n,t),this._camera.updateMatrixWorld();const i=this.getPosition(pe);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(t){const n=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,o=this._sphericalEnd.radius-this._spherical.radius,a=Wo.subVectors(this._targetEnd,this._target),c=Jo.subVectors(this._focalOffsetEnd,this._focalOffset),p=this._zoomEnd-this._zoom;if(Se(n))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const b=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=$s(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,b,1/0,t),this._needsUpdate=!0}if(Se(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const b=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=$s(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,b,1/0,t),this._needsUpdate=!0}if(Se(o))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const b=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=$s(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,b,this.maxSpeed,t),this._needsUpdate=!0}if(Se(a.x)&&Se(a.y)&&Se(a.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const b=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Zo(this._target,this._targetEnd,this._targetVelocity,b,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(Se(c.x)&&Se(c.y)&&Se(c.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const b=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Zo(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,b,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(Se(p))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const b=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=$s(this._zoom,this._zoomEnd,this._zoomVelocity,b,1/0,t)}if(this.dollyToCursor){if(hn(this._camera)&&this._changedDolly!==0){const b=this._spherical.radius-this._lastDistance,C=this._camera,A=this._getCameraDirection(_s),E=pe.copy(A).cross(C.up).normalize();E.lengthSq()===0&&(E.x=1);const k=ye.crossVectors(E,A),O=this._sphericalEnd.radius*Math.tan(C.getEffectiveFOV()*ms*.5),N=(this._sphericalEnd.radius-b-this._sphericalEnd.radius)/this._sphericalEnd.radius,F=Rn.copy(this._targetEnd).add(E.multiplyScalar(this._dollyControlCoord.x*O*C.aspect)).add(k.multiplyScalar(this._dollyControlCoord.y*O)),M=pe.copy(this._targetEnd).lerp(F,N),D=this._lastDollyDirection===Un.IN&&this._spherical.radius<=this.minDistance,U=this._lastDollyDirection===Un.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(D||U)){this._sphericalEnd.radius-=b,this._spherical.radius-=b;const T=ye.copy(A).multiplyScalar(-b);M.add(T)}this._boundary.clampPoint(M,M);const S=ye.subVectors(M,this._targetEnd);this._targetEnd.copy(M),this._target.add(S),this._changedDolly-=b,Se(this._changedDolly)&&(this._changedDolly=0)}else if(Zt(this._camera)&&this._changedZoom!==0){const b=this._zoom-this._lastZoom,C=this._camera,A=pe.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(C.near+C.far)/(C.near-C.far)).unproject(C),E=ye.set(0,0,-1).applyQuaternion(C.quaternion),k=Rn.copy(A).add(E.multiplyScalar(-A.dot(C.up))),R=-(this._zoom-b-this._zoom)/this._zoom,N=this._getCameraDirection(_s),F=this._targetEnd.dot(N),M=pe.copy(this._targetEnd).lerp(k,R),D=M.dot(N),U=N.multiplyScalar(D-F);M.sub(U),this._boundary.clampPoint(M,M);const S=ye.subVectors(M,this._targetEnd);this._targetEnd.copy(M),this._target.add(S),this._changedZoom-=b,Se(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0);const d=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,d),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Se(this._focalOffset.x)||!Se(this._focalOffset.y)||!Se(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Pt.setFromMatrixColumn(this._camera.matrix,0),At.setFromMatrixColumn(this._camera.matrix,1),pn.setFromMatrixColumn(this._camera.matrix,2),Pt.multiplyScalar(this._focalOffset.x),At.multiplyScalar(-this._focalOffset.y),pn.multiplyScalar(this._focalOffset.z),pe.copy(Pt).add(At).add(pn),this._camera.position.add(pe)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),pe.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const y=this._needsUpdate;return y&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):y?(this.dispatchEvent({type:"update"}),Se(n,this.restThreshold)&&Se(i,this.restThreshold)&&Se(o,this.restThreshold)&&Se(a.x,this.restThreshold)&&Se(a.y,this.restThreshold)&&Se(a.z,this.restThreshold)&&Se(c.x,this.restThreshold)&&Se(c.y,this.restThreshold)&&Se(c.z,this.restThreshold)&&Se(p,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!y&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=y,this._needsUpdate=!1,y}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:fs(this.maxDistance),minZoom:this.minZoom,maxZoom:fs(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:fs(this.maxPolarAngle),minAzimuthAngle:fs(this.minAzimuthAngle),maxAzimuthAngle:fs(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:pe.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(t,n=!1){const i=JSON.parse(t);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=vs(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=vs(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=vs(i.maxPolarAngle),this.minAzimuthAngle=vs(i.minAzimuthAngle),this.maxAzimuthAngle=vs(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this.verticalDragToForward=i.verticalDragToForward,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],n),at.setFromVector3(pe.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(at.theta,at.phi,n),this.dollyTo(at.radius,n),this.zoomTo(i.zoom,n),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],n),this._needsUpdate=!0}connect(t){if(this._domElement){console.warn("camera-controls is already connected.");return}t.setAttribute("data-camera-controls-version",Mh),this._addAllEventListeners(t)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(t){return t.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(t){return this._getTargetDirection(t).negate()}_findPointerById(t){return this._activePointers.find(n=>n.pointerId===t)}_findPointerByMouseButton(t){return this._activePointers.find(n=>n.mouseButton===t)}_disposePointer(t){this._activePointers.splice(this._activePointers.indexOf(t),1)}_encloseToBoundary(t,n,i){const o=n.lengthSq();if(o===0)return t;const a=ye.copy(n).add(t),p=this._boundary.clampPoint(a,Rn).sub(a),d=p.lengthSq();if(d===0)return t.add(n);if(d===o)return t;if(i===0)return t.add(n).add(p);{const g=1+i*d/n.dot(p);return t.add(ye.copy(n).multiplyScalar(g)).add(p.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(hn(this._camera)){const t=this._camera,n=t.near,i=t.getEffectiveFOV()*ms,o=Math.tan(i*.5)*n,a=o*t.aspect;this._nearPlaneCorners[0].set(-a,-o,0),this._nearPlaneCorners[1].set(a,-o,0),this._nearPlaneCorners[2].set(a,o,0),this._nearPlaneCorners[3].set(-a,o,0)}else if(Zt(this._camera)){const t=this._camera,n=1/t.zoom,i=t.left*n,o=t.right*n,a=t.top*n,c=t.bottom*n;this._nearPlaneCorners[0].set(i,a,0),this._nearPlaneCorners[1].set(o,a,0),this._nearPlaneCorners[2].set(o,c,0),this._nearPlaneCorners[3].set(i,c,0)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||Hi(this._camera,"_collisionTest"))return t;const i=this._getTargetDirection(_s);nr.lookAt(Qo,i,this._camera.up);for(let o=0;o<4;o++){const a=ye.copy(this._nearPlaneCorners[o]);a.applyMatrix4(nr);const c=Rn.addVectors(this._target,a);ni.set(c,i),ni.far=this._spherical.radius+1;const p=ni.intersectObjects(this.colliderMeshes);p.length!==0&&p[0].distance<t&&(t=p[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const n=this._domElement.getBoundingClientRect();return t.x=n.left,t.y=n.top,this._viewport?(t.x+=this._viewport.x,t.y+=n.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=n.width,t.height=n.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(n=>{const i=()=>{this.removeEventListener("rest",i),n()};this.addEventListener("rest",i)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,n=new te.Sphere){const i=n,o=i.center;jn.makeEmpty(),t.traverseVisible(c=>{c.isMesh&&jn.expandByObject(c)}),jn.getCenter(o);let a=0;return t.traverseVisible(c=>{if(!c.isMesh)return;const p=c,d=p.geometry.clone();d.applyMatrix4(p.matrixWorld);const y=d.attributes.position;for(let b=0,C=y.count;b<C;b++)pe.fromBufferAttribute(y,b),a=Math.max(a,o.distanceToSquared(pe))}),i.radius=Math.sqrt(a),i}}const Sh=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args"],Th=_.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},minDistance:{default:Number.EPSILON},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{},touches:{}},emits:["change","start","end"],setup(v,{expose:t,emit:n}){const i=v,{makeDefault:o,minPolarAngle:a,maxPolarAngle:c,minAzimuthAngle:p,maxAzimuthAngle:d,minDistance:g,maxDistance:y,infinityDolly:b,minZoom:C,maxZoom:A,smoothTime:E,draggingSmoothTime:k,maxSpeed:O,azimuthRotateSpeed:R,polarRotateSpeed:N,dollySpeed:F,dollyDragInverted:M,truckSpeed:D,dollyToCursor:U,dragToOffset:S,verticalDragToForward:T,boundaryFriction:j,restThreshold:X,colliderMeshes:Z}=_.toRefs(i),J={Box3:m.Box3,MathUtils:{clamp:m.MathUtils.clamp},Matrix4:m.Matrix4,Quaternion:m.Quaternion,Raycaster:m.Raycaster,Sphere:m.Sphere,Spherical:m.Spherical,Vector2:m.Vector2,Vector3:m.Vector3,Vector4:m.Vector4};bs.install({THREE:J});const{state:le,extend:he,setState:oe}=Ae.useTresContext(),re=_.ref(null);he({CameraControls:bs}),_.watch(re,Ce=>{ne(),Ce&&o.value?oe("controls",Ce):oe("controls",null)});function ne(){De(re.value,"update",()=>n("change",re.value)),De(re.value,"controlend",()=>n("end",re.value)),De(re.value,"controlstart",()=>n("start",re.value))}const{onLoop:H}=Ae.useRenderLoop();return H(({delta:Ce})=>{var ge,de;(ge=re.value)!=null&&ge.enabled&&((de=re.value)==null||de.update(Ce))}),_.onUnmounted(()=>{re.value&&re.value.disconnect()}),t({value:re}),(Ce,ge)=>{var de;return _.unref(le).camera&&_.unref(le).renderer?(_.openBlock(),_.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:re,"min-polar-angle":_.unref(a),"max-polar-angle":_.unref(c),"min-azimuth-angle":_.unref(p),"max-azimuth-angle":_.unref(d),"min-distance":_.unref(g),"max-distance":_.unref(y),"infinity-dolly":_.unref(b),"min-zoom":_.unref(C),"max-zoom":_.unref(A),"smooth-time":_.unref(E),"dragging-smooth-time":_.unref(k),"max-speed":_.unref(O),"azimuth-rotate-speed":_.unref(R),"polar-rotate-speed":_.unref(N),"dolly-speed":_.unref(F),"dolly-drag-inverted":_.unref(M),"truck-speed":_.unref(D),"dolly-to-cursor":_.unref(U),"drag-to-offset":_.unref(S),"vertical-drag-to-forward":_.unref(T),"boundary-friction":_.unref(j),"rest-threshold":_.unref(X),"collider-meshes":_.unref(Z),args:[_.unref(le).camera||Ce.camera,((de=_.unref(le).renderer)==null?void 0:de.domElement)||Ce.domElement]},null,8,Sh)):_.createCommentVNode("",!0)}}});class Eh extends m.MeshStandardMaterial{constructor(n={}){super(n);ao(this,"_time");ao(this,"_factor");this.setValues(n),this._time={value:0},this._factor={value:1}}onBeforeCompile(n){n.uniforms||(n.uniforms={}),n.uniforms.time=this._time,n.uniforms.factor=this._factor,n.vertexShader=`
|
|
86
|
+
*/const N={LEFT:1,RIGHT:2,MIDDLE:4},D=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ye={NONE:0,IN:1,OUT:-1};function Ve(c){return c.isPerspectiveCamera}function ke(c){return c.isOrthographicCamera}const Xe=Math.PI*2,vn=Math.PI/2,An=1e-5,Je=Math.PI/180;function xe(c,e,t){return Math.max(e,Math.min(t,c))}function te(c,e=An){return Math.abs(c)<e}function J(c,e,t=An){return te(c-e,t)}function xn(c,e){return Math.round(c/e)*e}function He(c){return isFinite(c)?c:c<0?-Number.MAX_VALUE:Number.MAX_VALUE}function $e(c){return Math.abs(c)<Number.MAX_VALUE?c:c*(1/0)}function rt(c,e,t,n,s=1/0,o){n=Math.max(1e-4,n);const i=2/n,r=i*o,a=1/(1+r+.48*r*r+.235*r*r*r);let u=c-e;const d=e,p=s*n;u=xe(u,-p,p),e=c-u;const f=(t.value+i*u)*o;t.value=(t.value-i*f)*a;let m=e+(u+f)*a;return d-c>0==m>d&&(m=d,t.value=(m-d)/o),m}function Mn(c,e,t,n,s=1/0,o,i){n=Math.max(1e-4,n);const r=2/n,a=r*o,u=1/(1+a+.48*a*a+.235*a*a*a);let d=e.x,p=e.y,f=e.z,m=c.x-d,y=c.y-p,_=c.z-f;const x=d,S=p,O=f,M=s*n,g=M*M,A=m*m+y*y+_*_;if(A>g){const G=Math.sqrt(A);m=m/G*M,y=y/G*M,_=_/G*M}d=c.x-m,p=c.y-y,f=c.z-_;const b=(t.x+r*m)*o,w=(t.y+r*y)*o,v=(t.z+r*_)*o;t.x=(t.x-r*b)*u,t.y=(t.y-r*w)*u,t.z=(t.z-r*v)*u,i.x=d+(m+b)*u,i.y=p+(y+w)*u,i.z=f+(_+v)*u;const C=x-c.x,k=S-c.y,I=O-c.z,U=i.x-x,j=i.y-S,H=i.z-O;return C*U+k*j+I*H>0&&(i.x=x,i.y=S,i.z=O,t.x=(i.x-x)/o,t.y=(i.y-S)/o,t.z=(i.z-O)/o),i}function Pt(c,e){e.set(0,0),c.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=c.length,e.y/=c.length}function Ct(c,e){return ke(c)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Pi{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let o=0,i=s.length;o<i;o++)s[o].call(this,e)}}}const Ci="2.7.0",at=1/8,bn=typeof window<"u",Di=bn&&/Mac/.test(navigator.platform),Ii=!(bn&&"PointerEvent"in window);let V,Tn,lt,Dt,pe,R,W,Ze,et,Me,be,Ne,Sn,Ln,ge,tt,Qe,On,It,Pn,kt,Ft,ct;class nt extends Pi{static install(e){V=e.THREE,Tn=Object.freeze(new V.Vector3(0,0,0)),lt=Object.freeze(new V.Vector3(0,1,0)),Dt=Object.freeze(new V.Vector3(0,0,1)),pe=new V.Vector2,R=new V.Vector3,W=new V.Vector3,Ze=new V.Vector3,et=new V.Vector3,Me=new V.Vector3,be=new V.Vector3,Ne=new V.Vector3,Sn=new V.Vector3,Ln=new V.Vector3,ge=new V.Spherical,tt=new V.Spherical,Qe=new V.Box3,On=new V.Box3,It=new V.Sphere,Pn=new V.Quaternion,kt=new V.Quaternion,Ft=new V.Matrix4,ct=new V.Raycaster}static get ACTION(){return D}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=D.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ye.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new V.Vector3,this._focalOffsetVelocity=new V.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,A,b)=>{let w,v;if(Ve(this._camera)){const C=R.copy(this._camera.position).sub(this._target),k=this._camera.getEffectiveFOV()*Je,I=C.length()*Math.tan(k*.5);w=this.truckSpeed*g*I/this._elementRect.height,v=this.truckSpeed*A*I/this._elementRect.height}else if(ke(this._camera)){const C=this._camera;w=g*(C.right-C.left)/C.zoom/this._elementRect.width,v=A*(C.top-C.bottom)/C.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(w,0,!0),this.forward(-v,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y+v,this._focalOffsetEnd.z,!0):this.truck(w,v,!0)},this._rotateInternal=(g,A)=>{const b=Xe*this.azimuthRotateSpeed*g/this._elementRect.height,w=Xe*this.polarRotateSpeed*A/this._elementRect.height;this.rotate(b,w,!0)},this._dollyInternal=(g,A,b)=>{const w=Math.pow(.95,-g*this.dollySpeed),v=this._sphericalEnd.radius,C=this._sphericalEnd.radius*w,k=V.MathUtils.clamp(C,this.minDistance,this.maxDistance),I=k-C;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(C,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(I,!0),this._dollyToNoClamp(k,!0)):this._dollyToNoClamp(k,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?C:k)-v,this._dollyControlCoord.set(A,b)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,A,b)=>{const w=Math.pow(.95,g*this.dollySpeed),v=this._zoom,C=this._zoom*w;this.zoomTo(C,!0),this.dollyToCursor&&(this._changedZoom+=C-v,this._dollyControlCoord.set(A,b))},typeof V>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new V.Quaternion().setFromUnitVectors(this._camera.up,lt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=D.NONE,this._target=new V.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new V.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new V.Spherical().setFromVector3(R.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new V.Vector3,new V.Vector3,new V.Vector3,new V.Vector3],this._updateNearPlaneCorners(),this._boundary=new V.Box3(new V.Vector3(-1/0,-1/0,-1/0),new V.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new V.Vector2,this.mouseButtons={left:D.ROTATE,middle:D.DOLLY,right:D.TRUCK,wheel:Ve(this._camera)?D.DOLLY:ke(this._camera)?D.ZOOM:D.NONE},this.touches={one:D.TOUCH_ROTATE,two:Ve(this._camera)?D.TOUCH_DOLLY_TRUCK:ke(this._camera)?D.TOUCH_ZOOM_TRUCK:D.NONE,three:D.TOUCH_TRUCK};const n=new V.Vector2,s=new V.Vector2,o=new V.Vector2,i=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const w=this._domElement.getBoundingClientRect(),v=g.clientX/w.width,C=g.clientY/w.height;if(v<this._interactiveArea.left||v>this._interactiveArea.right||C<this._interactiveArea.top||C>this._interactiveArea.bottom)return}const A=g.pointerType!=="mouse"?null:(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.MIDDLE?N.MIDDLE:(g.buttons&N.RIGHT)===N.RIGHT?N.RIGHT:null;if(A!==null){const w=this._findPointerByMouseButton(A);w&&this._disposePointer(w)}if((g.buttons&N.LEFT)===N.LEFT&&this._lockedPointer)return;const b={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:A};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),this._isDragging=!0,_(g)},r=g=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const w=this._domElement.getBoundingClientRect(),v=g.clientX/w.width,C=g.clientY/w.height;if(v<this._interactiveArea.left||v>this._interactiveArea.right||C<this._interactiveArea.top||C>this._interactiveArea.bottom)return}const A=(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.MIDDLE?N.MIDDLE:(g.buttons&N.RIGHT)===N.RIGHT?N.RIGHT:null;if(A!==null){const w=this._findPointerByMouseButton(A);w&&this._disposePointer(w)}const b={pointerId:1,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.LEFT?N.MIDDLE:(g.buttons&N.RIGHT)===N.LEFT?N.RIGHT:null};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.addEventListener("mousemove",u),this._domElement.ownerDocument.addEventListener("mouseup",p),this._isDragging=!0,_(g)},a=g=>{g.cancelable&&g.preventDefault();const A=g.pointerId,b=this._lockedPointer||this._findPointerById(A);if(b){if(b.clientX=g.clientX,b.clientY=g.clientY,b.deltaX=g.movementX,b.deltaY=g.movementY,this._state=0,g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(g.buttons&N.LEFT)===N.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right);x()}},u=g=>{const A=this._lockedPointer||this._findPointerById(1);A&&(A.clientX=g.clientX,A.clientY=g.clientY,A.deltaX=g.movementX,A.deltaY=g.movementY,this._state=0,(this._lockedPointer||(g.buttons&N.LEFT)===N.LEFT)&&(this._state=this._state|this.mouseButtons.left),(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right),x())},d=g=>{const A=this._findPointerById(g.pointerId);if(!(A&&A===this._lockedPointer)){if(A&&this._disposePointer(A),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=D.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=D.NONE;S()}},p=()=>{const g=this._findPointerById(1);g&&g===this._lockedPointer||(g&&this._disposePointer(g),this._state=D.NONE,S())};let f=-1;const m=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===D.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),k=g.clientX/C.width,I=g.clientY/C.height;if(k<this._interactiveArea.left||k>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===D.ROTATE||this.mouseButtons.wheel===D.TRUCK){const C=performance.now();f-C<1e3&&this._getClientRect(this._elementRect),f=C}const A=Di?-1:-3,b=g.deltaMode===1?g.deltaY/A:g.deltaY/(A*10),w=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,v=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case D.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case D.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case D.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case D.DOLLY:{this._dollyInternal(-b,w,v),this._isUserControllingDolly=!0;break}case D.ZOOM:{this._zoomInternal(-b,w,v),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},y=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===nt.ACTION.NONE){const A=g instanceof PointerEvent?g.pointerId:(g instanceof MouseEvent,0),b=this._findPointerById(A);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",p);return}g.preventDefault()}},_=g=>{if(!this._enabled)return;if(Pt(this._activePointers,pe),this._getClientRect(this._elementRect),n.copy(pe),s.copy(pe),this._activePointers.length>=2){const b=pe.x-this._activePointers[1].clientX,w=pe.y-this._activePointers[1].clientY,v=Math.sqrt(b*b+w*w);o.set(0,v);const C=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,k=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;s.set(C,k)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(g.buttons&N.LEFT)===N.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&D.ROTATE)===D.ROTATE||(this._state&D.TOUCH_ROTATE)===D.TOUCH_ROTATE||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_ZOOM_ROTATE)===D.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&D.TRUCK)===D.TRUCK||(this._state&D.TOUCH_TRUCK)===D.TOUCH_TRUCK||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&D.DOLLY)===D.DOLLY||(this._state&D.TOUCH_DOLLY)===D.TOUCH_DOLLY||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&D.ZOOM)===D.ZOOM||(this._state&D.TOUCH_ZOOM)===D.TOUCH_ZOOM||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET||(this._state&D.TOUCH_ZOOM_ROTATE)===D.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&D.OFFSET)===D.OFFSET||(this._state&D.TOUCH_OFFSET)===D.TOUCH_OFFSET||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},x=()=>{if(!this._enabled)return;Pt(this._activePointers,pe);const A=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=A?-A.deltaX:s.x-pe.x,w=A?-A.deltaY:s.y-pe.y;if(s.copy(pe),((this._state&D.ROTATE)===D.ROTATE||(this._state&D.TOUCH_ROTATE)===D.TOUCH_ROTATE||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_ZOOM_ROTATE)===D.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,w),this._isUserControllingRotate=!0),(this._state&D.DOLLY)===D.DOLLY||(this._state&D.ZOOM)===D.ZOOM){const v=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,C=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,k=this.dollyDragInverted?-1:1;(this._state&D.DOLLY)===D.DOLLY?(this._dollyInternal(k*w*at,v,C),this._isUserControllingDolly=!0):(this._zoomInternal(k*w*at,v,C),this._isUserControllingZoom=!0)}if((this._state&D.TOUCH_DOLLY)===D.TOUCH_DOLLY||(this._state&D.TOUCH_ZOOM)===D.TOUCH_ZOOM||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_ZOOM_ROTATE)===D.TOUCH_ZOOM_ROTATE){const v=pe.x-this._activePointers[1].clientX,C=pe.y-this._activePointers[1].clientY,k=Math.sqrt(v*v+C*C),I=o.y-k;o.set(0,k);const U=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,j=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&D.TOUCH_DOLLY)===D.TOUCH_DOLLY||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*at,U,j),this._isUserControllingDolly=!0):(this._zoomInternal(I*at,U,j),this._isUserControllingZoom=!0)}((this._state&D.TRUCK)===D.TRUCK||(this._state&D.TOUCH_TRUCK)===D.TOUCH_TRUCK||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,w,!1),this._isUserControllingTruck=!0),((this._state&D.OFFSET)===D.OFFSET||(this._state&D.TOUCH_OFFSET)===D.TOUCH_OFFSET||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,w,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},S=()=>{Pt(this._activePointers,pe),s.copy(pe),(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",p),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",O),this._domElement.ownerDocument.addEventListener("pointerlockerror",M),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),_())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",O),this._domElement.ownerDocument.removeEventListener("pointerlockerror",M))};const O=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},M=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",i),Ii&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",m,{passive:!1}),this._domElement.addEventListener("contextmenu",y)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",i),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",m,{passive:!1}),this._domElement.removeEventListener("contextmenu",y),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.removeEventListener("pointerlockchange",O),this._domElement.ownerDocument.removeEventListener("pointerlockerror",M))},this.cancel=()=>{this._state!==D.NONE&&(this._state=D.NONE,this._activePointers.length=0,S())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=xe(e.width,0,1),this._interactiveArea.height=xe(e.height,0,1),this._interactiveArea.x=xe(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=xe(e.x,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const s=xe(e,this.minAzimuthAngle,this.maxAzimuthAngle),o=xe(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=o,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const i=!n||J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(i)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0,this._dollyToNoClamp(xe(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const i=this._collisionTest(),r=J(i,this._spherical.radius);if(!(n>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,i)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const o=!t||J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(et).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=xe(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||J(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),Me.setFromMatrixColumn(this._camera.matrix,0),be.setFromMatrixColumn(this._camera.matrix,1),Me.multiplyScalar(e),be.multiplyScalar(-t);const s=R.copy(Me).add(be),o=W.copy(this._targetEnd).add(s);return this.moveTo(o.x,o.y,o.z,n)}forward(e,t=!1){R.setFromMatrixColumn(this._camera.matrix,0),R.crossVectors(this._camera.up,R),R.multiplyScalar(e);const n=W.copy(this._targetEnd).add(R);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return R.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+R.x,this._targetEnd.y+R.y,this._targetEnd.z+R.z,t)}moveTo(e,t,n,s=!1){this._isUserControllingTruck=!1;const o=R.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,o,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const i=!s||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}lookInDirectionOf(e,t,n,s=!1){const r=R.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,s)}fitToBox(e,t,{cover:n=!1,paddingLeft:s=0,paddingRight:o=0,paddingBottom:i=0,paddingTop:r=0}={}){const a=[],u=e.isBox3?Qe.copy(e):Qe.setFromObject(e);u.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const d=xn(this._sphericalEnd.theta,vn),p=xn(this._sphericalEnd.phi,vn);a.push(this.rotateTo(d,p,t));const f=R.setFromSpherical(this._sphericalEnd).normalize(),m=Pn.setFromUnitVectors(f,Dt),y=J(Math.abs(f.y),1);y&&m.multiply(kt.setFromAxisAngle(lt,d)),m.multiply(this._yAxisUpSpaceInverse);const _=On.makeEmpty();W.copy(u.min).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setX(u.max.x).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setY(u.max.y).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setZ(u.min.z).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setZ(u.max.z).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setY(u.min.y).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setX(u.min.x).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).applyQuaternion(m),_.expandByPoint(W),_.min.x-=s,_.min.y-=i,_.max.x+=o,_.max.y+=r,m.setFromUnitVectors(Dt,f),y&&m.premultiply(kt.invert()),m.premultiply(this._yAxisUpSpace);const x=_.getSize(R),S=_.getCenter(W).applyQuaternion(m);if(Ve(this._camera)){const O=this.getDistanceToFitBox(x.x,x.y,x.z,n);a.push(this.moveTo(S.x,S.y,S.z,t)),a.push(this.dollyTo(O,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(ke(this._camera)){const O=this._camera,M=O.right-O.left,g=O.top-O.bottom,A=n?Math.max(M/x.x,g/x.y):Math.min(M/x.x,g/x.y);a.push(this.moveTo(S.x,S.y,S.z,t)),a.push(this.zoomTo(A,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const n=[],o=e instanceof V.Sphere?It.copy(e):nt.createBoundingSphere(e,It);if(n.push(this.moveTo(o.center.x,o.center.y,o.center.z,t)),Ve(this._camera)){const i=this.getDistanceToFitSphere(o.radius);n.push(this.dollyTo(i,t))}else if(ke(this._camera)){const i=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*o.radius,u=Math.min(i/a,r/a);n.push(this.zoomTo(u,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,s,o,i,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const a=W.set(s,o,i),u=R.set(e,t,n);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(u.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const d=!r||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(d)}lerpLookAt(e,t,n,s,o,i,r,a,u,d,p,f,m,y=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const _=R.set(s,o,i),x=W.set(e,t,n);ge.setFromVector3(x.sub(_).applyQuaternion(this._yAxisUpSpace));const S=Ze.set(d,p,f),O=W.set(r,a,u);tt.setFromVector3(O.sub(S).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(S,m));const M=tt.theta-ge.theta,g=tt.phi-ge.phi,A=tt.radius-ge.radius;this._sphericalEnd.set(ge.radius+A*m,ge.phi+g*m,ge.theta+M*m),this.normalizeRotations(),this._needsUpdate=!0,y||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const b=!y||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(b)}setPosition(e,t,n,s=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,n,s=!1){const o=this.getPosition(R),i=this.setLookAt(o.x,o.y,o.z,e,t,n,s);return this._sphericalEnd.phi=xe(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),i}setFocalOffset(e,t,n,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const o=!s||J(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&J(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&J(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Me.setFromMatrixColumn(this._camera.matrixWorldInverse,0),be.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ne.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=R.set(e,t,n),o=s.distanceTo(this._camera.position),i=s.sub(this._camera.position);Me.multiplyScalar(i.x),be.multiplyScalar(i.y),Ne.multiplyScalar(i.z),R.copy(Me).add(be).add(Ne),R.z=R.z+o,this.dollyTo(o,!1),this.setFocalOffset(-R.x,R.y,-R.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,s){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new V.Vector4,typeof e=="number"?this._viewport.set(e,t,n,s):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,s=!1){if(Ct(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=e/t,i=this._camera.getEffectiveFOV()*Je,r=this._camera.aspect;return((s?o>r:o<r)?t:e/r)*.5/Math.tan(i*.5)+n*.5}getDistanceToFitSphere(e){if(Ct(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Je,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,s=1<this._camera.aspect?t:n;return e/Math.sin(s*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof V.Spherical?e:new V.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Xe,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Xe),this._spherical.theta+=Xe*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Xe)}reset(e=!1){if(!J(this._camera.up.x,this._cameraUp0.x)||!J(this._camera.up.y,this._cameraUp0.y)||!J(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(R);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,lt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=R.subVectors(this._target,this._camera.position).normalize(),t=W.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e),this._camera.updateMatrixWorld();const n=this.getPosition(R);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,o=Sn.subVectors(this._targetEnd,this._target),i=Ln.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=rt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,e),this._needsUpdate=!0}if(te(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=rt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,e),this._needsUpdate=!0}if(te(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=rt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,e),this._needsUpdate=!0}if(te(o.x)&&te(o.y)&&te(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Mn(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(te(i.x)&&te(i.y)&&te(i.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Mn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(te(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=rt(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,e)}if(this.dollyToCursor){if(Ve(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,f=this._camera,m=this._getCameraDirection(et),y=R.copy(m).cross(f.up).normalize();y.lengthSq()===0&&(y.x=1);const _=W.crossVectors(y,m),x=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Je*.5),O=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,M=Ze.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*x*f.aspect)).add(_.multiplyScalar(this._dollyControlCoord.y*x)),g=R.copy(this._targetEnd).lerp(M,O),A=this._lastDollyDirection===Ye.IN&&this._spherical.radius<=this.minDistance,b=this._lastDollyDirection===Ye.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(A||b)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const v=W.copy(m).multiplyScalar(-p);g.add(v)}this._boundary.clampPoint(g,g);const w=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(w),this._changedDolly-=p,te(this._changedDolly)&&(this._changedDolly=0)}else if(ke(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,f=this._camera,m=R.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),y=W.set(0,0,-1).applyQuaternion(f.quaternion),_=Ze.copy(m).add(y.multiplyScalar(-m.dot(f.up))),S=-(this._zoom-p-this._zoom)/this._zoom,O=this._getCameraDirection(et),M=this._targetEnd.dot(O),g=R.copy(this._targetEnd).lerp(_,S),A=g.dot(O),b=O.multiplyScalar(A-M);g.sub(b),this._boundary.clampPoint(g,g);const w=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(w),this._changedZoom-=p,te(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0);const a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!te(this._focalOffset.x)||!te(this._focalOffset.y)||!te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Me.setFromMatrixColumn(this._camera.matrix,0),be.setFromMatrixColumn(this._camera.matrix,1),Ne.setFromMatrixColumn(this._camera.matrix,2),Me.multiplyScalar(this._focalOffset.x),be.multiplyScalar(-this._focalOffset.y),Ne.multiplyScalar(this._focalOffset.z),R.copy(Me).add(be).add(Ne),this._camera.position.add(R)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),R.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const d=this._needsUpdate;return d&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):d?(this.dispatchEvent({type:"update"}),te(t,this.restThreshold)&&te(n,this.restThreshold)&&te(s,this.restThreshold)&&te(o.x,this.restThreshold)&&te(o.y,this.restThreshold)&&te(o.z,this.restThreshold)&&te(i.x,this.restThreshold)&&te(i.y,this.restThreshold)&&te(i.z,this.restThreshold)&&te(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!d&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=d,this._needsUpdate=!1,d}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:He(this.maxDistance),minZoom:this.minZoom,maxZoom:He(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:He(this.maxPolarAngle),minAzimuthAngle:He(this.minAzimuthAngle),maxAzimuthAngle:He(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:R.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=$e(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=$e(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=$e(n.maxPolarAngle),this.minAzimuthAngle=$e(n.minAzimuthAngle),this.maxAzimuthAngle=$e(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),ge.setFromVector3(R.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ge.theta,ge.phi,t),this.dollyTo(ge.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",Ci),this._addAllEventListeners(e)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const s=t.lengthSq();if(s===0)return e;const o=W.copy(t).add(e),r=this._boundary.clampPoint(o,Ze).sub(o),a=r.lengthSq();if(a===0)return e.add(t);if(a===s)return e;if(n===0)return e.add(t).add(r);{const u=1+n*a/t.dot(r);return e.add(W.copy(t).multiplyScalar(u)).add(r.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Ve(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Je,s=Math.tan(n*.5)*t,o=s*e.aspect;this._nearPlaneCorners[0].set(-o,-s,0),this._nearPlaneCorners[1].set(o,-s,0),this._nearPlaneCorners[2].set(o,s,0),this._nearPlaneCorners[3].set(-o,s,0)}else if(ke(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,s=e.right*t,o=e.top*t,i=e.bottom*t;this._nearPlaneCorners[0].set(n,o,0),this._nearPlaneCorners[1].set(s,o,0),this._nearPlaneCorners[2].set(s,i,0),this._nearPlaneCorners[3].set(n,i,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Ct(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(et);Ft.lookAt(Tn,n,this._camera.up);for(let s=0;s<4;s++){const o=W.copy(this._nearPlaneCorners[s]);o.applyMatrix4(Ft);const i=Ze.addVectors(this._target,o);ct.set(i,n),ct.far=this._spherical.radius+1;const r=ct.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<e&&(e=r[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new V.Sphere){const n=t,s=n.center;Qe.makeEmpty(),e.traverseVisible(i=>{i.isMesh&&Qe.expandByObject(i)}),Qe.getCenter(s);let o=0;return e.traverseVisible(i=>{if(!i.isMesh)return;const r=i,a=r.geometry.clone();a.applyMatrix4(r.matrixWorld);const d=a.attributes.position;for(let p=0,f=d.count;p<f;p++)R.fromBufferAttribute(d,p),o=Math.max(o,s.distanceToSquared(R))}),n.radius=Math.sqrt(o),n}}const ki=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args"],Fi=h.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},minDistance:{default:Number.EPSILON},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{},touches:{}},emits:["change","start","end"],setup(c,{expose:e,emit:t}){const n=c,{makeDefault:s,minPolarAngle:o,maxPolarAngle:i,minAzimuthAngle:r,maxAzimuthAngle:a,minDistance:u,maxDistance:d,infinityDolly:p,minZoom:f,maxZoom:m,smoothTime:y,draggingSmoothTime:_,maxSpeed:x,azimuthRotateSpeed:S,polarRotateSpeed:O,dollySpeed:M,dollyDragInverted:g,truckSpeed:A,dollyToCursor:b,dragToOffset:w,verticalDragToForward:v,boundaryFriction:C,restThreshold:k,colliderMeshes:I}=h.toRefs(n),U={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};nt.install({THREE:U});const{camera:j,renderer:H,extend:G,controls:ne}=q.useTresContext(),X=h.ref(null);G({CameraControls:nt}),h.watchEffect(()=>{ae(),X.value&&s.value?ne.value=X.value:ne.value=null});function ae(){oe(X.value,"update",()=>t("change",X.value)),oe(X.value,"controlend",()=>t("end",X.value)),oe(X.value,"controlstart",()=>t("start",X.value))}const{onLoop:re}=q.useRenderLoop();return re(({delta:$})=>{var Q,K;(Q=X.value)!=null&&Q.enabled&&((K=X.value)==null||K.update($))}),h.onUnmounted(()=>{X.value&&X.value.disconnect()}),e({value:X}),($,Q)=>{var K;return h.unref(j)&&h.unref(H)?(h.openBlock(),h.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:X,"min-polar-angle":h.unref(o),"max-polar-angle":h.unref(i),"min-azimuth-angle":h.unref(r),"max-azimuth-angle":h.unref(a),"min-distance":h.unref(u),"max-distance":h.unref(d),"infinity-dolly":h.unref(p),"min-zoom":h.unref(f),"max-zoom":h.unref(m),"smooth-time":h.unref(y),"dragging-smooth-time":h.unref(_),"max-speed":h.unref(x),"azimuth-rotate-speed":h.unref(S),"polar-rotate-speed":h.unref(O),"dolly-speed":h.unref(M),"dolly-drag-inverted":h.unref(g),"truck-speed":h.unref(A),"dolly-to-cursor":h.unref(b),"drag-to-offset":h.unref(w),"vertical-drag-to-forward":h.unref(v),"boundary-friction":h.unref(C),"rest-threshold":h.unref(k),"collider-meshes":h.unref(I),args:[h.unref(j)||$.camera,((K=h.unref(H))==null?void 0:K.domElement)||$.domElement]},null,8,ki)):h.createCommentVNode("",!0)}}});class Ui extends l.MeshStandardMaterial{constructor(t={}){super(t);Nt(this,"_time");Nt(this,"_factor");this.setValues(t),this._time={value:0},this._factor={value:1}}onBeforeCompile(t){t.uniforms||(t.uniforms={}),t.uniforms.time=this._time,t.uniforms.factor=this._factor,t.vertexShader=`
|
|
87
87
|
uniform float time;
|
|
88
88
|
uniform float factor;
|
|
89
|
-
${
|
|
90
|
-
`,
|
|
89
|
+
${t.vertexShader}
|
|
90
|
+
`,t.vertexShader=t.vertexShader.replace("#include <begin_vertex>",`float theta = sin( time + position.y ) / 2.0 * factor;
|
|
91
91
|
float c = cos( theta );
|
|
92
92
|
float s = sin( theta );
|
|
93
93
|
mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
|
|
94
94
|
vec3 transformed = vec3( position ) * m;
|
|
95
|
-
vNormal = vNormal * m;`)}get time(){return this._time.value}set time(n){this._time.value=n}get factor(){return this._factor.value}set factor(n){this._factor.value=n}}const Oh=["factor"],Dh=_.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(v){const t=v,n=_.shallowRef(),{extend:i}=Ae.useTresContext();i({MeshWobbleMaterial:Eh});const{onLoop:o}=Ae.useRenderLoop();return o(({elapsed:a})=>{n.value&&(n.value.time=a*(t==null?void 0:t.speed))}),(a,c)=>(_.openBlock(),_.createElementBlock("TresMeshWobbleMaterial",_.mergeProps({ref_key:"materialRef",ref:n,factor:a.factor},a.$attrs),null,16,Oh))}}),Vh=["args"],Ih=["color"],Bh=_.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"boxRef",ref:a},c.$attrs),[_.createElementVNode("TresBoxGeometry",{args:_.unref(i)},null,8,Vh),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,Ih)])],16))}}),Fh=["args"],Nh=["color"],Uh=_.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"circleRef",ref:a},c.$attrs),[_.createElementVNode("TresCircleGeometry",{args:_.unref(i)},null,8,Fh),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,Nh)])],16))}}),zh=["args"],Rh=["color"],jh=_.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"coneRef",ref:a},c.$attrs),[_.createElementVNode("TresConeGeometry",{args:_.unref(i)},null,8,zh),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,Rh)])],16))}}),Gh=["args"],Kh=["color"],Yh=_.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"dodecahedronRef",ref:a},c.$attrs),[_.createElementVNode("TresDodecahedronGeometry",{args:_.unref(i)},null,8,Gh),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,Kh)])],16))}}),Xh=["args"],Zh=["color"],qh=_.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"icosahedronRef",ref:a},c.$attrs),[_.createElementVNode("TresIcosahedronGeometry",{args:_.unref(i)},null,8,Xh),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,Zh)])],16))}}),Qh=["args"],Wh=["color"],Jh=_.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"octahedronRef",ref:a},c.$attrs),[_.createElementVNode("TresOctahedronGeometry",{args:_.unref(i)},null,8,Qh),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,Wh)])],16))}}),Hh=["rotation"],$h=["args"],ep=["color"],tp=_.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"planeRef",ref:a,rotation:[-Math.PI/2,0,0]},c.$attrs),[_.createElementVNode("TresPlaneGeometry",{args:_.unref(i)},null,8,$h),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,ep)])],16,Hh))}}),np=["args"],sp=["color"],ip=_.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"ringRef",ref:a},c.$attrs),[_.createElementVNode("TresRingGeometry",{args:_.unref(i)},null,8,np),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,sp)])],16))}}),rp=["args"],op=["color"],ap=_.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"sphereRef",ref:a},c.$attrs),[_.createElementVNode("TresSphereGeometry",{args:_.unref(i)},null,8,rp),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,op)])],16))}}),lp=["rotation"],cp=["args"],hp=["color"],pp=_.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"tetrahedronRef",ref:a,rotation:[-Math.PI/2,0,0]},c.$attrs),[_.createElementVNode("TresTetrahedronGeometry",{args:_.unref(i)},null,8,cp),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,hp)])],16,lp))}}),up=["args"],dp=["color"],mp=_.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"torusRef",ref:a},c.$attrs),[_.createElementVNode("TresTorusGeometry",{args:_.unref(i)},null,8,up),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,dp)])],16))}}),fp=["args"],vp=["color"],_p=_.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"torusKnotRef",ref:a},c.$attrs),[_.createElementVNode("TresTorusKnotGeometry",{args:_.unref(i)},null,8,fp),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,vp)])],16))}}),gp=["args"],bp=["color"],wp=_.defineComponent({__name:"Tube",props:{args:{default:()=>[new m.QuadraticBezierCurve3(new m.Vector3(-1,0,0),new m.Vector3(0,1,0),new m.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(v,{expose:t}){const n=v,{args:i,color:o}=_.toRefs(n),a=_.shallowRef();return t({value:a}),(c,p)=>(_.openBlock(),_.createElementBlock("TresMesh",_.mergeProps({ref_key:"tubeRef",ref:a},c.$attrs),[_.createElementVNode("TresTubeGeometry",{args:_.unref(i)},null,8,gp),_.renderSlot(c.$slots,"default",{},()=>[_.createElementVNode("TresMeshBasicMaterial",{color:_.unref(o)},null,8,bp)])],16))}}),yp=["receive-shadow","rotation"],xp=["args"],Cp=_.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Pp=_.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(v){const t=v,n=p=>p===0?0:Math.pow(2,10*p-10),{floor:i,segments:o,receiveShadow:a}=_.toRefs(t),c=_.ref(null);return _.watch(()=>[o.value,i.value,c.value],([p,d,g])=>{if(!g||p===null)return;let y=0;const b=p/p/2,C=g.attributes.position;for(let A=0;A<p+1;A++)for(let E=0;E<p+1;E++)C.setXYZ(y++,A/p-b+(A===0?-d:0),E/p-b,n(A/p));C.needsUpdate=!0,g.computeVertexNormals()}),(p,d)=>(_.openBlock(),_.createElementBlock("TresGroup",_.normalizeProps(_.guardReactiveProps(p.$attrs)),[_.createElementVNode("TresMesh",{"receive-shadow":_.unref(a),rotation:[-Math.PI/2,0,Math.PI/2]},[_.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:c,args:[1,1,_.unref(o),_.unref(o)]},null,8,xp),_.renderSlot(p.$slots,"default",{},()=>[Cp])],8,yp)],16))}});var sr={exports:{}};/*! Tweakpane 3.1.10 (c) 2016 cocopon, licensed under the MIT license. */(function(v,t){(function(n,i){i(t)})(Io,function(n){class i{constructor(e){const[s,h]=e.split("-"),x=s.split(".");this.major=parseInt(x[0],10),this.minor=parseInt(x[1],10),this.patch=parseInt(x[2],10),this.prerelease=h??null}toString(){const e=[this.major,this.minor,this.patch].join(".");return this.prerelease!==null?[e,this.prerelease].join("-"):e}}class o{constructor(e){this.controller_=e}get element(){return this.controller_.view.element}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(e){this.controller_.viewProps.set("disabled",e)}get hidden(){return this.controller_.viewProps.get("hidden")}set hidden(e){this.controller_.viewProps.set("hidden",e)}dispose(){this.controller_.viewProps.set("disposed",!0)}}class a{constructor(e){this.target=e}}class c extends a{constructor(e,s,h,x){super(e),this.value=s,this.presetKey=h,this.last=x??!0}}class p extends a{constructor(e,s,h){super(e),this.value=s,this.presetKey=h}}class d extends a{constructor(e,s){super(e),this.expanded=s}}class g extends a{constructor(e,s){super(e),this.index=s}}function y(r){return r}function b(r){return r==null}function C(r,e){if(r.length!==e.length)return!1;for(let s=0;s<r.length;s++)if(r[s]!==e[s])return!1;return!0}function A(r,e){let s=r;do{const h=Object.getOwnPropertyDescriptor(s,e);if(h&&(h.set!==void 0||h.writable===!0))return!0;s=Object.getPrototypeOf(s)}while(s!==null);return!1}const E={alreadydisposed:()=>"View has been already disposed",invalidparams:r=>`Invalid parameters for '${r.name}'`,nomatchingcontroller:r=>`No matching controller for '${r.key}'`,nomatchingview:r=>`No matching view for '${JSON.stringify(r.params)}'`,notbindable:()=>"Value is not bindable",propertynotfound:r=>`Property '${r.name}' not found`,shouldneverhappen:()=>"This error should never happen"};class k{static alreadyDisposed(){return new k({type:"alreadydisposed"})}static notBindable(){return new k({type:"notbindable"})}static propertyNotFound(e){return new k({type:"propertynotfound",context:{name:e}})}static shouldNeverHappen(){return new k({type:"shouldneverhappen"})}constructor(e){var s;this.message=(s=E[e.type](e.context))!==null&&s!==void 0?s:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=e.type}}class O{constructor(e,s,h){this.obj_=e,this.key_=s,this.presetKey_=h??s}static isBindable(e){return!(e===null||typeof e!="object"&&typeof e!="function")}get key(){return this.key_}get presetKey(){return this.presetKey_}read(){return this.obj_[this.key_]}write(e){this.obj_[this.key_]=e}writeProperty(e,s){const h=this.read();if(!O.isBindable(h))throw k.notBindable();if(!(e in h))throw k.propertyNotFound(e);h[e]=s}}class R extends o{get label(){return this.controller_.props.get("label")}set label(e){this.controller_.props.set("label",e)}get title(){var e;return(e=this.controller_.valueController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.valueController.props.set("title",e)}on(e,s){const h=s.bind(this);return this.controller_.valueController.emitter.on(e,()=>{h(new a(this))}),this}}class N{constructor(){this.observers_={}}on(e,s){let h=this.observers_[e];return h||(h=this.observers_[e]=[]),h.push({handler:s}),this}off(e,s){const h=this.observers_[e];return h&&(this.observers_[e]=h.filter(x=>x.handler!==s)),this}emit(e,s){const h=this.observers_[e];h&&h.forEach(x=>{x.handler(s)})}}const F="tp";function M(r){return(s,h)=>[F,"-",r,"v",s?`_${s}`:"",h?`-${h}`:""].join("")}function D(r,e){return s=>e(r(s))}function U(r){return r.rawValue}function S(r,e){r.emitter.on("change",D(U,e)),e(r.rawValue)}function T(r,e,s){S(r.value(e),s)}function j(r,e,s){s?r.classList.add(e):r.classList.remove(e)}function X(r,e){return s=>{j(r,e,s)}}function Z(r,e){S(r,s=>{e.textContent=s??""})}const J=M("btn");class le{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(J()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("button");h.classList.add(J("b")),s.viewProps.bindDisabled(h),this.element.appendChild(h),this.buttonElement=h;const x=e.createElement("div");x.classList.add(J("t")),Z(s.props.value("title"),x),this.buttonElement.appendChild(x)}}class he{constructor(e,s){this.emitter=new N,this.onClick_=this.onClick_.bind(this),this.props=s.props,this.viewProps=s.viewProps,this.view=new le(e,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class oe{constructor(e,s){var h;this.constraint_=s==null?void 0:s.constraint,this.equals_=(h=s==null?void 0:s.equals)!==null&&h!==void 0?h:(x,L)=>x===L,this.emitter=new N,this.rawValue_=e}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,s){const h=s??{forceEmit:!1,last:!0},x=this.constraint_?this.constraint_.constrain(e):e,L=this.rawValue_;this.equals_(L,x)&&!h.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=x,this.emitter.emit("change",{options:h,previousRawValue:L,rawValue:x,sender:this}))}}class re{constructor(e){this.emitter=new N,this.value_=e}get rawValue(){return this.value_}set rawValue(e){this.setRawValue(e,{forceEmit:!1,last:!0})}setRawValue(e,s){const h=s??{forceEmit:!1,last:!0},x=this.value_;x===e&&!h.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=e,this.emitter.emit("change",{options:h,previousRawValue:x,rawValue:this.value_,sender:this}))}}function ne(r,e){const s=e==null?void 0:e.constraint,h=e==null?void 0:e.equals;return!s&&!h?new re(r):new oe(r,e)}class H{constructor(e){this.emitter=new N,this.valMap_=e;for(const s in this.valMap_)this.valMap_[s].emitter.on("change",()=>{this.emitter.emit("change",{key:s,sender:this})})}static createCore(e){return Object.keys(e).reduce((h,x)=>Object.assign(h,{[x]:ne(e[x])}),{})}static fromObject(e){const s=this.createCore(e);return new H(s)}get(e){return this.valMap_[e].rawValue}set(e,s){this.valMap_[e].rawValue=s}value(e){return this.valMap_[e]}}function Ce(r,e){const h=Object.keys(e).reduce((x,L)=>{if(x===void 0)return;const I=e[L],q=I(r[L]);return q.succeeded?Object.assign(Object.assign({},x),{[L]:q.value}):void 0},{});return h}function ge(r,e){return r.reduce((s,h)=>{if(s===void 0)return;const x=e(h);if(!(!x.succeeded||x.value===void 0))return[...s,x.value]},[])}function de(r){return r===null?!1:typeof r=="object"}function me(r){return e=>s=>{if(!e&&s===void 0)return{succeeded:!1,value:void 0};if(e&&s===void 0)return{succeeded:!0,value:void 0};const h=r(s);return h!==void 0?{succeeded:!0,value:h}:{succeeded:!1,value:void 0}}}function ke(r){return{custom:e=>me(e)(r),boolean:me(e=>typeof e=="boolean"?e:void 0)(r),number:me(e=>typeof e=="number"?e:void 0)(r),string:me(e=>typeof e=="string"?e:void 0)(r),function:me(e=>typeof e=="function"?e:void 0)(r),constant:e=>me(s=>s===e?e:void 0)(r),raw:me(e=>e)(r),object:e=>me(s=>{if(de(s))return Ce(s,e)})(r),array:e=>me(s=>{if(Array.isArray(s))return ge(s,e)})(r)}}const B={optional:ke(!0),required:ke(!1)};function we(r,e){const s=B.required.object(e)(r);return s.succeeded?s.value:void 0}function ze(r){console.warn([`Missing '${r.key}' of ${r.target} in ${r.place}.`,"Please rebuild plugins with the latest core package."].join(" "))}function Ge(r){return r&&r.parentElement&&r.parentElement.removeChild(r),null}class Te{constructor(e){this.value_=e}static create(e){return[new Te(e),(s,h)=>{e.setRawValue(s,h)}]}get emitter(){return this.value_.emitter}get rawValue(){return this.value_.rawValue}}const lt=M("");function Gn(r,e){return X(r,lt(void 0,e))}class He extends H{constructor(e){var s;super(e),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=Te.create(ne(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(s=this.get("parent"))===null||s===void 0||s.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(e){var s,h,x;const L=e??{};return new He(H.createCore({disabled:(s=L.disabled)!==null&&s!==void 0?s:!1,disposed:!1,hidden:(h=L.hidden)!==null&&h!==void 0?h:!1,parent:(x=L.parent)!==null&&x!==void 0?x:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(e){S(this.globalDisabled_,Gn(e,"disabled")),T(this,"hidden",Gn(e,"hidden"))}bindDisabled(e){S(this.globalDisabled_,s=>{e.disabled=s})}bindTabIndex(e){S(this.globalDisabled_,s=>{e.tabIndex=s?-1:0})}handleDispose(e){this.value("disposed").emitter.on("change",s=>{s&&e()})}getGlobalDisabled_(){const e=this.get("parent");return(e?e.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(e){var s;const h=e.previousRawValue;h==null||h.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(s=this.get("parent"))===null||s===void 0||s.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}function Kn(){return["veryfirst","first","last","verylast"]}const un=M(""),gt={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class Et{constructor(e){this.parent_=null,this.blade=e.blade,this.view=e.view,this.viewProps=e.viewProps;const s=this.view.element;this.blade.value("positions").emitter.on("change",()=>{Kn().forEach(h=>{s.classList.remove(un(void 0,gt[h]))}),this.blade.get("positions").forEach(h=>{s.classList.add(un(void 0,gt[h]))})}),this.viewProps.handleDispose(()=>{Ge(s)})}get parent(){return this.parent_}set parent(e){if(this.parent_=e,!("parent"in this.viewProps.valMap_)){ze({key:"parent",target:He.name,place:"BladeController.parent"});return}this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}}const Ye="http://www.w3.org/2000/svg";function ct(r){r.offsetHeight}function dn(r,e){const s=r.style.transition;r.style.transition="none",e(),r.style.transition=s}function bt(r){return r.ontouchstart!==void 0}function Yn(){return globalThis}function ws(){return Yn().document}function Xn(r){const e=r.ownerDocument.defaultView;return e&&"document"in e?r.getContext("2d",{willReadFrequently:!0}):null}const Zn={check:'<path d="M2 8l4 4l8 -8"/>',dropdown:'<path d="M5 7h6l-3 3 z"/>',p2dpad:'<path d="M8 4v8"/><path d="M4 8h8"/><circle cx="12" cy="12" r="1.2"/>'};function Mt(r,e){const s=r.createElementNS(Ye,"svg");return s.innerHTML=Zn[e],s}function Ot(r,e,s){r.insertBefore(e,r.children[s])}function qn(r){r.parentElement&&r.parentElement.removeChild(r)}function mn(r){for(;r.children.length>0;)r.removeChild(r.children[0])}function Qn(r){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])}function kt(r){return r.relatedTarget?r.relatedTarget:"explicitOriginalTarget"in r?r.explicitOriginalTarget:null}const wt=M("lbl");function Dt(r,e){const s=r.createDocumentFragment();return e.split(`
|
|
96
|
-
`).map(x=>r.createTextNode(x)).forEach((x,L)=>{L>0&&s.appendChild(r.createElement("br")),s.appendChild(x)}),s}class z{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(wt()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("div");h.classList.add(wt("l")),T(s.props,"label",L=>{b(L)?this.element.classList.add(wt(void 0,"nol")):(this.element.classList.remove(wt(void 0,"nol")),Qn(h),h.appendChild(Dt(e,L)))}),this.element.appendChild(h),this.labelElement=h;const x=e.createElement("div");x.classList.add(wt("v")),this.element.appendChild(x),this.valueElement=x}}class W extends Et{constructor(e,s){const h=s.valueController.viewProps;super(Object.assign(Object.assign({},s),{view:new z(e,{props:s.props,viewProps:h}),viewProps:h})),this.props=s.props,this.valueController=s.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}}const ae={id:"button",type:"blade",accept(r){const e=B,s=we(r,{title:e.required.string,view:e.required.constant("button"),label:e.optional.string});return s?{params:s}:null},controller(r){return new W(r.document,{blade:r.blade,props:H.fromObject({label:r.params.label}),valueController:new he(r.document,{props:H.fromObject({title:r.params.title}),viewProps:r.viewProps})})},api(r){return!(r.controller instanceof W)||!(r.controller.valueController instanceof he)?null:new R(r.controller)}};class fe extends Et{constructor(e){super(e),this.value=e.value}}function Oe(){return new H({positions:ne([],{equals:C})})}class je extends H{constructor(e){super(e)}static create(e){const s={completed:!0,expanded:e,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},h=H.createCore(s);return new je(h)}get styleExpanded(){var e;return(e=this.get("temporaryExpanded"))!==null&&e!==void 0?e:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const e=this.get("expandedHeight");return this.get("shouldFixHeight")&&!b(e)?`${e}px`:"auto"}bindExpandedClass(e,s){const h=()=>{this.styleExpanded?e.classList.add(s):e.classList.remove(s)};T(this,"expanded",h),T(this,"temporaryExpanded",h)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function qt(r,e){let s=0;return dn(e,()=>{r.set("expandedHeight",null),r.set("temporaryExpanded",!0),ct(e),s=e.clientHeight,r.set("temporaryExpanded",null),ct(e)}),s}function fn(r,e){e.style.height=r.styleHeight}function Xe(r,e){r.value("expanded").emitter.on("beforechange",()=>{if(r.set("completed",!1),b(r.get("expandedHeight"))){const s=qt(r,e);s>0&&r.set("expandedHeight",s)}r.set("shouldFixHeight",!0),ct(e)}),r.emitter.on("change",()=>{fn(r,e)}),fn(r,e),e.addEventListener("transitionend",s=>{s.propertyName==="height"&&r.cleanUpTransition()})}class Ze extends o{constructor(e,s){super(e),this.rackApi_=s}}function rr(r,e){return r.addBlade(Object.assign(Object.assign({},e),{view:"button"}))}function or(r,e){return r.addBlade(Object.assign(Object.assign({},e),{view:"folder"}))}function ar(r,e){const s=e??{};return r.addBlade(Object.assign(Object.assign({},s),{view:"separator"}))}function ys(r,e){return r.addBlade(Object.assign(Object.assign({},e),{view:"tab"}))}class Vt{constructor(e){this.emitter=new N,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=e}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(e){for(const s of this.allItems())if(e(s))return s;return null}includes(e){return this.cache_.has(e)}add(e,s){if(this.includes(e))throw k.shouldNeverHappen();const h=s!==void 0?s:this.items_.length;this.items_.splice(h,0,e),this.cache_.add(e);const x=this.extract_(e);x&&(x.emitter.on("add",this.onSubListAdd_),x.emitter.on("remove",this.onSubListRemove_),x.allItems().forEach(L=>{this.cache_.add(L)})),this.emitter.emit("add",{index:h,item:e,root:this,target:this})}remove(e){const s=this.items_.indexOf(e);if(s<0)return;this.items_.splice(s,1),this.cache_.delete(e);const h=this.extract_(e);h&&(h.emitter.off("add",this.onSubListAdd_),h.emitter.off("remove",this.onSubListRemove_)),this.emitter.emit("remove",{index:s,item:e,root:this,target:this})}onSubListAdd_(e){this.cache_.add(e.item),this.emitter.emit("add",{index:e.index,item:e.item,root:this,target:e.target})}onSubListRemove_(e){this.cache_.delete(e.item),this.emitter.emit("remove",{index:e.index,item:e.item,root:this,target:e.target})}}class xs extends o{constructor(e){super(e),this.onBindingChange_=this.onBindingChange_.bind(this),this.emitter_=new N,this.controller_.binding.emitter.on("change",this.onBindingChange_)}get label(){return this.controller_.props.get("label")}set label(e){this.controller_.props.set("label",e)}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}refresh(){this.controller_.binding.read()}onBindingChange_(e){const s=e.sender.target.read();this.emitter_.emit("change",{event:new c(this,s,this.controller_.binding.target.presetKey,e.options.last)})}}class Ke extends W{constructor(e,s){super(e,s),this.binding=s.binding}}class Cs extends o{constructor(e){super(e),this.onBindingUpdate_=this.onBindingUpdate_.bind(this),this.emitter_=new N,this.controller_.binding.emitter.on("update",this.onBindingUpdate_)}get label(){return this.controller_.props.get("label")}set label(e){this.controller_.props.set("label",e)}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}refresh(){this.controller_.binding.read()}onBindingUpdate_(e){const s=e.sender.target.read();this.emitter_.emit("update",{event:new p(this,s,this.controller_.binding.target.presetKey)})}}class ht extends W{constructor(e,s){super(e,s),this.binding=s.binding,this.viewProps.bindDisabled(this.binding.ticker),this.viewProps.handleDispose(()=>{this.binding.dispose()})}}function ii(r){return r instanceof Wn?r.apiSet_:r instanceof Ze?r.rackApi_.apiSet_:null}function vn(r,e){const s=r.find(h=>h.controller_===e);if(!s)throw k.shouldNeverHappen();return s}function ri(r,e,s){if(!O.isBindable(r))throw k.notBindable();return new O(r,e,s)}class Wn extends o{constructor(e,s){super(e),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this),this.onRackInputChange_=this.onRackInputChange_.bind(this),this.onRackMonitorUpdate_=this.onRackMonitorUpdate_.bind(this),this.emitter_=new N,this.apiSet_=new Vt(ii),this.pool_=s;const h=this.controller_.rack;h.emitter.on("add",this.onRackAdd_),h.emitter.on("remove",this.onRackRemove_),h.emitter.on("inputchange",this.onRackInputChange_),h.emitter.on("monitorupdate",this.onRackMonitorUpdate_),h.children.forEach(x=>{this.setUpApi_(x)})}get children(){return this.controller_.rack.children.map(e=>vn(this.apiSet_,e))}addInput(e,s,h){const x=h??{},L=this.controller_.view.element.ownerDocument,I=this.pool_.createInput(L,ri(e,s,x.presetKey),x),q=new xs(I);return this.add(q,x.index)}addMonitor(e,s,h){const x=h??{},L=this.controller_.view.element.ownerDocument,I=this.pool_.createMonitor(L,ri(e,s),x),q=new Cs(I);return this.add(q,x.index)}addFolder(e){return or(this,e)}addButton(e){return rr(this,e)}addSeparator(e){return ar(this,e)}addTab(e){return ys(this,e)}add(e,s){this.controller_.rack.add(e.controller_,s);const h=this.apiSet_.find(x=>x.controller_===e.controller_);return h&&this.apiSet_.remove(h),this.apiSet_.add(e),e}remove(e){this.controller_.rack.remove(e.controller_)}addBlade(e){const s=this.controller_.view.element.ownerDocument,h=this.pool_.createBlade(s,e),x=this.pool_.createBladeApi(h);return this.add(x,e.index)}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}setUpApi_(e){this.apiSet_.find(h=>h.controller_===e)||this.apiSet_.add(this.pool_.createBladeApi(e))}onRackAdd_(e){this.setUpApi_(e.bladeController)}onRackRemove_(e){if(e.isRoot){const s=vn(this.apiSet_,e.bladeController);this.apiSet_.remove(s)}}onRackInputChange_(e){const s=e.bladeController;if(s instanceof Ke){const h=vn(this.apiSet_,s),x=s.binding;this.emitter_.emit("change",{event:new c(h,x.target.read(),x.target.presetKey,e.options.last)})}else if(s instanceof fe){const h=vn(this.apiSet_,s);this.emitter_.emit("change",{event:new c(h,s.value.rawValue,void 0,e.options.last)})}}onRackMonitorUpdate_(e){if(!(e.bladeController instanceof ht))throw k.shouldNeverHappen();const s=vn(this.apiSet_,e.bladeController),h=e.bladeController.binding;this.emitter_.emit("update",{event:new p(s,h.target.read(),h.target.presetKey)})}}class Ps extends Ze{constructor(e,s){super(e,new Wn(e.rackController,s)),this.emitter_=new N,this.controller_.foldable.value("expanded").emitter.on("change",h=>{this.emitter_.emit("fold",{event:new d(this,h.sender.rawValue)})}),this.rackApi_.on("change",h=>{this.emitter_.emit("change",{event:h})}),this.rackApi_.on("update",h=>{this.emitter_.emit("update",{event:h})})}get expanded(){return this.controller_.foldable.get("expanded")}set expanded(e){this.controller_.foldable.set("expanded",e)}get title(){return this.controller_.props.get("title")}set title(e){this.controller_.props.set("title",e)}get children(){return this.rackApi_.children}addInput(e,s,h){return this.rackApi_.addInput(e,s,h)}addMonitor(e,s,h){return this.rackApi_.addMonitor(e,s,h)}addFolder(e){return this.rackApi_.addFolder(e)}addButton(e){return this.rackApi_.addButton(e)}addSeparator(e){return this.rackApi_.addSeparator(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,s){return this.rackApi_.add(e,s)}remove(e){this.rackApi_.remove(e)}addBlade(e){return this.rackApi_.addBlade(e)}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}}class As extends Et{constructor(e){super({blade:e.blade,view:e.view,viewProps:e.rackController.viewProps}),this.rackController=e.rackController}}class lr{constructor(e,s){const h=M(s.viewName);this.element=e.createElement("div"),this.element.classList.add(h()),s.viewProps.bindClassModifiers(this.element)}}function cr(r,e){for(let s=0;s<r.length;s++){const h=r[s];if(h instanceof Ke&&h.binding===e)return h}return null}function hr(r,e){for(let s=0;s<r.length;s++){const h=r[s];if(h instanceof ht&&h.binding===e)return h}return null}function pr(r,e){for(let s=0;s<r.length;s++){const h=r[s];if(h instanceof fe&&h.value===e)return h}return null}function Ms(r){return r instanceof _n?r.rack:r instanceof As?r.rackController.rack:null}function ur(r){const e=Ms(r);return e?e.bcSet_:null}class dr{constructor(e){var s,h;this.onBladePositionsChange_=this.onBladePositionsChange_.bind(this),this.onSetAdd_=this.onSetAdd_.bind(this),this.onSetRemove_=this.onSetRemove_.bind(this),this.onChildDispose_=this.onChildDispose_.bind(this),this.onChildPositionsChange_=this.onChildPositionsChange_.bind(this),this.onChildInputChange_=this.onChildInputChange_.bind(this),this.onChildMonitorUpdate_=this.onChildMonitorUpdate_.bind(this),this.onChildValueChange_=this.onChildValueChange_.bind(this),this.onChildViewPropsChange_=this.onChildViewPropsChange_.bind(this),this.onDescendantLayout_=this.onDescendantLayout_.bind(this),this.onDescendantInputChange_=this.onDescendantInputChange_.bind(this),this.onDescendantMonitorUpdate_=this.onDescendantMonitorUpdate_.bind(this),this.emitter=new N,this.blade_=(s=e.blade)!==null&&s!==void 0?s:null,(h=this.blade_)===null||h===void 0||h.value("positions").emitter.on("change",this.onBladePositionsChange_),this.viewProps=e.viewProps,this.bcSet_=new Vt(ur),this.bcSet_.emitter.on("add",this.onSetAdd_),this.bcSet_.emitter.on("remove",this.onSetRemove_)}get children(){return this.bcSet_.items}add(e,s){var h;(h=e.parent)===null||h===void 0||h.remove(e),A(e,"parent")?e.parent=this:(e.parent_=this,ze({key:"parent",target:"BladeController",place:"BladeRack.add"})),this.bcSet_.add(e,s)}remove(e){A(e,"parent")?e.parent=null:(e.parent_=null,ze({key:"parent",target:"BladeController",place:"BladeRack.remove"})),this.bcSet_.remove(e)}find(e){return this.bcSet_.allItems().filter(s=>s instanceof e)}onSetAdd_(e){this.updatePositions_();const s=e.target===e.root;if(this.emitter.emit("add",{bladeController:e.item,index:e.index,isRoot:s,sender:this}),!s)return;const h=e.item;if(h.viewProps.emitter.on("change",this.onChildViewPropsChange_),h.blade.value("positions").emitter.on("change",this.onChildPositionsChange_),h.viewProps.handleDispose(this.onChildDispose_),h instanceof Ke)h.binding.emitter.on("change",this.onChildInputChange_);else if(h instanceof ht)h.binding.emitter.on("update",this.onChildMonitorUpdate_);else if(h instanceof fe)h.value.emitter.on("change",this.onChildValueChange_);else{const x=Ms(h);if(x){const L=x.emitter;L.on("layout",this.onDescendantLayout_),L.on("inputchange",this.onDescendantInputChange_),L.on("monitorupdate",this.onDescendantMonitorUpdate_)}}}onSetRemove_(e){this.updatePositions_();const s=e.target===e.root;if(this.emitter.emit("remove",{bladeController:e.item,isRoot:s,sender:this}),!s)return;const h=e.item;if(h instanceof Ke)h.binding.emitter.off("change",this.onChildInputChange_);else if(h instanceof ht)h.binding.emitter.off("update",this.onChildMonitorUpdate_);else if(h instanceof fe)h.value.emitter.off("change",this.onChildValueChange_);else{const x=Ms(h);if(x){const L=x.emitter;L.off("layout",this.onDescendantLayout_),L.off("inputchange",this.onDescendantInputChange_),L.off("monitorupdate",this.onDescendantMonitorUpdate_)}}}updatePositions_(){const e=this.bcSet_.items.filter(x=>!x.viewProps.get("hidden")),s=e[0],h=e[e.length-1];this.bcSet_.items.forEach(x=>{const L=[];x===s&&(L.push("first"),(!this.blade_||this.blade_.get("positions").includes("veryfirst"))&&L.push("veryfirst")),x===h&&(L.push("last"),(!this.blade_||this.blade_.get("positions").includes("verylast"))&&L.push("verylast")),x.blade.set("positions",L)})}onChildPositionsChange_(){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildViewPropsChange_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onChildDispose_(){this.bcSet_.items.filter(s=>s.viewProps.get("disposed")).forEach(s=>{this.bcSet_.remove(s)})}onChildInputChange_(e){const s=cr(this.find(Ke),e.sender);if(!s)throw k.alreadyDisposed();this.emitter.emit("inputchange",{bladeController:s,options:e.options,sender:this})}onChildMonitorUpdate_(e){const s=hr(this.find(ht),e.sender);if(!s)throw k.alreadyDisposed();this.emitter.emit("monitorupdate",{bladeController:s,sender:this})}onChildValueChange_(e){const s=pr(this.find(fe),e.sender);if(!s)throw k.alreadyDisposed();this.emitter.emit("inputchange",{bladeController:s,options:e.options,sender:this})}onDescendantLayout_(e){this.updatePositions_(),this.emitter.emit("layout",{sender:this})}onDescendantInputChange_(e){this.emitter.emit("inputchange",{bladeController:e.bladeController,options:e.options,sender:this})}onDescendantMonitorUpdate_(e){this.emitter.emit("monitorupdate",{bladeController:e.bladeController,sender:this})}onBladePositionsChange_(){this.updatePositions_()}}class _n extends Et{constructor(e,s){super(Object.assign(Object.assign({},s),{view:new lr(e,{viewName:"brk",viewProps:s.viewProps})})),this.onRackAdd_=this.onRackAdd_.bind(this),this.onRackRemove_=this.onRackRemove_.bind(this);const h=new dr({blade:s.root?void 0:s.blade,viewProps:s.viewProps});h.emitter.on("add",this.onRackAdd_),h.emitter.on("remove",this.onRackRemove_),this.rack=h,this.viewProps.handleDispose(()=>{for(let x=this.rack.children.length-1;x>=0;x--)this.rack.children[x].viewProps.set("disposed",!0)})}onRackAdd_(e){e.isRoot&&Ot(this.view.element,e.bladeController.view.element,e.index)}onRackRemove_(e){e.isRoot&&qn(e.bladeController.view.element)}}const oi=M("cnt");class mr{constructor(e,s){var h;this.className_=M((h=s.viewName)!==null&&h!==void 0?h:"fld"),this.element=e.createElement("div"),this.element.classList.add(this.className_(),oi()),s.viewProps.bindClassModifiers(this.element),this.foldable_=s.foldable,this.foldable_.bindExpandedClass(this.element,this.className_(void 0,"expanded")),T(this.foldable_,"completed",X(this.element,this.className_(void 0,"cpl")));const x=e.createElement("button");x.classList.add(this.className_("b")),T(s.props,"title",se=>{b(se)?this.element.classList.add(this.className_(void 0,"not")):this.element.classList.remove(this.className_(void 0,"not"))}),s.viewProps.bindDisabled(x),this.element.appendChild(x),this.buttonElement=x;const L=e.createElement("div");L.classList.add(this.className_("i")),this.element.appendChild(L);const I=e.createElement("div");I.classList.add(this.className_("t")),Z(s.props.value("title"),I),this.buttonElement.appendChild(I),this.titleElement=I;const q=e.createElement("div");q.classList.add(this.className_("m")),this.buttonElement.appendChild(q);const ee=s.containerElement;ee.classList.add(this.className_("c")),this.element.appendChild(ee),this.containerElement=ee}}class Jn extends As{constructor(e,s){var h;const x=je.create((h=s.expanded)!==null&&h!==void 0?h:!0),L=new _n(e,{blade:s.blade,root:s.root,viewProps:s.viewProps});super(Object.assign(Object.assign({},s),{rackController:L,view:new mr(e,{containerElement:L.view.element,foldable:x,props:s.props,viewName:s.root?"rot":void 0,viewProps:s.viewProps})})),this.onTitleClick_=this.onTitleClick_.bind(this),this.props=s.props,this.foldable=x,Xe(this.foldable,this.view.containerElement),this.rackController.rack.emitter.on("add",()=>{this.foldable.cleanUpTransition()}),this.rackController.rack.emitter.on("remove",()=>{this.foldable.cleanUpTransition()}),this.view.buttonElement.addEventListener("click",this.onTitleClick_)}get document(){return this.view.element.ownerDocument}onTitleClick_(){this.foldable.set("expanded",!this.foldable.get("expanded"))}}const fr={id:"folder",type:"blade",accept(r){const e=B,s=we(r,{title:e.required.string,view:e.required.constant("folder"),expanded:e.optional.boolean});return s?{params:s}:null},controller(r){return new Jn(r.document,{blade:r.blade,expanded:r.params.expanded,props:H.fromObject({title:r.params.title}),viewProps:r.viewProps})},api(r){return r.controller instanceof Jn?new Ps(r.controller,r.pool):null}};class Qt extends fe{constructor(e,s){const h=s.valueController.viewProps;super(Object.assign(Object.assign({},s),{value:s.valueController.value,view:new z(e,{props:s.props,viewProps:h}),viewProps:h})),this.props=s.props,this.valueController=s.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}}class ai extends o{}const ks=M("spr");class vr{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(ks()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("hr");h.classList.add(ks("r")),this.element.appendChild(h)}}class gn extends Et{constructor(e,s){super(Object.assign(Object.assign({},s),{view:new vr(e,{viewProps:s.viewProps})}))}}const _r={id:"separator",type:"blade",accept(r){const s=we(r,{view:B.required.constant("separator")});return s?{params:s}:null},controller(r){return new gn(r.document,{blade:r.blade,viewProps:r.viewProps})},api(r){return r.controller instanceof gn?new ai(r.controller):null}},Fe=M("tbi");class gr{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(Fe()),s.viewProps.bindClassModifiers(this.element),T(s.props,"selected",L=>{L?this.element.classList.add(Fe(void 0,"sel")):this.element.classList.remove(Fe(void 0,"sel"))});const h=e.createElement("button");h.classList.add(Fe("b")),s.viewProps.bindDisabled(h),this.element.appendChild(h),this.buttonElement=h;const x=e.createElement("div");x.classList.add(Fe("t")),Z(s.props.value("title"),x),this.buttonElement.appendChild(x),this.titleElement=x}}class Hn{constructor(e,s){this.emitter=new N,this.onClick_=this.onClick_.bind(this),this.props=s.props,this.viewProps=s.viewProps,this.view=new gr(e,{props:s.props,viewProps:s.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class li{constructor(e,s){this.onItemClick_=this.onItemClick_.bind(this),this.ic_=new Hn(e,{props:s.itemProps,viewProps:He.create()}),this.ic_.emitter.on("click",this.onItemClick_),this.cc_=new _n(e,{blade:Oe(),viewProps:He.create()}),this.props=s.props,T(this.props,"selected",h=>{this.itemController.props.set("selected",h),this.contentController.viewProps.set("hidden",!h)})}get itemController(){return this.ic_}get contentController(){return this.cc_}onItemClick_(){this.props.set("selected",!0)}}class Ls{constructor(e,s){this.controller_=e,this.rackApi_=s}get title(){var e;return(e=this.controller_.itemController.props.get("title"))!==null&&e!==void 0?e:""}set title(e){this.controller_.itemController.props.set("title",e)}get selected(){return this.controller_.props.get("selected")}set selected(e){this.controller_.props.set("selected",e)}get children(){return this.rackApi_.children}addButton(e){return this.rackApi_.addButton(e)}addFolder(e){return this.rackApi_.addFolder(e)}addSeparator(e){return this.rackApi_.addSeparator(e)}addTab(e){return this.rackApi_.addTab(e)}add(e,s){this.rackApi_.add(e,s)}remove(e){this.rackApi_.remove(e)}addInput(e,s,h){return this.rackApi_.addInput(e,s,h)}addMonitor(e,s,h){return this.rackApi_.addMonitor(e,s,h)}addBlade(e){return this.rackApi_.addBlade(e)}}class ci extends Ze{constructor(e,s){super(e,new Wn(e.rackController,s)),this.onPageAdd_=this.onPageAdd_.bind(this),this.onPageRemove_=this.onPageRemove_.bind(this),this.onSelect_=this.onSelect_.bind(this),this.emitter_=new N,this.pageApiMap_=new Map,this.rackApi_.on("change",h=>{this.emitter_.emit("change",{event:h})}),this.rackApi_.on("update",h=>{this.emitter_.emit("update",{event:h})}),this.controller_.tab.selectedIndex.emitter.on("change",this.onSelect_),this.controller_.pageSet.emitter.on("add",this.onPageAdd_),this.controller_.pageSet.emitter.on("remove",this.onPageRemove_),this.controller_.pageSet.items.forEach(h=>{this.setUpPageApi_(h)})}get pages(){return this.controller_.pageSet.items.map(e=>{const s=this.pageApiMap_.get(e);if(!s)throw k.shouldNeverHappen();return s})}addPage(e){const s=this.controller_.view.element.ownerDocument,h=new li(s,{itemProps:H.fromObject({selected:!1,title:e.title}),props:H.fromObject({selected:!1})});this.controller_.add(h,e.index);const x=this.pageApiMap_.get(h);if(!x)throw k.shouldNeverHappen();return x}removePage(e){this.controller_.remove(e)}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}setUpPageApi_(e){const s=this.rackApi_.apiSet_.find(x=>x.controller_===e.contentController);if(!s)throw k.shouldNeverHappen();const h=new Ls(e,s);this.pageApiMap_.set(e,h)}onPageAdd_(e){this.setUpPageApi_(e.item)}onPageRemove_(e){if(!this.pageApiMap_.get(e.item))throw k.shouldNeverHappen();this.pageApiMap_.delete(e.item)}onSelect_(e){this.emitter_.emit("select",{event:new g(this,e.rawValue)})}}const hi=-1;class br{constructor(){this.onItemSelectedChange_=this.onItemSelectedChange_.bind(this),this.empty=ne(!0),this.selectedIndex=ne(hi),this.items_=[]}add(e,s){const h=s??this.items_.length;this.items_.splice(h,0,e),e.emitter.on("change",this.onItemSelectedChange_),this.keepSelection_()}remove(e){const s=this.items_.indexOf(e);s<0||(this.items_.splice(s,1),e.emitter.off("change",this.onItemSelectedChange_),this.keepSelection_())}keepSelection_(){if(this.items_.length===0){this.selectedIndex.rawValue=hi,this.empty.rawValue=!0;return}const e=this.items_.findIndex(s=>s.rawValue);e<0?(this.items_.forEach((s,h)=>{s.rawValue=h===0}),this.selectedIndex.rawValue=0):(this.items_.forEach((s,h)=>{s.rawValue=h===e}),this.selectedIndex.rawValue=e),this.empty.rawValue=!1}onItemSelectedChange_(e){if(e.rawValue){const s=this.items_.findIndex(h=>h===e.sender);this.items_.forEach((h,x)=>{h.rawValue=x===s}),this.selectedIndex.rawValue=s}else this.keepSelection_()}}const Wt=M("tab");class Jt{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(Wt(),oi()),s.viewProps.bindClassModifiers(this.element),S(s.empty,X(this.element,Wt(void 0,"nop")));const h=e.createElement("div");h.classList.add(Wt("t")),this.element.appendChild(h),this.itemsElement=h;const x=e.createElement("div");x.classList.add(Wt("i")),this.element.appendChild(x);const L=s.contentsElement;L.classList.add(Wt("c")),this.element.appendChild(L),this.contentsElement=L}}class bn extends As{constructor(e,s){const h=new _n(e,{blade:s.blade,viewProps:s.viewProps}),x=new br;super({blade:s.blade,rackController:h,view:new Jt(e,{contentsElement:h.view.element,empty:x.empty,viewProps:s.viewProps})}),this.onPageAdd_=this.onPageAdd_.bind(this),this.onPageRemove_=this.onPageRemove_.bind(this),this.pageSet_=new Vt(()=>null),this.pageSet_.emitter.on("add",this.onPageAdd_),this.pageSet_.emitter.on("remove",this.onPageRemove_),this.tab=x}get pageSet(){return this.pageSet_}add(e,s){this.pageSet_.add(e,s)}remove(e){this.pageSet_.remove(this.pageSet_.items[e])}onPageAdd_(e){const s=e.item;Ot(this.view.itemsElement,s.itemController.view.element,e.index),s.itemController.viewProps.set("parent",this.viewProps),this.rackController.rack.add(s.contentController,e.index),this.tab.add(s.props.value("selected"))}onPageRemove_(e){const s=e.item;qn(s.itemController.view.element),s.itemController.viewProps.set("parent",null),this.rackController.rack.remove(s.contentController),this.tab.remove(s.props.value("selected"))}}const Ss={id:"tab",type:"blade",accept(r){const e=B,s=we(r,{pages:e.required.array(e.required.object({title:e.required.string})),view:e.required.constant("tab")});return!s||s.pages.length===0?null:{params:s}},controller(r){const e=new bn(r.document,{blade:r.blade,viewProps:r.viewProps});return r.params.pages.forEach(s=>{const h=new li(r.document,{itemProps:H.fromObject({selected:!1,title:s.title}),props:H.fromObject({selected:!1})});e.add(h)}),e},api(r){return r.controller instanceof bn?new ci(r.controller,r.pool):null}};function wr(r,e){const s=r.accept(e.params);if(!s)return null;const h=B.optional.boolean(e.params.disabled).value,x=B.optional.boolean(e.params.hidden).value;return r.controller({blade:Oe(),document:e.document,params:Object.assign(Object.assign({},s.params),{disabled:h,hidden:x}),viewProps:He.create({disabled:h,hidden:x})})}class pi{constructor(){this.disabled=!1,this.emitter=new N}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class Ts{constructor(e,s){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=e,this.emitter=new N,this.interval_=s,this.setTimer_()}get disabled(){return this.disabled_}set disabled(e){this.disabled_=e,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const e=this.doc_.defaultView;e&&e.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const e=this.doc_.defaultView;e&&(this.timerId_=e.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class $n{constructor(e){this.onValueChange_=this.onValueChange_.bind(this),this.reader=e.reader,this.writer=e.writer,this.emitter=new N,this.value=e.value,this.value.emitter.on("change",this.onValueChange_),this.target=e.target,this.read()}read(){const e=this.target.read();e!==void 0&&(this.value.rawValue=this.reader(e))}write_(e){this.writer(this.target,e)}onValueChange_(e){this.write_(e.rawValue),this.emitter.emit("change",{options:e.options,rawValue:e.rawValue,sender:this})}}function Ve(r,e){for(;r.length<e;)r.push(void 0)}function ui(r){const e=[];return Ve(e,r),ne(e)}function Ht(r){const e=r.indexOf(void 0);return e<0?r:r.slice(0,e)}function $e(r,e){const s=[...Ht(r),e];return s.length>r.length?s.splice(0,s.length-r.length):Ve(s,r.length),s}class yr{constructor(e){this.onTick_=this.onTick_.bind(this),this.reader_=e.reader,this.target=e.target,this.emitter=new N,this.value=e.value,this.ticker=e.ticker,this.ticker.emitter.on("tick",this.onTick_),this.read()}dispose(){this.ticker.dispose()}read(){const e=this.target.read();if(e===void 0)return;const s=this.value.rawValue,h=this.reader_(e);this.value.rawValue=$e(s,h),this.emitter.emit("update",{rawValue:h,sender:this})}onTick_(e){this.read()}}class wn{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((s,h)=>h.constrain(s),e)}}function st(r,e){if(r instanceof e)return r;if(r instanceof wn){const s=r.constraints.reduce((h,x)=>h||(x instanceof e?x:null),null);if(s)return s}return null}class $t{constructor(e){this.values=H.fromObject({max:e.max,min:e.min})}constrain(e){const s=this.values.get("max"),h=this.values.get("min");return Math.min(Math.max(e,h),s)}}class yn{constructor(e){this.values=H.fromObject({options:e})}get options(){return this.values.get("options")}constrain(e){const s=this.values.get("options");return s.length===0||s.filter(x=>x.value===e).length>0?e:s[0].value}}class Es{constructor(e){this.values=H.fromObject({max:e.max,min:e.min})}get maxValue(){return this.values.get("max")}get minValue(){return this.values.get("min")}constrain(e){const s=this.values.get("max"),h=this.values.get("min");let x=e;return b(h)||(x=Math.max(x,h)),b(s)||(x=Math.min(x,s)),x}}class es{constructor(e,s=0){this.step=e,this.origin=s}constrain(e){const s=this.origin%this.step,h=Math.round((e-s)/this.step);return s+h*this.step}}const en=M("lst");class di{constructor(e,s){this.onValueChange_=this.onValueChange_.bind(this),this.props_=s.props,this.element=e.createElement("div"),this.element.classList.add(en()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("select");h.classList.add(en("s")),s.viewProps.bindDisabled(h),this.element.appendChild(h),this.selectElement=h;const x=e.createElement("div");x.classList.add(en("m")),x.appendChild(Mt(e,"dropdown")),this.element.appendChild(x),s.value.emitter.on("change",this.onValueChange_),this.value_=s.value,T(this.props_,"options",L=>{mn(this.selectElement),L.forEach(I=>{const q=e.createElement("option");q.textContent=I.text,this.selectElement.appendChild(q)}),this.update_()})}update_(){const e=this.props_.get("options").map(s=>s.value);this.selectElement.selectedIndex=e.indexOf(this.value_.rawValue)}onValueChange_(){this.update_()}}class xn{constructor(e,s){this.onSelectChange_=this.onSelectChange_.bind(this),this.props=s.props,this.value=s.value,this.viewProps=s.viewProps,this.view=new di(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.view.selectElement.addEventListener("change",this.onSelectChange_)}onSelectChange_(e){const s=e.currentTarget;this.value.rawValue=this.props.get("options")[s.selectedIndex].value}}const mi=M("pop");class xr{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(mi()),s.viewProps.bindClassModifiers(this.element),S(s.shows,X(this.element,mi(void 0,"v")))}}class fi{constructor(e,s){this.shows=ne(!1),this.viewProps=s.viewProps,this.view=new xr(e,{shows:this.shows,viewProps:this.viewProps})}}const vi=M("txt");class Cr{constructor(e,s){this.onChange_=this.onChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(vi()),s.viewProps.bindClassModifiers(this.element),this.props_=s.props,this.props_.emitter.on("change",this.onChange_);const h=e.createElement("input");h.classList.add(vi("i")),h.type="text",s.viewProps.bindDisabled(h),this.element.appendChild(h),this.inputElement=h,s.value.emitter.on("change",this.onChange_),this.value_=s.value,this.refresh()}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value_.rawValue)}onChange_(){this.refresh()}}class ts{constructor(e,s){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=s.parser,this.props=s.props,this.value=s.value,this.viewProps=s.viewProps,this.view=new Cr(e,{props:s.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const h=e.currentTarget.value,x=this.parser_(h);b(x)||(this.value.rawValue=x),this.view.refresh()}}function Pr(r){return String(r)}function _i(r){return r==="false"?!1:!!r}function gi(r){return Pr(r)}class Ar{constructor(e){this.text=e}evaluate(){return Number(this.text)}toString(){return this.text}}const Mr={"**":(r,e)=>Math.pow(r,e),"*":(r,e)=>r*e,"/":(r,e)=>r/e,"%":(r,e)=>r%e,"+":(r,e)=>r+e,"-":(r,e)=>r-e,"<<":(r,e)=>r<<e,">>":(r,e)=>r>>e,">>>":(r,e)=>r>>>e,"&":(r,e)=>r&e,"^":(r,e)=>r^e,"|":(r,e)=>r|e};class kr{constructor(e,s,h){this.left=s,this.operator=e,this.right=h}evaluate(){const e=Mr[this.operator];if(!e)throw new Error(`unexpected binary operator: '${this.operator}`);return e(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const bi={"+":r=>r,"-":r=>-r,"~":r=>~r};class Lr{constructor(e,s){this.operator=e,this.expression=s}evaluate(){const e=bi[this.operator];if(!e)throw new Error(`unexpected unary operator: '${this.operator}`);return e(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function Os(r){return(e,s)=>{for(let h=0;h<r.length;h++){const x=r[h](e,s);if(x!=="")return x}return""}}function It(r,e){var s;const h=r.substr(e).match(/^\s+/);return(s=h&&h[0])!==null&&s!==void 0?s:""}function Sr(r,e){const s=r.substr(e,1);return s.match(/^[1-9]$/)?s:""}function Cn(r,e){var s;const h=r.substr(e).match(/^[0-9]+/);return(s=h&&h[0])!==null&&s!==void 0?s:""}function Tr(r,e){const s=Cn(r,e);if(s!=="")return s;const h=r.substr(e,1);if(e+=1,h!=="-"&&h!=="+")return"";const x=Cn(r,e);return x===""?"":h+x}function pt(r,e){const s=r.substr(e,1);if(e+=1,s.toLowerCase()!=="e")return"";const h=Tr(r,e);return h===""?"":s+h}function wi(r,e){const s=r.substr(e,1);if(s==="0")return s;const h=Sr(r,e);return e+=h.length,h===""?"":h+Cn(r,e)}function Er(r,e){const s=wi(r,e);if(e+=s.length,s==="")return"";const h=r.substr(e,1);if(e+=h.length,h!==".")return"";const x=Cn(r,e);return e+=x.length,s+h+x+pt(r,e)}function yi(r,e){const s=r.substr(e,1);if(e+=s.length,s!==".")return"";const h=Cn(r,e);return e+=h.length,h===""?"":s+h+pt(r,e)}function Or(r,e){const s=wi(r,e);return e+=s.length,s===""?"":s+pt(r,e)}const xi=Os([Er,yi,Or]);function Ds(r,e){var s;const h=r.substr(e).match(/^[01]+/);return(s=h&&h[0])!==null&&s!==void 0?s:""}function Dr(r,e){const s=r.substr(e,2);if(e+=s.length,s.toLowerCase()!=="0b")return"";const h=Ds(r,e);return h===""?"":s+h}function Ci(r,e){var s;const h=r.substr(e).match(/^[0-7]+/);return(s=h&&h[0])!==null&&s!==void 0?s:""}function et(r,e){const s=r.substr(e,2);if(e+=s.length,s.toLowerCase()!=="0o")return"";const h=Ci(r,e);return h===""?"":s+h}function Vr(r,e){var s;const h=r.substr(e).match(/^[0-9a-f]+/i);return(s=h&&h[0])!==null&&s!==void 0?s:""}function Ir(r,e){const s=r.substr(e,2);if(e+=s.length,s.toLowerCase()!=="0x")return"";const h=Vr(r,e);return h===""?"":s+h}const Vs=Os([Dr,et,Ir]),Br=Os([Vs,xi]);function Lt(r,e){const s=Br(r,e);return e+=s.length,s===""?null:{evaluable:new Ar(s),cursor:e}}function Is(r,e){const s=r.substr(e,1);if(e+=s.length,s!=="(")return null;const h=ns(r,e);if(!h)return null;e=h.cursor,e+=It(r,e).length;const x=r.substr(e,1);return e+=x.length,x!==")"?null:{evaluable:h.evaluable,cursor:e}}function Fr(r,e){var s;return(s=Lt(r,e))!==null&&s!==void 0?s:Is(r,e)}function Bs(r,e){const s=Fr(r,e);if(s)return s;const h=r.substr(e,1);if(e+=h.length,h!=="+"&&h!=="-"&&h!=="~")return null;const x=Bs(r,e);return x?(e=x.cursor,{cursor:e,evaluable:new Lr(h,x.evaluable)}):null}function Nr(r,e,s){s+=It(e,s).length;const h=r.filter(x=>e.startsWith(x,s))[0];return h?(s+=h.length,s+=It(e,s).length,{cursor:s,operator:h}):null}function Bt(r,e){return(s,h)=>{const x=r(s,h);if(!x)return null;h=x.cursor;let L=x.evaluable;for(;;){const I=Nr(e,s,h);if(!I)break;h=I.cursor;const q=r(s,h);if(!q)return null;h=q.cursor,L=new kr(I.operator,L,q.evaluable)}return L?{cursor:h,evaluable:L}:null}}const Pi=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((r,e)=>Bt(r,e),Bs);function ns(r,e){return e+=It(r,e).length,Pi(r,e)}function Ai(r){const e=ns(r,0);return!e||e.cursor+It(r,e.cursor).length!==r.length?null:e.evaluable}function ut(r){var e;const s=Ai(r);return(e=s==null?void 0:s.evaluate())!==null&&e!==void 0?e:null}function yt(r){if(typeof r=="number")return r;if(typeof r=="string"){const e=ut(r);if(!b(e))return e}return 0}function Ur(r){return String(r)}function Ne(r){return e=>e.toFixed(Math.max(Math.min(r,20),0))}const Mi=Ne(0);function Pn(r){return Mi(r)+"%"}function Fs(r){return String(r)}function St(r){return r}function tn({primary:r,secondary:e,forward:s,backward:h}){let x=!1;function L(I){x||(x=!0,I(),x=!1)}r.emitter.on("change",I=>{L(()=>{e.setRawValue(s(r,e),I.options)})}),e.emitter.on("change",I=>{L(()=>{r.setRawValue(h(r,e),I.options)}),L(()=>{e.setRawValue(s(r,e),I.options)})}),L(()=>{e.setRawValue(s(r,e),{forceEmit:!1,last:!0})})}function Re(r,e){const s=r*(e.altKey?.1:1)*(e.shiftKey?10:1);return e.upKey?+s:e.downKey?-s:0}function An(r){return{altKey:r.altKey,downKey:r.key==="ArrowDown",shiftKey:r.shiftKey,upKey:r.key==="ArrowUp"}}function dt(r){return{altKey:r.altKey,downKey:r.key==="ArrowLeft",shiftKey:r.shiftKey,upKey:r.key==="ArrowRight"}}function ki(r){return r==="ArrowUp"||r==="ArrowDown"}function ss(r){return ki(r)||r==="ArrowLeft"||r==="ArrowRight"}function Ns(r,e){var s,h;const x=e.ownerDocument.defaultView,L=e.getBoundingClientRect();return{x:r.pageX-(((s=x&&x.scrollX)!==null&&s!==void 0?s:0)+L.left),y:r.pageY-(((h=x&&x.scrollY)!==null&&h!==void 0?h:0)+L.top)}}class Ft{constructor(e){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=e,this.emitter=new N,e.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),e.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd_),e.addEventListener("mousedown",this.onMouseDown_)}computePosition_(e){const s=this.elem_.getBoundingClientRect();return{bounds:{width:s.width,height:s.height},point:e?{x:e.x,y:e.y}:null}}onMouseDown_(e){var s;e.preventDefault(),(s=e.currentTarget)===null||s===void 0||s.focus();const h=this.elem_.ownerDocument;h.addEventListener("mousemove",this.onDocumentMouseMove_),h.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(Ns(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseMove_(e){this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(Ns(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onDocumentMouseUp_(e){const s=this.elem_.ownerDocument;s.removeEventListener("mousemove",this.onDocumentMouseMove_),s.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(Ns(e,this.elem_)),sender:this,shiftKey:e.shiftKey})}onTouchStart_(e){e.preventDefault();const s=e.targetTouches.item(0),h=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:e.altKey,data:this.computePosition_(s?{x:s.clientX-h.left,y:s.clientY-h.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=s}onTouchMove_(e){const s=e.targetTouches.item(0),h=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:e.altKey,data:this.computePosition_(s?{x:s.clientX-h.left,y:s.clientY-h.top}:void 0),sender:this,shiftKey:e.shiftKey}),this.lastTouch_=s}onTouchEnd_(e){var s;const h=(s=e.targetTouches.item(0))!==null&&s!==void 0?s:this.lastTouch_,x=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:e.altKey,data:this.computePosition_(h?{x:h.clientX-x.left,y:h.clientY-x.top}:void 0),sender:this,shiftKey:e.shiftKey})}}function Le(r,e,s,h,x){const L=(r-e)/(s-e);return h+L*(x-h)}function Us(r){return String(r.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function Ie(r,e,s){return Math.min(Math.max(r,e),s)}function nn(r,e){return(r%e+e)%e}const qe=M("txt");class zs{constructor(e,s){this.onChange_=this.onChange_.bind(this),this.props_=s.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(qe(),qe(void 0,"num")),s.arrayPosition&&this.element.classList.add(qe(void 0,s.arrayPosition)),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("input");h.classList.add(qe("i")),h.type="text",s.viewProps.bindDisabled(h),this.element.appendChild(h),this.inputElement=h,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=s.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add(qe()),this.inputElement.classList.add(qe("i"));const x=e.createElement("div");x.classList.add(qe("k")),this.element.appendChild(x),this.knobElement=x;const L=e.createElementNS(Ye,"svg");L.classList.add(qe("g")),this.knobElement.appendChild(L);const I=e.createElementNS(Ye,"path");I.classList.add(qe("gb")),L.appendChild(I),this.guideBodyElem_=I;const q=e.createElementNS(Ye,"path");q.classList.add(qe("gh")),L.appendChild(q),this.guideHeadElem_=q;const ee=e.createElement("div");ee.classList.add(M("tt")()),this.knobElement.appendChild(ee),this.tooltipElem_=ee,s.value.emitter.on("change",this.onChange_),this.value=s.value,this.refresh()}onDraggingChange_(e){if(e.rawValue===null){this.element.classList.remove(qe(void 0,"drg"));return}this.element.classList.add(qe(void 0,"drg"));const s=e.rawValue/this.props_.get("draggingScale"),h=s+(s>0?-1:s<0?1:0),x=Ie(-h,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${h+x},0 L${h},4 L${h+x},8`,`M ${s},-1 L${s},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${s},4`);const L=this.props_.get("formatter");this.tooltipElem_.textContent=L(this.value.rawValue),this.tooltipElem_.style.left=`${s}px`}refresh(){const e=this.props_.get("formatter");this.inputElement.value=e(this.value.rawValue)}onChange_(){this.refresh()}}class Mn{constructor(e,s){var h;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.baseStep_=s.baseStep,this.parser_=s.parser,this.props=s.props,this.sliderProps_=(h=s.sliderProps)!==null&&h!==void 0?h:null,this.value=s.value,this.viewProps=s.viewProps,this.dragging_=ne(null),this.view=new zs(e,{arrayPosition:s.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const x=new Ft(this.view.knobElement);x.emitter.on("down",this.onPointerDown_),x.emitter.on("move",this.onPointerMove_),x.emitter.on("up",this.onPointerUp_)}constrainValue_(e){var s,h;const x=(s=this.sliderProps_)===null||s===void 0?void 0:s.get("minValue"),L=(h=this.sliderProps_)===null||h===void 0?void 0:h.get("maxValue");let I=e;return x!==void 0&&(I=Math.max(I,x)),L!==void 0&&(I=Math.min(I,L)),I}onInputChange_(e){const h=e.currentTarget.value,x=this.parser_(h);b(x)||(this.value.rawValue=this.constrainValue_(x)),this.view.refresh()}onInputKeyDown_(e){const s=Re(this.baseStep_,An(e));s!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+s),{forceEmit:!1,last:!1})}onInputKeyUp_(e){Re(this.baseStep_,An(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(e){if(!e.point)return null;const s=e.point.x-e.bounds.width/2;return this.constrainValue_(this.originRawValue_+s*this.props.get("draggingScale"))}onPointerMove_(e){const s=this.computeDraggingValue_(e.data);s!==null&&(this.value.setRawValue(s,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(e){const s=this.computeDraggingValue_(e.data);s!==null&&(this.value.setRawValue(s,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}const Rs=M("sld");class Qe{constructor(e,s){this.onChange_=this.onChange_.bind(this),this.props_=s.props,this.props_.emitter.on("change",this.onChange_),this.element=e.createElement("div"),this.element.classList.add(Rs()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("div");h.classList.add(Rs("t")),s.viewProps.bindTabIndex(h),this.element.appendChild(h),this.trackElement=h;const x=e.createElement("div");x.classList.add(Rs("k")),this.trackElement.appendChild(x),this.knobElement=x,s.value.emitter.on("change",this.onChange_),this.value=s.value,this.update_()}update_(){const e=Ie(Le(this.value.rawValue,this.props_.get("minValue"),this.props_.get("maxValue"),0,100),0,100);this.knobElement.style.width=`${e}%`}onChange_(){this.update_()}}class js{constructor(e,s){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDownOrMove_=this.onPointerDownOrMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.baseStep_=s.baseStep,this.value=s.value,this.viewProps=s.viewProps,this.props=s.props,this.view=new Qe(e,{props:this.props,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ft(this.view.trackElement),this.ptHandler_.emitter.on("down",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("move",this.onPointerDownOrMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.trackElement.addEventListener("keydown",this.onKeyDown_),this.view.trackElement.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,s){e.point&&this.value.setRawValue(Le(Ie(e.point.x,0,e.bounds.width),0,e.bounds.width,this.props.get("minValue"),this.props.get("maxValue")),s)}onPointerDownOrMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const s=Re(this.baseStep_,dt(e));s!==0&&this.value.setRawValue(this.value.rawValue+s,{forceEmit:!1,last:!1})}onKeyUp_(e){Re(this.baseStep_,dt(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const kn=M("sldtxt");class Gs{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(kn());const h=e.createElement("div");h.classList.add(kn("s")),this.sliderView_=s.sliderView,h.appendChild(this.sliderView_.element),this.element.appendChild(h);const x=e.createElement("div");x.classList.add(kn("t")),this.textView_=s.textView,x.appendChild(this.textView_.element),this.element.appendChild(x)}}class is{constructor(e,s){this.value=s.value,this.viewProps=s.viewProps,this.sliderC_=new js(e,{baseStep:s.baseStep,props:s.sliderProps,value:s.value,viewProps:this.viewProps}),this.textC_=new Mn(e,{baseStep:s.baseStep,parser:s.parser,props:s.textProps,sliderProps:s.sliderProps,value:s.value,viewProps:s.viewProps}),this.view=new Gs(e,{sliderView:this.sliderC_.view,textView:this.textC_.view})}get sliderController(){return this.sliderC_}get textController(){return this.textC_}}function it(r,e){r.write(e)}function Ln(r){const e=B;if(Array.isArray(r))return e.required.array(e.required.object({text:e.required.string,value:e.required.raw}))(r).value;if(typeof r=="object")return e.required.raw(r).value}function Ks(r){if(r==="inline"||r==="popup")return r}function xt(r){const e=B;return e.required.object({max:e.optional.number,min:e.optional.number,step:e.optional.number})(r).value}function Li(r){if(Array.isArray(r))return r;const e=[];return Object.keys(r).forEach(s=>{e.push({text:s,value:r[s]})}),e}function Ys(r){return b(r)?null:new yn(Li(r))}function zr(r){const e=r?st(r,es):null;return e?e.step:null}function rs(r,e){const s=r&&st(r,es);return s?Us(s.step):Math.max(Us(e),2)}function Nt(r){const e=zr(r);return e??1}function Ut(r,e){var s;const h=r&&st(r,es),x=Math.abs((s=h==null?void 0:h.step)!==null&&s!==void 0?s:e);return x===0?.1:Math.pow(10,Math.floor(Math.log10(x))-1)}const Sn=M("ckb");class Tn{constructor(e,s){this.onValueChange_=this.onValueChange_.bind(this),this.element=e.createElement("div"),this.element.classList.add(Sn()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("label");h.classList.add(Sn("l")),this.element.appendChild(h);const x=e.createElement("input");x.classList.add(Sn("i")),x.type="checkbox",h.appendChild(x),this.inputElement=x,s.viewProps.bindDisabled(this.inputElement);const L=e.createElement("div");L.classList.add(Sn("w")),h.appendChild(L);const I=Mt(e,"check");L.appendChild(I),s.value.emitter.on("change",this.onValueChange_),this.value=s.value,this.update_()}update_(){this.inputElement.checked=this.value.rawValue}onValueChange_(){this.update_()}}class Si{constructor(e,s){this.onInputChange_=this.onInputChange_.bind(this),this.value=s.value,this.viewProps=s.viewProps,this.view=new Tn(e,{value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(e){const s=e.currentTarget;this.value.rawValue=s.checked}}function Ti(r){const e=[],s=Ys(r.options);return s&&e.push(s),new wn(e)}const os={id:"input-bool",type:"input",accept:(r,e)=>{if(typeof r!="boolean")return null;const h=we(e,{options:B.optional.custom(Ln)});return h?{initialValue:r,params:h}:null},binding:{reader:r=>_i,constraint:r=>Ti(r.params),writer:r=>it},controller:r=>{const e=r.document,s=r.value,h=r.constraint,x=h&&st(h,yn);return x?new xn(e,{props:new H({options:x.values.value("options")}),value:s,viewProps:r.viewProps}):new Si(e,{value:s,viewProps:r.viewProps})}},zt=M("col");class Xs{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(zt()),s.foldable.bindExpandedClass(this.element,zt(void 0,"expanded")),T(s.foldable,"completed",X(this.element,zt(void 0,"cpl")));const h=e.createElement("div");h.classList.add(zt("h")),this.element.appendChild(h);const x=e.createElement("div");x.classList.add(zt("s")),h.appendChild(x),this.swatchElement=x;const L=e.createElement("div");if(L.classList.add(zt("t")),h.appendChild(L),this.textElement=L,s.pickerLayout==="inline"){const I=e.createElement("div");I.classList.add(zt("p")),this.element.appendChild(I),this.pickerElement=I}else this.pickerElement=null}}function Rr(r,e,s){const h=Ie(r/255,0,1),x=Ie(e/255,0,1),L=Ie(s/255,0,1),I=Math.max(h,x,L),q=Math.min(h,x,L),ee=I-q;let se=0,xe=0;const Pe=(q+I)/2;return ee!==0&&(xe=ee/(1-Math.abs(I+q-1)),h===I?se=(x-L)/ee:x===I?se=2+(L-h)/ee:se=4+(h-x)/ee,se=se/6+(se<0?1:0)),[se*360,xe*100,Pe*100]}function jr(r,e,s){const h=(r%360+360)%360,x=Ie(e/100,0,1),L=Ie(s/100,0,1),I=(1-Math.abs(2*L-1))*x,q=I*(1-Math.abs(h/60%2-1)),ee=L-I/2;let se,xe,Pe;return h>=0&&h<60?[se,xe,Pe]=[I,q,0]:h>=60&&h<120?[se,xe,Pe]=[q,I,0]:h>=120&&h<180?[se,xe,Pe]=[0,I,q]:h>=180&&h<240?[se,xe,Pe]=[0,q,I]:h>=240&&h<300?[se,xe,Pe]=[q,0,I]:[se,xe,Pe]=[I,0,q],[(se+ee)*255,(xe+ee)*255,(Pe+ee)*255]}function Gr(r,e,s){const h=Ie(r/255,0,1),x=Ie(e/255,0,1),L=Ie(s/255,0,1),I=Math.max(h,x,L),q=Math.min(h,x,L),ee=I-q;let se;ee===0?se=0:I===h?se=60*(((x-L)/ee%6+6)%6):I===x?se=60*((L-h)/ee+2):se=60*((h-x)/ee+4);const xe=I===0?0:ee/I,Pe=I;return[se,xe*100,Pe*100]}function Ei(r,e,s){const h=nn(r,360),x=Ie(e/100,0,1),L=Ie(s/100,0,1),I=L*x,q=I*(1-Math.abs(h/60%2-1)),ee=L-I;let se,xe,Pe;return h>=0&&h<60?[se,xe,Pe]=[I,q,0]:h>=60&&h<120?[se,xe,Pe]=[q,I,0]:h>=120&&h<180?[se,xe,Pe]=[0,I,q]:h>=180&&h<240?[se,xe,Pe]=[0,q,I]:h>=240&&h<300?[se,xe,Pe]=[q,0,I]:[se,xe,Pe]=[I,0,q],[(se+ee)*255,(xe+ee)*255,(Pe+ee)*255]}function f(r,e,s){const h=s+e*(100-Math.abs(2*s-100))/200;return[r,h!==0?e*(100-Math.abs(2*s-100))/h:0,s+e*(100-Math.abs(2*s-100))/(2*100)]}function l(r,e,s){const h=100-Math.abs(s*(200-e)/100-100);return[r,h!==0?e*s/h:0,s*(200-e)/(2*100)]}function u(r){return[r[0],r[1],r[2]]}function w(r,e){return[r[0],r[1],r[2],e]}const P={hsl:{hsl:(r,e,s)=>[r,e,s],hsv:f,rgb:jr},hsv:{hsl:l,hsv:(r,e,s)=>[r,e,s],rgb:Ei},rgb:{hsl:Rr,hsv:Gr,rgb:(r,e,s)=>[r,e,s]}};function V(r,e){return[e==="float"?1:r==="rgb"?255:360,e==="float"?1:r==="rgb"?255:100,e==="float"?1:r==="rgb"?255:100]}function G(r,e){return r===e?e:nn(r,e)}function Q(r,e,s){var h;const x=V(e,s);return[e==="rgb"?Ie(r[0],0,x[0]):G(r[0],x[0]),Ie(r[1],0,x[1]),Ie(r[2],0,x[2]),Ie((h=r[3])!==null&&h!==void 0?h:1,0,1)]}function be(r,e,s,h){const x=V(e,s),L=V(e,h);return r.map((I,q)=>I/x[q]*L[q])}function tt(r,e,s){const h=be(r,e.mode,e.type,"int"),x=P[e.mode][s.mode](...h);return be(x,s.mode,"int",s.type)}function nt(r,e){return typeof r!="object"||b(r)?!1:e in r&&typeof r[e]=="number"}class ue{static black(e="int"){return new ue([0,0,0],"rgb",e)}static fromObject(e,s="int"){const h="a"in e?[e.r,e.g,e.b,e.a]:[e.r,e.g,e.b];return new ue(h,"rgb",s)}static toRgbaObject(e,s="int"){return e.toRgbaObject(s)}static isRgbColorObject(e){return nt(e,"r")&&nt(e,"g")&&nt(e,"b")}static isRgbaColorObject(e){return this.isRgbColorObject(e)&&nt(e,"a")}static isColorObject(e){return this.isRgbColorObject(e)}static equals(e,s){if(e.mode!==s.mode)return!1;const h=e.comps_,x=s.comps_;for(let L=0;L<h.length;L++)if(h[L]!==x[L])return!1;return!0}constructor(e,s,h="int"){this.mode=s,this.type=h,this.comps_=Q(e,s,h)}getComponents(e,s="int"){return w(tt(u(this.comps_),{mode:this.mode,type:this.type},{mode:e??this.mode,type:s}),this.comps_[3])}toRgbaObject(e="int"){const s=this.getComponents("rgb",e);return{r:s[0],g:s[1],b:s[2],a:s[3]}}}const Tt=M("colp");class Kr{constructor(e,s){this.alphaViews_=null,this.element=e.createElement("div"),this.element.classList.add(Tt()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("div");h.classList.add(Tt("hsv"));const x=e.createElement("div");x.classList.add(Tt("sv")),this.svPaletteView_=s.svPaletteView,x.appendChild(this.svPaletteView_.element),h.appendChild(x);const L=e.createElement("div");L.classList.add(Tt("h")),this.hPaletteView_=s.hPaletteView,L.appendChild(this.hPaletteView_.element),h.appendChild(L),this.element.appendChild(h);const I=e.createElement("div");if(I.classList.add(Tt("rgb")),this.textView_=s.textView,I.appendChild(this.textView_.element),this.element.appendChild(I),s.alphaViews){this.alphaViews_={palette:s.alphaViews.palette,text:s.alphaViews.text};const q=e.createElement("div");q.classList.add(Tt("a"));const ee=e.createElement("div");ee.classList.add(Tt("ap")),ee.appendChild(this.alphaViews_.palette.element),q.appendChild(ee);const se=e.createElement("div");se.classList.add(Tt("at")),se.appendChild(this.alphaViews_.text.element),q.appendChild(se),this.element.appendChild(q)}}get allFocusableElements(){const e=[this.svPaletteView_.element,this.hPaletteView_.element,this.textView_.modeSelectElement,...this.textView_.textViews.map(s=>s.inputElement)];return this.alphaViews_&&e.push(this.alphaViews_.palette.element,this.alphaViews_.text.inputElement),e}}function Lp(r){return r==="int"?"int":r==="float"?"float":void 0}function Yr(r){const e=B;return we(r,{alpha:e.optional.boolean,color:e.optional.object({alpha:e.optional.boolean,type:e.optional.custom(Lp)}),expanded:e.optional.boolean,picker:e.optional.custom(Ks)})}function En(r){return r?.1:1}function On(r){var e;return(e=r.color)===null||e===void 0?void 0:e.type}function Sp(r,e){return r.alpha===e.alpha&&r.mode===e.mode&&r.notation===e.notation&&r.type===e.type}function mt(r,e){const s=r.match(/^(.+)%$/);return Math.min(s?parseFloat(s[1])*.01*e:parseFloat(r),e)}const Tp={deg:r=>r,grad:r=>r*360/400,rad:r=>r*360/(2*Math.PI),turn:r=>r*360};function ta(r){const e=r.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);if(!e)return parseFloat(r);const s=parseFloat(e[1]),h=e[2];return Tp[h](s)}function na(r){const e=r.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const s=[mt(e[1],255),mt(e[2],255),mt(e[3],255)];return isNaN(s[0])||isNaN(s[1])||isNaN(s[2])?null:s}function sa(r){return e=>{const s=na(e);return s?new ue(s,"rgb",r):null}}function ia(r){const e=r.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const s=[mt(e[1],255),mt(e[2],255),mt(e[3],255),mt(e[4],1)];return isNaN(s[0])||isNaN(s[1])||isNaN(s[2])||isNaN(s[3])?null:s}function ra(r){return e=>{const s=ia(e);return s?new ue(s,"rgb",r):null}}function oa(r){const e=r.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const s=[ta(e[1]),mt(e[2],100),mt(e[3],100)];return isNaN(s[0])||isNaN(s[1])||isNaN(s[2])?null:s}function aa(r){return e=>{const s=oa(e);return s?new ue(s,"hsl",r):null}}function la(r){const e=r.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);if(!e)return null;const s=[ta(e[1]),mt(e[2],100),mt(e[3],100),mt(e[4],1)];return isNaN(s[0])||isNaN(s[1])||isNaN(s[2])||isNaN(s[3])?null:s}function ca(r){return e=>{const s=la(e);return s?new ue(s,"hsl",r):null}}function ha(r){const e=r.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];const s=r.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return s?[parseInt(s[1],16),parseInt(s[2],16),parseInt(s[3],16)]:null}function Ep(r){const e=ha(r);return e?new ue(e,"rgb","int"):null}function pa(r){const e=r.match(/^#?([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);if(e)return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),Le(parseInt(e[4]+e[4],16),0,255,0,1)];const s=r.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);return s?[parseInt(s[1],16),parseInt(s[2],16),parseInt(s[3],16),Le(parseInt(s[4],16),0,255,0,1)]:null}function Op(r){const e=pa(r);return e?new ue(e,"rgb","int"):null}function ua(r){const e=r.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const s=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])];return isNaN(s[0])||isNaN(s[1])||isNaN(s[2])?null:s}function da(r){return e=>{const s=ua(e);return s?new ue(s,"rgb",r):null}}function ma(r){const e=r.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);if(!e)return null;const s=[parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]),parseFloat(e[4])];return isNaN(s[0])||isNaN(s[1])||isNaN(s[2])||isNaN(s[3])?null:s}function fa(r){return e=>{const s=ma(e);return s?new ue(s,"rgb",r):null}}const Dp=[{parser:ha,result:{alpha:!1,mode:"rgb",notation:"hex"}},{parser:pa,result:{alpha:!0,mode:"rgb",notation:"hex"}},{parser:na,result:{alpha:!1,mode:"rgb",notation:"func"}},{parser:ia,result:{alpha:!0,mode:"rgb",notation:"func"}},{parser:oa,result:{alpha:!1,mode:"hsl",notation:"func"}},{parser:la,result:{alpha:!0,mode:"hsl",notation:"func"}},{parser:ua,result:{alpha:!1,mode:"rgb",notation:"object"}},{parser:ma,result:{alpha:!0,mode:"rgb",notation:"object"}}];function Vp(r){return Dp.reduce((e,{parser:s,result:h})=>e||(s(r)?h:null),null)}function Xr(r,e="int"){const s=Vp(r);return s?s.notation==="hex"&&e!=="float"?Object.assign(Object.assign({},s),{type:"int"}):s.notation==="func"?Object.assign(Object.assign({},s),{type:e}):null:null}const va={int:[Ep,Op,sa("int"),ra("int"),aa("int"),ca("int"),da("int"),fa("int")],float:[sa("float"),ra("float"),aa("float"),ca("float"),da("float"),fa("float")]};function Ip(r){const e=va[r];return s=>{if(typeof s!="string")return ue.black(r);const h=e.reduce((x,L)=>x||L(s),null);return h??ue.black(r)}}function Zr(r){const e=va[r];return s=>e.reduce((h,x)=>h||x(s),null)}function _a(r){const e=Ie(Math.floor(r),0,255).toString(16);return e.length===1?`0${e}`:e}function ga(r,e="#"){const s=u(r.getComponents("rgb")).map(_a).join("");return`${e}${s}`}function qr(r,e="#"){const s=r.getComponents("rgb"),h=[s[0],s[1],s[2],s[3]*255].map(_a).join("");return`${e}${h}`}function ba(r,e){const s=Ne(e==="float"?2:0);return`rgb(${u(r.getComponents("rgb",e)).map(x=>s(x)).join(", ")})`}function Bp(r){return e=>ba(e,r)}function Oi(r,e){const s=Ne(2),h=Ne(e==="float"?2:0);return`rgba(${r.getComponents("rgb",e).map((L,I)=>(I===3?s:h)(L)).join(", ")})`}function Fp(r){return e=>Oi(e,r)}function Np(r){const e=[Ne(0),Pn,Pn];return`hsl(${u(r.getComponents("hsl")).map((h,x)=>e[x](h)).join(", ")})`}function Up(r){const e=[Ne(0),Pn,Pn,Ne(2)];return`hsla(${r.getComponents("hsl").map((h,x)=>e[x](h)).join(", ")})`}function wa(r,e){const s=Ne(e==="float"?2:0),h=["r","g","b"];return`{${u(r.getComponents("rgb",e)).map((L,I)=>`${h[I]}: ${s(L)}`).join(", ")}}`}function zp(r){return e=>wa(e,r)}function ya(r,e){const s=Ne(2),h=Ne(e==="float"?2:0),x=["r","g","b","a"];return`{${r.getComponents("rgb",e).map((I,q)=>{const ee=q===3?s:h;return`${x[q]}: ${ee(I)}`}).join(", ")}}`}function Rp(r){return e=>ya(e,r)}const jp=[{format:{alpha:!1,mode:"rgb",notation:"hex",type:"int"},stringifier:ga},{format:{alpha:!0,mode:"rgb",notation:"hex",type:"int"},stringifier:qr},{format:{alpha:!1,mode:"hsl",notation:"func",type:"int"},stringifier:Np},{format:{alpha:!0,mode:"hsl",notation:"func",type:"int"},stringifier:Up},...["int","float"].reduce((r,e)=>[...r,{format:{alpha:!1,mode:"rgb",notation:"func",type:e},stringifier:Bp(e)},{format:{alpha:!0,mode:"rgb",notation:"func",type:e},stringifier:Fp(e)},{format:{alpha:!1,mode:"rgb",notation:"object",type:e},stringifier:zp(e)},{format:{alpha:!0,mode:"rgb",notation:"object",type:e},stringifier:Rp(e)}],[])];function Qr(r){return jp.reduce((e,s)=>e||(Sp(s.format,r)?s.stringifier:null),null)}const Zs=M("apl");class Gp{constructor(e,s){this.onValueChange_=this.onValueChange_.bind(this),this.value=s.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Zs()),s.viewProps.bindClassModifiers(this.element),s.viewProps.bindTabIndex(this.element);const h=e.createElement("div");h.classList.add(Zs("b")),this.element.appendChild(h);const x=e.createElement("div");x.classList.add(Zs("c")),h.appendChild(x),this.colorElem_=x;const L=e.createElement("div");L.classList.add(Zs("m")),this.element.appendChild(L),this.markerElem_=L;const I=e.createElement("div");I.classList.add(Zs("p")),this.markerElem_.appendChild(I),this.previewElem_=I,this.update_()}update_(){const e=this.value.rawValue,s=e.getComponents("rgb"),h=new ue([s[0],s[1],s[2],0],"rgb"),x=new ue([s[0],s[1],s[2],255],"rgb"),L=["to right",Oi(h),Oi(x)];this.colorElem_.style.background=`linear-gradient(${L.join(",")})`,this.previewElem_.style.backgroundColor=Oi(e);const I=Le(s[3],0,1,0,100);this.markerElem_.style.left=`${I}%`}onValueChange_(){this.update_()}}class Kp{constructor(e,s){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=s.value,this.viewProps=s.viewProps,this.view=new Gp(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ft(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,s){if(!e.point)return;const h=e.point.x/e.bounds.width,x=this.value.rawValue,[L,I,q]=x.getComponents("hsv");this.value.setRawValue(new ue([L,I,q,h],"hsv"),s)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const s=Re(En(!0),dt(e));if(s===0)return;const h=this.value.rawValue,[x,L,I,q]=h.getComponents("hsv");this.value.setRawValue(new ue([x,L,I,q+s],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){Re(En(!0),dt(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const as=M("coltxt");function Yp(r){const e=r.createElement("select"),s=[{text:"RGB",value:"rgb"},{text:"HSL",value:"hsl"},{text:"HSV",value:"hsv"}];return e.appendChild(s.reduce((h,x)=>{const L=r.createElement("option");return L.textContent=x.text,L.value=x.value,h.appendChild(L),h},r.createDocumentFragment())),e}class Xp{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(as()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("div");h.classList.add(as("m")),this.modeElem_=Yp(e),this.modeElem_.classList.add(as("ms")),h.appendChild(this.modeSelectElement),s.viewProps.bindDisabled(this.modeElem_);const x=e.createElement("div");x.classList.add(as("mm")),x.appendChild(Mt(e,"dropdown")),h.appendChild(x),this.element.appendChild(h);const L=e.createElement("div");L.classList.add(as("w")),this.element.appendChild(L),this.textsElem_=L,this.textViews_=s.textViews,this.applyTextViews_(),S(s.colorMode,I=>{this.modeElem_.value=I})}get modeSelectElement(){return this.modeElem_}get textViews(){return this.textViews_}set textViews(e){this.textViews_=e,this.applyTextViews_()}applyTextViews_(){mn(this.textsElem_);const e=this.element.ownerDocument;this.textViews_.forEach(s=>{const h=e.createElement("div");h.classList.add(as("c")),h.appendChild(s.element),this.textsElem_.appendChild(h)})}}function Zp(r){return Ne(r==="float"?2:0)}function qp(r,e,s){const h=V(r,e)[s];return new $t({min:0,max:h})}function Wr(r,e,s){return new Mn(r,{arrayPosition:s===0?"fst":s===3-1?"lst":"mid",baseStep:En(!1),parser:e.parser,props:H.fromObject({draggingScale:e.colorType==="float"?.01:1,formatter:Zp(e.colorType)}),value:ne(0,{constraint:qp(e.colorMode,e.colorType,s)}),viewProps:e.viewProps})}class Qp{constructor(e,s){this.onModeSelectChange_=this.onModeSelectChange_.bind(this),this.colorType_=s.colorType,this.parser_=s.parser,this.value=s.value,this.viewProps=s.viewProps,this.colorMode=ne(this.value.rawValue.mode),this.ccs_=this.createComponentControllers_(e),this.view=new Xp(e,{colorMode:this.colorMode,textViews:[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view],viewProps:this.viewProps}),this.view.modeSelectElement.addEventListener("change",this.onModeSelectChange_)}createComponentControllers_(e){const s={colorMode:this.colorMode.rawValue,colorType:this.colorType_,parser:this.parser_,viewProps:this.viewProps},h=[Wr(e,s,0),Wr(e,s,1),Wr(e,s,2)];return h.forEach((x,L)=>{tn({primary:this.value,secondary:x.value,forward:I=>I.rawValue.getComponents(this.colorMode.rawValue,this.colorType_)[L],backward:(I,q)=>{const ee=this.colorMode.rawValue,se=I.rawValue.getComponents(ee,this.colorType_);return se[L]=q.rawValue,new ue(w(u(se),se[3]),ee,this.colorType_)}})}),h}onModeSelectChange_(e){const s=e.currentTarget;this.colorMode.rawValue=s.value,this.ccs_=this.createComponentControllers_(this.view.element.ownerDocument),this.view.textViews=[this.ccs_[0].view,this.ccs_[1].view,this.ccs_[2].view]}}const Jr=M("hpl");class Wp{constructor(e,s){this.onValueChange_=this.onValueChange_.bind(this),this.value=s.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Jr()),s.viewProps.bindClassModifiers(this.element),s.viewProps.bindTabIndex(this.element);const h=e.createElement("div");h.classList.add(Jr("c")),this.element.appendChild(h);const x=e.createElement("div");x.classList.add(Jr("m")),this.element.appendChild(x),this.markerElem_=x,this.update_()}update_(){const e=this.value.rawValue,[s]=e.getComponents("hsv");this.markerElem_.style.backgroundColor=ba(new ue([s,100,100],"hsv"));const h=Le(s,0,360,0,100);this.markerElem_.style.left=`${h}%`}onValueChange_(){this.update_()}}class Jp{constructor(e,s){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=s.value,this.viewProps=s.viewProps,this.view=new Wp(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ft(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,s){if(!e.point)return;const h=Le(Ie(e.point.x,0,e.bounds.width),0,e.bounds.width,0,360),x=this.value.rawValue,[,L,I,q]=x.getComponents("hsv");this.value.setRawValue(new ue([h,L,I,q],"hsv"),s)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){const s=Re(En(!1),dt(e));if(s===0)return;const h=this.value.rawValue,[x,L,I,q]=h.getComponents("hsv");this.value.setRawValue(new ue([x+s,L,I,q],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){Re(En(!1),dt(e))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}const Hr=M("svp"),xa=64;class Hp{constructor(e,s){this.onValueChange_=this.onValueChange_.bind(this),this.value=s.value,this.value.emitter.on("change",this.onValueChange_),this.element=e.createElement("div"),this.element.classList.add(Hr()),s.viewProps.bindClassModifiers(this.element),s.viewProps.bindTabIndex(this.element);const h=e.createElement("canvas");h.height=xa,h.width=xa,h.classList.add(Hr("c")),this.element.appendChild(h),this.canvasElement=h;const x=e.createElement("div");x.classList.add(Hr("m")),this.element.appendChild(x),this.markerElem_=x,this.update_()}update_(){const e=Xn(this.canvasElement);if(!e)return;const h=this.value.rawValue.getComponents("hsv"),x=this.canvasElement.width,L=this.canvasElement.height,I=e.getImageData(0,0,x,L),q=I.data;for(let xe=0;xe<L;xe++)for(let Pe=0;Pe<x;Pe++){const Dn=Le(Pe,0,x,0,100),Qs=Le(xe,0,L,100,0),Ws=Ei(h[0],Dn,Qs),Di=(xe*x+Pe)*4;q[Di]=Ws[0],q[Di+1]=Ws[1],q[Di+2]=Ws[2],q[Di+3]=255}e.putImageData(I,0,0);const ee=Le(h[1],0,100,0,100);this.markerElem_.style.left=`${ee}%`;const se=Le(h[2],0,100,100,0);this.markerElem_.style.top=`${se}%`}onValueChange_(){this.update_()}}class $p{constructor(e,s){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=s.value,this.viewProps=s.viewProps,this.view=new Hp(e,{value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ft(this.view.element),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_)}handlePointerEvent_(e,s){if(!e.point)return;const h=Le(e.point.x,0,e.bounds.width,0,100),x=Le(e.point.y,0,e.bounds.height,100,0),[L,,,I]=this.value.rawValue.getComponents("hsv");this.value.setRawValue(new ue([L,h,x,I],"hsv"),s)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onKeyDown_(e){ss(e.key)&&e.preventDefault();const[s,h,x,L]=this.value.rawValue.getComponents("hsv"),I=En(!1),q=Re(I,dt(e)),ee=Re(I,An(e));q===0&&ee===0||this.value.setRawValue(new ue([s,h+q,x+ee,L],"hsv"),{forceEmit:!1,last:!1})}onKeyUp_(e){const s=En(!1),h=Re(s,dt(e)),x=Re(s,An(e));h===0&&x===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class eu{constructor(e,s){this.value=s.value,this.viewProps=s.viewProps,this.hPaletteC_=new Jp(e,{value:this.value,viewProps:this.viewProps}),this.svPaletteC_=new $p(e,{value:this.value,viewProps:this.viewProps}),this.alphaIcs_=s.supportsAlpha?{palette:new Kp(e,{value:this.value,viewProps:this.viewProps}),text:new Mn(e,{parser:ut,baseStep:.1,props:H.fromObject({draggingScale:.01,formatter:Ne(2)}),value:ne(0,{constraint:new $t({min:0,max:1})}),viewProps:this.viewProps})}:null,this.alphaIcs_&&tn({primary:this.value,secondary:this.alphaIcs_.text.value,forward:h=>h.rawValue.getComponents()[3],backward:(h,x)=>{const L=h.rawValue.getComponents();return L[3]=x.rawValue,new ue(L,h.rawValue.mode)}}),this.textC_=new Qp(e,{colorType:s.colorType,parser:ut,value:this.value,viewProps:this.viewProps}),this.view=new Kr(e,{alphaViews:this.alphaIcs_?{palette:this.alphaIcs_.palette.view,text:this.alphaIcs_.text.view}:null,hPaletteView:this.hPaletteC_.view,supportsAlpha:s.supportsAlpha,svPaletteView:this.svPaletteC_.view,textView:this.textC_.view,viewProps:this.viewProps})}get textController(){return this.textC_}}const $r=M("colsw");class tu{constructor(e,s){this.onValueChange_=this.onValueChange_.bind(this),s.value.emitter.on("change",this.onValueChange_),this.value=s.value,this.element=e.createElement("div"),this.element.classList.add($r()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("div");h.classList.add($r("sw")),this.element.appendChild(h),this.swatchElem_=h;const x=e.createElement("button");x.classList.add($r("b")),s.viewProps.bindDisabled(x),this.element.appendChild(x),this.buttonElement=x,this.update_()}update_(){const e=this.value.rawValue;this.swatchElem_.style.backgroundColor=qr(e)}onValueChange_(){this.update_()}}class nu{constructor(e,s){this.value=s.value,this.viewProps=s.viewProps,this.view=new tu(e,{value:this.value,viewProps:this.viewProps})}}class eo{constructor(e,s){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=s.value,this.viewProps=s.viewProps,this.foldable_=je.create(s.expanded),this.swatchC_=new nu(e,{value:this.value,viewProps:this.viewProps});const h=this.swatchC_.view.buttonElement;h.addEventListener("blur",this.onButtonBlur_),h.addEventListener("click",this.onButtonClick_),this.textC_=new ts(e,{parser:s.parser,props:H.fromObject({formatter:s.formatter}),value:this.value,viewProps:this.viewProps}),this.view=new Xs(e,{foldable:this.foldable_,pickerLayout:s.pickerLayout}),this.view.swatchElement.appendChild(this.swatchC_.view.element),this.view.textElement.appendChild(this.textC_.view.element),this.popC_=s.pickerLayout==="popup"?new fi(e,{viewProps:this.viewProps}):null;const x=new eu(e,{colorType:s.colorType,supportsAlpha:s.supportsAlpha,value:this.value,viewProps:this.viewProps});x.view.allFocusableElements.forEach(L=>{L.addEventListener("blur",this.onPopupChildBlur_),L.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=x,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(x.view.element),tn({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:L=>L.rawValue,backward:(L,I)=>I.rawValue})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Xe(this.foldable_,this.view.pickerElement))}get textController(){return this.textC_}onButtonBlur_(e){if(!this.popC_)return;const s=this.view.element,h=e.relatedTarget;(!h||!s.contains(h))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const s=this.popC_.view.element,h=kt(e);h&&s.contains(h)||h&&h===this.swatchC_.view.buttonElement&&!bt(s.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.swatchC_.view.buttonElement.focus()}}function su(r,e){return ue.isColorObject(r)?ue.fromObject(r,e):ue.black(e)}function iu(r){return u(r.getComponents("rgb")).reduce((e,s)=>e<<8|Math.floor(s)&255,0)}function ru(r){return r.getComponents("rgb").reduce((e,s,h)=>{const x=Math.floor(h===3?s*255:s)&255;return e<<8|x},0)>>>0}function ou(r){return new ue([r>>16&255,r>>8&255,r&255],"rgb")}function au(r){return new ue([r>>24&255,r>>16&255,r>>8&255,Le(r&255,0,255,0,1)],"rgb")}function lu(r){return typeof r!="number"?ue.black():ou(r)}function cu(r){return typeof r!="number"?ue.black():au(r)}function hu(r){const e=Qr(r);return e?(s,h)=>{it(s,e(h))}:null}function pu(r){const e=r?ru:iu;return(s,h)=>{it(s,e(h))}}function uu(r,e,s){const h=e.toRgbaObject(s);r.writeProperty("r",h.r),r.writeProperty("g",h.g),r.writeProperty("b",h.b),r.writeProperty("a",h.a)}function du(r,e,s){const h=e.toRgbaObject(s);r.writeProperty("r",h.r),r.writeProperty("g",h.g),r.writeProperty("b",h.b)}function mu(r,e){return(s,h)=>{r?uu(s,h,e):du(s,h,e)}}function to(r){var e;return!!(r!=null&&r.alpha||!((e=r==null?void 0:r.color)===null||e===void 0)&&e.alpha)}function fu(r){return r?e=>qr(e,"0x"):e=>ga(e,"0x")}function vu(r){return"color"in r||"view"in r&&r.view==="color"}const _u={id:"input-color-number",type:"input",accept:(r,e)=>{if(typeof r!="number"||!vu(e))return null;const s=Yr(e);return s?{initialValue:r,params:s}:null},binding:{reader:r=>to(r.params)?cu:lu,equals:ue.equals,writer:r=>pu(to(r.params))},controller:r=>{const e=to(r.params),s="expanded"in r.params?r.params.expanded:void 0,h="picker"in r.params?r.params.picker:void 0;return new eo(r.document,{colorType:"int",expanded:s??!1,formatter:fu(e),parser:Zr("int"),pickerLayout:h??"popup",supportsAlpha:e,value:r.value,viewProps:r.viewProps})}};function gu(r){return ue.isRgbaColorObject(r)}function bu(r){return e=>su(e,r)}function wu(r,e){return s=>r?ya(s,e):wa(s,e)}const yu={id:"input-color-object",type:"input",accept:(r,e)=>{if(!ue.isColorObject(r))return null;const s=Yr(e);return s?{initialValue:r,params:s}:null},binding:{reader:r=>bu(On(r.params)),equals:ue.equals,writer:r=>mu(gu(r.initialValue),On(r.params))},controller:r=>{var e;const s=ue.isRgbaColorObject(r.initialValue),h="expanded"in r.params?r.params.expanded:void 0,x="picker"in r.params?r.params.picker:void 0,L=(e=On(r.params))!==null&&e!==void 0?e:"int";return new eo(r.document,{colorType:L,expanded:h??!1,formatter:wu(s,L),parser:Zr(L),pickerLayout:x??"popup",supportsAlpha:s,value:r.value,viewProps:r.viewProps})}},xu={id:"input-color-string",type:"input",accept:(r,e)=>{if(typeof r!="string"||"view"in e&&e.view==="text")return null;const s=Xr(r,On(e));if(!s||!Qr(s))return null;const x=Yr(e);return x?{initialValue:r,params:x}:null},binding:{reader:r=>{var e;return Ip((e=On(r.params))!==null&&e!==void 0?e:"int")},equals:ue.equals,writer:r=>{const e=Xr(r.initialValue,On(r.params));if(!e)throw k.shouldNeverHappen();const s=hu(e);if(!s)throw k.notBindable();return s}},controller:r=>{const e=Xr(r.initialValue,On(r.params));if(!e)throw k.shouldNeverHappen();const s=Qr(e);if(!s)throw k.shouldNeverHappen();const h="expanded"in r.params?r.params.expanded:void 0,x="picker"in r.params?r.params.picker:void 0;return new eo(r.document,{colorType:e.type,expanded:h??!1,formatter:s,parser:Zr(e.type),pickerLayout:x??"popup",supportsAlpha:e.alpha,value:r.value,viewProps:r.viewProps})}};class sn{constructor(e){this.components=e.components,this.asm_=e.assembly}constrain(e){const s=this.asm_.toComponents(e).map((h,x)=>{var L,I;return(I=(L=this.components[x])===null||L===void 0?void 0:L.constrain(h))!==null&&I!==void 0?I:h});return this.asm_.fromComponents(s)}}const Ca=M("pndtxt");class Cu{constructor(e,s){this.textViews=s.textViews,this.element=e.createElement("div"),this.element.classList.add(Ca()),this.textViews.forEach(h=>{const x=e.createElement("div");x.classList.add(Ca("a")),x.appendChild(h.element),this.element.appendChild(x)})}}function Pu(r,e,s){return new Mn(r,{arrayPosition:s===0?"fst":s===e.axes.length-1?"lst":"mid",baseStep:e.axes[s].baseStep,parser:e.parser,props:e.axes[s].textProps,value:ne(0,{constraint:e.axes[s].constraint}),viewProps:e.viewProps})}class no{constructor(e,s){this.value=s.value,this.viewProps=s.viewProps,this.acs_=s.axes.map((h,x)=>Pu(e,s,x)),this.acs_.forEach((h,x)=>{tn({primary:this.value,secondary:h.value,forward:L=>s.assembly.toComponents(L.rawValue)[x],backward:(L,I)=>{const q=s.assembly.toComponents(L.rawValue);return q[x]=I.rawValue,s.assembly.fromComponents(q)}})}),this.view=new Cu(e,{textViews:this.acs_.map(h=>h.view)})}}function Pa(r,e){return"step"in r&&!b(r.step)?new es(r.step,e):null}function Aa(r){return!b(r.max)&&!b(r.min)?new $t({max:r.max,min:r.min}):!b(r.max)||!b(r.min)?new Es({max:r.max,min:r.min}):null}function Au(r){const e=st(r,$t);if(e)return[e.values.get("min"),e.values.get("max")];const s=st(r,Es);return s?[s.minValue,s.maxValue]:[void 0,void 0]}function Mu(r,e){const s=[],h=Pa(r,e);h&&s.push(h);const x=Aa(r);x&&s.push(x);const L=Ys(r.options);return L&&s.push(L),new wn(s)}const ku={id:"input-number",type:"input",accept:(r,e)=>{if(typeof r!="number")return null;const s=B,h=we(e,{format:s.optional.function,max:s.optional.number,min:s.optional.number,options:s.optional.custom(Ln),step:s.optional.number});return h?{initialValue:r,params:h}:null},binding:{reader:r=>yt,constraint:r=>Mu(r.params,r.initialValue),writer:r=>it},controller:r=>{var e;const s=r.value,h=r.constraint,x=h&&st(h,yn);if(x)return new xn(r.document,{props:new H({options:x.values.value("options")}),value:s,viewProps:r.viewProps});const L=(e="format"in r.params?r.params.format:void 0)!==null&&e!==void 0?e:Ne(rs(h,s.rawValue)),I=h&&st(h,$t);return I?new is(r.document,{baseStep:Nt(h),parser:ut,sliderProps:new H({maxValue:I.values.value("max"),minValue:I.values.value("min")}),textProps:H.fromObject({draggingScale:Ut(h,s.rawValue),formatter:L}),value:s,viewProps:r.viewProps}):new Mn(r.document,{baseStep:Nt(h),parser:ut,props:H.fromObject({draggingScale:Ut(h,s.rawValue),formatter:L}),value:s,viewProps:r.viewProps})}};class rn{constructor(e=0,s=0){this.x=e,this.y=s}getComponents(){return[this.x,this.y]}static isObject(e){if(b(e))return!1;const s=e.x,h=e.y;return!(typeof s!="number"||typeof h!="number")}static equals(e,s){return e.x===s.x&&e.y===s.y}toObject(){return{x:this.x,y:this.y}}}const Ma={toComponents:r=>r.getComponents(),fromComponents:r=>new rn(...r)},ls=M("p2d");class Lu{constructor(e,s){this.element=e.createElement("div"),this.element.classList.add(ls()),s.viewProps.bindClassModifiers(this.element),S(s.expanded,X(this.element,ls(void 0,"expanded")));const h=e.createElement("div");h.classList.add(ls("h")),this.element.appendChild(h);const x=e.createElement("button");x.classList.add(ls("b")),x.appendChild(Mt(e,"p2dpad")),s.viewProps.bindDisabled(x),h.appendChild(x),this.buttonElement=x;const L=e.createElement("div");if(L.classList.add(ls("t")),h.appendChild(L),this.textElement=L,s.pickerLayout==="inline"){const I=e.createElement("div");I.classList.add(ls("p")),this.element.appendChild(I),this.pickerElement=I}else this.pickerElement=null}}const on=M("p2dp");class Su{constructor(e,s){this.onFoldableChange_=this.onFoldableChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.invertsY_=s.invertsY,this.maxValue_=s.maxValue,this.element=e.createElement("div"),this.element.classList.add(on()),s.layout==="popup"&&this.element.classList.add(on(void 0,"p")),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("div");h.classList.add(on("p")),s.viewProps.bindTabIndex(h),this.element.appendChild(h),this.padElement=h;const x=e.createElementNS(Ye,"svg");x.classList.add(on("g")),this.padElement.appendChild(x),this.svgElem_=x;const L=e.createElementNS(Ye,"line");L.classList.add(on("ax")),L.setAttributeNS(null,"x1","0"),L.setAttributeNS(null,"y1","50%"),L.setAttributeNS(null,"x2","100%"),L.setAttributeNS(null,"y2","50%"),this.svgElem_.appendChild(L);const I=e.createElementNS(Ye,"line");I.classList.add(on("ax")),I.setAttributeNS(null,"x1","50%"),I.setAttributeNS(null,"y1","0"),I.setAttributeNS(null,"x2","50%"),I.setAttributeNS(null,"y2","100%"),this.svgElem_.appendChild(I);const q=e.createElementNS(Ye,"line");q.classList.add(on("l")),q.setAttributeNS(null,"x1","50%"),q.setAttributeNS(null,"y1","50%"),this.svgElem_.appendChild(q),this.lineElem_=q;const ee=e.createElement("div");ee.classList.add(on("m")),this.padElement.appendChild(ee),this.markerElem_=ee,s.value.emitter.on("change",this.onValueChange_),this.value=s.value,this.update_()}get allFocusableElements(){return[this.padElement]}update_(){const[e,s]=this.value.rawValue.getComponents(),h=this.maxValue_,x=Le(e,-h,+h,0,100),L=Le(s,-h,+h,0,100),I=this.invertsY_?100-L:L;this.lineElem_.setAttributeNS(null,"x2",`${x}%`),this.lineElem_.setAttributeNS(null,"y2",`${I}%`),this.markerElem_.style.left=`${x}%`,this.markerElem_.style.top=`${I}%`}onValueChange_(){this.update_()}onFoldableChange_(){this.update_()}}function ka(r,e,s){return[Re(e[0],dt(r)),Re(e[1],An(r))*(s?1:-1)]}class Tu{constructor(e,s){this.onPadKeyDown_=this.onPadKeyDown_.bind(this),this.onPadKeyUp_=this.onPadKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.value=s.value,this.viewProps=s.viewProps,this.baseSteps_=s.baseSteps,this.maxValue_=s.maxValue,this.invertsY_=s.invertsY,this.view=new Su(e,{invertsY:this.invertsY_,layout:s.layout,maxValue:this.maxValue_,value:this.value,viewProps:this.viewProps}),this.ptHandler_=new Ft(this.view.padElement),this.ptHandler_.emitter.on("down",this.onPointerDown_),this.ptHandler_.emitter.on("move",this.onPointerMove_),this.ptHandler_.emitter.on("up",this.onPointerUp_),this.view.padElement.addEventListener("keydown",this.onPadKeyDown_),this.view.padElement.addEventListener("keyup",this.onPadKeyUp_)}handlePointerEvent_(e,s){if(!e.point)return;const h=this.maxValue_,x=Le(e.point.x,0,e.bounds.width,-h,+h),L=Le(this.invertsY_?e.bounds.height-e.point.y:e.point.y,0,e.bounds.height,-h,+h);this.value.setRawValue(new rn(x,L),s)}onPointerDown_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerMove_(e){this.handlePointerEvent_(e.data,{forceEmit:!1,last:!1})}onPointerUp_(e){this.handlePointerEvent_(e.data,{forceEmit:!0,last:!0})}onPadKeyDown_(e){ss(e.key)&&e.preventDefault();const[s,h]=ka(e,this.baseSteps_,this.invertsY_);s===0&&h===0||this.value.setRawValue(new rn(this.value.rawValue.x+s,this.value.rawValue.y+h),{forceEmit:!1,last:!1})}onPadKeyUp_(e){const[s,h]=ka(e,this.baseSteps_,this.invertsY_);s===0&&h===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class Eu{constructor(e,s){var h,x;this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.onPadButtonBlur_=this.onPadButtonBlur_.bind(this),this.onPadButtonClick_=this.onPadButtonClick_.bind(this),this.value=s.value,this.viewProps=s.viewProps,this.foldable_=je.create(s.expanded),this.popC_=s.pickerLayout==="popup"?new fi(e,{viewProps:this.viewProps}):null;const L=new Tu(e,{baseSteps:[s.axes[0].baseStep,s.axes[1].baseStep],invertsY:s.invertsY,layout:s.pickerLayout,maxValue:s.maxValue,value:this.value,viewProps:this.viewProps});L.view.allFocusableElements.forEach(I=>{I.addEventListener("blur",this.onPopupChildBlur_),I.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=L,this.textC_=new no(e,{assembly:Ma,axes:s.axes,parser:s.parser,value:this.value,viewProps:this.viewProps}),this.view=new Lu(e,{expanded:this.foldable_.value("expanded"),pickerLayout:s.pickerLayout,viewProps:this.viewProps}),this.view.textElement.appendChild(this.textC_.view.element),(h=this.view.buttonElement)===null||h===void 0||h.addEventListener("blur",this.onPadButtonBlur_),(x=this.view.buttonElement)===null||x===void 0||x.addEventListener("click",this.onPadButtonClick_),this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),tn({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:I=>I.rawValue,backward:(I,q)=>q.rawValue})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Xe(this.foldable_,this.view.pickerElement))}onPadButtonBlur_(e){if(!this.popC_)return;const s=this.view.element,h=e.relatedTarget;(!h||!s.contains(h))&&(this.popC_.shows.rawValue=!1)}onPadButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.view.allFocusableElements[0].focus()}onPopupChildBlur_(e){if(!this.popC_)return;const s=this.popC_.view.element,h=kt(e);h&&s.contains(h)||h&&h===this.view.buttonElement&&!bt(s.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(e){this.popC_?e.key==="Escape"&&(this.popC_.shows.rawValue=!1):this.view.pickerElement&&e.key==="Escape"&&this.view.buttonElement.focus()}}class cs{constructor(e=0,s=0,h=0){this.x=e,this.y=s,this.z=h}getComponents(){return[this.x,this.y,this.z]}static isObject(e){if(b(e))return!1;const s=e.x,h=e.y,x=e.z;return!(typeof s!="number"||typeof h!="number"||typeof x!="number")}static equals(e,s){return e.x===s.x&&e.y===s.y&&e.z===s.z}toObject(){return{x:this.x,y:this.y,z:this.z}}}const La={toComponents:r=>r.getComponents(),fromComponents:r=>new cs(...r)};function Ou(r){return cs.isObject(r)?new cs(r.x,r.y,r.z):new cs}function Du(r,e){r.writeProperty("x",e.x),r.writeProperty("y",e.y),r.writeProperty("z",e.z)}function Vu(r,e){return new sn({assembly:La,components:[Rt("x"in r?r.x:void 0,e.x),Rt("y"in r?r.y:void 0,e.y),Rt("z"in r?r.z:void 0,e.z)]})}function so(r,e){return{baseStep:Nt(e),constraint:e,textProps:H.fromObject({draggingScale:Ut(e,r),formatter:Ne(rs(e,r))})}}const Iu={id:"input-point3d",type:"input",accept:(r,e)=>{if(!cs.isObject(r))return null;const s=B,h=we(e,{x:s.optional.custom(xt),y:s.optional.custom(xt),z:s.optional.custom(xt)});return h?{initialValue:r,params:h}:null},binding:{reader:r=>Ou,constraint:r=>Vu(r.params,r.initialValue),equals:cs.equals,writer:r=>Du},controller:r=>{const e=r.value,s=r.constraint;if(!(s instanceof sn))throw k.shouldNeverHappen();return new no(r.document,{assembly:La,axes:[so(e.rawValue.x,s.components[0]),so(e.rawValue.y,s.components[1]),so(e.rawValue.z,s.components[2])],parser:ut,value:e,viewProps:r.viewProps})}};class hs{constructor(e=0,s=0,h=0,x=0){this.x=e,this.y=s,this.z=h,this.w=x}getComponents(){return[this.x,this.y,this.z,this.w]}static isObject(e){if(b(e))return!1;const s=e.x,h=e.y,x=e.z,L=e.w;return!(typeof s!="number"||typeof h!="number"||typeof x!="number"||typeof L!="number")}static equals(e,s){return e.x===s.x&&e.y===s.y&&e.z===s.z&&e.w===s.w}toObject(){return{x:this.x,y:this.y,z:this.z,w:this.w}}}const Sa={toComponents:r=>r.getComponents(),fromComponents:r=>new hs(...r)};function Bu(r){return hs.isObject(r)?new hs(r.x,r.y,r.z,r.w):new hs}function Fu(r,e){r.writeProperty("x",e.x),r.writeProperty("y",e.y),r.writeProperty("z",e.z),r.writeProperty("w",e.w)}function Nu(r,e){return new sn({assembly:Sa,components:[Rt("x"in r?r.x:void 0,e.x),Rt("y"in r?r.y:void 0,e.y),Rt("z"in r?r.z:void 0,e.z),Rt("w"in r?r.w:void 0,e.w)]})}function Uu(r,e){return{baseStep:Nt(e),constraint:e,textProps:H.fromObject({draggingScale:Ut(e,r),formatter:Ne(rs(e,r))})}}const zu={id:"input-point4d",type:"input",accept:(r,e)=>{if(!hs.isObject(r))return null;const s=B,h=we(e,{x:s.optional.custom(xt),y:s.optional.custom(xt),z:s.optional.custom(xt),w:s.optional.custom(xt)});return h?{initialValue:r,params:h}:null},binding:{reader:r=>Bu,constraint:r=>Nu(r.params,r.initialValue),equals:hs.equals,writer:r=>Fu},controller:r=>{const e=r.value,s=r.constraint;if(!(s instanceof sn))throw k.shouldNeverHappen();return new no(r.document,{assembly:Sa,axes:e.rawValue.getComponents().map((h,x)=>Uu(h,s.components[x])),parser:ut,value:e,viewProps:r.viewProps})}};function Ru(r){const e=[],s=Ys(r.options);return s&&e.push(s),new wn(e)}const ju={id:"input-string",type:"input",accept:(r,e)=>{if(typeof r!="string")return null;const h=we(e,{options:B.optional.custom(Ln)});return h?{initialValue:r,params:h}:null},binding:{reader:r=>Fs,constraint:r=>Ru(r.params),writer:r=>it},controller:r=>{const e=r.document,s=r.value,h=r.constraint,x=h&&st(h,yn);return x?new xn(e,{props:new H({options:x.values.value("options")}),value:s,viewProps:r.viewProps}):new ts(e,{parser:L=>L,props:H.fromObject({formatter:St}),value:s,viewProps:r.viewProps})}},qs={monitor:{defaultInterval:200,defaultLineCount:3}},Ta=M("mll");class Gu{constructor(e,s){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=s.formatter,this.element=e.createElement("div"),this.element.classList.add(Ta()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("textarea");h.classList.add(Ta("i")),h.style.height=`calc(var(--bld-us) * ${s.lineCount})`,h.readOnly=!0,s.viewProps.bindDisabled(h),this.element.appendChild(h),this.textareaElem_=h,s.value.emitter.on("change",this.onValueUpdate_),this.value=s.value,this.update_()}update_(){const e=this.textareaElem_,s=e.scrollTop===e.scrollHeight-e.clientHeight,h=[];this.value.rawValue.forEach(x=>{x!==void 0&&h.push(this.formatter_(x))}),e.textContent=h.join(`
|
|
97
|
-
`),s&&(e.scrollTop=e.scrollHeight)}onValueUpdate_(){this.update_()}}class io{constructor(e,s){this.value=s.value,this.viewProps=s.viewProps,this.view=new Gu(e,{formatter:s.formatter,lineCount:s.lineCount,value:this.value,viewProps:this.viewProps})}}const Ea=M("sgl");class Ku{constructor(e,s){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=s.formatter,this.element=e.createElement("div"),this.element.classList.add(Ea()),s.viewProps.bindClassModifiers(this.element);const h=e.createElement("input");h.classList.add(Ea("i")),h.readOnly=!0,h.type="text",s.viewProps.bindDisabled(h),this.element.appendChild(h),this.inputElement=h,s.value.emitter.on("change",this.onValueUpdate_),this.value=s.value,this.update_()}update_(){const e=this.value.rawValue,s=e[e.length-1];this.inputElement.value=s!==void 0?this.formatter_(s):""}onValueUpdate_(){this.update_()}}class ro{constructor(e,s){this.value=s.value,this.viewProps=s.viewProps,this.view=new Ku(e,{formatter:s.formatter,value:this.value,viewProps:this.viewProps})}}const Yu={id:"monitor-bool",type:"monitor",accept:(r,e)=>{if(typeof r!="boolean")return null;const h=we(e,{lineCount:B.optional.number});return h?{initialValue:r,params:h}:null},binding:{reader:r=>_i},controller:r=>{var e;return r.value.rawValue.length===1?new ro(r.document,{formatter:gi,value:r.value,viewProps:r.viewProps}):new io(r.document,{formatter:gi,lineCount:(e=r.params.lineCount)!==null&&e!==void 0?e:qs.monitor.defaultLineCount,value:r.value,viewProps:r.viewProps})}},an=M("grl");class Xu{constructor(e,s){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=e.createElement("div"),this.element.classList.add(an()),s.viewProps.bindClassModifiers(this.element),this.formatter_=s.formatter,this.props_=s.props,this.cursor_=s.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const h=e.createElementNS(Ye,"svg");h.classList.add(an("g")),h.style.height=`calc(var(--bld-us) * ${s.lineCount})`,this.element.appendChild(h),this.svgElem_=h;const x=e.createElementNS(Ye,"polyline");this.svgElem_.appendChild(x),this.lineElem_=x;const L=e.createElement("div");L.classList.add(an("t"),M("tt")()),this.element.appendChild(L),this.tooltipElem_=L,s.value.emitter.on("change",this.onValueUpdate_),this.value=s.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const e=this.svgElem_.getBoundingClientRect(),s=this.value.rawValue.length-1,h=this.props_.get("minValue"),x=this.props_.get("maxValue"),L=[];this.value.rawValue.forEach((xe,Pe)=>{if(xe===void 0)return;const Dn=Le(Pe,0,s,0,e.width),Qs=Le(xe,h,x,e.height,0);L.push([Dn,Qs].join(","))}),this.lineElem_.setAttributeNS(null,"points",L.join(" "));const I=this.tooltipElem_,q=this.value.rawValue[this.cursor_.rawValue];if(q===void 0){I.classList.remove(an("t","a"));return}const ee=Le(this.cursor_.rawValue,0,s,0,e.width),se=Le(q,h,x,e.height,0);I.style.left=`${ee}px`,I.style.top=`${se}px`,I.textContent=`${this.formatter_(q)}`,I.classList.contains(an("t","a"))||(I.classList.add(an("t","a"),an("t","in")),ct(I),I.classList.remove(an("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class Zu{constructor(e,s){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props_=s.props,this.value=s.value,this.viewProps=s.viewProps,this.cursor_=ne(-1),this.view=new Xu(e,{cursor:this.cursor_,formatter:s.formatter,lineCount:s.lineCount,props:this.props_,value:this.value,viewProps:this.viewProps}),!bt(e))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const h=new Ft(this.view.element);h.emitter.on("down",this.onGraphPointerDown_),h.emitter.on("move",this.onGraphPointerMove_),h.emitter.on("up",this.onGraphPointerUp_)}}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(e){const s=this.view.element.getBoundingClientRect();this.cursor_.rawValue=Math.floor(Le(e.offsetX,0,s.width,0,this.value.rawValue.length))}onGraphPointerDown_(e){this.onGraphPointerMove_(e)}onGraphPointerMove_(e){if(!e.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(Le(e.data.point.x,0,e.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}function oo(r){return"format"in r&&!b(r.format)?r.format:Ne(2)}function qu(r){var e;return r.value.rawValue.length===1?new ro(r.document,{formatter:oo(r.params),value:r.value,viewProps:r.viewProps}):new io(r.document,{formatter:oo(r.params),lineCount:(e=r.params.lineCount)!==null&&e!==void 0?e:qs.monitor.defaultLineCount,value:r.value,viewProps:r.viewProps})}function Qu(r){var e,s,h;return new Zu(r.document,{formatter:oo(r.params),lineCount:(e=r.params.lineCount)!==null&&e!==void 0?e:qs.monitor.defaultLineCount,props:H.fromObject({maxValue:(s="max"in r.params?r.params.max:null)!==null&&s!==void 0?s:100,minValue:(h="min"in r.params?r.params.min:null)!==null&&h!==void 0?h:0}),value:r.value,viewProps:r.viewProps})}function Oa(r){return"view"in r&&r.view==="graph"}const Wu={id:"monitor-number",type:"monitor",accept:(r,e)=>{if(typeof r!="number")return null;const s=B,h=we(e,{format:s.optional.function,lineCount:s.optional.number,max:s.optional.number,min:s.optional.number,view:s.optional.string});return h?{initialValue:r,params:h}:null},binding:{defaultBufferSize:r=>Oa(r)?64:1,reader:r=>yt},controller:r=>Oa(r.params)?Qu(r):qu(r)},Ju={id:"monitor-string",type:"monitor",accept:(r,e)=>{if(typeof r!="string")return null;const s=B,h=we(e,{lineCount:s.optional.number,multiline:s.optional.boolean});return h?{initialValue:r,params:h}:null},binding:{reader:r=>Fs},controller:r=>{var e;const s=r.value;return s.rawValue.length>1||"multiline"in r.params&&r.params.multiline?new io(r.document,{formatter:St,lineCount:(e=r.params.lineCount)!==null&&e!==void 0?e:qs.monitor.defaultLineCount,value:s,viewProps:r.viewProps}):new ro(r.document,{formatter:St,value:s,viewProps:r.viewProps})}};function Hu(r,e){var s;const h=r.accept(e.target.read(),e.params);if(b(h))return null;const x=B,L={target:e.target,initialValue:h.initialValue,params:h.params},I=r.binding.reader(L),q=r.binding.constraint?r.binding.constraint(L):void 0,ee=ne(I(h.initialValue),{constraint:q,equals:r.binding.equals}),se=new $n({reader:I,target:e.target,value:ee,writer:r.binding.writer(L)}),xe=x.optional.boolean(e.params.disabled).value,Pe=x.optional.boolean(e.params.hidden).value,Dn=r.controller({constraint:q,document:e.document,initialValue:h.initialValue,params:h.params,value:se.value,viewProps:He.create({disabled:xe,hidden:Pe})});return new Ke(e.document,{binding:se,blade:Oe(),props:H.fromObject({label:"label"in e.params?(s=x.optional.string(e.params.label).value)!==null&&s!==void 0?s:null:e.target.key}),valueController:Dn})}function $u(r,e){return e===0?new pi:new Ts(r,e??qs.monitor.defaultInterval)}function ed(r,e){var s,h,x;const L=B,I=r.accept(e.target.read(),e.params);if(b(I))return null;const q={target:e.target,initialValue:I.initialValue,params:I.params},ee=r.binding.reader(q),se=(h=(s=L.optional.number(e.params.bufferSize).value)!==null&&s!==void 0?s:r.binding.defaultBufferSize&&r.binding.defaultBufferSize(I.params))!==null&&h!==void 0?h:1,xe=L.optional.number(e.params.interval).value,Pe=new yr({reader:ee,target:e.target,ticker:$u(e.document,xe),value:ui(se)}),Dn=L.optional.boolean(e.params.disabled).value,Qs=L.optional.boolean(e.params.hidden).value,Ws=r.controller({document:e.document,params:I.params,value:Pe.value,viewProps:He.create({disabled:Dn,hidden:Qs})});return new ht(e.document,{binding:Pe,blade:Oe(),props:H.fromObject({label:"label"in e.params?(x=L.optional.string(e.params.label).value)!==null&&x!==void 0?x:null:e.target.key}),valueController:Ws})}class td{constructor(){this.pluginsMap_={blades:[],inputs:[],monitors:[]}}getAll(){return[...this.pluginsMap_.blades,...this.pluginsMap_.inputs,...this.pluginsMap_.monitors]}register(e){e.type==="blade"?this.pluginsMap_.blades.unshift(e):e.type==="input"?this.pluginsMap_.inputs.unshift(e):e.type==="monitor"&&this.pluginsMap_.monitors.unshift(e)}createInput(e,s,h){const x=s.read();if(b(x))throw new k({context:{key:s.key},type:"nomatchingcontroller"});const L=this.pluginsMap_.inputs.reduce((I,q)=>I??Hu(q,{document:e,target:s,params:h}),null);if(L)return L;throw new k({context:{key:s.key},type:"nomatchingcontroller"})}createMonitor(e,s,h){const x=this.pluginsMap_.monitors.reduce((L,I)=>L??ed(I,{document:e,params:h,target:s}),null);if(x)return x;throw new k({context:{key:s.key},type:"nomatchingcontroller"})}createBlade(e,s){const h=this.pluginsMap_.blades.reduce((x,L)=>x??wr(L,{document:e,params:s}),null);if(!h)throw new k({type:"nomatchingview",context:{params:s}});return h}createBladeApi(e){if(e instanceof Ke)return new xs(e);if(e instanceof ht)return new Cs(e);if(e instanceof _n)return new Wn(e,this);const s=this.pluginsMap_.blades.reduce((h,x)=>h??x.api({controller:e,pool:this}),null);if(!s)throw k.shouldNeverHappen();return s}}function nd(){const r=new td;return[ld,Iu,zu,ju,ku,xu,yu,_u,os,Yu,Ju,Wu,ae,fr,_r,Ss].forEach(e=>{r.register(e)}),r}function sd(r){return rn.isObject(r)?new rn(r.x,r.y):new rn}function id(r,e){r.writeProperty("x",e.x),r.writeProperty("y",e.y)}function Rt(r,e){if(!r)return;const s=[],h=Pa(r,e);h&&s.push(h);const x=Aa(r);return x&&s.push(x),new wn(s)}function rd(r,e){return new sn({assembly:Ma,components:[Rt("x"in r?r.x:void 0,e.x),Rt("y"in r?r.y:void 0,e.y)]})}function Da(r,e){const[s,h]=r?Au(r):[];if(!b(s)||!b(h))return Math.max(Math.abs(s??0),Math.abs(h??0));const x=Nt(r);return Math.max(Math.abs(x)*10,Math.abs(e)*10)}function od(r,e){const s=e instanceof sn?e.components[0]:void 0,h=e instanceof sn?e.components[1]:void 0,x=Da(s,r.x),L=Da(h,r.y);return Math.max(x,L)}function Va(r,e){return{baseStep:Nt(e),constraint:e,textProps:H.fromObject({draggingScale:Ut(e,r),formatter:Ne(rs(e,r))})}}function ad(r){if(!("y"in r))return!1;const e=r.y;return e&&"inverted"in e?!!e.inverted:!1}const ld={id:"input-point2d",type:"input",accept:(r,e)=>{if(!rn.isObject(r))return null;const s=B,h=we(e,{expanded:s.optional.boolean,picker:s.optional.custom(Ks),x:s.optional.custom(xt),y:s.optional.object({inverted:s.optional.boolean,max:s.optional.number,min:s.optional.number,step:s.optional.number})});return h?{initialValue:r,params:h}:null},binding:{reader:r=>sd,constraint:r=>rd(r.params,r.initialValue),equals:rn.equals,writer:r=>id},controller:r=>{const e=r.document,s=r.value,h=r.constraint;if(!(h instanceof sn))throw k.shouldNeverHappen();const x="expanded"in r.params?r.params.expanded:void 0,L="picker"in r.params?r.params.picker:void 0;return new Eu(e,{axes:[Va(s.rawValue.x,h.components[0]),Va(s.rawValue.y,h.components[1])],expanded:x??!1,invertsY:ad(r.params),maxValue:od(s.rawValue,h),parser:ut,pickerLayout:L??"popup",value:s,viewProps:r.viewProps})}};class Ia extends o{constructor(e){super(e),this.emitter_=new N,this.controller_.valueController.value.emitter.on("change",s=>{this.emitter_.emit("change",{event:new c(this,s.rawValue)})})}get label(){return this.controller_.props.get("label")}set label(e){this.controller_.props.set("label",e)}get options(){return this.controller_.valueController.props.get("options")}set options(e){this.controller_.valueController.props.set("options",e)}get value(){return this.controller_.valueController.value.rawValue}set value(e){this.controller_.valueController.value.rawValue=e}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}}class Ba extends o{constructor(e){super(e),this.emitter_=new N,this.controller_.valueController.value.emitter.on("change",s=>{this.emitter_.emit("change",{event:new c(this,s.rawValue)})})}get label(){return this.controller_.props.get("label")}set label(e){this.controller_.props.set("label",e)}get maxValue(){return this.controller_.valueController.sliderController.props.get("maxValue")}set maxValue(e){this.controller_.valueController.sliderController.props.set("maxValue",e)}get minValue(){return this.controller_.valueController.sliderController.props.get("minValue")}set minValue(e){this.controller_.valueController.sliderController.props.set("minValue",e)}get value(){return this.controller_.valueController.value.rawValue}set value(e){this.controller_.valueController.value.rawValue=e}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}}class Fa extends o{constructor(e){super(e),this.emitter_=new N,this.controller_.valueController.value.emitter.on("change",s=>{this.emitter_.emit("change",{event:new c(this,s.rawValue)})})}get label(){return this.controller_.props.get("label")}set label(e){this.controller_.props.set("label",e)}get formatter(){return this.controller_.valueController.props.get("formatter")}set formatter(e){this.controller_.valueController.props.set("formatter",e)}get value(){return this.controller_.valueController.value.rawValue}set value(e){this.controller_.valueController.value.rawValue=e}on(e,s){const h=s.bind(this);return this.emitter_.on(e,x=>{h(x.event)}),this}}const cd=function(){return{id:"list",type:"blade",accept(r){const e=B,s=we(r,{options:e.required.custom(Ln),value:e.required.raw,view:e.required.constant("list"),label:e.optional.string});return s?{params:s}:null},controller(r){const e=new yn(Li(r.params.options)),s=ne(r.params.value,{constraint:e}),h=new xn(r.document,{props:new H({options:e.values.value("options")}),value:s,viewProps:r.viewProps});return new Qt(r.document,{blade:r.blade,props:H.fromObject({label:r.params.label}),valueController:h})},api(r){return!(r.controller instanceof Qt)||!(r.controller.valueController instanceof xn)?null:new Ia(r.controller)}}}();function hd(r){return r.reduce((e,s)=>Object.assign(e,{[s.presetKey]:s.read()}),{})}function pd(r,e){r.forEach(s=>{const h=e[s.target.presetKey];h!==void 0&&s.writer(s.target,s.reader(h))})}class ud extends Ps{constructor(e,s){super(e,s)}get element(){return this.controller_.view.element}importPreset(e){const s=this.controller_.rackController.rack.find(Ke).map(h=>h.binding);pd(s,e),this.refresh()}exportPreset(){const e=this.controller_.rackController.rack.find(Ke).map(s=>s.binding.target);return hd(e)}refresh(){this.controller_.rackController.rack.find(Ke).forEach(e=>{e.binding.read()}),this.controller_.rackController.rack.find(ht).forEach(e=>{e.binding.read()})}}class dd extends Jn{constructor(e,s){super(e,{expanded:s.expanded,blade:s.blade,props:s.props,root:!0,viewProps:s.viewProps})}}const md={id:"slider",type:"blade",accept(r){const e=B,s=we(r,{max:e.required.number,min:e.required.number,view:e.required.constant("slider"),format:e.optional.function,label:e.optional.string,value:e.optional.number});return s?{params:s}:null},controller(r){var e,s;const h=(e=r.params.value)!==null&&e!==void 0?e:0,x=new $t({max:r.params.max,min:r.params.min}),L=new is(r.document,{baseStep:1,parser:ut,sliderProps:new H({maxValue:x.values.value("max"),minValue:x.values.value("min")}),textProps:H.fromObject({draggingScale:Ut(void 0,h),formatter:(s=r.params.format)!==null&&s!==void 0?s:Ur}),value:ne(h,{constraint:x}),viewProps:r.viewProps});return new Qt(r.document,{blade:r.blade,props:H.fromObject({label:r.params.label}),valueController:L})},api(r){return!(r.controller instanceof Qt)||!(r.controller.valueController instanceof is)?null:new Ba(r.controller)}},fd=function(){return{id:"text",type:"blade",accept(r){const e=B,s=we(r,{parse:e.required.function,value:e.required.raw,view:e.required.constant("text"),format:e.optional.function,label:e.optional.string});return s?{params:s}:null},controller(r){var e;const s=new ts(r.document,{parser:r.params.parse,props:H.fromObject({formatter:(e=r.params.format)!==null&&e!==void 0?e:h=>String(h)}),value:ne(r.params.value),viewProps:r.viewProps});return new Qt(r.document,{blade:r.blade,props:H.fromObject({label:r.params.label}),valueController:s})},api(r){return!(r.controller instanceof Qt)||!(r.controller.valueController instanceof ts)?null:new Fa(r.controller)}}}();function vd(r){const e=r.createElement("div");return e.classList.add(M("dfw")()),r.body&&r.body.appendChild(e),e}function Na(r,e,s){if(r.querySelector(`style[data-tp-style=${e}]`))return;const h=r.createElement("style");h.dataset.tpStyle=e,h.textContent=s,r.head.appendChild(h)}class _d extends ud{constructor(e){var s,h;const x=e??{},L=(s=x.document)!==null&&s!==void 0?s:ws(),I=nd(),q=new dd(L,{expanded:x.expanded,blade:Oe(),props:H.fromObject({title:x.title}),viewProps:He.create()});super(q,I),this.pool_=I,this.containerElem_=(h=x.container)!==null&&h!==void 0?h:vd(L),this.containerElem_.appendChild(this.element),this.doc_=L,this.usesDefaultWrapper_=!x.container,this.setUpDefaultPlugins_()}get document(){if(!this.doc_)throw k.alreadyDisposed();return this.doc_}dispose(){const e=this.containerElem_;if(!e)throw k.alreadyDisposed();if(this.usesDefaultWrapper_){const s=e.parentElement;s&&s.removeChild(e)}this.containerElem_=null,this.doc_=null,super.dispose()}registerPlugin(e){("plugin"in e?[e.plugin]:"plugins"in e?e.plugins:[]).forEach(h=>{this.pool_.register(h),this.embedPluginStyle_(h)})}embedPluginStyle_(e){e.css&&Na(this.document,`plugin-${e.id}`,e.css)}setUpDefaultPlugins_(){Na(this.document,"default",'.tp-tbiv_b,.tp-coltxtv_ms,.tp-ckbv_i,.tp-rotv_b,.tp-fldv_b,.tp-mllv_i,.tp-sglv_i,.tp-grlv_g,.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw,.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-p2dv_b:hover,.tp-btnv_b:hover,.tp-lstv_s:hover{background-color:var(--btn-bg-h)}.tp-p2dv_b:focus,.tp-btnv_b:focus,.tp-lstv_s:focus{background-color:var(--btn-bg-f)}.tp-p2dv_b:active,.tp-btnv_b:active,.tp-lstv_s:active{background-color:var(--btn-bg-a)}.tp-p2dv_b:disabled,.tp-btnv_b:disabled,.tp-lstv_s:disabled{opacity:.5}.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-txtv_i:hover,.tp-p2dpv_p:hover,.tp-colswv_sw:hover{background-color:var(--in-bg-h)}.tp-txtv_i:focus,.tp-p2dpv_p:focus,.tp-colswv_sw:focus{background-color:var(--in-bg-f)}.tp-txtv_i:active,.tp-p2dpv_p:active,.tp-colswv_sw:active{background-color:var(--in-bg-a)}.tp-txtv_i:disabled,.tp-p2dpv_p:disabled,.tp-colswv_sw:disabled{opacity:.5}.tp-mllv_i,.tp-sglv_i,.tp-grlv_g{background-color:var(--mo-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--mo-fg);height:var(--bld-us);scrollbar-color:currentColor rgba(0,0,0,0);scrollbar-width:thin;width:100%}.tp-mllv_i::-webkit-scrollbar,.tp-sglv_i::-webkit-scrollbar,.tp-grlv_g::-webkit-scrollbar{height:8px;width:8px}.tp-mllv_i::-webkit-scrollbar-corner,.tp-sglv_i::-webkit-scrollbar-corner,.tp-grlv_g::-webkit-scrollbar-corner{background-color:rgba(0,0,0,0)}.tp-mllv_i::-webkit-scrollbar-thumb,.tp-sglv_i::-webkit-scrollbar-thumb,.tp-grlv_g::-webkit-scrollbar-thumb{background-clip:padding-box;background-color:currentColor;border:rgba(0,0,0,0) solid 2px;border-radius:4px}.tp-rotv{--font-family: var(--tp-font-family, Roboto Mono, Source Code Pro, Menlo, Courier, monospace);--bs-br: var(--tp-base-border-radius, 6px);--cnt-h-p: var(--tp-container-horizontal-padding, 4px);--cnt-v-p: var(--tp-container-vertical-padding, 4px);--elm-br: var(--tp-element-border-radius, 2px);--bld-s: var(--tp-blade-spacing, 4px);--bld-us: var(--tp-blade-unit-size, 20px);--bs-bg: var(--tp-base-background-color, hsl(230, 7%, 17%));--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--btn-bg: var(--tp-button-background-color, hsl(230, 7%, 70%));--btn-bg-a: var(--tp-button-background-color-active, #d6d7db);--btn-bg-f: var(--tp-button-background-color-focus, #c8cad0);--btn-bg-h: var(--tp-button-background-color-hover, #bbbcc4);--btn-fg: var(--tp-button-foreground-color, hsl(230, 7%, 17%));--cnt-bg: var(--tp-container-background-color, rgba(187, 188, 196, 0.1));--cnt-bg-a: var(--tp-container-background-color-active, rgba(187, 188, 196, 0.25));--cnt-bg-f: var(--tp-container-background-color-focus, rgba(187, 188, 196, 0.2));--cnt-bg-h: var(--tp-container-background-color-hover, rgba(187, 188, 196, 0.15));--cnt-fg: var(--tp-container-foreground-color, hsl(230, 7%, 75%));--in-bg: var(--tp-input-background-color, rgba(187, 188, 196, 0.1));--in-bg-a: var(--tp-input-background-color-active, rgba(187, 188, 196, 0.25));--in-bg-f: var(--tp-input-background-color-focus, rgba(187, 188, 196, 0.2));--in-bg-h: var(--tp-input-background-color-hover, rgba(187, 188, 196, 0.15));--in-fg: var(--tp-input-foreground-color, hsl(230, 7%, 75%));--lbl-fg: var(--tp-label-foreground-color, rgba(187, 188, 196, 0.7));--mo-bg: var(--tp-monitor-background-color, rgba(0, 0, 0, 0.2));--mo-fg: var(--tp-monitor-foreground-color, rgba(187, 188, 196, 0.7));--grv-fg: var(--tp-groove-foreground-color, rgba(187, 188, 196, 0.1))}.tp-rotv_c>.tp-cntv.tp-v-lst,.tp-tabv_c .tp-brkv>.tp-cntv.tp-v-lst,.tp-fldv_c>.tp-cntv.tp-v-lst{margin-bottom:calc(-1*var(--cnt-v-p))}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-tabv_c .tp-brkv>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_c{border-bottom-left-radius:0}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-tabv_c .tp-brkv>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_b{border-bottom-left-radius:0}.tp-rotv_c>*:not(.tp-v-fst),.tp-tabv_c .tp-brkv>*:not(.tp-v-fst),.tp-fldv_c>*:not(.tp-v-fst){margin-top:var(--bld-s)}.tp-rotv_c>.tp-sprv:not(.tp-v-fst),.tp-tabv_c .tp-brkv>.tp-sprv:not(.tp-v-fst),.tp-fldv_c>.tp-sprv:not(.tp-v-fst),.tp-rotv_c>.tp-cntv:not(.tp-v-fst),.tp-tabv_c .tp-brkv>.tp-cntv:not(.tp-v-fst),.tp-fldv_c>.tp-cntv:not(.tp-v-fst){margin-top:var(--cnt-v-p)}.tp-rotv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-tabv_c .tp-brkv>.tp-sprv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-rotv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-tabv_c .tp-brkv>.tp-cntv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-cntv+*:not(.tp-v-hidden){margin-top:var(--cnt-v-p)}.tp-rotv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-tabv_c .tp-brkv>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-fldv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-rotv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-tabv_c .tp-brkv>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-fldv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv{margin-top:0}.tp-tabv_c .tp-brkv>.tp-cntv,.tp-fldv_c>.tp-cntv{margin-left:4px}.tp-tabv_c .tp-brkv>.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-fldv>.tp-fldv_b{border-top-left-radius:var(--elm-br);border-bottom-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv>.tp-fldv.tp-fldv-expanded>.tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b{border-bottom-left-radius:0}.tp-tabv_c .tp-brkv .tp-fldv>.tp-fldv_c,.tp-fldv_c .tp-fldv>.tp-fldv_c{border-bottom-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv>.tp-cntv+.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-cntv+.tp-fldv>.tp-fldv_b{border-top-left-radius:0}.tp-tabv_c .tp-brkv>.tp-cntv+.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-cntv+.tp-tabv>.tp-tabv_t{border-top-left-radius:0}.tp-tabv_c .tp-brkv>.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-tabv>.tp-tabv_t{border-top-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv .tp-tabv>.tp-tabv_c,.tp-fldv_c .tp-tabv>.tp-tabv_c{border-bottom-left-radius:var(--elm-br)}.tp-rotv_b,.tp-fldv_b{background-color:var(--cnt-bg);color:var(--cnt-fg);cursor:pointer;display:block;height:calc(var(--bld-us) + 4px);line-height:calc(var(--bld-us) + 4px);overflow:hidden;padding-left:var(--cnt-h-p);padding-right:calc(4px + var(--bld-us) + var(--cnt-h-p));position:relative;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%;transition:border-radius .2s ease-in-out .2s}.tp-rotv_b:hover,.tp-fldv_b:hover{background-color:var(--cnt-bg-h)}.tp-rotv_b:focus,.tp-fldv_b:focus{background-color:var(--cnt-bg-f)}.tp-rotv_b:active,.tp-fldv_b:active{background-color:var(--cnt-bg-a)}.tp-rotv_b:disabled,.tp-fldv_b:disabled{opacity:.5}.tp-rotv_m,.tp-fldv_m{background:linear-gradient(to left, var(--cnt-fg), var(--cnt-fg) 2px, transparent 2px, transparent 4px, var(--cnt-fg) 4px);border-radius:2px;bottom:0;content:"";display:block;height:6px;right:calc(var(--cnt-h-p) + (var(--bld-us) + 4px - 6px)/2 - 2px);margin:auto;opacity:.5;position:absolute;top:0;transform:rotate(90deg);transition:transform .2s ease-in-out;width:6px}.tp-rotv.tp-rotv-expanded .tp-rotv_m,.tp-fldv.tp-fldv-expanded>.tp-fldv_b>.tp-fldv_m{transform:none}.tp-rotv_c,.tp-fldv_c{box-sizing:border-box;height:0;opacity:0;overflow:hidden;padding-bottom:0;padding-top:0;position:relative;transition:height .2s ease-in-out,opacity .2s linear,padding .2s ease-in-out}.tp-rotv.tp-rotv-cpl:not(.tp-rotv-expanded) .tp-rotv_c,.tp-fldv.tp-fldv-cpl:not(.tp-fldv-expanded)>.tp-fldv_c{display:none}.tp-rotv.tp-rotv-expanded .tp-rotv_c,.tp-fldv.tp-fldv-expanded>.tp-fldv_c{opacity:1;padding-bottom:var(--cnt-v-p);padding-top:var(--cnt-v-p);transform:none;overflow:visible;transition:height .2s ease-in-out,opacity .2s linear .2s,padding .2s ease-in-out}.tp-lstv,.tp-coltxtv_m{position:relative}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m,.tp-coltxtv_mm{bottom:0;margin:auto;pointer-events:none;position:absolute;right:2px;top:0}.tp-lstv_m svg,.tp-coltxtv_mm svg{bottom:0;height:16px;margin:auto;position:absolute;right:0;top:0;width:16px}.tp-lstv_m svg path,.tp-coltxtv_mm svg path{fill:currentColor}.tp-pndtxtv,.tp-coltxtv_w{display:flex}.tp-pndtxtv_a,.tp-coltxtv_c{width:100%}.tp-pndtxtv_a+.tp-pndtxtv_a,.tp-coltxtv_c+.tp-pndtxtv_a,.tp-pndtxtv_a+.tp-coltxtv_c,.tp-coltxtv_c+.tp-coltxtv_c{margin-left:2px}.tp-btnv_b{width:100%}.tp-btnv_t{text-align:center}.tp-ckbv_l{display:block;position:relative}.tp-ckbv_i{left:0;opacity:0;position:absolute;top:0}.tp-ckbv_w{background-color:var(--in-bg);border-radius:var(--elm-br);cursor:pointer;display:block;height:var(--bld-us);position:relative;width:var(--bld-us)}.tp-ckbv_w svg{bottom:0;display:block;height:16px;left:0;margin:auto;opacity:0;position:absolute;right:0;top:0;width:16px}.tp-ckbv_w svg path{fill:none;stroke:var(--in-fg);stroke-width:2}.tp-ckbv_i:hover+.tp-ckbv_w{background-color:var(--in-bg-h)}.tp-ckbv_i:focus+.tp-ckbv_w{background-color:var(--in-bg-f)}.tp-ckbv_i:active+.tp-ckbv_w{background-color:var(--in-bg-a)}.tp-ckbv_i:checked+.tp-ckbv_w svg{opacity:1}.tp-ckbv.tp-v-disabled .tp-ckbv_w{opacity:.5}.tp-colv{position:relative}.tp-colv_h{display:flex}.tp-colv_s{flex-grow:0;flex-shrink:0;width:var(--bld-us)}.tp-colv_t{flex:1;margin-left:4px}.tp-colv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-colv.tp-colv-expanded.tp-colv-cpl .tp-colv_p{overflow:visible}.tp-colv.tp-colv-expanded .tp-colv_p{margin-top:var(--bld-s);opacity:1}.tp-colv .tp-popv{left:calc(-1*var(--cnt-h-p));right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-colpv_h,.tp-colpv_ap{margin-left:6px;margin-right:6px}.tp-colpv_h{margin-top:var(--bld-s)}.tp-colpv_rgb{display:flex;margin-top:var(--bld-s);width:100%}.tp-colpv_a{display:flex;margin-top:var(--cnt-v-p);padding-top:calc(var(--cnt-v-p) + 2px);position:relative}.tp-colpv_a::before{background-color:var(--grv-fg);content:"";height:2px;left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:0}.tp-colpv.tp-v-disabled .tp-colpv_a::before{opacity:.5}.tp-colpv_ap{align-items:center;display:flex;flex:3}.tp-colpv_at{flex:1;margin-left:4px}.tp-svpv{border-radius:var(--elm-br);outline:none;overflow:hidden;position:relative}.tp-svpv.tp-v-disabled{opacity:.5}.tp-svpv_c{cursor:crosshair;display:block;height:calc(var(--bld-us)*4);width:100%}.tp-svpv_m{border-radius:100%;border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;filter:drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));height:12px;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;width:12px}.tp-svpv:focus .tp-svpv_m{border-color:#fff}.tp-hplv{cursor:pointer;height:var(--bld-us);outline:none;position:relative}.tp-hplv.tp-v-disabled{opacity:.5}.tp-hplv_c{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAABCAYAAABubagXAAAAQ0lEQVQoU2P8z8Dwn0GCgQEDi2OK/RBgYHjBgIpfovFh8j8YBIgzFGQxuqEgPhaDOT5gOhPkdCxOZeBg+IDFZZiGAgCaSSMYtcRHLgAAAABJRU5ErkJggg==);background-position:left top;background-repeat:no-repeat;background-size:100% 100%;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;position:absolute;top:50%;width:100%}.tp-hplv_m{border-radius:var(--elm-br);border:rgba(255,255,255,.75) solid 2px;box-shadow:0 0 2px rgba(0,0,0,.1);box-sizing:border-box;height:12px;left:50%;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;top:50%;width:12px}.tp-hplv:focus .tp-hplv_m{border-color:#fff}.tp-aplv{cursor:pointer;height:var(--bld-us);outline:none;position:relative;width:100%}.tp-aplv.tp-v-disabled{opacity:.5}.tp-aplv_b{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:4px 4px;background-position:0 0,2px 2px;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;overflow:hidden;position:absolute;top:50%;width:100%}.tp-aplv_c{bottom:0;left:0;position:absolute;right:0;top:0}.tp-aplv_m{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:12px 12px;background-position:0 0,6px 6px;border-radius:var(--elm-br);box-shadow:0 0 2px rgba(0,0,0,.1);height:12px;left:50%;margin-left:-6px;margin-top:-6px;overflow:hidden;pointer-events:none;position:absolute;top:50%;width:12px}.tp-aplv_p{border-radius:var(--elm-br);border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;bottom:0;left:0;position:absolute;right:0;top:0}.tp-aplv:focus .tp-aplv_p{border-color:#fff}.tp-colswv{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:10px 10px;background-position:0 0,5px 5px;border-radius:var(--elm-br);overflow:hidden}.tp-colswv.tp-v-disabled{opacity:.5}.tp-colswv_sw{border-radius:0}.tp-colswv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;cursor:pointer;display:block;height:var(--bld-us);left:0;margin:0;outline:none;padding:0;position:absolute;top:0;width:var(--bld-us)}.tp-colswv_b:focus::after{border:rgba(255,255,255,.75) solid 2px;border-radius:var(--elm-br);bottom:0;content:"";display:block;left:0;position:absolute;right:0;top:0}.tp-coltxtv{display:flex;width:100%}.tp-coltxtv_m{margin-right:4px}.tp-coltxtv_ms{border-radius:var(--elm-br);color:var(--lbl-fg);cursor:pointer;height:var(--bld-us);line-height:var(--bld-us);padding:0 18px 0 4px}.tp-coltxtv_ms:hover{background-color:var(--in-bg-h)}.tp-coltxtv_ms:focus{background-color:var(--in-bg-f)}.tp-coltxtv_ms:active{background-color:var(--in-bg-a)}.tp-coltxtv_mm{color:var(--lbl-fg)}.tp-coltxtv.tp-v-disabled .tp-coltxtv_mm{opacity:.5}.tp-coltxtv_w{flex:1}.tp-dfwv{position:absolute;top:8px;right:8px;width:256px}.tp-fldv{position:relative}.tp-fldv.tp-fldv-not .tp-fldv_b{display:none}.tp-fldv_t{padding-left:4px}.tp-fldv_b:disabled .tp-fldv_m{display:none}.tp-fldv_c{padding-left:4px}.tp-fldv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--bld-us) + 4px);width:var(--bs-br)}.tp-fldv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-fldv_b:hover+.tp-fldv_i{color:var(--cnt-bg-h)}.tp-fldv_b:focus+.tp-fldv_i{color:var(--cnt-bg-f)}.tp-fldv_b:active+.tp-fldv_i{color:var(--cnt-bg-a)}.tp-fldv.tp-v-disabled>.tp-fldv_i{opacity:.5}.tp-grlv{position:relative}.tp-grlv_g{display:block;height:calc(var(--bld-us)*3)}.tp-grlv_g polyline{fill:none;stroke:var(--mo-fg);stroke-linejoin:round}.tp-grlv_t{margin-top:-4px;transition:left .05s,top .05s;visibility:hidden}.tp-grlv_t.tp-grlv_t-a{visibility:visible}.tp-grlv_t.tp-grlv_t-in{transition:none}.tp-grlv.tp-v-disabled .tp-grlv_g{opacity:.5}.tp-grlv .tp-ttv{background-color:var(--mo-fg)}.tp-grlv .tp-ttv::before{border-top-color:var(--mo-fg)}.tp-lblv{align-items:center;display:flex;line-height:1.3;padding-left:var(--cnt-h-p);padding-right:var(--cnt-h-p)}.tp-lblv.tp-lblv-nol{display:block}.tp-lblv_l{color:var(--lbl-fg);flex:1;-webkit-hyphens:auto;hyphens:auto;overflow:hidden;padding-left:4px;padding-right:16px}.tp-lblv.tp-v-disabled .tp-lblv_l{opacity:.5}.tp-lblv.tp-lblv-nol .tp-lblv_l{display:none}.tp-lblv_v{align-self:flex-start;flex-grow:0;flex-shrink:0;width:160px}.tp-lblv.tp-lblv-nol .tp-lblv_v{width:100%}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m{color:var(--btn-fg)}.tp-sglv_i{padding:0 4px}.tp-sglv.tp-v-disabled .tp-sglv_i{opacity:.5}.tp-mllv_i{display:block;height:calc(var(--bld-us)*3);line-height:var(--bld-us);padding:0 4px;resize:none;white-space:pre}.tp-mllv.tp-v-disabled .tp-mllv_i{opacity:.5}.tp-p2dv{position:relative}.tp-p2dv_h{display:flex}.tp-p2dv_b{height:var(--bld-us);margin-right:4px;position:relative;width:var(--bld-us)}.tp-p2dv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-p2dv_b svg path{stroke:currentColor;stroke-width:2}.tp-p2dv_b svg circle{fill:currentColor}.tp-p2dv_t{flex:1}.tp-p2dv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-p2dv.tp-p2dv-expanded .tp-p2dv_p{margin-top:var(--bld-s);opacity:1}.tp-p2dv .tp-popv{left:calc(-1*var(--cnt-h-p));right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-p2dpv{padding-left:calc(var(--bld-us) + 4px)}.tp-p2dpv_p{cursor:crosshair;height:0;overflow:hidden;padding-bottom:100%;position:relative}.tp-p2dpv.tp-v-disabled .tp-p2dpv_p{opacity:.5}.tp-p2dpv_g{display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.tp-p2dpv_ax{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_l{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_m{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;position:absolute;width:4px}.tp-p2dpv_p:focus .tp-p2dpv_m{background-color:var(--in-fg);border-width:0}.tp-popv{background-color:var(--bs-bg);border-radius:6px;box-shadow:0 2px 4px var(--bs-sh);display:none;max-width:168px;padding:var(--cnt-v-p) var(--cnt-h-p);position:absolute;visibility:hidden;z-index:1000}.tp-popv.tp-popv-v{display:block;visibility:visible}.tp-sprv_r{background-color:var(--grv-fg);border-width:0;display:block;height:2px;margin:0;width:100%}.tp-sprv.tp-v-disabled .tp-sprv_r{opacity:.5}.tp-sldv.tp-v-disabled{opacity:.5}.tp-sldv_t{box-sizing:border-box;cursor:pointer;height:var(--bld-us);margin:0 6px;outline:none;position:relative}.tp-sldv_t::before{background-color:var(--in-bg);border-radius:1px;bottom:0;content:"";display:block;height:2px;left:0;margin:auto;position:absolute;right:0;top:0}.tp-sldv_k{height:100%;left:0;position:absolute;top:0}.tp-sldv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";display:block;height:2px;left:0;margin-bottom:auto;margin-top:auto;position:absolute;right:0;top:0}.tp-sldv_k::after{background-color:var(--btn-bg);border-radius:var(--elm-br);bottom:0;content:"";display:block;height:12px;margin-bottom:auto;margin-top:auto;position:absolute;right:-6px;top:0;width:12px}.tp-sldv_t:hover .tp-sldv_k::after{background-color:var(--btn-bg-h)}.tp-sldv_t:focus .tp-sldv_k::after{background-color:var(--btn-bg-f)}.tp-sldv_t:active .tp-sldv_k::after{background-color:var(--btn-bg-a)}.tp-sldtxtv{display:flex}.tp-sldtxtv_s{flex:2}.tp-sldtxtv_t{flex:1;margin-left:4px}.tp-tabv{position:relative}.tp-tabv_t{align-items:flex-end;color:var(--cnt-bg);display:flex;overflow:hidden;position:relative}.tp-tabv_t:hover{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus){color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active){color:var(--cnt-bg-a)}.tp-tabv_t::before{background-color:currentColor;bottom:0;content:"";height:2px;left:0;pointer-events:none;position:absolute;right:0}.tp-tabv.tp-v-disabled .tp-tabv_t::before{opacity:.5}.tp-tabv.tp-tabv-nop .tp-tabv_t{height:calc(var(--bld-us) + 4px);position:relative}.tp-tabv.tp-tabv-nop .tp-tabv_t::before{background-color:var(--cnt-bg);bottom:0;content:"";height:2px;left:0;position:absolute;right:0}.tp-tabv_c{padding-bottom:var(--cnt-v-p);padding-left:4px;padding-top:var(--cnt-v-p)}.tp-tabv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--bld-us) + 4px);width:var(--bs-br)}.tp-tabv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-tabv_t:hover+.tp-tabv_i{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus)+.tp-tabv_i{color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active)+.tp-tabv_i{color:var(--cnt-bg-a)}.tp-tabv.tp-v-disabled>.tp-tabv_i{opacity:.5}.tp-tbiv{flex:1;min-width:0;position:relative}.tp-tbiv+.tp-tbiv{margin-left:2px}.tp-tbiv+.tp-tbiv.tp-v-disabled::before{opacity:.5}.tp-tbiv_b{display:block;padding-left:calc(var(--cnt-h-p) + 4px);padding-right:calc(var(--cnt-h-p) + 4px);position:relative;width:100%}.tp-tbiv_b:disabled{opacity:.5}.tp-tbiv_b::before{background-color:var(--cnt-bg);bottom:2px;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.tp-tbiv_b:hover::before{background-color:var(--cnt-bg-h)}.tp-tbiv_b:focus::before{background-color:var(--cnt-bg-f)}.tp-tbiv_b:active::before{background-color:var(--cnt-bg-a)}.tp-tbiv_t{color:var(--cnt-fg);height:calc(var(--bld-us) + 4px);line-height:calc(var(--bld-us) + 4px);opacity:.5;overflow:hidden;text-overflow:ellipsis}.tp-tbiv.tp-tbiv-sel .tp-tbiv_t{opacity:1}.tp-txtv{position:relative}.tp-txtv_i{padding:0 4px}.tp-txtv.tp-txtv-fst .tp-txtv_i{border-bottom-right-radius:0;border-top-right-radius:0}.tp-txtv.tp-txtv-mid .tp-txtv_i{border-radius:0}.tp-txtv.tp-txtv-lst .tp-txtv_i{border-bottom-left-radius:0;border-top-left-radius:0}.tp-txtv.tp-txtv-num .tp-txtv_i{text-align:right}.tp-txtv.tp-txtv-drg .tp-txtv_i{opacity:.3}.tp-txtv_k{cursor:pointer;height:100%;left:-3px;position:absolute;top:0;width:12px}.tp-txtv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";height:calc(var(--bld-us) - 4px);left:50%;margin-bottom:auto;margin-left:-1px;margin-top:auto;opacity:.1;position:absolute;top:0;transition:border-radius .1s,height .1s,transform .1s,width .1s;width:2px}.tp-txtv_k:hover::before,.tp-txtv.tp-txtv-drg .tp-txtv_k::before{opacity:1}.tp-txtv.tp-txtv-drg .tp-txtv_k::before{border-radius:50%;height:4px;transform:translateX(-1px);width:4px}.tp-txtv_g{bottom:0;display:block;height:8px;left:50%;margin:auto;overflow:visible;pointer-events:none;position:absolute;top:0;visibility:hidden;width:100%}.tp-txtv.tp-txtv-drg .tp-txtv_g{visibility:visible}.tp-txtv_gb{fill:none;stroke:var(--in-fg);stroke-dasharray:1}.tp-txtv_gh{fill:none;stroke:var(--in-fg)}.tp-txtv .tp-ttv{margin-left:6px;visibility:hidden}.tp-txtv.tp-txtv-drg .tp-ttv{visibility:visible}.tp-ttv{background-color:var(--in-fg);border-radius:var(--elm-br);color:var(--bs-bg);padding:2px 4px;pointer-events:none;position:absolute;transform:translate(-50%, -100%)}.tp-ttv::before{border-color:var(--in-fg) rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);border-style:solid;border-width:2px;box-sizing:border-box;content:"";font-size:.9em;height:4px;left:50%;margin-left:-2px;position:absolute;top:100%;width:4px}.tp-rotv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);font-family:var(--font-family);font-size:11px;font-weight:500;line-height:1;text-align:left}.tp-rotv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br);border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br);padding-left:calc(4px + var(--bld-us) + var(--cnt-h-p));text-align:center}.tp-rotv.tp-rotv-expanded .tp-rotv_b{border-bottom-left-radius:0;border-bottom-right-radius:0}.tp-rotv.tp-rotv-not .tp-rotv_b{display:none}.tp-rotv_b:disabled .tp-rotv_m{display:none}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c .tp-fldv.tp-v-vlst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-right-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst{margin-top:calc(-1*var(--cnt-v-p))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst>.tp-fldv_b{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst{margin-top:calc(-1*var(--cnt-v-p))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst>.tp-tabv_t{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv.tp-v-disabled,.tp-rotv .tp-v-disabled{pointer-events:none}.tp-rotv.tp-v-hidden,.tp-rotv .tp-v-hidden{display:none}'),this.pool_.getAll().forEach(e=>{this.embedPluginStyle_(e)}),this.registerPlugin({plugins:[md,cd,Ss,fd]})}}const gd=new i("3.1.10");n.BladeApi=o,n.ButtonApi=R,n.FolderApi=Ps,n.InputBindingApi=xs,n.ListApi=Ia,n.MonitorBindingApi=Cs,n.Pane=_d,n.SeparatorApi=ai,n.SliderApi=Ba,n.TabApi=ci,n.TabPageApi=Ls,n.TextApi=Fa,n.TpChangeEvent=c,n.VERSION=gd,Object.defineProperty(n,"__esModule",{value:!0})})})(sr,sr.exports);var Ap=sr.exports,ir={exports:{}};(function(v,t){(function(n,i){i(t)})(Io,function(n){class i{constructor(l){this.controller_=l}get element(){return this.controller_.view.element}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(l){this.controller_.viewProps.set("disabled",l)}get hidden(){return this.controller_.viewProps.get("hidden")}set hidden(l){this.controller_.viewProps.set("hidden",l)}dispose(){this.controller_.viewProps.set("disposed",!0)}}class o{constructor(l){this.target=l}}class a extends o{constructor(l,u,w,P){super(l),this.value=u,this.presetKey=w,this.last=P??!0}}function c(f){return f}function p(f){return f==null}const d={alreadydisposed:()=>"View has been already disposed",invalidparams:f=>`Invalid parameters for '${f.name}'`,nomatchingcontroller:f=>`No matching controller for '${f.key}'`,nomatchingview:f=>`No matching view for '${JSON.stringify(f.params)}'`,notbindable:()=>"Value is not bindable",propertynotfound:f=>`Property '${f.name}' not found`,shouldneverhappen:()=>"This error should never happen"};class g{constructor(l){var u;this.message=(u=d[l.type](l.context))!==null&&u!==void 0?u:"Unexpected error",this.name=this.constructor.name,this.stack=new Error(this.message).stack,this.type=l.type}static alreadyDisposed(){return new g({type:"alreadydisposed"})}static notBindable(){return new g({type:"notbindable"})}static propertyNotFound(l){return new g({type:"propertynotfound",context:{name:l}})}static shouldNeverHappen(){return new g({type:"shouldneverhappen"})}}class y{constructor(){this.observers_={}}on(l,u){let w=this.observers_[l];return w||(w=this.observers_[l]=[]),w.push({handler:u}),this}off(l,u){const w=this.observers_[l];return w&&(this.observers_[l]=w.filter(P=>P.handler!==u)),this}emit(l,u){const w=this.observers_[l];w&&w.forEach(P=>{P.handler(u)})}}const b="tp";function C(f){return(u,w)=>[b,"-",f,"v",u?`_${u}`:"",w?`-${w}`:""].join("")}function A(f,l){return u=>l(f(u))}function E(f){return f.rawValue}function k(f,l){f.emitter.on("change",A(E,l)),l(f.rawValue)}function O(f,l,u){k(f.value(l),u)}function R(f,l,u){u?f.classList.add(l):f.classList.remove(l)}function N(f,l){return u=>{R(f,l,u)}}function F(f,l){k(f,u=>{l.textContent=u??""})}const M=C("btn");class D{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(M()),u.viewProps.bindClassModifiers(this.element);const w=l.createElement("button");w.classList.add(M("b")),u.viewProps.bindDisabled(w),this.element.appendChild(w),this.buttonElement=w;const P=l.createElement("div");P.classList.add(M("t")),F(u.props.value("title"),P),this.buttonElement.appendChild(P)}}class U{constructor(l,u){this.emitter=new y,this.onClick_=this.onClick_.bind(this),this.props=u.props,this.viewProps=u.viewProps,this.view=new D(l,{props:this.props,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("click",this.onClick_)}onClick_(){this.emitter.emit("click",{sender:this})}}class S{constructor(l,u){var w;this.constraint_=u==null?void 0:u.constraint,this.equals_=(w=u==null?void 0:u.equals)!==null&&w!==void 0?w:(P,V)=>P===V,this.emitter=new y,this.rawValue_=l}get constraint(){return this.constraint_}get rawValue(){return this.rawValue_}set rawValue(l){this.setRawValue(l,{forceEmit:!1,last:!0})}setRawValue(l,u){const w=u??{forceEmit:!1,last:!0},P=this.constraint_?this.constraint_.constrain(l):l,V=this.rawValue_;this.equals_(V,P)&&!w.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.rawValue_=P,this.emitter.emit("change",{options:w,previousRawValue:V,rawValue:P,sender:this}))}}class T{constructor(l){this.emitter=new y,this.value_=l}get rawValue(){return this.value_}set rawValue(l){this.setRawValue(l,{forceEmit:!1,last:!0})}setRawValue(l,u){const w=u??{forceEmit:!1,last:!0},P=this.value_;P===l&&!w.forceEmit||(this.emitter.emit("beforechange",{sender:this}),this.value_=l,this.emitter.emit("change",{options:w,previousRawValue:P,rawValue:this.value_,sender:this}))}}function j(f,l){const u=l==null?void 0:l.constraint,w=l==null?void 0:l.equals;return!u&&!w?new T(f):new S(f,l)}class X{constructor(l){this.emitter=new y,this.valMap_=l;for(const u in this.valMap_)this.valMap_[u].emitter.on("change",()=>{this.emitter.emit("change",{key:u,sender:this})})}static createCore(l){return Object.keys(l).reduce((w,P)=>Object.assign(w,{[P]:j(l[P])}),{})}static fromObject(l){const u=this.createCore(l);return new X(u)}get(l){return this.valMap_[l].rawValue}set(l,u){this.valMap_[l].rawValue=u}value(l){return this.valMap_[l]}}function Z(f,l){const w=Object.keys(l).reduce((P,V)=>{if(P===void 0)return;const G=l[V],Q=G(f[V]);return Q.succeeded?Object.assign(Object.assign({},P),{[V]:Q.value}):void 0},{});return w}function J(f,l){return f.reduce((u,w)=>{if(u===void 0)return;const P=l(w);if(!(!P.succeeded||P.value===void 0))return[...u,P.value]},[])}function le(f){return f===null?!1:typeof f=="object"}function he(f){return l=>u=>{if(!l&&u===void 0)return{succeeded:!1,value:void 0};if(l&&u===void 0)return{succeeded:!0,value:void 0};const w=f(u);return w!==void 0?{succeeded:!0,value:w}:{succeeded:!1,value:void 0}}}function oe(f){return{custom:l=>he(l)(f),boolean:he(l=>typeof l=="boolean"?l:void 0)(f),number:he(l=>typeof l=="number"?l:void 0)(f),string:he(l=>typeof l=="string"?l:void 0)(f),function:he(l=>typeof l=="function"?l:void 0)(f),constant:l=>he(u=>u===l?l:void 0)(f),raw:he(l=>l)(f),object:l=>he(u=>{if(le(u))return Z(u,l)})(f),array:l=>he(u=>{if(Array.isArray(u))return J(u,l)})(f)}}const re={optional:oe(!0),required:oe(!1)};function ne(f,l){const u=re.required.object(l)(f);return u.succeeded?u.value:void 0}function H(f){console.warn([`Missing '${f.key}' of ${f.target} in ${f.place}.`,"Please rebuild plugins with the latest core package."].join(" "))}function Ce(f){return f&&f.parentElement&&f.parentElement.removeChild(f),null}class ge{constructor(l){this.value_=l}static create(l){return[new ge(l),(u,w)=>{l.setRawValue(u,w)}]}get emitter(){return this.value_.emitter}get rawValue(){return this.value_.rawValue}}const de=C("");function me(f,l){return N(f,de(void 0,l))}class ke extends X{constructor(l){var u;super(l),this.onDisabledChange_=this.onDisabledChange_.bind(this),this.onParentChange_=this.onParentChange_.bind(this),this.onParentGlobalDisabledChange_=this.onParentGlobalDisabledChange_.bind(this),[this.globalDisabled_,this.setGlobalDisabled_]=ge.create(j(this.getGlobalDisabled_())),this.value("disabled").emitter.on("change",this.onDisabledChange_),this.value("parent").emitter.on("change",this.onParentChange_),(u=this.get("parent"))===null||u===void 0||u.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_)}static create(l){var u,w,P;const V=l??{};return new ke(X.createCore({disabled:(u=V.disabled)!==null&&u!==void 0?u:!1,disposed:!1,hidden:(w=V.hidden)!==null&&w!==void 0?w:!1,parent:(P=V.parent)!==null&&P!==void 0?P:null}))}get globalDisabled(){return this.globalDisabled_}bindClassModifiers(l){k(this.globalDisabled_,me(l,"disabled")),O(this,"hidden",me(l,"hidden"))}bindDisabled(l){k(this.globalDisabled_,u=>{l.disabled=u})}bindTabIndex(l){k(this.globalDisabled_,u=>{l.tabIndex=u?-1:0})}handleDispose(l){this.value("disposed").emitter.on("change",u=>{u&&l()})}getGlobalDisabled_(){const l=this.get("parent");return(l?l.globalDisabled.rawValue:!1)||this.get("disabled")}updateGlobalDisabled_(){this.setGlobalDisabled_(this.getGlobalDisabled_())}onDisabledChange_(){this.updateGlobalDisabled_()}onParentGlobalDisabledChange_(){this.updateGlobalDisabled_()}onParentChange_(l){var u;const w=l.previousRawValue;w==null||w.globalDisabled.emitter.off("change",this.onParentGlobalDisabledChange_),(u=this.get("parent"))===null||u===void 0||u.globalDisabled.emitter.on("change",this.onParentGlobalDisabledChange_),this.updateGlobalDisabled_()}}function B(){return["veryfirst","first","last","verylast"]}const we=C(""),ze={veryfirst:"vfst",first:"fst",last:"lst",verylast:"vlst"};class Ge{constructor(l){this.parent_=null,this.blade=l.blade,this.view=l.view,this.viewProps=l.viewProps;const u=this.view.element;this.blade.value("positions").emitter.on("change",()=>{B().forEach(w=>{u.classList.remove(we(void 0,ze[w]))}),this.blade.get("positions").forEach(w=>{u.classList.add(we(void 0,ze[w]))})}),this.viewProps.handleDispose(()=>{Ce(u)})}get parent(){return this.parent_}set parent(l){if(this.parent_=l,!("parent"in this.viewProps.valMap_)){H({key:"parent",target:ke.name,place:"BladeController.parent"});return}this.viewProps.set("parent",this.parent_?this.parent_.viewProps:null)}}const Te="http://www.w3.org/2000/svg";function lt(f){f.offsetHeight}function Gn(f,l){const u=f.style.transition;f.style.transition="none",l(),f.style.transition=u}function He(f){return f.ontouchstart!==void 0}function Kn(f){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])}function un(f){return f.relatedTarget?f.relatedTarget:"explicitOriginalTarget"in f?f.explicitOriginalTarget:null}const gt=C("lbl");function Et(f,l){const u=f.createDocumentFragment();return l.split(`
|
|
98
|
-
`).map(P=>f.createTextNode(P)).forEach((P,V)=>{V>0&&u.appendChild(f.createElement("br")),u.appendChild(P)}),u}class Ye{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(gt()),u.viewProps.bindClassModifiers(this.element);const w=l.createElement("div");w.classList.add(gt("l")),O(u.props,"label",V=>{p(V)?this.element.classList.add(gt(void 0,"nol")):(this.element.classList.remove(gt(void 0,"nol")),Kn(w),w.appendChild(Et(l,V)))}),this.element.appendChild(w),this.labelElement=w;const P=l.createElement("div");P.classList.add(gt("v")),this.element.appendChild(P),this.valueElement=P}}class ct extends Ge{constructor(l,u){const w=u.valueController.viewProps;super(Object.assign(Object.assign({},u),{view:new Ye(l,{props:u.props,viewProps:w}),viewProps:w})),this.props=u.props,this.valueController=u.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}}class dn extends Ge{constructor(l){super(l),this.value=l.value}}class bt extends X{constructor(l){super(l)}static create(l){const u={completed:!0,expanded:l,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},w=X.createCore(u);return new bt(w)}get styleExpanded(){var l;return(l=this.get("temporaryExpanded"))!==null&&l!==void 0?l:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const l=this.get("expandedHeight");return this.get("shouldFixHeight")&&!p(l)?`${l}px`:"auto"}bindExpandedClass(l,u){const w=()=>{this.styleExpanded?l.classList.add(u):l.classList.remove(u)};O(this,"expanded",w),O(this,"temporaryExpanded",w)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function Yn(f){return bt.create(f)}function ws(f,l){let u=0;return Gn(l,()=>{f.set("expandedHeight",null),f.set("temporaryExpanded",!0),lt(l),u=l.clientHeight,f.set("temporaryExpanded",null),lt(l)}),u}function Xn(f,l){l.style.height=f.styleHeight}function Zn(f,l){f.value("expanded").emitter.on("beforechange",()=>{f.set("completed",!1),p(f.get("expandedHeight"))&&f.set("expandedHeight",ws(f,l)),f.set("shouldFixHeight",!0),lt(l)}),f.emitter.on("change",()=>{Xn(f,l)}),Xn(f,l),l.addEventListener("transitionend",u=>{u.propertyName==="height"&&f.cleanUpTransition()})}class Mt{constructor(l,u){const w=C(u.viewName);this.element=l.createElement("div"),this.element.classList.add(w()),u.viewProps.bindClassModifiers(this.element)}}class Ot extends dn{constructor(l,u){const w=u.valueController.viewProps;super(Object.assign(Object.assign({},u),{value:u.valueController.value,view:new Ye(l,{props:u.props,viewProps:w}),viewProps:w})),this.props=u.props,this.valueController=u.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}}class qn{constructor(){this.disabled=!1,this.emitter=new y}dispose(){}tick(){this.disabled||this.emitter.emit("tick",{sender:this})}}class mn{constructor(l,u){this.disabled_=!1,this.timerId_=null,this.onTick_=this.onTick_.bind(this),this.doc_=l,this.emitter=new y,this.interval_=u,this.setTimer_()}get disabled(){return this.disabled_}set disabled(l){this.disabled_=l,this.disabled_?this.clearTimer_():this.setTimer_()}dispose(){this.clearTimer_()}clearTimer_(){if(this.timerId_===null)return;const l=this.doc_.defaultView;l&&l.clearInterval(this.timerId_),this.timerId_=null}setTimer_(){if(this.clearTimer_(),this.interval_<=0)return;const l=this.doc_.defaultView;l&&(this.timerId_=l.setInterval(this.onTick_,this.interval_))}onTick_(){this.disabled_||this.emitter.emit("tick",{sender:this})}}class Qn{constructor(l){this.constraints=l}constrain(l){return this.constraints.reduce((u,w)=>w.constrain(u),l)}}function kt(f,l){if(f instanceof l)return f;if(f instanceof Qn){const u=f.constraints.reduce((w,P)=>w||(P instanceof l?P:null),null);if(u)return u}return null}class wt{constructor(l){this.values=X.fromObject({max:l.max,min:l.min})}constrain(l){const u=this.values.get("max"),w=this.values.get("min");return Math.min(Math.max(l,w),u)}}class Dt{constructor(l){this.values=X.fromObject({max:l.max,min:l.min})}get maxValue(){return this.values.get("max")}get minValue(){return this.values.get("min")}constrain(l){const u=this.values.get("max"),w=this.values.get("min");let P=l;return p(w)||(P=Math.max(P,w)),p(u)||(P=Math.min(P,u)),P}}class z{constructor(l,u=0){this.step=l,this.origin=u}constrain(l){const u=this.origin%this.step,w=Math.round((l-u)/this.step);return u+w*this.step}}const W=C("pop");class ae{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(W()),u.viewProps.bindClassModifiers(this.element),k(u.shows,N(this.element,W(void 0,"v")))}}class fe{constructor(l,u){this.shows=j(!1),this.viewProps=u.viewProps,this.view=new ae(l,{shows:this.shows,viewProps:this.viewProps})}}const Oe=C("txt");class je{constructor(l,u){this.onChange_=this.onChange_.bind(this),this.element=l.createElement("div"),this.element.classList.add(Oe()),u.viewProps.bindClassModifiers(this.element),this.props_=u.props,this.props_.emitter.on("change",this.onChange_);const w=l.createElement("input");w.classList.add(Oe("i")),w.type="text",u.viewProps.bindDisabled(w),this.element.appendChild(w),this.inputElement=w,u.value.emitter.on("change",this.onChange_),this.value_=u.value,this.refresh()}refresh(){const l=this.props_.get("formatter");this.inputElement.value=l(this.value_.rawValue)}onChange_(){this.refresh()}}class qt{constructor(l,u){this.onInputChange_=this.onInputChange_.bind(this),this.parser_=u.parser,this.props=u.props,this.value=u.value,this.viewProps=u.viewProps,this.view=new je(l,{props:u.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_)}onInputChange_(l){const w=l.currentTarget.value,P=this.parser_(w);p(P)||(this.value.rawValue=P),this.view.refresh()}}function fn(f){return f==="false"?!1:!!f}class Xe{constructor(l){this.text=l}evaluate(){return Number(this.text)}toString(){return this.text}}const Ze={"**":(f,l)=>Math.pow(f,l),"*":(f,l)=>f*l,"/":(f,l)=>f/l,"%":(f,l)=>f%l,"+":(f,l)=>f+l,"-":(f,l)=>f-l,"<<":(f,l)=>f<<l,">>":(f,l)=>f>>l,">>>":(f,l)=>f>>>l,"&":(f,l)=>f&l,"^":(f,l)=>f^l,"|":(f,l)=>f|l};class rr{constructor(l,u,w){this.left=u,this.operator=l,this.right=w}evaluate(){const l=Ze[this.operator];if(!l)throw new Error(`unexpected binary operator: '${this.operator}`);return l(this.left.evaluate(),this.right.evaluate())}toString(){return["b(",this.left.toString(),this.operator,this.right.toString(),")"].join(" ")}}const or={"+":f=>f,"-":f=>-f,"~":f=>~f};class ar{constructor(l,u){this.operator=l,this.expression=u}evaluate(){const l=or[this.operator];if(!l)throw new Error(`unexpected unary operator: '${this.operator}`);return l(this.expression.evaluate())}toString(){return["u(",this.operator,this.expression.toString(),")"].join(" ")}}function ys(f){return(l,u)=>{for(let w=0;w<f.length;w++){const P=f[w](l,u);if(P!=="")return P}return""}}function Vt(f,l){var u;const w=f.substr(l).match(/^\s+/);return(u=w&&w[0])!==null&&u!==void 0?u:""}function xs(f,l){const u=f.substr(l,1);return u.match(/^[1-9]$/)?u:""}function Ke(f,l){var u;const w=f.substr(l).match(/^[0-9]+/);return(u=w&&w[0])!==null&&u!==void 0?u:""}function Cs(f,l){const u=Ke(f,l);if(u!=="")return u;const w=f.substr(l,1);if(l+=1,w!=="-"&&w!=="+")return"";const P=Ke(f,l);return P===""?"":w+P}function ht(f,l){const u=f.substr(l,1);if(l+=1,u.toLowerCase()!=="e")return"";const w=Cs(f,l);return w===""?"":u+w}function ii(f,l){const u=f.substr(l,1);if(u==="0")return u;const w=xs(f,l);return l+=w.length,w===""?"":w+Ke(f,l)}function vn(f,l){const u=ii(f,l);if(l+=u.length,u==="")return"";const w=f.substr(l,1);if(l+=w.length,w!==".")return"";const P=Ke(f,l);return l+=P.length,u+w+P+ht(f,l)}function ri(f,l){const u=f.substr(l,1);if(l+=u.length,u!==".")return"";const w=Ke(f,l);return l+=w.length,w===""?"":u+w+ht(f,l)}function Wn(f,l){const u=ii(f,l);return l+=u.length,u===""?"":u+ht(f,l)}const Ps=ys([vn,ri,Wn]);function As(f,l){var u;const w=f.substr(l).match(/^[01]+/);return(u=w&&w[0])!==null&&u!==void 0?u:""}function lr(f,l){const u=f.substr(l,2);if(l+=u.length,u.toLowerCase()!=="0b")return"";const w=As(f,l);return w===""?"":u+w}function cr(f,l){var u;const w=f.substr(l).match(/^[0-7]+/);return(u=w&&w[0])!==null&&u!==void 0?u:""}function hr(f,l){const u=f.substr(l,2);if(l+=u.length,u.toLowerCase()!=="0o")return"";const w=cr(f,l);return w===""?"":u+w}function pr(f,l){var u;const w=f.substr(l).match(/^[0-9a-f]+/i);return(u=w&&w[0])!==null&&u!==void 0?u:""}function Ms(f,l){const u=f.substr(l,2);if(l+=u.length,u.toLowerCase()!=="0x")return"";const w=pr(f,l);return w===""?"":u+w}const ur=ys([lr,hr,Ms]),dr=ys([ur,Ps]);function _n(f,l){const u=dr(f,l);return l+=u.length,u===""?null:{evaluable:new Xe(u),cursor:l}}function oi(f,l){const u=f.substr(l,1);if(l+=u.length,u!=="(")return null;const w=ks(f,l);if(!w)return null;l=w.cursor,l+=Vt(f,l).length;const P=f.substr(l,1);return l+=P.length,P!==")"?null:{evaluable:w.evaluable,cursor:l}}function mr(f,l){var u;return(u=_n(f,l))!==null&&u!==void 0?u:oi(f,l)}function Jn(f,l){const u=mr(f,l);if(u)return u;const w=f.substr(l,1);if(l+=w.length,w!=="+"&&w!=="-"&&w!=="~")return null;const P=Jn(f,l);return P?(l=P.cursor,{cursor:l,evaluable:new ar(w,P.evaluable)}):null}function fr(f,l,u){u+=Vt(l,u).length;const w=f.filter(P=>l.startsWith(P,u))[0];return w?(u+=w.length,u+=Vt(l,u).length,{cursor:u,operator:w}):null}function Qt(f,l){return(u,w)=>{const P=f(u,w);if(!P)return null;w=P.cursor;let V=P.evaluable;for(;;){const G=fr(l,u,w);if(!G)break;w=G.cursor;const Q=f(u,w);if(!Q)return null;w=Q.cursor,V=new rr(G.operator,V,Q.evaluable)}return V?{cursor:w,evaluable:V}:null}}const ai=[["**"],["*","/","%"],["+","-"],["<<",">>>",">>"],["&"],["^"],["|"]].reduce((f,l)=>Qt(f,l),Jn);function ks(f,l){return l+=Vt(f,l).length,ai(f,l)}function vr(f){const l=ks(f,0);return!l||l.cursor+Vt(f,l.cursor).length!==f.length?null:l.evaluable}function gn(f){var l;const u=vr(f);return(l=u==null?void 0:u.evaluate())!==null&&l!==void 0?l:null}function _r(f){if(typeof f=="number")return f;if(typeof f=="string"){const l=gn(f);if(!p(l))return l}return 0}function Fe(f){return l=>l.toFixed(Math.max(Math.min(f,20),0))}const gr=Fe(0);function Hn(f){return gr(f)+"%"}function li(f){return String(f)}function Ls(f,l){for(;f.length<l;)f.push(void 0)}function ci(f){const l=[];return Ls(l,f),j(l)}function hi(f){const l=f.indexOf(void 0);return l<0?f:f.slice(0,l)}function br(f,l){const u=[...hi(f),l];return u.length>f.length?u.splice(0,u.length-f.length):Ls(u,f.length),u}function Wt({primary:f,secondary:l,forward:u,backward:w}){let P=!1;function V(G){P||(P=!0,G(),P=!1)}f.emitter.on("change",G=>{V(()=>{l.setRawValue(u(f,l),G.options)})}),l.emitter.on("change",G=>{V(()=>{f.setRawValue(w(f,l),G.options)}),V(()=>{l.setRawValue(u(f,l),G.options)})}),V(()=>{l.setRawValue(u(f,l),{forceEmit:!1,last:!0})})}function Jt(f,l){const u=f*(l.altKey?.1:1)*(l.shiftKey?10:1);return l.upKey?+u:l.downKey?-u:0}function bn(f){return{altKey:f.altKey,downKey:f.key==="ArrowDown",shiftKey:f.shiftKey,upKey:f.key==="ArrowUp"}}function Ss(f){return{altKey:f.altKey,downKey:f.key==="ArrowLeft",shiftKey:f.shiftKey,upKey:f.key==="ArrowRight"}}function wr(f){return f==="ArrowUp"||f==="ArrowDown"}function pi(f){return wr(f)||f==="ArrowLeft"||f==="ArrowRight"}function Ts(f,l){var u,w;const P=l.ownerDocument.defaultView,V=l.getBoundingClientRect();return{x:f.pageX-(((u=P&&P.scrollX)!==null&&u!==void 0?u:0)+V.left),y:f.pageY-(((w=P&&P.scrollY)!==null&&w!==void 0?w:0)+V.top)}}class $n{constructor(l){this.lastTouch_=null,this.onDocumentMouseMove_=this.onDocumentMouseMove_.bind(this),this.onDocumentMouseUp_=this.onDocumentMouseUp_.bind(this),this.onMouseDown_=this.onMouseDown_.bind(this),this.onTouchEnd_=this.onTouchEnd_.bind(this),this.onTouchMove_=this.onTouchMove_.bind(this),this.onTouchStart_=this.onTouchStart_.bind(this),this.elem_=l,this.emitter=new y,l.addEventListener("touchstart",this.onTouchStart_,{passive:!1}),l.addEventListener("touchmove",this.onTouchMove_,{passive:!0}),l.addEventListener("touchend",this.onTouchEnd_),l.addEventListener("mousedown",this.onMouseDown_)}computePosition_(l){const u=this.elem_.getBoundingClientRect();return{bounds:{width:u.width,height:u.height},point:l?{x:l.x,y:l.y}:null}}onMouseDown_(l){var u;l.preventDefault(),(u=l.currentTarget)===null||u===void 0||u.focus();const w=this.elem_.ownerDocument;w.addEventListener("mousemove",this.onDocumentMouseMove_),w.addEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("down",{altKey:l.altKey,data:this.computePosition_(Ts(l,this.elem_)),sender:this,shiftKey:l.shiftKey})}onDocumentMouseMove_(l){this.emitter.emit("move",{altKey:l.altKey,data:this.computePosition_(Ts(l,this.elem_)),sender:this,shiftKey:l.shiftKey})}onDocumentMouseUp_(l){const u=this.elem_.ownerDocument;u.removeEventListener("mousemove",this.onDocumentMouseMove_),u.removeEventListener("mouseup",this.onDocumentMouseUp_),this.emitter.emit("up",{altKey:l.altKey,data:this.computePosition_(Ts(l,this.elem_)),sender:this,shiftKey:l.shiftKey})}onTouchStart_(l){l.preventDefault();const u=l.targetTouches.item(0),w=this.elem_.getBoundingClientRect();this.emitter.emit("down",{altKey:l.altKey,data:this.computePosition_(u?{x:u.clientX-w.left,y:u.clientY-w.top}:void 0),sender:this,shiftKey:l.shiftKey}),this.lastTouch_=u}onTouchMove_(l){const u=l.targetTouches.item(0),w=this.elem_.getBoundingClientRect();this.emitter.emit("move",{altKey:l.altKey,data:this.computePosition_(u?{x:u.clientX-w.left,y:u.clientY-w.top}:void 0),sender:this,shiftKey:l.shiftKey}),this.lastTouch_=u}onTouchEnd_(l){var u;const w=(u=l.targetTouches.item(0))!==null&&u!==void 0?u:this.lastTouch_,P=this.elem_.getBoundingClientRect();this.emitter.emit("up",{altKey:l.altKey,data:this.computePosition_(w?{x:w.clientX-P.left,y:w.clientY-P.top}:void 0),sender:this,shiftKey:l.shiftKey})}}function Ve(f,l,u,w,P){const V=(f-l)/(u-l);return w+V*(P-w)}function ui(f){return String(f.toFixed(10)).split(".")[1].replace(/0+$/,"").length}function Ht(f,l,u){return Math.min(Math.max(f,l),u)}const $e=C("txt");class yr{constructor(l,u){this.onChange_=this.onChange_.bind(this),this.props_=u.props,this.props_.emitter.on("change",this.onChange_),this.element=l.createElement("div"),this.element.classList.add($e(),$e(void 0,"num")),u.arrayPosition&&this.element.classList.add($e(void 0,u.arrayPosition)),u.viewProps.bindClassModifiers(this.element);const w=l.createElement("input");w.classList.add($e("i")),w.type="text",u.viewProps.bindDisabled(w),this.element.appendChild(w),this.inputElement=w,this.onDraggingChange_=this.onDraggingChange_.bind(this),this.dragging_=u.dragging,this.dragging_.emitter.on("change",this.onDraggingChange_),this.element.classList.add($e()),this.inputElement.classList.add($e("i"));const P=l.createElement("div");P.classList.add($e("k")),this.element.appendChild(P),this.knobElement=P;const V=l.createElementNS(Te,"svg");V.classList.add($e("g")),this.knobElement.appendChild(V);const G=l.createElementNS(Te,"path");G.classList.add($e("gb")),V.appendChild(G),this.guideBodyElem_=G;const Q=l.createElementNS(Te,"path");Q.classList.add($e("gh")),V.appendChild(Q),this.guideHeadElem_=Q;const be=l.createElement("div");be.classList.add(C("tt")()),this.knobElement.appendChild(be),this.tooltipElem_=be,u.value.emitter.on("change",this.onChange_),this.value=u.value,this.refresh()}onDraggingChange_(l){if(l.rawValue===null){this.element.classList.remove($e(void 0,"drg"));return}this.element.classList.add($e(void 0,"drg"));const u=l.rawValue/this.props_.get("draggingScale"),w=u+(u>0?-1:u<0?1:0),P=Ht(-w,-4,4);this.guideHeadElem_.setAttributeNS(null,"d",[`M ${w+P},0 L${w},4 L${w+P},8`,`M ${u},-1 L${u},9`].join(" ")),this.guideBodyElem_.setAttributeNS(null,"d",`M 0,4 L${u},4`);const V=this.props_.get("formatter");this.tooltipElem_.textContent=V(this.value.rawValue),this.tooltipElem_.style.left=`${u}px`}refresh(){const l=this.props_.get("formatter");this.inputElement.value=l(this.value.rawValue)}onChange_(){this.refresh()}}class wn{constructor(l,u){var w;this.originRawValue_=0,this.onInputChange_=this.onInputChange_.bind(this),this.onInputKeyDown_=this.onInputKeyDown_.bind(this),this.onInputKeyUp_=this.onInputKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.baseStep_=u.baseStep,this.parser_=u.parser,this.props=u.props,this.sliderProps_=(w=u.sliderProps)!==null&&w!==void 0?w:null,this.value=u.value,this.viewProps=u.viewProps,this.dragging_=j(null),this.view=new yr(l,{arrayPosition:u.arrayPosition,dragging:this.dragging_,props:this.props,value:this.value,viewProps:this.viewProps}),this.view.inputElement.addEventListener("change",this.onInputChange_),this.view.inputElement.addEventListener("keydown",this.onInputKeyDown_),this.view.inputElement.addEventListener("keyup",this.onInputKeyUp_);const P=new $n(this.view.knobElement);P.emitter.on("down",this.onPointerDown_),P.emitter.on("move",this.onPointerMove_),P.emitter.on("up",this.onPointerUp_)}constrainValue_(l){var u,w;const P=(u=this.sliderProps_)===null||u===void 0?void 0:u.get("minValue"),V=(w=this.sliderProps_)===null||w===void 0?void 0:w.get("maxValue");let G=l;return P!==void 0&&(G=Math.max(G,P)),V!==void 0&&(G=Math.min(G,V)),G}onInputChange_(l){const w=l.currentTarget.value,P=this.parser_(w);p(P)||(this.value.rawValue=this.constrainValue_(P)),this.view.refresh()}onInputKeyDown_(l){const u=Jt(this.baseStep_,bn(l));u!==0&&this.value.setRawValue(this.constrainValue_(this.value.rawValue+u),{forceEmit:!1,last:!1})}onInputKeyUp_(l){Jt(this.baseStep_,bn(l))!==0&&this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}onPointerDown_(){this.originRawValue_=this.value.rawValue,this.dragging_.rawValue=0}computeDraggingValue_(l){if(!l.point)return null;const u=l.point.x-l.bounds.width/2;return this.constrainValue_(this.originRawValue_+u*this.props.get("draggingScale"))}onPointerMove_(l){const u=this.computeDraggingValue_(l.data);u!==null&&(this.value.setRawValue(u,{forceEmit:!1,last:!1}),this.dragging_.rawValue=this.value.rawValue-this.originRawValue_)}onPointerUp_(l){const u=this.computeDraggingValue_(l.data);u!==null&&(this.value.setRawValue(u,{forceEmit:!0,last:!0}),this.dragging_.rawValue=null)}}function st(f,l){f.write(l)}function $t(f){const l=f?kt(f,z):null;return l?l.step:null}function yn(f,l){const u=f&&kt(f,z);return u?ui(u.step):Math.max(ui(l),2)}function Es(f){const l=$t(f);return l??1}function es(f,l){var u;const w=f&&kt(f,z),P=Math.abs((u=w==null?void 0:w.step)!==null&&u!==void 0?u:l);return P===0?.1:Math.pow(10,Math.floor(Math.log10(P))-1)}function en(f){return[f[0],f[1],f[2]]}function di(f){const l=Ht(Math.floor(f),0,255).toString(16);return l.length===1?`0${l}`:l}function xn(f,l="#"){const u=en(f.getComponents("rgb")).map(di).join("");return`${l}${u}`}function mi(f,l="#"){const u=f.getComponents("rgb"),w=[u[0],u[1],u[2],u[3]*255].map(di).join("");return`${l}${w}`}function xr(f,l){const u=Fe(l==="float"?2:0);return`rgb(${en(f.getComponents("rgb",l)).map(P=>u(P)).join(", ")})`}function fi(f){return l=>xr(l,f)}function vi(f,l){const u=Fe(2),w=Fe(l==="float"?2:0);return`rgba(${f.getComponents("rgb",l).map((V,G)=>(G===3?u:w)(V)).join(", ")})`}function Cr(f){return l=>vi(l,f)}function ts(f){const l=[Fe(0),Hn,Hn];return`hsl(${en(f.getComponents("hsl")).map((w,P)=>l[P](w)).join(", ")})`}function Pr(f){const l=[Fe(0),Hn,Hn,Fe(2)];return`hsla(${f.getComponents("hsl").map((w,P)=>l[P](w)).join(", ")})`}function _i(f,l){const u=Fe(l==="float"?2:0),w=["r","g","b"];return`{${en(f.getComponents("rgb",l)).map((V,G)=>`${w[G]}: ${u(V)}`).join(", ")}}`}function gi(f){return l=>_i(l,f)}function Ar(f,l){const u=Fe(2),w=Fe(l==="float"?2:0),P=["r","g","b","a"];return`{${f.getComponents("rgb",l).map((G,Q)=>{const be=Q===3?u:w;return`${P[Q]}: ${be(G)}`}).join(", ")}}`}function Mr(f){return l=>Ar(l,f)}[...["int","float"].reduce((f,l)=>[...f,{format:{alpha:!1,mode:"rgb",notation:"func",type:l},stringifier:fi(l)},{format:{alpha:!0,mode:"rgb",notation:"func",type:l},stringifier:Cr(l)},{format:{alpha:!1,mode:"rgb",notation:"object",type:l},stringifier:gi(l)},{format:{alpha:!0,mode:"rgb",notation:"object",type:l},stringifier:Mr(l)}],[])];class kr{constructor(l){this.components=l.components,this.asm_=l.assembly}constrain(l){const u=this.asm_.toComponents(l).map((w,P)=>{var V,G;return(G=(V=this.components[P])===null||V===void 0?void 0:V.constrain(w))!==null&&G!==void 0?G:w});return this.asm_.fromComponents(u)}}const bi=C("pndtxt");class Lr{constructor(l,u){this.textViews=u.textViews,this.element=l.createElement("div"),this.element.classList.add(bi()),this.textViews.forEach(w=>{const P=l.createElement("div");P.classList.add(bi("a")),P.appendChild(w.element),this.element.appendChild(P)})}}function Os(f,l,u){return new wn(f,{arrayPosition:u===0?"fst":u===l.axes.length-1?"lst":"mid",baseStep:l.axes[u].baseStep,parser:l.parser,props:l.axes[u].textProps,value:j(0,{constraint:l.axes[u].constraint}),viewProps:l.viewProps})}class It{constructor(l,u){this.value=u.value,this.viewProps=u.viewProps,this.acs_=u.axes.map((w,P)=>Os(l,u,P)),this.acs_.forEach((w,P)=>{Wt({primary:this.value,secondary:w.value,forward:V=>u.assembly.toComponents(V.rawValue)[P],backward:(V,G)=>{const Q=u.assembly.toComponents(V.rawValue);return Q[P]=G.rawValue,u.assembly.fromComponents(Q)}})}),this.view=new Lr(l,{textViews:this.acs_.map(w=>w.view)})}}function Sr(f,l){return"step"in f&&!p(f.step)?new z(f.step,l):null}function Cn(f){return!p(f.max)&&!p(f.min)?new wt({max:f.max,min:f.min}):!p(f.max)||!p(f.min)?new Dt({max:f.max,min:f.min}):null}const Tr={monitor:{defaultInterval:200,defaultLineCount:3}},pt=C("grl");class wi{constructor(l,u){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=l.createElement("div"),this.element.classList.add(pt()),u.viewProps.bindClassModifiers(this.element),this.formatter_=u.formatter,this.props_=u.props,this.cursor_=u.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const w=l.createElementNS(Te,"svg");w.classList.add(pt("g")),w.style.height=`calc(var(--bld-us) * ${u.lineCount})`,this.element.appendChild(w),this.svgElem_=w;const P=l.createElementNS(Te,"polyline");this.svgElem_.appendChild(P),this.lineElem_=P;const V=l.createElement("div");V.classList.add(pt("t"),C("tt")()),this.element.appendChild(V),this.tooltipElem_=V,u.value.emitter.on("change",this.onValueUpdate_),this.value=u.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const l=this.svgElem_.getBoundingClientRect(),u=this.value.rawValue.length-1,w=this.props_.get("minValue"),P=this.props_.get("maxValue"),V=[];this.value.rawValue.forEach((nt,ue)=>{if(nt===void 0)return;const Tt=Ve(ue,0,u,0,l.width),Kr=Ve(nt,w,P,l.height,0);V.push([Tt,Kr].join(","))}),this.lineElem_.setAttributeNS(null,"points",V.join(" "));const G=this.tooltipElem_,Q=this.value.rawValue[this.cursor_.rawValue];if(Q===void 0){G.classList.remove(pt("t","a"));return}const be=Ve(this.cursor_.rawValue,0,u,0,l.width),tt=Ve(Q,w,P,l.height,0);G.style.left=`${be}px`,G.style.top=`${tt}px`,G.textContent=`${this.formatter_(Q)}`,G.classList.contains(pt("t","a"))||(G.classList.add(pt("t","a"),pt("t","in")),lt(G),G.classList.remove(pt("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class Er{constructor(l,u){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.props_=u.props,this.value=u.value,this.viewProps=u.viewProps,this.cursor_=j(-1),this.view=new wi(l,{cursor:this.cursor_,formatter:u.formatter,lineCount:u.lineCount,props:this.props_,value:this.value,viewProps:this.viewProps}),!He(l))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGraphMouseLeave_);else{const w=new $n(this.view.element);w.emitter.on("down",this.onGraphPointerDown_),w.emitter.on("move",this.onGraphPointerMove_),w.emitter.on("up",this.onGraphPointerUp_)}}onGraphMouseLeave_(){this.cursor_.rawValue=-1}onGraphMouseMove_(l){const u=this.view.element.getBoundingClientRect();this.cursor_.rawValue=Math.floor(Ve(l.offsetX,0,u.width,0,this.value.rawValue.length))}onGraphPointerDown_(l){this.onGraphPointerMove_(l)}onGraphPointerMove_(l){if(!l.data.point){this.cursor_.rawValue=-1;return}this.cursor_.rawValue=Math.floor(Ve(l.data.point.x,0,l.data.bounds.width,0,this.value.rawValue.length))}onGraphPointerUp_(){this.cursor_.rawValue=-1}}class yi{constructor(l){this.controller_=l}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(l){this.controller_.viewProps.set("disabled",l)}get title(){var l;return(l=this.controller_.props.get("title"))!==null&&l!==void 0?l:""}set title(l){this.controller_.props.set("title",l)}on(l,u){const w=u.bind(this);return this.controller_.emitter.on(l,()=>{w(new o(this))}),this}}class Or extends o{constructor(l,u,w){super(l),this.cell=u,this.index=w}}class xi extends i{constructor(l){super(l),this.cellToApiMap_=new Map,this.emitter_=new y;const u=this.controller_.valueController;u.cellControllers.forEach((w,P)=>{const V=new yi(w);this.cellToApiMap_.set(w,V),w.emitter.on("click",()=>{const G=P%u.size[0],Q=Math.floor(P/u.size[0]);this.emitter_.emit("click",{event:new Or(this,V,[G,Q])})})})}cell(l,u){const w=this.controller_.valueController,P=w.cellControllers[u*w.size[0]+l];return this.cellToApiMap_.get(P)}on(l,u){const w=u.bind(this);return this.emitter_.on(l,P=>{w(P.event)}),this}}class Ds{constructor(l,u){this.size=u.size;const[w,P]=this.size,V=[];for(let G=0;G<P;G++)for(let Q=0;Q<w;Q++){const be=new U(l,{props:X.fromObject(Object.assign({},u.cellConfig(Q,G))),viewProps:ke.create()});V.push(be)}this.cellCs_=V,this.viewProps=ke.create(),this.viewProps.handleDispose(()=>{this.cellCs_.forEach(G=>{G.viewProps.set("disposed",!0)})}),this.view=new Mt(l,{viewProps:this.viewProps,viewName:"btngrid"}),this.view.element.style.gridTemplateColumns=`repeat(${w}, 1fr)`,this.cellCs_.forEach(G=>{this.view.element.appendChild(G.view.element)})}get cellControllers(){return this.cellCs_}}const Dr={id:"buttongrid",type:"blade",css:'.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--bld-us)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--bld-s);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-cbzpv_t{margin-top:var(--bld-s)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--bld-us)*5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--bld-us));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--bld-us) - 8px);margin-top:calc((var(--bld-us) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',accept(f){const l=re,u=ne(f,{cells:l.required.function,size:l.required.array(l.required.number),view:l.required.constant("buttongrid"),label:l.optional.string});return u?{params:u}:null},controller(f){return new ct(f.document,{blade:f.blade,props:X.fromObject({label:f.params.label}),valueController:new Ds(f.document,{cellConfig:f.params.cells,size:f.params.size})})},api(f){return!(f.controller instanceof ct)||!(f.controller.valueController instanceof Ds)?null:new xi(f.controller)}};class Ci extends i{get label(){return this.controller_.props.get("label")}set label(l){this.controller_.props.set("label",l)}get value(){return this.controller_.valueController.value.rawValue}set value(l){this.controller_.valueController.value.rawValue=l}on(l,u){const w=u.bind(this);return this.controller_.valueController.value.emitter.on(l,P=>{w(new a(this,P.rawValue,void 0,P.options.last))}),this}}function et(f,l,u){return f*(1-u)+l*u}const Vr=20,Ir=.001,Vs=100;function Br(f,l){let u=.25,w=.5,P=-1;for(let V=0;V<Vr;V++){const[G,Q]=f.curve(w);if(w+=u*(G<l?1:-1),P=Q,u*=.5,Math.abs(l-G)<Ir)break}return P}class Lt{constructor(l=0,u=0,w=1,P=1){this.cache_=[],this.comps_=[l,u,w,P]}get x1(){return this.comps_[0]}get y1(){return this.comps_[1]}get x2(){return this.comps_[2]}get y2(){return this.comps_[3]}static isObject(l){return p(l)||!Array.isArray(l)?!1:typeof l[0]=="number"&&typeof l[1]=="number"&&typeof l[2]=="number"&&typeof l[3]=="number"}static equals(l,u){return l.x1===u.x1&&l.y1===u.y1&&l.x2===u.x2&&l.y2===u.y2}curve(l){const u=et(0,this.x1,l),w=et(0,this.y1,l),P=et(this.x1,this.x2,l),V=et(this.y1,this.y2,l),G=et(this.x2,1,l),Q=et(this.y2,1,l),be=et(u,P,l),tt=et(w,V,l),nt=et(P,G,l),ue=et(V,Q,l);return[et(be,nt,l),et(tt,ue,l)]}y(l){if(this.cache_.length===0){const u=[];for(let w=0;w<Vs;w++)u.push(Br(this,Ve(w,0,Vs-1,0,1)));this.cache_=u}return this.cache_[Math.round(Ve(Ht(l,0,1),0,1,0,Vs-1))]}toObject(){return[this.comps_[0],this.comps_[1],this.comps_[2],this.comps_[3]]}}const Is={toComponents:f=>f.toObject(),fromComponents:f=>new Lt(...f)};function Fr(f){const l=Fe(2);return`cubic-bezier(${f.toObject().map(w=>l(w)).join(", ")})`}const Bs=[0,.5,.5,1];function Nr(f){const l=f.match(/^cubic-bezier\s*\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*\)$/);if(!l)return new Lt(...Bs);const u=[l[1],l[2],l[3],l[4]].reduce((w,P)=>{if(!w)return null;const V=Number(P);return isNaN(V)?null:[...w,V]},[]);return new Lt(...u??Bs)}const Bt=C("cbz");class Pi{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(Bt()),u.viewProps.bindClassModifiers(this.element),u.foldable.bindExpandedClass(this.element,Bt(void 0,"expanded")),O(u.foldable,"completed",N(this.element,Bt(void 0,"cpl")));const w=l.createElement("div");w.classList.add(Bt("h")),this.element.appendChild(w);const P=l.createElement("button");P.classList.add(Bt("b")),u.viewProps.bindDisabled(P);const V=l.createElementNS(Te,"svg");V.innerHTML='<path d="M2 13C8 13 8 3 14 3"/>',P.appendChild(V),w.appendChild(P),this.buttonElement=P;const G=l.createElement("div");if(G.classList.add(Bt("t")),w.appendChild(G),this.textElement=G,u.pickerLayout==="inline"){const Q=l.createElement("div");Q.classList.add(Bt("p")),this.element.appendChild(Q),this.pickerElement=Q}else this.pickerElement=null}}const ns=C("cbzp");class Ai{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(ns()),u.viewProps.bindClassModifiers(this.element);const w=l.createElement("div");w.classList.add(ns("g")),this.element.appendChild(w),this.graphElement=w;const P=l.createElement("div");P.classList.add(ns("t")),this.element.appendChild(P),this.textElement=P}}function ut(f,l){const u=new MutationObserver(P=>{for(const V of P)V.type==="childList"&&V.addedNodes.forEach(G=>{G.contains(G)&&(l(),u.disconnect())})}),w=f.ownerDocument;u.observe(w.body,{attributes:!0,childList:!0,subtree:!0})}const yt=C("cbzg");function Ur(f,l){return u=>l(f(u))}class Ne{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(yt()),u.viewProps.bindClassModifiers(this.element),u.viewProps.bindTabIndex(this.element);const w=l.createElement("div");w.classList.add(yt("p")),this.element.appendChild(w),this.previewElement=w;const P=l.createElementNS(Te,"svg");P.classList.add(yt("g")),this.element.appendChild(P),this.svgElem_=P;const V=l.createElementNS(Te,"path");V.classList.add(yt("u")),this.svgElem_.appendChild(V),this.guideElem_=V;const G=l.createElementNS(Te,"polyline");G.classList.add(yt("l")),this.svgElem_.appendChild(G),this.lineElem_=G,this.handleElems_=[l.createElement("div"),l.createElement("div")],this.handleElems_.forEach(Q=>{Q.classList.add(yt("h")),this.element.appendChild(Q)}),this.vectorElems_=[l.createElementNS(Te,"line"),l.createElementNS(Te,"line")],this.vectorElems_.forEach(Q=>{Q.classList.add(yt("v")),this.svgElem_.appendChild(Q)}),this.value_=u.value,this.value_.emitter.on("change",this.onValueChange_.bind(this)),this.sel_=u.selection,this.handleElems_.forEach((Q,be)=>{k(this.sel_,Ur(tt=>tt===be,N(Q,yt("h","sel"))))}),ut(this.element,()=>{this.refresh()})}getVertMargin_(l){return l*.25}valueToPosition(l,u){const w=this.element.getBoundingClientRect(),P=w.width,V=w.height,G=this.getVertMargin_(V);return{x:Ve(l,0,1,0,P),y:Ve(u,0,1,V-G,G)}}positionToValue(l,u){const w=this.element.getBoundingClientRect(),P=w.width,V=w.height,G=this.getVertMargin_(V);return{x:Ht(Ve(l,0,P,0,1),0,1),y:Ve(u,V-G,G,0,1)}}refresh(){this.guideElem_.setAttributeNS(null,"d",[0,1].map(V=>{const G=this.valueToPosition(0,V),Q=this.valueToPosition(1,V);return[`M ${G.x},${G.y}`,`L ${Q.x},${Q.y}`].join(" ")}).join(" "));const l=this.value_.rawValue,u=[];let w=0;for(;;){const V=this.valueToPosition(...l.curve(w));if(u.push([V.x,V.y].join(",")),w>=1)break;w=Math.min(w+.05,1)}this.lineElem_.setAttributeNS(null,"points",u.join(" "));const P=l.toObject();[0,1].forEach(V=>{const G=this.valueToPosition(V,V),Q=this.valueToPosition(P[V*2],P[V*2+1]),be=this.vectorElems_[V];be.setAttributeNS(null,"x1",String(G.x)),be.setAttributeNS(null,"y1",String(G.y)),be.setAttributeNS(null,"x2",String(Q.x)),be.setAttributeNS(null,"y2",String(Q.y));const tt=this.handleElems_[V];tt.style.left=`${Q.x}px`,tt.style.top=`${Q.y}px`})}onValueChange_(){this.refresh()}}const Mi=24,Pn=400,Fs=1e3,St=C("cbzprv");class tn{constructor(l,u){this.stopped_=!0,this.startTime_=-1,this.onDispose_=this.onDispose_.bind(this),this.onTimer_=this.onTimer_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.element=l.createElement("div"),this.element.classList.add(St()),u.viewProps.bindClassModifiers(this.element);const w=l.createElementNS(Te,"svg");w.classList.add(St("g")),this.element.appendChild(w),this.svgElem_=w;const P=l.createElementNS(Te,"path");P.classList.add(St("t")),this.svgElem_.appendChild(P),this.ticksElem_=P;const V=l.createElement("div");V.classList.add(St("m")),this.element.appendChild(V),this.markerElem_=V,this.value_=u.value,this.value_.emitter.on("change",this.onValueChange_),u.viewProps.handleDispose(this.onDispose_),ut(this.element,()=>{this.refresh()})}play(){this.stop(),this.updateMarker_(0),this.markerElem_.classList.add(St("m","a")),this.startTime_=new Date().getTime()+Pn,this.stopped_=!1,requestAnimationFrame(this.onTimer_)}stop(){this.stopped_=!0,this.markerElem_.classList.remove(St("m","a"))}onDispose_(){this.stop()}updateMarker_(l){const u=this.value_.rawValue.y(Ht(l,0,1));this.markerElem_.style.left=`${u*100}%`}refresh(){const l=this.svgElem_.getBoundingClientRect(),u=l.width,w=l.height,P=[],V=this.value_.rawValue;for(let G=0;G<Mi;G++){const Q=Ve(G,0,Mi-1,0,1),be=Ve(V.y(Q),0,1,0,u);P.push(`M ${be},0 v${w}`)}this.ticksElem_.setAttributeNS(null,"d",P.join(" "))}onTimer_(){if(this.startTime_===null)return;const l=new Date().getTime()-this.startTime_,u=l/Fs;this.updateMarker_(u),l>Fs+Pn&&this.stop(),this.stopped_||requestAnimationFrame(this.onTimer_)}onValueChange_(){this.refresh(),this.play()}}function Re(f,l,u,w){const P=u-f,V=w-l;return Math.sqrt(P*P+V*V)}function An(f,l,u,w){const P=Re(f,l,u,w),V=Math.atan2(w-l,u-f),G=Math.round(V/(Math.PI/4))*Math.PI/4;return{x:f+Math.cos(G)*P,y:l+Math.sin(G)*P}}class dt{constructor(l,u){this.onKeyDown_=this.onKeyDown_.bind(this),this.onKeyUp_=this.onKeyUp_.bind(this),this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.baseStep_=u.baseStep,this.value=u.value,this.sel_=j(0),this.viewProps=u.viewProps,this.view=new Ne(l,{selection:this.sel_,value:this.value,viewProps:this.viewProps}),this.view.element.addEventListener("keydown",this.onKeyDown_),this.view.element.addEventListener("keyup",this.onKeyUp_),this.prevView_=new tn(l,{value:this.value,viewProps:this.viewProps}),this.prevView_.element.addEventListener("mousedown",P=>{P.stopImmediatePropagation(),P.preventDefault(),this.prevView_.play()}),this.view.previewElement.appendChild(this.prevView_.element);const w=new $n(this.view.element);w.emitter.on("down",this.onPointerDown_),w.emitter.on("move",this.onPointerMove_),w.emitter.on("up",this.onPointerUp_)}refresh(){this.view.refresh(),this.prevView_.refresh(),this.prevView_.play()}updateValue_(l,u,w){const P=this.sel_.rawValue,V=this.value.rawValue.toObject(),G=this.view.positionToValue(l.x,l.y),Q=u?An(P,P,G.x,G.y):G;V[P*2]=Q.x,V[P*2+1]=Q.y,this.value.setRawValue(new Lt(...V),w)}onPointerDown_(l){const u=l.data;if(!u.point)return;const w=this.value.rawValue,P=this.view.valueToPosition(w.x1,w.y1),V=Re(u.point.x,u.point.y,P.x,P.y),G=this.view.valueToPosition(w.x2,w.y2),Q=Re(u.point.x,u.point.y,G.x,G.y);this.sel_.rawValue=V<=Q?0:1,this.updateValue_(u.point,l.shiftKey,{forceEmit:!1,last:!1})}onPointerMove_(l){const u=l.data;u.point&&this.updateValue_(u.point,l.shiftKey,{forceEmit:!1,last:!1})}onPointerUp_(l){const u=l.data;u.point&&this.updateValue_(u.point,l.shiftKey,{forceEmit:!0,last:!0})}onKeyDown_(l){pi(l.key)&&l.preventDefault();const u=this.sel_.rawValue,w=this.value.rawValue.toObject();w[u*2]+=Jt(this.baseStep_,Ss(l)),w[u*2+1]+=Jt(this.baseStep_,bn(l)),this.value.setRawValue(new Lt(...w),{forceEmit:!1,last:!1})}onKeyUp_(l){pi(l.key)&&l.preventDefault();const u=Jt(this.baseStep_,Ss(l)),w=Jt(this.baseStep_,bn(l));u===0&&w===0||this.value.setRawValue(this.value.rawValue,{forceEmit:!0,last:!0})}}class ki{constructor(l,u){this.value=u.value,this.viewProps=u.viewProps,this.view=new Ai(l,{viewProps:this.viewProps}),this.gc_=new dt(l,{baseStep:u.axis.baseStep,value:this.value,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.gc_.view.element);const w=Object.assign(Object.assign({},u.axis),{constraint:new Dt({max:1,min:0})}),P=Object.assign(Object.assign({},u.axis),{constraint:void 0});this.tc_=new It(l,{assembly:Is,axes:[w,P,w,P],parser:gn,value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element)}get allFocusableElements(){return[this.gc_.view.element,...this.tc_.view.textViews.map(l=>l.inputElement)]}refresh(){this.gc_.refresh()}}class ss{constructor(l,u){this.onButtonBlur_=this.onButtonBlur_.bind(this),this.onButtonClick_=this.onButtonClick_.bind(this),this.onPopupChildBlur_=this.onPopupChildBlur_.bind(this),this.onPopupChildKeydown_=this.onPopupChildKeydown_.bind(this),this.value=u.value,this.viewProps=u.viewProps,this.foldable_=Yn(u.expanded),this.view=new Pi(l,{foldable:this.foldable_,pickerLayout:u.pickerLayout,viewProps:this.viewProps}),this.view.buttonElement.addEventListener("blur",this.onButtonBlur_),this.view.buttonElement.addEventListener("click",this.onButtonClick_),this.tc_=new qt(l,{parser:Nr,props:X.fromObject({formatter:Fr}),value:this.value,viewProps:this.viewProps}),this.view.textElement.appendChild(this.tc_.view.element),this.popC_=u.pickerLayout==="popup"?new fe(l,{viewProps:this.viewProps}):null;const w=new ki(l,{axis:u.axis,value:this.value,viewProps:this.viewProps});w.allFocusableElements.forEach(P=>{P.addEventListener("blur",this.onPopupChildBlur_),P.addEventListener("keydown",this.onPopupChildKeydown_)}),this.pickerC_=w,this.popC_?(this.view.element.appendChild(this.popC_.view.element),this.popC_.view.element.appendChild(this.pickerC_.view.element),k(this.popC_.shows,P=>{P&&w.refresh()}),Wt({primary:this.foldable_.value("expanded"),secondary:this.popC_.shows,forward:P=>P.rawValue,backward:(P,V)=>V.rawValue})):this.view.pickerElement&&(this.view.pickerElement.appendChild(this.pickerC_.view.element),Zn(this.foldable_,this.view.pickerElement))}onButtonBlur_(l){if(!this.popC_)return;const u=l.relatedTarget;(!u||!this.popC_.view.element.contains(u))&&(this.popC_.shows.rawValue=!1)}onButtonClick_(){this.foldable_.set("expanded",!this.foldable_.get("expanded")),this.foldable_.get("expanded")&&this.pickerC_.allFocusableElements[0].focus()}onPopupChildBlur_(l){if(!this.popC_)return;const u=this.popC_.view.element,w=un(l);w&&u.contains(w)||w&&w===this.view.buttonElement&&!He(u.ownerDocument)||(this.popC_.shows.rawValue=!1)}onPopupChildKeydown_(l){this.popC_&&l.key==="Escape"&&(this.popC_.shows.rawValue=!1)}}function Ns(){return new kr({assembly:Is,components:[0,1,2,3].map(f=>f%2===0?new Dt({min:0,max:1}):void 0)})}const Ft={id:"cubic-bezier",type:"blade",css:'.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--bld-us)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--bld-s);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-cbzpv_t{margin-top:var(--bld-s)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--bld-us)*5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--bld-us));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--bld-us) - 8px);margin-top:calc((var(--bld-us) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',accept(f){const l=re,u=ne(f,{value:l.required.array(l.required.number),view:l.required.constant("cubicbezier"),expanded:l.optional.boolean,label:l.optional.string,picker:l.optional.custom(w=>w==="inline"||w==="popup"?w:void 0)});return u?{params:u}:null},controller(f){var l,u;const w=new Lt(...f.params.value),P=j(w,{constraint:Ns(),equals:Lt.equals}),V=new ss(f.document,{axis:{baseStep:.1,textProps:X.fromObject({draggingScale:.01,formatter:Fe(2)})},expanded:(l=f.params.expanded)!==null&&l!==void 0?l:!1,pickerLayout:(u=f.params.picker)!==null&&u!==void 0?u:"popup",value:P,viewProps:f.viewProps});return new Ot(f.document,{blade:f.blade,props:X.fromObject({label:f.params.label}),valueController:V})},api(f){return!(f.controller instanceof Ot)||!(f.controller.valueController instanceof ss)?null:new Ci(f.controller)}};class Le extends i{begin(){this.controller_.valueController.begin()}end(){this.controller_.valueController.end()}}const Us=20;class Ie{constructor(){this.start_=null,this.duration_=0,this.fps_=null,this.frameCount_=0,this.timestamps_=[]}get duration(){return this.duration_}get fps(){return this.fps_}begin(l){this.start_=l.getTime()}calculateFps_(l){if(this.timestamps_.length===0)return null;const u=this.timestamps_[0];return 1e3*(this.frameCount_-u.frameCount)/(l-u.time)}compactTimestamps_(){if(this.timestamps_.length<=Us)return;const l=this.timestamps_.length-Us;this.timestamps_.splice(0,l);const u=this.timestamps_[0].frameCount;this.timestamps_.forEach(w=>{w.frameCount-=u}),this.frameCount_-=u}end(l){if(this.start_===null)return;const u=l.getTime();this.duration_=u-this.start_,this.start_=null,this.fps_=this.calculateFps_(u),this.timestamps_.push({frameCount:this.frameCount_,time:u}),++this.frameCount_,this.compactTimestamps_()}}const nn=C("fps");class qe{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(nn()),u.viewProps.bindClassModifiers(this.element),this.graphElement=l.createElement("div"),this.graphElement.classList.add(nn("g")),this.element.appendChild(this.graphElement);const w=l.createElement("div");w.classList.add(nn("l")),this.element.appendChild(w);const P=l.createElement("span");P.classList.add(nn("v")),P.textContent="--",w.appendChild(P),this.valueElement=P;const V=l.createElement("span");V.classList.add(nn("u")),V.textContent="FPS",w.appendChild(V)}}class zs{constructor(l,u){this.stopwatch_=new Ie,this.onTick_=this.onTick_.bind(this),this.ticker_=u.ticker,this.ticker_.emitter.on("tick",this.onTick_),this.value_=u.value,this.viewProps=u.viewProps,this.view=new qe(l,{viewProps:this.viewProps}),this.graphC_=new Er(l,{formatter:Fe(0),lineCount:u.lineCount,props:X.fromObject({maxValue:u.maxValue,minValue:u.minValue}),value:this.value_,viewProps:this.viewProps}),this.view.graphElement.appendChild(this.graphC_.view.element),this.viewProps.handleDispose(()=>{this.graphC_.viewProps.set("disposed",!0),this.ticker_.dispose()})}begin(){this.stopwatch_.begin(new Date)}end(){this.stopwatch_.end(new Date)}onTick_(){const l=this.stopwatch_.fps;if(l!==null){const u=this.value_.rawValue;this.value_.rawValue=br(u,l),this.view.valueElement.textContent=l.toFixed(0)}}}function Mn(f,l){return l===0?new qn:new mn(f,l??Tr.monitor.defaultInterval)}const Rs={id:"fpsgraph",type:"blade",accept(f){const l=re,u=ne(f,{view:l.required.constant("fpsgraph"),interval:l.optional.number,label:l.optional.string,lineCount:l.optional.number,max:l.optional.number,min:l.optional.number});return u?{params:u}:null},controller(f){var l,u,w,P;const V=(l=f.params.interval)!==null&&l!==void 0?l:500;return new ct(f.document,{blade:f.blade,props:X.fromObject({label:f.params.label}),valueController:new zs(f.document,{lineCount:(u=f.params.lineCount)!==null&&u!==void 0?u:2,maxValue:(w=f.params.max)!==null&&w!==void 0?w:90,minValue:(P=f.params.min)!==null&&P!==void 0?P:0,ticker:Mn(f.document,V),value:ci(80),viewProps:f.viewProps})})},api(f){return!(f.controller instanceof ct)||!(f.controller.valueController instanceof zs)?null:new Le(f.controller)}};class Qe{constructor(l,u){this.min=l,this.max=u}static isObject(l){if(typeof l!="object"||l===null)return!1;const u=l.min,w=l.max;return!(typeof u!="number"||typeof w!="number")}static equals(l,u){return l.min===u.min&&l.max===u.max}get length(){return this.max-this.min}toObject(){return{min:this.min,max:this.max}}}const js={fromComponents:f=>new Qe(f[0],f[1]),toComponents:f=>[f.min,f.max]};class kn{constructor(l){this.edge=l}constrain(l){var u,w,P,V,G,Q,be,tt;if(l.min<=l.max)return new Qe((w=(u=this.edge)===null||u===void 0?void 0:u.constrain(l.min))!==null&&w!==void 0?w:l.min,(V=(P=this.edge)===null||P===void 0?void 0:P.constrain(l.max))!==null&&V!==void 0?V:l.max);const nt=(l.min+l.max)/2;return new Qe((Q=(G=this.edge)===null||G===void 0?void 0:G.constrain(nt))!==null&&Q!==void 0?Q:nt,(tt=(be=this.edge)===null||be===void 0?void 0:be.constrain(nt))!==null&&tt!==void 0?tt:nt)}}const Gs=C("rsltxt");class is{constructor(l,u){this.sliderView_=u.sliderView,this.textView_=u.textView,this.element=l.createElement("div"),this.element.classList.add(Gs());const w=l.createElement("div");w.classList.add(Gs("s")),w.appendChild(this.sliderView_.element),this.element.appendChild(w);const P=l.createElement("div");P.classList.add(Gs("t")),P.appendChild(this.textView_.element),this.element.appendChild(P)}}const it=C("rsl");class Ln{constructor(l,u){this.onSliderPropsChange_=this.onSliderPropsChange_.bind(this),this.onValueChange_=this.onValueChange_.bind(this),this.sliderProps_=u.sliderProps,this.sliderProps_.emitter.on("change",this.onSliderPropsChange_),this.element=l.createElement("div"),this.element.classList.add(it()),u.viewProps.bindClassModifiers(this.element),this.value_=u.value,this.value_.emitter.on("change",this.onValueChange_);const w=l.createElement("div");w.classList.add(it("t")),this.element.appendChild(w),this.trackElement=w;const P=l.createElement("div");P.classList.add(it("b")),w.appendChild(P),this.barElement=P;const V=["min","max"].map(G=>{const Q=l.createElement("div");return Q.classList.add(it("k"),it("k",G)),w.appendChild(Q),Q});this.knobElements=[V[0],V[1]],this.update_()}valueToX_(l){const u=this.sliderProps_.get("minValue"),w=this.sliderProps_.get("maxValue");return Ht(Ve(l,u,w,0,1),0,1)*100}update_(){const l=this.value_.rawValue;l.length===0?this.element.classList.add(it(void 0,"zero")):this.element.classList.remove(it(void 0,"zero"));const u=[this.valueToX_(l.min),this.valueToX_(l.max)];this.barElement.style.left=`${u[0]}%`,this.barElement.style.right=`${100-u[1]}%`,this.knobElements.forEach((w,P)=>{w.style.left=`${u[P]}%`})}onSliderPropsChange_(){this.update_()}onValueChange_(){this.update_()}}class Ks{constructor(l,u){this.grabbing_=null,this.grabOffset_=0,this.onPointerDown_=this.onPointerDown_.bind(this),this.onPointerMove_=this.onPointerMove_.bind(this),this.onPointerUp_=this.onPointerUp_.bind(this),this.sliderProps=u.sliderProps,this.viewProps=u.viewProps,this.value=u.value,this.view=new Ln(l,{sliderProps:this.sliderProps,value:this.value,viewProps:u.viewProps});const w=new $n(this.view.trackElement);w.emitter.on("down",this.onPointerDown_),w.emitter.on("move",this.onPointerMove_),w.emitter.on("up",this.onPointerUp_)}ofs_(){return this.grabbing_==="min"?this.view.knobElements[0].getBoundingClientRect().width/2:this.grabbing_==="max"?-this.view.knobElements[1].getBoundingClientRect().width/2:0}valueFromData_(l){if(!l.point)return null;const u=(l.point.x+this.ofs_())/l.bounds.width,w=this.sliderProps.get("minValue"),P=this.sliderProps.get("maxValue");return Ve(u,0,1,w,P)}onPointerDown_(l){if(!l.data.point)return;const u=l.data.point.x/l.data.bounds.width,w=this.value.rawValue,P=this.sliderProps.get("minValue"),V=this.sliderProps.get("maxValue"),G=Ve(w.min,P,V,0,1),Q=Ve(w.max,P,V,0,1);Math.abs(Q-u)<=.025?this.grabbing_="max":Math.abs(G-u)<=.025?this.grabbing_="min":u>=G&&u<=Q?(this.grabbing_="length",this.grabOffset_=Ve(u-G,0,1,0,V-P)):u<G?(this.grabbing_="min",this.onPointerMove_(l)):u>Q&&(this.grabbing_="max",this.onPointerMove_(l))}applyPointToValue_(l,u){const w=this.valueFromData_(l);if(w===null)return;const P=this.sliderProps.get("minValue"),V=this.sliderProps.get("maxValue");if(this.grabbing_==="min")this.value.setRawValue(new Qe(w,this.value.rawValue.max),u);else if(this.grabbing_==="max")this.value.setRawValue(new Qe(this.value.rawValue.min,w),u);else if(this.grabbing_==="length"){const G=this.value.rawValue.length;let Q=w-this.grabOffset_,be=Q+G;Q<P?(Q=P,be=P+G):be>V&&(Q=V-G,be=V),this.value.setRawValue(new Qe(Q,be),u)}}onPointerMove_(l){this.applyPointToValue_(l.data,{forceEmit:!1,last:!1})}onPointerUp_(l){this.applyPointToValue_(l.data,{forceEmit:!0,last:!0}),this.grabbing_=null}}class xt{constructor(l,u){this.value=u.value,this.viewProps=u.viewProps,this.sc_=new Ks(l,u);const w={baseStep:u.baseStep,constraint:u.constraint,textProps:X.fromObject({draggingScale:u.draggingScale,formatter:u.formatter})};this.tc_=new It(l,{assembly:js,axes:[w,w],parser:u.parser,value:this.value,viewProps:u.viewProps}),this.view=new is(l,{sliderView:this.sc_.view,textView:this.tc_.view})}get textController(){return this.tc_}}function Li(f){return Qe.isObject(f)?new Qe(f.min,f.max):new Qe(0,0)}function Ys(f,l){f.writeProperty("max",l.max),f.writeProperty("min",l.min)}function zr(f){const l=[],u=Cn(f);u&&l.push(u);const w=Sr(f);return w&&l.push(w),new kn(new Qn(l))}const rs={id:"input-interval",type:"input",css:'.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--bld-us)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--bld-s);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-cbzpv_t{margin-top:var(--bld-s)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--bld-us)*5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--bld-us));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--bld-us) - 8px);margin-top:calc((var(--bld-us) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',accept:(f,l)=>{if(!Qe.isObject(f))return null;const u=re,w=ne(l,{format:u.optional.function,max:u.optional.number,min:u.optional.number,step:u.optional.number});return w?{initialValue:new Qe(f.min,f.max),params:w}:null},binding:{reader:f=>Li,constraint:f=>zr(f.params),equals:Qe.equals,writer:f=>Ys},controller(f){var l;const u=f.value,w=f.constraint;if(!(w instanceof kn))throw g.shouldNeverHappen();const P=(u.rawValue.min+u.rawValue.max)/2,V=(l=f.params.format)!==null&&l!==void 0?l:Fe(yn(w.edge,P)),G=w.edge&&kt(w.edge,wt);if(G)return new xt(f.document,{baseStep:Es(w.edge),constraint:w.edge,draggingScale:es(w.edge,P),formatter:V,parser:gn,sliderProps:new X({maxValue:G.values.value("max"),minValue:G.values.value("min")}),value:u,viewProps:f.viewProps});const Q={baseStep:Es(w.edge),constraint:w.edge,textProps:X.fromObject({draggingScale:P,formatter:V})};return new It(f.document,{assembly:js,axes:[Q,Q],parser:gn,value:u,viewProps:f.viewProps})}};class Nt{constructor(l){this.controller_=l}get disabled(){return this.controller_.viewProps.get("disabled")}set disabled(l){this.controller_.viewProps.set("disabled",l)}get title(){var l;return(l=this.controller_.props.get("title"))!==null&&l!==void 0?l:""}set title(l){this.controller_.props.set("title",l)}}class Ut extends a{constructor(l,u,w,P,V){super(l,P,V),this.cell=u,this.index=w}}class Sn extends i{constructor(l){super(l),this.cellToApiMap_=new Map,this.controller_.valueController.cellControllers.forEach(w=>{const P=new Nt(w);this.cellToApiMap_.set(w,P)})}get value(){return this.controller_.value}cell(l,u){const w=this.controller_.valueController,P=w.cellControllers[u*w.size[0]+l];return this.cellToApiMap_.get(P)}on(l,u){const w=u.bind(this);this.controller_.value.emitter.on(l,P=>{const V=this.controller_.valueController,G=V.findCellByValue(P.rawValue);if(!G)return;const Q=this.cellToApiMap_.get(G);if(!Q)return;const be=V.cellControllers.indexOf(G);w(new Ut(this,Q,[be%V.size[0],Math.floor(be/V.size[0])],P.rawValue,void 0))})}}const Tn=C("rad");class Si{constructor(l,u){this.element=l.createElement("div"),this.element.classList.add(Tn()),u.viewProps.bindClassModifiers(this.element);const w=l.createElement("label");w.classList.add(Tn("l")),this.element.appendChild(w);const P=l.createElement("input");P.classList.add(Tn("i")),P.name=u.name,P.type="radio",u.viewProps.bindDisabled(P),w.appendChild(P),this.inputElement=P;const V=l.createElement("div");V.classList.add(Tn("b")),w.appendChild(V);const G=l.createElement("div");G.classList.add(Tn("t")),V.appendChild(G),O(u.props,"title",Q=>{G.textContent=Q})}}class Ti{constructor(l,u){this.props=u.props,this.viewProps=u.viewProps,this.view=new Si(l,{name:u.name,props:this.props,viewProps:this.viewProps})}}class os{constructor(l,u){this.cellCs_=[],this.cellValues_=[],this.onCellInputChange_=this.onCellInputChange_.bind(this),this.size=u.size;const[w,P]=this.size;for(let V=0;V<P;V++)for(let G=0;G<w;G++){const Q=new Ti(l,{name:u.groupName,props:X.fromObject(Object.assign({},u.cellConfig(G,V))),viewProps:ke.create()});this.cellCs_.push(Q),this.cellValues_.push(u.cellConfig(G,V).value)}this.value=u.value,k(this.value,V=>{const G=this.findCellByValue(V);G&&(G.view.inputElement.checked=!0)}),this.viewProps=ke.create(),this.view=new Mt(l,{viewProps:this.viewProps,viewName:"radgrid"}),this.view.element.style.gridTemplateColumns=`repeat(${w}, 1fr)`,this.cellCs_.forEach(V=>{V.view.inputElement.addEventListener("change",this.onCellInputChange_),this.view.element.appendChild(V.view.element)})}get cellControllers(){return this.cellCs_}findCellByValue(l){const u=this.cellValues_.findIndex(w=>w===l);return u<0?null:this.cellCs_[u]}onCellInputChange_(l){const u=l.currentTarget,w=this.cellCs_.findIndex(P=>P.view.inputElement===u);w<0||(this.value.rawValue=this.cellValues_[w])}}const zt=function(){return{id:"radiogrid",type:"blade",accept(f){const l=re,u=ne(f,{cells:l.required.function,groupName:l.required.string,size:l.required.array(l.required.number),value:l.required.raw,view:l.required.constant("radiogrid"),label:l.optional.string});return u?{params:u}:null},controller(f){return new Ot(f.document,{blade:f.blade,props:X.fromObject({label:f.params.label}),valueController:new os(f.document,{groupName:f.params.groupName,cellConfig:f.params.cells,size:f.params.size,value:j(f.params.value)})})},api(f){return!(f.controller instanceof Ot)||!(f.controller.valueController instanceof os)?null:new Sn(f.controller)}}}();function Xs(f){return{id:"input-radiogrid",type:"input",accept(l,u){if(!f.isType(l))return null;const w=re,P=ne(u,{cells:w.required.function,groupName:w.required.string,size:w.required.array(w.required.number),view:w.required.constant("radiogrid")});return P?{initialValue:l,params:P}:null},binding:f.binding,controller:l=>new os(l.document,{cellConfig:l.params.cells,groupName:l.params.groupName,size:l.params.size,value:l.value})}}const Rr=Xs({isType:f=>typeof f=="number",binding:{reader:f=>_r,writer:f=>st}}),jr=Xs({isType:f=>typeof f=="string",binding:{reader:f=>li,writer:f=>st}}),Gr=Xs({isType:f=>typeof f=="boolean",binding:{reader:f=>fn,writer:f=>st}}),Ei=[Dr,Ft,Rs,rs,zt,Gr,Rr,jr];n.ButtonCellApi=yi,n.ButtonGridApi=xi,n.ButtonGridController=Ds,n.CubicBezier=Lt,n.CubicBezierApi=Ci,n.CubicBezierAssembly=Is,n.CubicBezierController=ss,n.CubicBezierGraphController=dt,n.CubicBezierGraphView=Ne,n.CubicBezierPickerController=ki,n.CubicBezierPickerView=Ai,n.CubicBezierPreviewView=tn,n.CubicBezierView=Pi,n.FpsGraphBladeApi=Le,n.FpsGraphController=zs,n.FpsView=qe,n.Fpswatch=Ie,n.Interval=Qe,n.IntervalAssembly=js,n.IntervalConstraint=kn,n.RadioCellApi=Nt,n.RadioController=Ti,n.RadioGridApi=Sn,n.RadioGridController=os,n.RadioView=Si,n.RangeSliderController=Ks,n.RangeSliderTextController=xt,n.RangeSliderTextView=is,n.RangeSliderView=Ln,n.TpRadioGridChangeEvent=Ut,n.plugins=Ei,Object.defineProperty(n,"__esModule",{value:!0})})})(ir,ir.exports);var ea=ir.exports;const Mp=Ua({__proto__:null,default:gc(ea)},[ea]);let _t,si;const kp=(v="body")=>{_t||(_t=new Ap.Pane({container:document.querySelector(v)}),_t.element.style.position="absolute",_t.element.style.top="1rem",_t.element.style.right="1rem",_t.element.style.zIndex="9999",_t.registerPlugin(Mp),si=_t.addBlade({view:"fpsgraph",label:"fpsgraph"}));function t(){_t&&_t.dispose()}return _.onMounted(()=>{const{onBeforeLoop:n,onAfterLoop:i,resume:o}=Ae.useRenderLoop();o(),n(()=>si.begin()),i(()=>si.end())}),_.onUnmounted(()=>{t()}),{pane:_t,fpsGraph:si,disposeTweakPane:t}};$.Backdrop=Pp,$.Box=Bh,$.CameraControls=Th,$.Circle=Uh,$.Cone=jh,$.ContactShadows=Gc,$.Dodecahedron=Yh,$.Environment=Ac,$.FBXModel=ch,$.GLTFModel=lh,$.Icosahedron=qh,$.KeyboardControls=_h,$.Levioso=Fc,$.MapControls=Ch,$.MeshWobbleMaterial=Dh,$.MouseParallax=oh,$.Octahedron=Jh,$.OrbitControls=dh,$.Plane=tp,$.PointerLockControls=yh,$.Precipitation=Ec,$.Ring=ip,$.ScrollControls=Ph,$.Smoke=Bc,$.Sphere=ap,$.Stars=Lc,$.Tetrahedron=pp,$.Text3D=Cc,$.Torus=mp,$.TorusKnot=_p,$.TransformControls=bh,$.Tube=wp,$.useAnimations=Pc,$.useEnvironment=Bo,$.useFBX=jo,$.useGLTF=Ro,$.useProgress=ph,$.useTweakPane=kp,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
|
|
95
|
+
vNormal = vNormal * m;`)}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}const Bi=["factor"],Vi=h.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(c){const e=c,t=h.shallowRef(),{extend:n}=q.useTresContext();n({MeshWobbleMaterial:Ui});const{onLoop:s}=q.useRenderLoop();return s(({elapsed:o})=>{t.value&&(t.value.time=o*(e==null?void 0:e.speed))}),(o,i)=>(h.openBlock(),h.createElementBlock("TresMeshWobbleMaterial",h.mergeProps({ref_key:"materialRef",ref:t,factor:o.factor},o.$attrs),null,16,Bi))}}),Ni=["args"],zi=["color"],Ri=h.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"boxRef",ref:o},i.$attrs),[h.createElementVNode("TresBoxGeometry",{args:h.unref(n)},null,8,Ni),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,zi)])],16))}}),Ei=["args"],Gi=["color"],ji=h.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"circleRef",ref:o},i.$attrs),[h.createElementVNode("TresCircleGeometry",{args:h.unref(n)},null,8,Ei),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Gi)])],16))}}),Yi=["args"],Xi=["color"],Zi=h.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"coneRef",ref:o},i.$attrs),[h.createElementVNode("TresConeGeometry",{args:h.unref(n)},null,8,Yi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Xi)])],16))}}),Qi=["args"],Ki=["color"],Wi=h.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"dodecahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresDodecahedronGeometry",{args:h.unref(n)},null,8,Qi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Ki)])],16))}}),qi=["args"],Ji=["color"],Hi=h.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"icosahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresIcosahedronGeometry",{args:h.unref(n)},null,8,qi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Ji)])],16))}}),$i=["args"],er=["color"],tr=h.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"octahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresOctahedronGeometry",{args:h.unref(n)},null,8,$i),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,er)])],16))}}),nr=["rotation"],sr=["args"],or=["color"],ir=h.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"planeRef",ref:o,rotation:[-Math.PI/2,0,0]},i.$attrs),[h.createElementVNode("TresPlaneGeometry",{args:h.unref(n)},null,8,sr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,or)])],16,nr))}}),rr=["args"],ar=["color"],lr=h.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"ringRef",ref:o},i.$attrs),[h.createElementVNode("TresRingGeometry",{args:h.unref(n)},null,8,rr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,ar)])],16))}}),cr=["args"],hr=["color"],ur=h.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"sphereRef",ref:o},i.$attrs),[h.createElementVNode("TresSphereGeometry",{args:h.unref(n)},null,8,cr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,hr)])],16))}}),pr=["rotation"],dr=["args"],fr=["color"],mr=h.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tetrahedronRef",ref:o,rotation:[-Math.PI/2,0,0]},i.$attrs),[h.createElementVNode("TresTetrahedronGeometry",{args:h.unref(n)},null,8,dr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,fr)])],16,pr))}}),gr=["args"],_r=["color"],yr=h.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusRef",ref:o},i.$attrs),[h.createElementVNode("TresTorusGeometry",{args:h.unref(n)},null,8,gr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,_r)])],16))}}),wr=["args"],vr=["color"],Ar=h.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusKnotRef",ref:o},i.$attrs),[h.createElementVNode("TresTorusKnotGeometry",{args:h.unref(n)},null,8,wr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,vr)])],16))}}),xr=["args"],Mr=["color"],br=h.defineComponent({__name:"Tube",props:{args:{default:()=>[new l.QuadraticBezierCurve3(new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tubeRef",ref:o},i.$attrs),[h.createElementVNode("TresTubeGeometry",{args:h.unref(n)},null,8,xr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Mr)])],16))}}),Tr=["receive-shadow","rotation"],Sr=["args"],Lr=h.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Or=h.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(c){const e=c,t=r=>r===0?0:Math.pow(2,10*r-10),{floor:n,segments:s,receiveShadow:o}=h.toRefs(e),i=h.ref(null);return h.watch(()=>[s.value,n.value,i.value],([r,a,u])=>{if(!u||r===null)return;let d=0;const p=r/r/2,f=u.attributes.position;for(let m=0;m<r+1;m++)for(let y=0;y<r+1;y++)f.setXYZ(d++,m/r-p+(m===0?-a:0),y/r-p,t(m/r));f.needsUpdate=!0,u.computeVertexNormals()}),(r,a)=>(h.openBlock(),h.createElementBlock("TresGroup",h.normalizeProps(h.guardReactiveProps(r.$attrs)),[h.createElementVNode("TresMesh",{"receive-shadow":h.unref(o),rotation:[-Math.PI/2,0,Math.PI/2]},[h.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,h.unref(s),h.unref(s)]},null,8,Sr),h.renderSlot(r.$slots,"default",{},()=>[Lr])],8,Tr)],16))}});let ve,ht;const Pr=(c="body")=>{ve||(ve=new En.Pane({container:document.querySelector(c)}),ve.element.style.position="absolute",ve.element.style.top="1rem",ve.element.style.right="1rem",ve.element.style.zIndex="9999",ve.registerPlugin(Yn),ht=ve.addBlade({view:"fpsgraph",label:"fpsgraph"}));function e(){ve&&ve.dispose()}return h.onMounted(()=>{const{onBeforeLoop:t,onAfterLoop:n,resume:s}=q.useRenderLoop();s(),t(()=>ht.begin()),n(()=>ht.end())}),h.onUnmounted(()=>{e()}),{pane:ve,fpsGraph:ht,disposeTweakPane:e}};B.Backdrop=Or,B.Box=Ri,B.CameraControls=Fi,B.Circle=ji,B.Cone=Zi,B.ContactShadows=Qo,B.Dodecahedron=Wi,B.Environment=Co,B.FBXModel=di,B.GLTFModel=pi,B.Icosahedron=Hi,B.KeyboardControls=Ai,B.Levioso=Go,B.MapControls=Li,B.MeshWobbleMaterial=Vi,B.MouseParallax=hi,B.Octahedron=tr,B.OrbitControls=_i,B.Plane=ir,B.PointerLockControls=Ti,B.Precipitation=Bo,B.Ring=lr,B.ScrollControls=Oi,B.Smoke=Eo,B.Sphere=ur,B.Stars=ko,B.Tetrahedron=mr,B.Text3D=Oo,B.Torus=yr,B.TorusKnot=Ar,B.TransformControls=Mi,B.Tube=br,B.useAnimations=Po,B.useEnvironment=pn,B.useFBX=yn,B.useGLTF=_n,B.useProgress=mi,B.useTweakPane=Pr,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|